Author: cazfi Date: Sat Apr 23 21:45:35 2016 New Revision: 32465 URL: http://svn.gna.org/viewcvs/freeciv?rev=32465&view=rev Log: Replaced GtkPixcomm based put_unit_gpixmap_city_overlays() with GtkImage based solutions in gtk3- and gtk3x-clients.
See patch #7124 Modified: trunk/client/gui-gtk-3.0/citydlg.c trunk/client/gui-gtk-3.0/mapview.c trunk/client/gui-gtk-3.0/mapview.h trunk/client/gui-gtk-3.x/citydlg.c trunk/client/gui-gtk-3.x/mapview.c trunk/client/gui-gtk-3.x/mapview.h Modified: trunk/client/gui-gtk-3.0/citydlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/citydlg.c?rev=32465&r1=32464&r2=32465&view=diff ============================================================================== --- trunk/client/gui-gtk-3.0/citydlg.c (original) +++ trunk/client/gui-gtk-3.0/citydlg.c Sat Apr 23 21:45:35 2016 @@ -61,6 +61,7 @@ #include "graphics.h" #include "gui_main.h" #include "gui_stuff.h" +#include "gtkpixcomm.h" #include "happiness.h" #include "helpdlg.h" #include "inputdlg.h" @@ -94,6 +95,7 @@ struct unit_node { GtkWidget *cmd; GtkWidget *pix; + int height; }; /* get 'struct unit_node' and related function */ @@ -348,7 +350,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); @@ -1509,7 +1511,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)); @@ -1517,7 +1519,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), @@ -2063,7 +2065,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; @@ -2072,8 +2073,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); @@ -2095,9 +2097,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, @@ -2177,9 +2178,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); @@ -2200,7 +2201,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: trunk/client/gui-gtk-3.0/mapview.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/mapview.c?rev=32465&r1=32464&r2=32465&view=diff ============================================================================== --- trunk/client/gui-gtk-3.0/mapview.c (original) +++ trunk/client/gui-gtk-3.0/mapview.c Sat Apr 23 21:45:35 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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: trunk/client/gui-gtk-3.0/mapview.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/mapview.h?rev=32465&r1=32464&r2=32465&view=diff ============================================================================== --- trunk/client/gui-gtk-3.0/mapview.h (original) +++ trunk/client/gui-gtk-3.0/mapview.h Sat Apr 23 21:45:35 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,6 @@ /* client/gui-gtk-3.0 */ #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); Modified: trunk/client/gui-gtk-3.x/citydlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/citydlg.c?rev=32465&r1=32464&r2=32465&view=diff ============================================================================== --- trunk/client/gui-gtk-3.x/citydlg.c (original) +++ trunk/client/gui-gtk-3.x/citydlg.c Sat Apr 23 21:45:35 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 */ @@ -348,7 +350,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); @@ -1508,7 +1510,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)); @@ -1516,7 +1518,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), @@ -2092,7 +2094,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; @@ -2101,8 +2102,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); @@ -2124,9 +2126,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, @@ -2206,9 +2207,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); @@ -2229,7 +2230,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: trunk/client/gui-gtk-3.x/mapview.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/mapview.c?rev=32465&r1=32464&r2=32465&view=diff ============================================================================== --- trunk/client/gui-gtk-3.x/mapview.c (original) +++ trunk/client/gui-gtk-3.x/mapview.c Sat Apr 23 21:45:35 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -476,20 +476,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) @@ -507,15 +493,23 @@ 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); + 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); + + gtk_image_set_from_surface(p, store.surface); + cairo_surface_destroy(store.surface); } /************************************************************************** Modified: trunk/client/gui-gtk-3.x/mapview.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/mapview.h?rev=32465&r1=32464&r2=32465&view=diff ============================================================================== --- trunk/client/gui-gtk-3.x/mapview.h (original) +++ trunk/client/gui-gtk-3.x/mapview.h Sat Apr 23 21:45:35 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,6 @@ /* client/gui-gtk-3.x */ #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