1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2024-12-16 10:21:15 +01:00

Player name editing.

This commit is contained in:
gyboth 2009-02-22 19:33:35 +00:00
parent 5e4df31346
commit 6cf432a00b
7 changed files with 94 additions and 14 deletions

View File

@ -1,6 +1,9 @@
15/03/2009: v2.3.2
- added Turkish translation and hints (thanks to Cem Uykun)
- added Greek translation and hints (thanks to Ilias Makris)
- added more meaning to autosave filenames (user, country etc.)
- added W-L-D and cup round robin rank info to the next opponent view
- added possibility to edit player names
29/01/2009: v2.3.1
- added possibility for multiple tables in leagues (think

View File

@ -120,7 +120,8 @@ callback_player_activate(gint idx)
selected_row = idx;
on_menu_move_to_youth_academy_activate(NULL, NULL);
}
else
else if(gtk_notebook_get_current_page(
GTK_NOTEBOOK(lookup_widget(window.main, "notebook_player"))) == 0)
{
if(selected_row == -1)
{
@ -911,5 +912,5 @@ callback_show_youth_academy(void)
treeview_show_player_list(
GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
player_get_pointers_from_array(current_user.youth_academy.players),
attributes, FALSE);
attributes, FALSE, FALSE);
}

View File

@ -290,7 +290,8 @@ treeview_create_player_list(GPtrArray *players, gint *attributes, gint max,
/** Set up the tree view for a player list */
void
treeview_set_up_player_list(GtkTreeView *treeview, gint *attributes, gint max,
gboolean show_separator, gboolean sortable)
gboolean show_separator, gboolean transfer_list,
gboolean sortable)
{
#ifdef DEBUG
printf("treeview_set_up_player_list\n");
@ -356,6 +357,23 @@ treeview_set_up_player_list(GtkTreeView *treeview, gint *attributes, gint max,
GINT_TO_POINTER(attributes[i]),
NULL);
if(transfer_list && attributes[i] == PLAYER_LIST_ATTRIBUTE_NAME)
{
g_object_set(renderer, "editable", TRUE, NULL);
g_signal_connect (renderer,
"editing-started",
G_CALLBACK (treeview_helper_player_name_editing_started),
NULL);
g_signal_connect (renderer,
"editing-canceled",
G_CALLBACK (treeview_helper_player_name_editing_canceled),
NULL);
g_signal_connect (renderer,
"edited",
G_CALLBACK (treeview_helper_player_name_editing_done),
NULL);
}
if(attributes[i] != PLAYER_LIST_ATTRIBUTE_NAME &&
attributes[i] != PLAYER_LIST_ATTRIBUTE_TEAM &&
attributes[i] != PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP)
@ -404,11 +422,12 @@ treeview_set_up_player_list(GtkTreeView *treeview, gint *attributes, gint max,
@param treeview The treeview we fill.
@param players The pointer array with the players. We free it afterwards.
@param attrib The #PlayerListAttribute that determines which attributes to show.
@param show_separator Whether we draw a blank line after the 11th player. */
@param show_separator Whether we draw a blank line after the 11th player.
@param transfer_list Whether we show the second player list used for transfer view. */
void
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players,
PlayerListAttribute attribute,
gboolean show_separator)
gboolean show_separator, gboolean transfer_list)
{
#ifdef DEBUG
printf("treeview_show_player_list\n");
@ -429,7 +448,7 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players,
attributes[cnt++] = i;
}
treeview_set_up_player_list(treeview, attributes, columns, show_separator, sortable);
treeview_set_up_player_list(treeview, attributes, columns, show_separator, transfer_list, sortable);
model = treeview_create_player_list(players, attributes,
columns, show_separator,
@ -461,7 +480,7 @@ treeview_show_user_player_list(void)
{
players = player_get_pointers_from_array(current_user.tm->players);
user_set_player_list_attributes(&current_user, &attribute, i + 1);
treeview_show_player_list(GTK_TREE_VIEW(treeview[i]), players, attribute, TRUE);
treeview_show_player_list(GTK_TREE_VIEW(treeview[i]), players, attribute, TRUE, (i == 1));
}
}
@ -477,7 +496,7 @@ treeview_show_player_list_team(GtkTreeView *treeview, const Team *tm, gint scout
GPtrArray *players = player_get_pointers_from_array(tm->players);
treeview_show_player_list(treeview, players,
treeview_helper_get_attributes_from_scout(scout), TRUE);
treeview_helper_get_attributes_from_scout(scout), TRUE, FALSE);
}
/** Show the commentary and the minute belonging to the unit.
@ -1739,7 +1758,7 @@ treeview_show_transfer_list(GtkTreeView *treeview)
g_ptr_array_add(players, player_of_id_team(trans(i).tm, trans(i).id));
treeview_show_player_list(treeview, players,
treeview_helper_get_attributes_from_scout(current_user.scout), FALSE);
treeview_helper_get_attributes_from_scout(current_user.scout), FALSE, FALSE);
}
/** Create attack, midfield and defend bars. */
@ -2067,7 +2086,7 @@ treeview_show_all_players(gint clid)
treeview_show_player_list(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
players,
treeview_helper_get_attributes_from_scout(current_user.scout), FALSE);
treeview_helper_get_attributes_from_scout(current_user.scout), FALSE, FALSE);
}
GtkTreeModel*

