Author: cazfi
Date: Thu Oct 27 05:48:15 2016
New Revision: 34257

URL: http://svn.gna.org/viewcvs/freeciv?rev=34257&view=rev
Log:
Replaced GtkPixcomm based put_unit_gpixmap_city_overlays() with GtkImage based 
solutions in
gtk3.22-client.

See patch #7124

Modified:
    branches/S2_6/client/gui-gtk-3.22/citydlg.c
    branches/S2_6/client/gui-gtk-3.22/mapview.c
    branches/S2_6/client/gui-gtk-3.22/mapview.h

Modified: branches/S2_6/client/gui-gtk-3.22/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/citydlg.c?rev=34257&r1=34256&r2=34257&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/citydlg.c (original)
+++ branches/S2_6/client/gui-gtk-3.22/citydlg.c Thu Oct 27 05:48:15 2016
@@ -60,6 +60,7 @@
 #include "graphics.h"
 #include "gui_main.h"
 #include "gui_stuff.h"
+#include "gtkpixcomm.h"
 #include "happiness.h"
 #include "helpdlg.h"
 #include "inputdlg.h"
@@ -93,6 +94,7 @@
 struct unit_node {
   GtkWidget *cmd;
   GtkWidget *pix;
+  int height;
 };
 
 /* get 'struct unit_node' and related function */
