Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11577) add player border icons.
Home

[Freeciv-Dev] (PR#11577) add player border icons.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11577) add player border icons.
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Fri, 17 Dec 2004 08:22:36 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11577 >

This patch adds player border icons instead of just setting the cell
background to the colour. So it looks nicer.

Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/plrdlg.c,v
retrieving revision 1.47
diff -u -r1.47 plrdlg.c
--- client/gui-gtk-2.0/plrdlg.c 25 Nov 2004 06:57:17 -0000      1.47
+++ client/gui-gtk-2.0/plrdlg.c 17 Dec 2004 16:17:50 -0000
@@ -100,6 +100,32 @@
 /**************************************************************************
 ...
 **************************************************************************/
+static GdkPixbuf *create_player_icon(struct player *plr)
+{
+  int width, height;
+  GdkPixbuf *tmp;
+  GdkPixmap *pixmap;
+
+  gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+
+  pixmap = gdk_pixmap_new(root_window, width, height, -1);
+
+  gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_BLACK]);
+  gdk_draw_rectangle(pixmap, civ_gc, TRUE, 0, 0, width, height);
+
+  gdk_gc_set_foreground(civ_gc, colors_standard[player_color(plr)]);
+  gdk_draw_rectangle(pixmap, civ_gc, TRUE, 1, 1, width - 2, height - 2);
+
+  tmp = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 
+      0, 0, 0, 0, -1, -1);
+
+  g_object_unref(pixmap);
+  return tmp;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
 static void update_players_menu(void)
 {
   GtkTreeModel *model;
@@ -197,7 +223,7 @@
       model_types[i] = GDK_TYPE_PIXBUF;
       break;
     case COL_COLOR:
-      model_types[i] = GDK_TYPE_COLOR;
+      model_types[i] = GDK_TYPE_PIXBUF;
       break;
     case COL_BOOLEAN:
       model_types[i] = G_TYPE_BOOLEAN;
@@ -300,10 +326,10 @@
         "active", i, NULL);
       break;
     case COL_COLOR:
-      renderer = gtk_cell_renderer_text_new();
+      renderer = gtk_cell_renderer_pixbuf_new();
 
       col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,
-             "background-gdk", i, NULL);
+             "pixbuf", i, NULL);
       break;
     case COL_TEXT:
       renderer = gtk_cell_renderer_text_new();
@@ -489,7 +515,7 @@
 static void build_row(GtkTreeIter *it, int i)
 {
   struct player *plr = get_player(i);
-  GdkPixbuf *flag;
+  GdkPixbuf *pixbuf;
   gint style, weight;
   int k;
   gchar *p;
@@ -503,13 +529,14 @@
        gtk_list_store_set(store, it, k, p, -1);
        break;
       case COL_FLAG:
-        flag = get_flag(get_nation_by_plr(plr));
-        gtk_list_store_set(store, it, k, flag, -1);
-        g_object_unref(flag);
+        pixbuf = get_flag(get_nation_by_plr(plr));
+        gtk_list_store_set(store, it, k, pixbuf, -1);
+        g_object_unref(pixbuf);
        break;
       case COL_COLOR:
-        gtk_list_store_set(store, it, k,
-                          colors_standard[player_color(plr)], -1);
+       pixbuf = create_player_icon(plr);
+        gtk_list_store_set(store, it, k, pixbuf, -1);
+       g_object_unref(pixbuf);
        break;
       case COL_BOOLEAN:
         gtk_list_store_set(store, it, k, (gboolean)pcol->bool_func(plr), -1);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11577) add player border icons., Vasco Alexandre da Silva Costa <=