View File

@ -49,12 +49,14 @@ treeview_create_player_list(GPtrArray *players, gint *attributes, gint max,
gboolean show_separator, gboolean sortable, gboolean status);
void
treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max,
gboolean show_separator, gboolean sortable);
treeview_set_up_player_list(GtkTreeView *treeview, gint *attributes, gint max,
gboolean show_separator, gboolean transfer_list,
gboolean sortable);
void
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListAttribute attribute,
gboolean show_separator);
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players,
PlayerListAttribute attribute,
gboolean show_separator, gboolean transfer_list);
void
treeview_show_user_player_list(void);

View File

@ -1976,3 +1976,42 @@ treeview_helper_job_exchange(GtkTreeViewColumn *col,
g_object_set(renderer, "text", buf, NULL);
}
void
treeview_helper_player_name_editing_done(GtkCellRendererText *renderer,
gchar *path,
gchar *new_text,
gpointer user_data)
{
gint idx;
idx = (gint)strtol(path, NULL, 0);
if(idx == 11)
return;
idx = (idx > 11) ? idx - 1 : idx;
g_free(g_array_index(current_user.tm->players, Player, idx).name);
g_array_index(current_user.tm->players, Player, idx).name = g_strdup(new_text);
gtk_widget_set_sensitive(lookup_widget(window.main, "menubar1"), TRUE);
gtk_widget_set_sensitive(lookup_widget(window.main, "hbox1"), TRUE);
}
void
treeview_helper_player_name_editing_canceled(GtkCellRendererText *renderer,
gpointer user_data)
{
gtk_widget_set_sensitive(lookup_widget(window.main, "menubar1"), TRUE);
gtk_widget_set_sensitive(lookup_widget(window.main, "hbox1"), TRUE);
}
void
treeview_helper_player_name_editing_started(GtkCellRenderer *renderer,
GtkCellEditable *editable,
gchar *path,
gpointer user_data)
{
gtk_widget_set_sensitive(lookup_widget(window.main, "menubar1"), FALSE);
gtk_widget_set_sensitive(lookup_widget(window.main, "hbox1"), FALSE);
}

View File

@ -243,4 +243,19 @@ treeview_helper_news_additional(GtkTreeViewColumn *col,
GtkTreeIter *iter,
gpointer user_data);
void
treeview_helper_player_name_editing_done(GtkCellRendererText *renderer,
gchar *path,
gchar *new_text,
gpointer user_data);
void
treeview_helper_player_name_editing_started(GtkCellRenderer *renderer,
GtkCellEditable *editable,
gchar *path,
gpointer user_data);
void
treeview_helper_player_name_editing_canceled(GtkCellRendererText *renderer,
gpointer user_data);
#endif

View File

@ -20,6 +20,7 @@
<start_idx>1</start_idx>
<end_idx>1</end_idx>
</choose_team>
<choose_team>
<choose_team_sid>germany_dfb</choose_team_sid>
<number_of_teams>1</number_of_teams>