Author: jtn
Date: Thu Dec 24 11:08:53 2015
New Revision: 31190

URL: http://svn.gna.org/viewcvs/freeciv?rev=31190&view=rev
Log:
Display player colors in pregame in Gtk clients.

See gna patch #6719.

Modified:
    trunk/client/gui-gtk-2.0/pages.c
    trunk/client/gui-gtk-2.0/plrdlg.c
    trunk/client/gui-gtk-2.0/plrdlg.h
    trunk/client/gui-gtk-3.0/pages.c
    trunk/client/gui-gtk-3.0/plrdlg.c
    trunk/client/gui-gtk-3.0/plrdlg.h
    trunk/client/gui-gtk-3.x/pages.c
    trunk/client/gui-gtk-3.x/plrdlg.c
    trunk/client/gui-gtk-3.x/plrdlg.h

Modified: trunk/client/gui-gtk-2.0/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/pages.c?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/pages.c    (original)
+++ trunk/client/gui-gtk-2.0/pages.c    Thu Dec 24 11:08:53 2015
@@ -1362,13 +1362,14 @@
 static GtkWidget *start_aifill_spin = NULL;
 
 
-/* NB: Must match creation arugments in connection_list_store_new(). */
+/* NB: Must match creation arguments in connection_list_store_new(). */
 enum connection_list_columns {
   CL_COL_PLAYER_NUMBER = 0,
   CL_COL_USER_NAME,
   CL_COL_READY_STATE,
   CL_COL_PLAYER_NAME,
   CL_COL_FLAG,
+  CL_COL_COLOR,
   CL_COL_NATION,
   CL_COL_TEAM,
   CL_COL_CONN_ID,
@@ -1390,6 +1391,7 @@
                             G_TYPE_BOOLEAN,     /* CL_COL_READY_STATE */
                             G_TYPE_STRING,      /* CL_COL_PLAYER_NAME */
                             GDK_TYPE_PIXBUF,    /* CL_COL_FLAG */
+                            GDK_TYPE_PIXBUF,    /* CL_COL_COLOR */
                             G_TYPE_STRING,      /* CL_COL_NATION */
                             G_TYPE_STRING,      /* CL_COL_TEAM */
                             G_TYPE_INT,         /* CL_COL_CONN_ID */
@@ -2249,7 +2251,7 @@
     GtkTreePath *path;
     GtkTreeIter child, prev_child, *pprev_child;
     GtkTreeIter parent, prev_parent, *pprev_parent = NULL;
-    GdkPixbuf *pixbuf;
+    GdkPixbuf *flag, *color;
     gboolean collapsed;
     struct player *pselected_player;
     struct connection *pselected_conn;
@@ -2267,7 +2269,8 @@
       if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
         conn_id = -1;
         access_level = ALLOW_NONE;
-        pixbuf = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+        flag = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+        color = create_player_icon(pplayer);
 
         conn_list_iterate(pplayer->connections, pconn) {
           if (pconn->playing == pplayer && !pconn->observer) {
@@ -2316,7 +2319,8 @@
                            CL_COL_USER_NAME, name,
                            CL_COL_READY_STATE, is_ready,
                            CL_COL_PLAYER_NAME, plr_name,
-                           CL_COL_FLAG, pixbuf,
+                           CL_COL_FLAG, flag,
+                           CL_COL_COLOR, color,
                            CL_COL_NATION, nation,
                            CL_COL_TEAM, team,
                            CL_COL_CONN_ID, conn_id,
@@ -2377,8 +2381,11 @@
 
         prev_parent = parent;
         pprev_parent = &prev_parent;
-        if (pixbuf) {
-          g_object_unref(pixbuf);
+        if (flag) {
+          g_object_unref(flag);
+        }
+        if (color) {
+          g_object_unref(color);
         }
       }
     } players_iterate_end;
@@ -2631,6 +2638,8 @@
                CL_COL_PLAYER_NAME, NULL);
   add_tree_col(view, GDK_TYPE_PIXBUF, _("Flag"),
                CL_COL_FLAG, NULL);
+  add_tree_col(view, GDK_TYPE_PIXBUF, _("Border"),
+               CL_COL_COLOR, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Nation"),
                CL_COL_NATION, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Team"),

Modified: trunk/client/gui-gtk-2.0/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/plrdlg.c?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/plrdlg.c   (original)
+++ trunk/client/gui-gtk-2.0/plrdlg.c   Thu Dec 24 11:08:53 2015
@@ -101,14 +101,20 @@
   }
 }
 
