#include #include "file.h" #include "free.h" #include "gui.h" #include "league.h" #include "live_game.h" #include "maths.h" #include "misc.h" #include "option.h" #include "support.h" #include "team.h" #include "treeview.h" #include "treeview_cell.h" #include "user.h" #include "variables.h" #include "window.h" /** Select the row that's been clicked on. */ void treeview_select_row(GtkTreeView *treeview, GdkEventButton *event) { GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); GtkTreePath *path; if(!gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, &path, NULL, NULL, NULL)) return; gtk_tree_selection_select_path(selection, path); gtk_tree_path_free(path); } /** Return the number in the 'column'th column of the currently selected row of the treeview. @param treeview The treeview argument. @param column The column we'd like to get the contents of. @return The number in the given column of the selected row. */ gint treeview_get_index(GtkTreeView *treeview, gint column) { gint value; GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); GtkTreeModel *model; GtkTreeIter iter; gtk_tree_selection_get_selected(selection, &model, &iter); gtk_tree_model_get(model, &iter, column, &value, -1); return value; } /** Return the pointer in the 'column'th column of the currently selected row of the treeview. @param treeview The treeview argument. @param column The column we'd like to get the content of. @return The pointer in the given column of the selected row. */ /*d*/ gpointer treeview_get_pointer(GtkTreeView *treeview, gint column) { gpointer ptr; GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); GtkTreeModel *model; GtkTreeIter iter; gtk_tree_selection_get_selected(selection, &model, &iter); gtk_tree_model_get(model, &iter, column, &ptr, -1); return ptr; } /** * Removes all columns from a GTK treeview. I didn't find a better way * to completely clear a treeview :-/. * @param treeview The pointer to the treeview widget we'd like to clear. */ void treeview_clear(GtkTreeView *treeview) { gint i; gint number_of_columns; GtkTreeView *list = (treeview == NULL) ? GTK_TREE_VIEW(lookup_widget(window.main, "player_info")) : treeview; gtk_tree_view_set_model(GTK_TREE_VIEW(list), NULL); number_of_columns = 0; while(gtk_tree_view_get_column(GTK_TREE_VIEW(list), number_of_columns) != NULL) number_of_columns++; for(i = number_of_columns - 1; i >= 0; i--) gtk_tree_view_remove_column( GTK_TREE_VIEW(list), gtk_tree_view_get_column(GTK_TREE_VIEW(list), i)); } /** Return number of given column or -1 if not found or on error. @param col The column pointer. @return The index of the column within the treeview. */ gint treeview_get_col_number_column (GtkTreeViewColumn *col) { GList *cols; gint num; g_return_val_if_fail ( col != NULL, -1 ); g_return_val_if_fail ( col->tree_view != NULL, -1 ); cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(col->tree_view)); num = g_list_index(cols, (gpointer) col); g_list_free(cols); return num; } /** Return the filename of the icon going with the LiveGameEvent with type event_type. @param event_type The type of the event. @return A filename specifying a pixmap. */ gchar* treeview_live_game_icon(gint event_type) { if(event_type == LIVE_GAME_EVENT_START_MATCH || event_type == LIVE_GAME_EVENT_END_MATCH || event_type == LIVE_GAME_EVENT_HALF_TIME || event_type == LIVE_GAME_EVENT_EXTRA_TIME || event_type == LIVE_GAME_EVENT_PENALTIES) return const_str("string_live_game_event_start_match_icon"); else if(event_type == LIVE_GAME_EVENT_LOST_POSSESSION) return const_str("string_live_game_event_lost_possession_icon"); else if(event_type == LIVE_GAME_EVENT_PENALTY) return const_str("string_live_game_event_penalty_icon"); else if(event_type == LIVE_GAME_EVENT_SCORING_CHANCE || event_type == LIVE_GAME_EVENT_FREE_KICK) return const_str("string_live_game_event_scoring_chance_icon"); else if(event_type == LIVE_GAME_EVENT_GOAL) return const_str("string_live_game_event_goal_icon"); else if(event_type == LIVE_GAME_EVENT_OWN_GOAL) return const_str("string_live_game_event_own_goal_icon"); else if(event_type == LIVE_GAME_EVENT_POST || event_type == LIVE_GAME_EVENT_CROSS_BAR) return const_str("string_live_game_event_post_icon"); else if(event_type == LIVE_GAME_EVENT_SAVE) return const_str("string_live_game_event_save_icon"); else if(event_type == LIVE_GAME_EVENT_MISSED) return const_str("string_live_game_event_missed_icon"); else if(event_type == LIVE_GAME_EVENT_FOUL) return const_str("string_live_game_event_foul_icon"); else if(event_type == LIVE_GAME_EVENT_FOUL_YELLOW) return const_str("string_live_game_event_foul_yellow_icon"); else if(event_type == LIVE_GAME_EVENT_SEND_OFF) return const_str("string_live_game_event_send_off_icon"); else if(event_type == LIVE_GAME_EVENT_INJURY) return const_str("string_live_game_event_injury_icon"); else if(event_type == LIVE_GAME_EVENT_TEMP_INJURY) return const_str("string_live_game_event_temp_injury_icon"); else if(event_type == LIVE_GAME_EVENT_STADIUM_BREAKDOWN) return const_str("string_live_game_event_stadium_breakdown_icon"); else if(event_type == LIVE_GAME_EVENT_STADIUM_FIRE) return const_str("string_live_game_event_stadium_fire_icon"); else if(event_type == LIVE_GAME_EVENT_STADIUM_RIOTS) return const_str("string_live_game_event_stadium_riots_icon"); else if(event_type == LIVE_GAME_EVENT_SUBSTITUTION) return const_str("string_live_game_event_substitution_icon"); else if(event_type == LIVE_GAME_EVENT_STRUCTURE_CHANGE) return const_str("string_live_game_event_structure_change_icon"); else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND) return const_str("string_live_game_event_style_change_all_out_defend_icon"); else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND) return const_str("string_live_game_event_style_change_defend_icon"); else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED) return const_str("string_live_game_event_style_change_balanced_icon"); else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK) return const_str("string_live_game_event_style_change_attack_icon"); else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK) return const_str("string_live_game_event_style_change_all_out_attack_icon"); else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE_ANTI) return const_str("string_live_game_event_boost_change_anti_icon"); else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE_OFF) return const_str("string_live_game_event_boost_change_off_icon"); else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE_ON) return const_str("string_live_game_event_boost_change_on_icon"); else return ""; } /** Return a new pixbuf created from the specified filename. @param filename Name of a pixmap file located in one of the support directories. @return A new pixbuf or NULL on error. */ GdkPixbuf* treeview_pixbuf_from_filename(gchar *filename) { GdkPixbuf *symbol = NULL; GError *error = NULL; gchar *symbol_file = NULL; if(filename != NULL && strlen(filename) != 0) { symbol_file = file_find_support_file(filename); if(symbol_file != NULL) { symbol = gdk_pixbuf_new_from_file(symbol_file, &error); misc_print_error(&error, FALSE); g_free(symbol_file); } } else symbol = NULL; return symbol; } /** Creates the model for the treeview in the team selection window. The model contains a list of all the teams from the leagues in the country::leagues array; if show_cup_teams is TRUE, the teams from international cups are shown, too. @param show_cup_teams Whether or not teams from international cups are shown. @param show_user_teams Whether or not user teams are shown. @return The model containing the team names. */ GtkTreeModel* treeview_create_team_selection_list(gboolean show_cup_teams, gboolean show_user_teams) { gint i, j, cnt = 1; GtkListStore *liststore; GtkTreeIter iter; GdkPixbuf *symbol = NULL; liststore = gtk_list_store_new(4, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_STRING); for(i=0;ilen;i++) { symbol = treeview_pixbuf_from_filename(lig(i).symbol->str); for(j=0;jlen;j++) { if(team_is_user(&g_array_index(lig(i).teams, Team, j)) == -1) { gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, cnt++, 1, symbol, 2, (gpointer)&g_array_index(lig(i).teams, Team, j), 3, lig(i).name->str, -1); } } if(symbol != NULL) g_object_unref(symbol); } if(!show_cup_teams) return GTK_TREE_MODEL(liststore); for(i=0;ilen;i++) if(cp(i).type == CUP_TYPE_INTERNATIONAL) for(j=0;jlen;j++) { symbol = treeview_pixbuf_from_filename(g_array_index(cp(i).teams, Team, j).symbol->str); gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, cnt++, 1, symbol, 2, (gpointer)&g_array_index(cp(i).teams, Team, j), 3, cp(i).name->str, -1); if(symbol != NULL) g_object_unref(symbol); } return GTK_TREE_MODEL(liststore); } /** Sets up the treeview for the team selection window. Columns and cell renderers are added etc. @param treeview The treeview that gets configured. */ void treeview_set_up_team_selection_treeview (GtkTreeView *treeview) { GtkTreeViewColumn *col; GtkCellRenderer *renderer; gtk_tree_selection_set_mode( gtk_tree_view_get_selection(treeview), GTK_SELECTION_BROWSE); gtk_tree_view_set_rules_hint(treeview, TRUE); /* Numbering the teams */ col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", 0); /* Flags */ col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "pixbuf", 1); /* Team column */ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, _("Team")); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_set_cell_data_func(col, renderer, treeview_cell_team_selection, GINT_TO_POINTER(2), NULL); /* League column */ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, _("League")); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", 3); } /** Shows the list of teams in the game. If show_cup_teams is TRUE, the teams from international cups are shown, too. @param treeview The treeview we show the list in. @param show_cup_teams Whether or not teams from international cups are shown. @param show_user_teams Whether or not user teams are shown. */ void treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams, gboolean show_user_teams) { GtkTreeModel *team_list = treeview_create_team_selection_list(show_cup_teams, show_user_teams); GtkTreeSelection *selection; treeview_clear(treeview); treeview_set_up_team_selection_treeview(treeview); gtk_tree_view_set_model(treeview, team_list); selection = gtk_tree_view_get_selection(treeview); gtk_tree_selection_select_path(selection, gtk_tree_path_new_from_string("0")); g_object_unref(team_list); } /** Create the list store for a player list. @param players The array containing the players. @param attributes An array containing the attributes we show. @param max The size of the attribute array. @param separator Whether we draw a blank line after the 11th player. */ GtkTreeModel* treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboolean show_separator) { gint i, j; GtkListStore *liststore; GtkTreeIter iter; GType types[max + 1]; types[0] = G_TYPE_INT; for(i=0;ilen;i++) { gtk_list_store_append(liststore, &iter); if(show_separator && i == 11) { gtk_list_store_set(liststore, &iter, 0, const_int("int_treeview_cell_int_empty"), -1); for(j=0;jtm), attribute, TRUE); } /** Show the commentary and the minute belonging to the unit. @param unit The #LiveGameUnit we show. */ void treeview_live_game_show_commentary(const LiveGameUnit *unit) { GdkPixbuf *symbol = NULL; GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(lookup_widget(window.live, "scrolledwindow9"))); GtkListStore *liststore = GTK_LIST_STORE( gtk_tree_view_get_model(GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary")))); GtkTreeIter iter; gchar buf[SMALL]; symbol = treeview_pixbuf_from_filename(treeview_live_game_icon(unit->event.type)); sprintf(buf, "%3d.", live_game_unit_get_minute(unit)); gtk_list_store_prepend(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, buf, 1, symbol, 2, unit->event.commentary->str, -1); if(symbol != NULL) g_object_unref(symbol); adjustment->value = adjustment->lower - adjustment->page_size; gtk_adjustment_value_changed(adjustment); } /** Create the list store for the live game commentary treeview. @param unit The unit we show. @return The liststore. */ GtkTreeModel* treeview_live_game_create_init_commentary(const LiveGameUnit *unit) { GtkListStore *liststore; GtkTreeIter iter; GdkPixbuf *symbol = NULL; gchar buf[SMALL]; liststore = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING); sprintf(buf, "%3d.", unit->minute); symbol = treeview_pixbuf_from_filename(treeview_live_game_icon(unit->event.type)); gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, buf, 1, symbol, 2, unit->event.commentary->str, -1); if(symbol != NULL) g_object_unref(symbol); return GTK_TREE_MODEL(liststore); } /** Set up the commentary treeview for the live game. */ void treeview_live_game_set_up_commentary(void) { GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary")); GtkTreeViewColumn *col; GtkCellRenderer *renderer; gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview), GTK_SELECTION_NONE); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", 0); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "pixbuf", 1); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", 2); } /** Show the first commentary of the live game @param unit The #LiveGameUnit we show. */ void treeview_live_game_show_initial_commentary(const LiveGameUnit *unit) { GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary")); GtkTreeModel *model = NULL; treeview_clear(treeview); gtk_tree_view_set_headers_visible(treeview, FALSE); treeview_live_game_set_up_commentary(); model = treeview_live_game_create_init_commentary(unit); gtk_tree_view_set_model(treeview, model); g_object_unref(model); } /** Fill the liststore for the live game result treeview. @param unit The current live game unit. @return The liststore we created. */ GtkTreeModel* treeview_live_game_create_result(const LiveGameUnit *unit) { GtkListStore *liststore; GtkTreeIter iter; GdkPixbuf *symbol = NULL; symbol = treeview_pixbuf_from_filename("possession_ball.png"); liststore = gtk_list_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, GDK_TYPE_PIXBUF); gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, NULL, 1, (gpointer)usr(stat2).live_game.fix, 2, (gpointer)unit, 3, (gpointer)usr(stat2).live_game.fix, 4, NULL, -1); gtk_list_store_set(liststore, &iter, 0 + (unit->possession == 1) * 4, symbol, -1); if(symbol != NULL) g_object_unref(symbol); return GTK_TREE_MODEL(liststore); } /** Set up the treeview columns for the result. */ void treeview_live_game_set_up_result(void) { GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.live, "treeview_result")); GtkTreeViewColumn *col; GtkCellRenderer *renderer; gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview), GTK_SELECTION_NONE); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(col, renderer, FALSE); gtk_tree_view_column_add_attribute(col, renderer, "pixbuf", 0); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_set_cell_data_func(col, renderer, treeview_cell_live_game_result, NULL, NULL); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_set_cell_data_func(col, renderer, treeview_cell_live_game_result, NULL, NULL); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_set_cell_data_func(col, renderer, treeview_cell_live_game_result, NULL, NULL); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(col, renderer, FALSE); gtk_tree_view_column_add_attribute(col, renderer, "pixbuf", 4); } /** Write the current result of the live game into the corresponding treeview. @param unit The current live game unit. */ void treeview_live_game_show_result(const LiveGameUnit *unit) { GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.live, "treeview_result")); GtkTreeModel *model = NULL; treeview_clear(treeview); gtk_tree_view_set_headers_visible(treeview, FALSE); treeview_live_game_set_up_result(); model = treeview_live_game_create_result(unit); gtk_tree_view_set_model(treeview, model); g_object_unref(model); } /** Fill a tree model with the users. */ GtkTreeModel* treeview_create_users_startup(void) { gint i; GtkListStore *liststore; GtkTreeIter iter; liststore = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); for(i=0;ilen;i++) { gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, i + 1, 1, usr(i).name->str, 2, usr(i).tm->name->str, -1); if(stat0 == STATUS_TEAM_SELECTION && usr(i).scout != 0) { if(usr(i).scout == 1) gtk_list_store_set(liststore, &iter, 3, lig(0).name->str, -1); else gtk_list_store_set(liststore, &iter, 3, lig(ligs->len - 1).name->str, -1); } else gtk_list_store_set(liststore, &iter, 3, league_from_clid(usr(i).tm->clid)->name->str, -1); } return GTK_TREE_MODEL(liststore); } /** Set up the users treeview. @param treeview The treeview we use. */ void treeview_set_up_users_startup(GtkTreeView *treeview) { gint i; GtkTreeViewColumn *col; GtkCellRenderer *renderer; gchar *titles[4] = {"", _("Name"), _("Team"), _("Start in")}; gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview), GTK_SELECTION_SINGLE); for(i=0;i<4;i++) { col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, titles[i]); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", i); } } /** Show the list of users at startup. @param treeview The treeview we use. */ void treeview_show_users_startup(void) { GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.startup_users, "treeview_users")); GtkTreeModel *model = NULL; treeview_clear(treeview); gtk_tree_view_set_headers_visible(treeview, TRUE); treeview_set_up_users_startup(treeview); model = treeview_create_users_startup(); gtk_tree_view_set_model(treeview, model); g_object_unref(model); } /** Fill a model with live game stats. @param live_game The live game. */ GtkTreeModel* treeview_create_game_stats(LiveGame *live_game) { gint i, j, k; LiveGameStats *stats = &live_game->stats; GtkListStore *liststore; GtkTreeIter iter; gchar buf[2][SMALL]; gchar buf3[SMALL]; gchar *categories[LIVE_GAME_STAT_VALUE_END] = {_("Goals (w/o pen.)"), _("Shots"), _("Shot %"), _("Possession"), _("Penalties"), _("Fouls"), _("Yellows"), _("Reds"), _("Injuries")}; liststore = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); sprintf(buf[0], "%d : %d", math_sum_int_array(live_game->fix->result[0], 3), math_sum_int_array(live_game->fix->result[1], 3)); gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, live_game->fix->teams[0]->name->str, 1, buf[0], 2, live_game->fix->teams[1]->name->str, -1); for(k=0;k"); if(k == LIVE_GAME_STAT_ARRAY_INJURED) sprintf(buf[0], " ", const_str("string_treeview_cell_color_player_injury")); else if(k == LIVE_GAME_STAT_ARRAY_REDS) sprintf(buf[0], " ", const_str("string_treeview_cell_color_player_banned")); else if(k == LIVE_GAME_STAT_ARRAY_YELLOWS) sprintf(buf[0], " ", const_str("string_treeview_cell_color_player_yellow_danger")); } for(i=0;iplayers[k][0]->len, stats->players[k][1]->len);i++) { gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 1, "", -1); for(j=0;j<2;j++) { if(i < stats->players[k][j]->len) { sprintf(buf3, "%s%s%s", buf[0], ((GString*)g_ptr_array_index(stats->players[k][j], i))->str, buf[1]); gtk_list_store_set(liststore, &iter, j * 2, buf3, -1); } } } } gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, "", 1, "", 2, "", -1); for(i=0;ivalues[j][i]); gtk_list_store_append(liststore, &iter); gtk_list_store_set(liststore, &iter, 0, buf[0], 1, categories[i], 2, buf[1], -1); } return GTK_TREE_MODEL(liststore); } /** Configure a treeview to show game stats. @param treeview The treeview. */ void treeview_set_up_game_stats(GtkTreeView *treeview) { gint i; GtkTreeViewColumn *col; GtkCellRenderer *renderer; gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview), GTK_SELECTION_NONE); for(i=0;i<3;i++) { col = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "markup", i); g_object_set(renderer, "xalign", 0 + (2 - i) * 0.5, NULL); } } /** Show the stats of the live game in a treeview. @param live_game The live game. */ void treeview_show_game_stats(GtkTreeView *treeview, LiveGame *live_game) { GtkTreeModel *model = NULL; treeview_clear(treeview); gtk_tree_view_set_headers_visible(treeview, FALSE); treeview_set_up_game_stats(treeview); model = treeview_create_game_stats(live_game); gtk_tree_view_set_model(treeview, model); g_object_unref(model); }