From 7228f92adb17462242ab033ed18d6c2664e36993 Mon Sep 17 00:00:00 2001 From: gyboth Date: Wed, 12 Jan 2005 20:49:24 +0000 Subject: [PATCH] Added icon possibility for the live game. --- src/treeview.c | 121 ++++++++++++++------- src/treeview.h | 6 + support_files/pixmaps/live_game/goal.png | Bin 0 -> 1122 bytes support_files/pixmaps/live_game/red.png | Bin 0 -> 584 bytes support_files/pixmaps/live_game/save.png | Bin 0 -> 661 bytes support_files/pixmaps/live_game/yellow.png | Bin 0 -> 553 bytes 6 files changed, 90 insertions(+), 37 deletions(-) create mode 100644 support_files/pixmaps/live_game/goal.png create mode 100644 support_files/pixmaps/live_game/red.png create mode 100644 support_files/pixmaps/live_game/save.png create mode 100644 support_files/pixmaps/live_game/yellow.png diff --git a/src/treeview.c b/src/treeview.c index 929887d5..b08c51f5 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -14,6 +14,66 @@ #include "variables.h" #include "window.h" +/** 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) +{ + switch(event_type) + { + default: + return ""; + break; + case LIVE_GAME_EVENT_FOUL_YELLOW: + return "yellow.png"; + break; + case LIVE_GAME_EVENT_FOUL_RED: + return "red.png"; + break; + case LIVE_GAME_EVENT_SEND_OFF: + return "red.png"; + break; + case LIVE_GAME_EVENT_SAVE: + return "save.png"; + break; + case LIVE_GAME_EVENT_GOAL: + return "goal.png"; + break; + } + + 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; + + printf("%s %p ", filename, symbol);fflush(NULL); + + return symbol; +} + /** Return the number in the 'column'th column of the currently selected row of the treeview. @param treeview The treeview argument. @@ -125,8 +185,6 @@ treeview_create_team_selection_list(gboolean show_cup_teams) GtkListStore *liststore; GtkTreeIter iter; GdkPixbuf *symbol = NULL; - GError *error = NULL; - gchar *symbol_file = NULL; liststore = gtk_list_store_new(4, G_TYPE_INT, @@ -136,20 +194,7 @@ treeview_create_team_selection_list(gboolean show_cup_teams) for(i=0;ilen;i++) { - if(strlen(lig(i).symbol->str) != 0) - { - symbol_file = file_find_support_file(lig(i).symbol->str); - if(symbol_file != NULL) - { - symbol = gdk_pixbuf_new_from_file(symbol_file, &error); - g_free(symbol_file); - } - else - symbol = NULL; - misc_print_error(&error, FALSE); - } - else - symbol = NULL; + symbol = treeview_pixbuf_from_filename(lig(i).symbol->str); for(j=0;jlen;j++) { @@ -161,6 +206,9 @@ treeview_create_team_selection_list(gboolean show_cup_teams) 3, lig(i).name->str, -1); } + + if(symbol != NULL) + g_object_unref(symbol); } if(!show_cup_teams) @@ -170,21 +218,8 @@ treeview_create_team_selection_list(gboolean show_cup_teams) if(cp(i).type == CUP_TYPE_INTERNATIONAL) for(j=0;jlen;j++) { - if(strlen(g_array_index(cp(i).teams, Team, j).symbol->str) != 0) - { - symbol_file = - file_find_support_file(g_array_index(cp(i).teams, Team, j).symbol->str); - if(symbol_file != NULL) - { - symbol = gdk_pixbuf_new_from_file(symbol_file, &error); - g_free(symbol_file); - } - else - symbol = NULL; - misc_print_error(&error, FALSE); - } - else - symbol = NULL; + 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, @@ -193,6 +228,8 @@ treeview_create_team_selection_list(gboolean show_cup_teams) 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); @@ -454,6 +491,7 @@ treeview_live_game_show_game_unit(const LiveGameUnit *unit) void treeview_live_game_show_commentary(const LiveGameUnit *unit) { + GdkPixbuf *symbol = NULL; GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(lookup_widget(live_game.window, @@ -464,10 +502,15 @@ treeview_live_game_show_commentary(const LiveGameUnit *unit) GtkTreeIter iter; gchar buf[SMALL]; + symbol = + treeview_pixbuf_from_filename(treeview_live_game_icon(unit->event.type)); sprintf(buf, "%d.", live_game_unit_get_minute(unit)); gtk_list_store_prepend(liststore, &iter); - gtk_list_store_set(liststore, &iter, 0, buf, 1, NULL, - 2, unit->event.commentary->str, -1); + 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); @@ -484,8 +527,6 @@ treeview_live_game_create_init_commentary(const LiveGameUnit *unit) GtkListStore *liststore; GtkTreeIter iter; GdkPixbuf *symbol = NULL; - GError *error = NULL; - gchar *symbol_file = NULL; gchar buf[SMALL]; liststore = gtk_list_store_new(3, @@ -494,11 +535,17 @@ treeview_live_game_create_init_commentary(const LiveGameUnit *unit) G_TYPE_STRING); sprintf(buf, "%d.", unit->minute); - /*todo: icons*/ + + 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, NULL, 2, + 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); } diff --git a/src/treeview.h b/src/treeview.h index be92a6df..da593e92 100644 --- a/src/treeview.h +++ b/src/treeview.h @@ -5,6 +5,12 @@ #include "live_game_struct.h" #include "player_struct.h" +GdkPixbuf* +treeview_pixbuf_from_filename(gchar *filename); + +gchar* +treeview_live_game_icon(gint event_type); + gint treeview_get_index(GtkTreeView *treeview, gint column); diff --git a/support_files/pixmaps/live_game/goal.png b/support_files/pixmaps/live_game/goal.png new file mode 100644 index 0000000000000000000000000000000000000000..f047009371aa9e79887b2b7e61fbd642df554bd0 GIT binary patch literal 1122 zcmV-o1fBbdP)I000McNliru)C?XKI3aOX^a=m~1Mf*h zK~#9!ZB$!mTvZfZXPx#h5d5r-qhTus*d>E)h%7wooXP?>x)4 z{}hWwN~hCrIF56|b=|D%y5O86l}bTM3CD5ZI1U(NAfkmZ4EtMJTFz|epg0*F9j$U* z_bVbg#W~Ls5g23OoP&tKIfoDeLI`-C2iJA;*=+UT{QUfx@$qp{L0Bvng)!!wwYC!g z7-Lv0`8aiU8WU4DKtu^*V$bvN;(HhI`Q*$C?d^q6DxN$%JlrpYc;E9pFcP@%^8zL> z&0`~EP=?TT=zhHU+ySIg9$eRjloB@=eY77L1wmtfTMeFkICu2z*E&C?;o;$(N~z<< z7#L&ldu0w)7v7VCk|=kxhzNGa86 ztwoGnR$_|}jBVn`;}2A*i=qf&7~-wIcDTZVlfmNh8i=S{XsrvJa~NZwwMI>qgYHM0 z!AO9(fGZ^)+LMD)szRaG8qN6>`k!yd)xSz;$T?6-?Pmi61J?7r*a~nQ2cG9aN||_% za}Lk*65DXj!5D+Jw&DWc_pQ)cBZg86obx1)y$Aq75Fl<`ydLNAx>AaXNSSDPVbu{L zKz%NQhI*cuIf|mB(|!1xu z70Ti`f9WR9eRmzkGFS^#S4o^c{z&rVErrt}RCa>MbZ`qSmDVx0_%9msH5G)$So|u zjL6y9*>{yvuM?4siM9hk{N3Q3pOjLb?CtGUcb(XA3=IwKDwoTz8e_Tuv;lC42ttUE obAE+${-u=ibYEZJ+?{9t16Yjru=oDk_W%F@07*qoM6N<$f|m0UK>z>% literal 0 HcmV?d00001 diff --git a/support_files/pixmaps/live_game/red.png b/support_files/pixmaps/live_game/red.png new file mode 100644 index 0000000000000000000000000000000000000000..1f108668d64e0760978cd5b1b482b364f7bd9575 GIT binary patch literal 584 zcmV-O0=NB%P)I000SeMObu0Z*6U5ZgctbN=+B$ie_UDj>*gM)=)0Lyzn?z~M9q0Q_NGQa28#P2 z=v8Aa!{;p$_K7PS8YL2_j&tPV9G#FC^u^>Tm8K&JzdX~7D7aTxdi~q W4QMwI=$7CB0000<$zF literal 0 HcmV?d00001 diff --git a/support_files/pixmaps/live_game/save.png b/support_files/pixmaps/live_game/save.png new file mode 100644 index 0000000000000000000000000000000000000000..2d43df1f423ab21f1012bab1ddae8208fdb63d6c GIT binary patch literal 661 zcmV;G0&4wI000SeMObu0Z*6U5Zgcczxc(}T5biUFlb6WXR$0yf%(MG}gz=t2N@+2tke zYI%r@Tf1T9l`b`{71)RpBt5k~SR|2WJB^11MbLH*lbOl)%Y5^F)A#F=qg*Z%uHeV5 z9kA}ZpxOSk<0Dp9eH8j!W^rr`4jYSw!i6xm5z|eh&Y7ERI5+toYkixmR zdVH*(Rx1V{h=xZ{tuu(H43N!9I7$ZxAf1z#4!BaOye3`pJL6-wM^raQ-FIhZo=z>y z64Ce3Q<0}}<><(X8Wlq#tX~QZh;%o^`s-o_^$9uQ>@{upGoOkt+4A&~cTQuxCeaLt zpAFrgzak-@XgfabF9rpm2{S{WYaWbG#@A^Yxhh%gm*ThN!q%4_csHMQVaolz{K=MM zXqH4VnL1>4ca&{77H3|7O(kRIJm?xh>&P5R|Nj)P&15kWriJb3x#ZvN9}I>IpT v!r?WFqWpnCB(l!3Y$B1!X0zbWp2fcb?-Cu;oXK`+00000NkvXXu0mjfV7)2~ literal 0 HcmV?d00001 diff --git a/support_files/pixmaps/live_game/yellow.png b/support_files/pixmaps/live_game/yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..74e8dde8fed7fa653f466a894c51a082d9191954 GIT binary patch literal 553 zcmV+^0@nSBP)I000SeMObu0Z*6U5Zgc*Fx@-0yyO?s+jF2SBheAbMWoyJQ(V$uh`* zw8;QM^pqCS!(Rn|HXtqm*GM-gr$(fi^B~A!;+Z<^_@&oB8R~I$&XX+l@H#-@Jp>9Q zpZZgZ#cB8GRFCEDExP9s+-D4eE}t$IqFQ!-a6zL$_Gzg8un zZ##NXseF}^fT5=P@?srC2j=9)g|M6n#0lkCXLv^(rxj72m3XC5>Ga+8Rf6UxVC~6i zv2uzIWBz!0i*6@EY;<)LnQm$udW+2XyiT=i<#dS70jt?E5)2;vtK;fP zanSgdzjQe=VDMgeZHLba;F`mu*narZ{N1;*Xtw} rCqp|Z&zXMLWW&g?@jB66B;~+22mG8})E{|o00000NkvXXu0mjf?p5+Y literal 0 HcmV?d00001