-/**************************************************************************
-  Create pixbuf for player
-**************************************************************************/
-static GdkPixbuf *create_player_icon(const struct player *plr)
+/***************************************************************************
+  Create a small colored square representing the player color, for use
+  in player lists. 
+  May return NULL if the player has no color yet.
+***************************************************************************/
+GdkPixbuf *create_player_icon(const struct player *plr)
 {
   int width, height;
   GdkPixbuf *tmp;
   GdkPixmap *pixmap;
+
+  if (!player_has_color(tileset, plr)) {
+    return NULL;
+  }
 
   gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
 

Modified: trunk/client/gui-gtk-2.0/plrdlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/plrdlg.h?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/plrdlg.h   (original)
+++ trunk/client/gui-gtk-2.0/plrdlg.h   Thu Dec 24 11:08:53 2015
@@ -19,6 +19,7 @@
 
 /* Misc helper functions */
 GdkPixbuf *get_flag(const struct nation_type *pnation);
+GdkPixbuf *create_player_icon(const struct player *plr);
 
 extern struct gui_dialog *players_dialog_shell;
 #endif  /* FC__PLRDLG_H */

Modified: trunk/client/gui-gtk-3.0/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/pages.c?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/pages.c    (original)
+++ trunk/client/gui-gtk-3.0/pages.c    Thu Dec 24 11:08:53 2015
@@ -1433,13 +1433,14 @@
 static GtkWidget *start_aifill_spin = NULL;
 
 
-/* NB: Must match creation arugments in connection_list_store_new(). */
+/* NB: Must match creation arguments in connection_list_store_new(). */
 enum connection_list_columns {
   CL_COL_PLAYER_NUMBER = 0,
   CL_COL_USER_NAME,
   CL_COL_READY_STATE,
   CL_COL_PLAYER_NAME,
   CL_COL_FLAG,
+  CL_COL_COLOR,
   CL_COL_NATION,
   CL_COL_TEAM,
   CL_COL_CONN_ID,
@@ -1461,6 +1462,7 @@
                             G_TYPE_BOOLEAN,     /* CL_COL_READY_STATE */
                             G_TYPE_STRING,      /* CL_COL_PLAYER_NAME */
                             GDK_TYPE_PIXBUF,    /* CL_COL_FLAG */
+                            GDK_TYPE_PIXBUF,    /* CL_COL_COLOR */
                             G_TYPE_STRING,      /* CL_COL_NATION */
                             G_TYPE_STRING,      /* CL_COL_TEAM */
                             G_TYPE_INT,         /* CL_COL_CONN_ID */
@@ -2306,7 +2308,7 @@
     GtkTreePath *path;
     GtkTreeIter child, prev_child, *pprev_child;
     GtkTreeIter parent, prev_parent, *pprev_parent = NULL;
-    GdkPixbuf *pixbuf;
+    GdkPixbuf *flag, *color;
     gboolean collapsed;
     struct player *pselected_player;
     struct connection *pselected_conn;
@@ -2324,7 +2326,8 @@
       if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
         conn_id = -1;
         access_level = ALLOW_NONE;
-        pixbuf = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+        flag = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+        color = create_player_icon(pplayer);
 
         conn_list_iterate(pplayer->connections, pconn) {
           if (pconn->playing == pplayer && !pconn->observer) {
@@ -2373,7 +2376,8 @@
                            CL_COL_USER_NAME, name,
                            CL_COL_READY_STATE, is_ready,
                            CL_COL_PLAYER_NAME, plr_name,
-                           CL_COL_FLAG, pixbuf,
+                           CL_COL_FLAG, flag,
+                           CL_COL_COLOR, color,
                            CL_COL_NATION, nation,
                            CL_COL_TEAM, team,
                            CL_COL_CONN_ID, conn_id,
@@ -2434,8 +2438,11 @@
 
         prev_parent = parent;
         pprev_parent = &prev_parent;
-        if (pixbuf) {
-          g_object_unref(pixbuf);
+        if (flag) {
+          g_object_unref(flag);
+        }
+        if (color) {
+          g_object_unref(color);
         }
       }
     } players_iterate_end;
@@ -2685,6 +2692,8 @@
                CL_COL_PLAYER_NAME, NULL);
   add_tree_col(view, GDK_TYPE_PIXBUF, _("Flag"),
                CL_COL_FLAG, NULL);
+  add_tree_col(view, GDK_TYPE_PIXBUF, _("Border"),
+               CL_COL_COLOR, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Nation"),
                CL_COL_NATION, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Team"),

Modified: trunk/client/gui-gtk-3.0/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/plrdlg.c?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/plrdlg.c   (original)
+++ trunk/client/gui-gtk-3.0/plrdlg.c   Thu Dec 24 11:08:53 2015
@@ -105,16 +105,22 @@
   }
 }
 
-/**************************************************************************
-  Create pixbuf for player
-**************************************************************************/
-static GdkPixbuf *create_player_icon(const struct player *plr)
+/***************************************************************************
+  Create a small colored square representing the player color, for use
+  in player lists. 
+  May return NULL if the player has no color yet.
+***************************************************************************/
+GdkPixbuf *create_player_icon(const struct player *plr)
 {
   int width, height;
   GdkPixbuf *tmp;
   cairo_surface_t *surface;
   struct color *color;
   cairo_t *cr;
+
+  if (!player_has_color(tileset, plr)) {
+    return NULL;
+  }
 
   gtk_icon_size_lookup_for_settings(
       gtk_settings_get_for_screen(gtk_widget_get_screen(top_notebook)), 

Modified: trunk/client/gui-gtk-3.0/plrdlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/plrdlg.h?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/plrdlg.h   (original)
+++ trunk/client/gui-gtk-3.0/plrdlg.h   Thu Dec 24 11:08:53 2015
@@ -19,6 +19,7 @@
 
 /* Misc helper functions */
 GdkPixbuf *get_flag(const struct nation_type *pnation);
+GdkPixbuf *create_player_icon(const struct player *plr);
 
 extern struct gui_dialog *players_dialog_shell;
 

Modified: trunk/client/gui-gtk-3.x/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/pages.c?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/pages.c    (original)
+++ trunk/client/gui-gtk-3.x/pages.c    Thu Dec 24 11:08:53 2015
@@ -1433,13 +1433,14 @@
 static GtkWidget *start_aifill_spin = NULL;
 
 
-/* NB: Must match creation arugments in connection_list_store_new(). */
+/* NB: Must match creation arguments in connection_list_store_new(). */
 enum connection_list_columns {
   CL_COL_PLAYER_NUMBER = 0,
   CL_COL_USER_NAME,
   CL_COL_READY_STATE,
   CL_COL_PLAYER_NAME,
   CL_COL_FLAG,
+  CL_COL_COLOR,
   CL_COL_NATION,
   CL_COL_TEAM,
   CL_COL_CONN_ID,
@@ -1461,6 +1462,7 @@
                             G_TYPE_BOOLEAN,     /* CL_COL_READY_STATE */
                             G_TYPE_STRING,      /* CL_COL_PLAYER_NAME */
                             GDK_TYPE_PIXBUF,    /* CL_COL_FLAG */
+                            GDK_TYPE_PIXBUF,    /* CL_COL_COLOR */
                             G_TYPE_STRING,      /* CL_COL_NATION */
                             G_TYPE_STRING,      /* CL_COL_TEAM */
                             G_TYPE_INT,         /* CL_COL_CONN_ID */
@@ -2306,7 +2308,7 @@
     GtkTreePath *path;
     GtkTreeIter child, prev_child, *pprev_child;
     GtkTreeIter parent, prev_parent, *pprev_parent = NULL;
-    GdkPixbuf *pixbuf;
+    GdkPixbuf *flag, *color;
     gboolean collapsed;
     struct player *pselected_player;
     struct connection *pselected_conn;
@@ -2324,7 +2326,8 @@
       if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
         conn_id = -1;
         access_level = ALLOW_NONE;
-        pixbuf = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+        flag = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+        color = create_player_icon(pplayer);
 
         conn_list_iterate(pplayer->connections, pconn) {
           if (pconn->playing == pplayer && !pconn->observer) {
@@ -2373,7 +2376,8 @@
                            CL_COL_USER_NAME, name,
                            CL_COL_READY_STATE, is_ready,
                            CL_COL_PLAYER_NAME, plr_name,
-                           CL_COL_FLAG, pixbuf,
+                           CL_COL_FLAG, flag,
+                           CL_COL_COLOR, color,
                            CL_COL_NATION, nation,
                            CL_COL_TEAM, team,
                            CL_COL_CONN_ID, conn_id,
@@ -2434,8 +2438,11 @@
 
         prev_parent = parent;
         pprev_parent = &prev_parent;
-        if (pixbuf) {
-          g_object_unref(pixbuf);
+        if (flag) {
+          g_object_unref(flag);
+        }
+        if (color) {
+          g_object_unref(color);
         }
       }
     } players_iterate_end;
@@ -2685,6 +2692,8 @@
                CL_COL_PLAYER_NAME, NULL);
   add_tree_col(view, GDK_TYPE_PIXBUF, _("Flag"),
                CL_COL_FLAG, NULL);
+  add_tree_col(view, GDK_TYPE_PIXBUF, _("Border"),
+               CL_COL_COLOR, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Nation"),
                CL_COL_NATION, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Team"),

Modified: trunk/client/gui-gtk-3.x/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/plrdlg.c?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/plrdlg.c   (original)
+++ trunk/client/gui-gtk-3.x/plrdlg.c   Thu Dec 24 11:08:53 2015
@@ -105,16 +105,22 @@
   }
 }
 
-/**************************************************************************
-  Create pixbuf for player
-**************************************************************************/
-static GdkPixbuf *create_player_icon(const struct player *plr)
+/***************************************************************************
+  Create a small colored square representing the player color, for use
+  in player lists. 
+  May return NULL if the player has no color yet.
+***************************************************************************/
+GdkPixbuf *create_player_icon(const struct player *plr)
 {
   int width, height;
   GdkPixbuf *tmp;
   cairo_surface_t *surface;
   struct color *color;
   cairo_t *cr;
+
+  if (!player_has_color(tileset, plr)) {
+    return NULL;
+  }
 
   gtk_icon_size_lookup_for_settings(
       gtk_settings_get_for_screen(gtk_widget_get_screen(top_notebook)), 

Modified: trunk/client/gui-gtk-3.x/plrdlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/plrdlg.h?rev=31190&r1=31189&r2=31190&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/plrdlg.h   (original)
+++ trunk/client/gui-gtk-3.x/plrdlg.h   Thu Dec 24 11:08:53 2015
@@ -19,6 +19,7 @@
 
 /* Misc helper functions */
 GdkPixbuf *get_flag(const struct nation_type *pnation);
+GdkPixbuf *create_player_icon(const struct player *plr);
 
 extern struct gui_dialog *players_dialog_shell;
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to