@@ -354,7 +356,7 @@
   init_citydlg_dimensions();
 
   dialog_list_iterate(dialog_list, pdialog) {
-    /* There's no reasonable way to resize a GtkPixcomm, so we don't try.
+    /* There's no reasonable way to resize a GtkImage, so we don't try.
        Instead we just redraw the overview within the existing area.  The
        player has to close and reopen the dialog to fix this. */
     city_dialog_update_map(pdialog);
@@ -1517,7 +1519,7 @@
   gtk_widget_realize(pdialog->shell);
 
   /* keep the icon of the executable on Windows (see PR#36491) */
-#ifndef WIN32_NATIVE
+#ifndef FREECIV_MSWINDOWS
   {
     GdkPixbuf *pixbuf = sprite_get_pixbuf(get_icon_sprite(tileset, 
ICON_CITYDLG));
 
@@ -1525,7 +1527,7 @@
     gtk_window_set_icon(GTK_WINDOW(pdialog->shell), pixbuf);
     g_object_unref(pixbuf);
   }
-#endif /* WIN32_NATIVE */
+#endif /* FREECIV_MSWINDOWS */
 
   /* Restore size of the city dialog. */
   gtk_window_set_default_size(GTK_WINDOW(pdialog->shell),
@@ -2067,7 +2069,6 @@
     for (i = m; i < n; i++) {
       GtkWidget *cmd, *pix;
       struct unit_node node;
-      int unit_height = tileset_unit_with_upkeep_height(tileset);
 
       cmd = gtk_button_new();
       node.cmd = cmd;
@@ -2076,8 +2077,9 @@
       gtk_widget_add_events(cmd,
          GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
 
-      pix = gtk_pixcomm_new(tileset_full_tile_width(tileset), unit_height);
+      pix = gtk_image_new();
       node.pix = pix;
+      node.height = tileset_unit_with_upkeep_height(tileset);
 
       gtk_container_add(GTK_CONTAINER(cmd), pix);
 
@@ -2099,9 +2101,8 @@
       cmd = pnode->cmd;
       pix = pnode->pix;
 
-      put_unit_gpixmap(punit, GTK_PIXCOMM(pix));
-      put_unit_gpixmap_city_overlays(punit, GTK_PIXCOMM(pix), punit->upkeep,
-                                     happy_cost);
+      put_unit_image_city_overlays(punit, GTK_IMAGE(pix), pnode->height,
+                                   punit->upkeep, happy_cost);
 
       g_signal_handlers_disconnect_matched(cmd,
          G_SIGNAL_MATCH_FUNC,
@@ -2181,9 +2182,9 @@
       gtk_widget_add_events(cmd,
          GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
 
-      pix = gtk_pixcomm_new(tileset_full_tile_width(tileset),
-                            tileset_full_tile_height(tileset));
+      pix = gtk_image_new();
       node.pix = pix;
+      node.height = tileset_full_tile_height(tileset);
 
       gtk_container_add(GTK_CONTAINER(cmd), pix);
 
@@ -2204,7 +2205,7 @@
       cmd = pnode->cmd;
       pix = pnode->pix;
 
-      put_unit_gpixmap(punit, GTK_PIXCOMM(pix));
+      put_unit_image(punit, GTK_IMAGE(pix));
 
       g_signal_handlers_disconnect_matched(cmd,
          G_SIGNAL_MATCH_FUNC,

Modified: branches/S2_6/client/gui-gtk-3.22/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/mapview.c?rev=34257&r1=34256&r2=34257&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/mapview.c (original)
+++ branches/S2_6/client/gui-gtk-3.22/mapview.c Thu Oct 27 05:48:15 2016
@@ -481,20 +481,6 @@
 }
 
 /**************************************************************************
-  Fill pixcomm with unit gfx
-**************************************************************************/
-void put_unit_gpixmap(struct unit *punit, GtkPixcomm *p)
-{
-  struct canvas canvas_store = FC_STATIC_CANVAS_INIT;
-
-  canvas_store.surface = gtk_pixcomm_get_surface(p);
-
-  gtk_pixcomm_clear(p);
-
-  put_unit(punit, &canvas_store, 1.0, 0, 0);
-}
-
-/**************************************************************************
   Fill image with unit gfx
 **************************************************************************/
 void put_unit_image(struct unit *punit, GtkImage *p)
@@ -515,15 +501,26 @@
   unit, the proper way to do this is probably something like what Civ II does.
   (One food/shield/mask drawn N times, possibly one top of itself. -- SKi 
 **************************************************************************/
-void put_unit_gpixmap_city_overlays(struct unit *punit, GtkPixcomm *p,
-                                    int *upkeep_cost, int happy_cost)
+void put_unit_image_city_overlays(struct unit *punit, GtkImage *p,
+                                  int height,
+                                  int *upkeep_cost, int happy_cost)
 {
   struct canvas store = FC_STATIC_CANVAS_INIT;
- 
-  store.surface = gtk_pixcomm_get_surface(p);
+  GdkPixbuf *pb;
+  int width = tileset_full_tile_width(tileset);
+
+  store.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+                                             width, height);
+
+  put_unit(punit, &store, 1.0, 0, 0);
 
   put_unit_city_overlays(punit, &store, 0, 
tileset_unit_layout_offset_y(tileset),
                          upkeep_cost, happy_cost);
+
+  pb = surface_get_pixbuf(store.surface, width, height);
+  gtk_image_set_from_pixbuf(p, pb);
+  g_object_unref(pb);
+  cairo_surface_destroy(store.surface);
 }
 
 /**************************************************************************

Modified: branches/S2_6/client/gui-gtk-3.22/mapview.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/mapview.h?rev=34257&r1=34256&r2=34257&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/mapview.h (original)
+++ branches/S2_6/client/gui-gtk-3.22/mapview.h Thu Oct 27 05:48:15 2016
@@ -25,7 +25,6 @@
 
 /* client/gui-gtk-3.22 */
 #include "canvas.h"
-#include "gtkpixcomm.h"
 #include "graphics.h"
 
 GdkPixbuf *get_thumb_pixbuf(int onoff);
@@ -37,12 +36,10 @@
 gboolean map_canvas_configure(GtkWidget *w, GdkEventConfigure *ev,
                               gpointer data);
 
-void put_unit_gpixmap(struct unit *punit, GtkPixcomm *p);
-
 void put_unit_image(struct unit *punit, GtkImage *p);
 
-void put_unit_gpixmap_city_overlays(struct unit *punit, GtkPixcomm *p,
-                                    int *upkeep_cost, int happy_cost);
+void put_unit_image_city_overlays(struct unit *punit, GtkImage *p,
+                                  int height, int *upkeep_cost, int 
happy_cost);
 
 void scrollbar_jump_callback(GtkAdjustment *adj, gpointer hscrollbar);
 void update_map_canvas_scrollbars_size(void);


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

Reply via email to