Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. "Read more...":https://support.plan.io/news/187

Feature #780502 ยป 0001-gtk3x-Avoid-get_image_new_from_surface-and-gtk_image.patch

Marko Lindqvist, 2018-10-18 12:54 PM

View differences:

client/gui-gtk-4.0/citydlg.c
pdialog->citizen_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
citizen_bar_width, citizen_bar_height);
pdialog->citizen_images = gtk_image_new_from_surface(pdialog->citizen_surface);
pdialog->citizen_images = gtk_image_new();
gtk_widget_set_margin_start(pdialog->citizen_images, 2);
gtk_widget_set_margin_end(pdialog->citizen_images, 2);
......
cairo_destroy(cr);
image_set_from_surface(GTK_IMAGE(pdialog->citizen_images), pdialog->citizen_surface);
gtk_widget_queue_draw(pdialog->citizen_images);
}
client/gui-gtk-4.0/diplodlg.c
/* Our flag */
flag_spr = get_nation_flag_sprite(tileset, nation_of_player(plr0));
image = gtk_image_new_from_surface(flag_spr->surface);
image = image_new_from_surface(flag_spr->surface);
gtk_container_add(GTK_CONTAINER(hbox), image);
/* Our name. */
......
/* Their flag */
flag_spr = get_nation_flag_sprite(tileset, nation_of_player(plr1));
image = gtk_image_new_from_surface(flag_spr->surface);
image = image_new_from_surface(flag_spr->surface);
gtk_container_add(GTK_CONTAINER(hbox), image);
/* Their name. */
client/gui-gtk-4.0/gui_main.c
for (i = 0; i < 10; i++) {
spr = i < 5 ? get_tax_sprite(tileset, O_SCIENCE) : get_tax_sprite(tileset, O_GOLD);
econ_label[i] = gtk_image_new_from_surface(spr->surface);
econ_label[i] = image_new_from_surface(spr->surface);
g_signal_connect(econ_label[i], "button_press_event",
G_CALLBACK(taxrates_callback), GINT_TO_POINTER(i));
gtk_grid_attach(GTK_GRID(table2), econ_label[i], i, 0, 1, 1);
......
/* science, environmental, govt, timeout */
spr = client_research_sprite();
if (spr != NULL) {
bulb_label = gtk_image_new_from_surface(spr->surface);
bulb_label = image_new_from_surface(spr->surface);
} else {
bulb_label = gtk_image_new();
}
spr = client_warming_sprite();
if (spr != NULL) {
sun_label = gtk_image_new_from_surface(spr->surface);
sun_label = image_new_from_surface(spr->surface);
} else {
sun_label = gtk_image_new();
}
spr = client_cooling_sprite();
if (spr != NULL) {
flake_label = gtk_image_new_from_surface(spr->surface);
flake_label = image_new_from_surface(spr->surface);
} else {
flake_label = gtk_image_new();
}
spr = client_government_sprite();
if (spr != NULL) {
government_label = gtk_image_new_from_surface(spr->surface);
government_label = image_new_from_surface(spr->surface);
} else {
government_label = gtk_image_new();
}
client/gui-gtk-4.0/happiness.c
GtkWidget *win;
GtkWidget *shell;
GtkWidget *cityname_label;
GtkWidget *feeling_images[NUM_HAPPINESS_MODIFIERS];
cairo_surface_t *feeling_surfaces[NUM_HAPPINESS_MODIFIERS];
GtkWidget *happiness_label[NUM_HAPPINESS_MODIFIERS];
GtkWidget *close;
......
/* list of citizens */
pdialog->feeling_surfaces[i] = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
FEELING_WIDTH, FEELING_HEIGHT);
img = gtk_image_new_from_surface(pdialog->feeling_surfaces[i]);
img = gtk_image_new();
pdialog->feeling_images[i] = img;
gtk_widget_set_margin_start(img, 5);
g_object_set_data(G_OBJECT(img), "pdialog", pdialog);
g_signal_connect(img, "button_press_event",
......
/**********************************************************************//**
Refresh citizens surface
**************************************************************************/
static void refresh_feeling_surface(cairo_surface_t *dst, struct city *pcity,
static void refresh_feeling_surface(GtkWidget *image,
cairo_surface_t *dst, struct city *pcity,
enum citizen_feeling index)
{
enum citizen_category categories[MAX_CITY_SIZE];
......
cairo_fill(cr);
}
image_set_from_surface(GTK_IMAGE(image), dst);
cairo_destroy(cr);
}
......
struct happiness_dialog *pdialog = get_happiness_dialog(pcity);
for (i = 0; i < FEELING_LAST; i++) {
refresh_feeling_surface(pdialog->feeling_surfaces[i], pdialog->pcity, i);
refresh_feeling_surface(pdialog->feeling_images[i],
pdialog->feeling_surfaces[i], pdialog->pcity, i);
}
}
client/gui-gtk-4.0/helpdlg.c
return;
}
gtk_image_set_from_surface(GTK_IMAGE(help_tile), spr->surface);
image_set_from_surface(GTK_IMAGE(help_tile), spr->surface);
gtk_widget_show(help_tile);
}
......
put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
}
gtk_image_set_from_surface(GTK_IMAGE(help_tile), canvas.surface);
image_set_from_surface(GTK_IMAGE(help_tile), canvas.surface);
gtk_widget_show(help_tile);
cairo_surface_destroy(canvas.surface);
}
client/gui-gtk-4.0/mapview.c
for (; d < client.conn.playing->economic.luxury /10; d++) {
struct sprite *spr = get_tax_sprite(tileset, O_LUXURY);
gtk_image_set_from_surface(GTK_IMAGE(econ_label[d]), spr->surface);
image_set_from_surface(GTK_IMAGE(econ_label[d]), spr->surface);
}
for (; d < (client.conn.playing->economic.science
+ client.conn.playing->economic.luxury) / 10; d++) {
struct sprite *spr = get_tax_sprite(tileset, O_SCIENCE);
gtk_image_set_from_surface(GTK_IMAGE(econ_label[d]), spr->surface);
image_set_from_surface(GTK_IMAGE(econ_label[d]), spr->surface);
}
for (; d < 10; d++) {
struct sprite *spr = get_tax_sprite(tileset, O_GOLD);
gtk_image_set_from_surface(GTK_IMAGE(econ_label[d]), spr->surface);
image_set_from_surface(GTK_IMAGE(econ_label[d]), spr->surface);
}
}
......
void set_indicator_icons(struct sprite *bulb, struct sprite *sol,
struct sprite *flake, struct sprite *gov)
{
gtk_image_set_from_surface(GTK_IMAGE(bulb_label), bulb->surface);
gtk_image_set_from_surface(GTK_IMAGE(sun_label), sol->surface);
gtk_image_set_from_surface(GTK_IMAGE(flake_label), flake->surface);
gtk_image_set_from_surface(GTK_IMAGE(government_label), gov->surface);
image_set_from_surface(GTK_IMAGE(bulb_label), bulb->surface);
image_set_from_surface(GTK_IMAGE(sun_label), sol->surface);
image_set_from_surface(GTK_IMAGE(flake_label), flake->surface);
image_set_from_surface(GTK_IMAGE(government_label), gov->surface);
}
/**********************************************************************//**
......
put_unit(punit, &store, 1.0, 0, 0);
gtk_image_set_from_surface(p, store.surface);
image_set_from_surface(p, store.surface);
cairo_surface_destroy(store.surface);
}
......
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);
image_set_from_surface(p, store.surface);
cairo_surface_destroy(store.surface);
}
client/gui-gtk-4.0/sprite.c
return pixbuf;
}
/************************************************************************//**
Create a GtkImage from cairo surface.
****************************************************************************/
GtkWidget *image_new_from_surface(cairo_surface_t *surf)
{
GdkPixbuf *pb;
GtkWidget *image;
pb = surface_get_pixbuf(surf,
cairo_image_surface_get_width(surf),
cairo_image_surface_get_height(surf));
image = gtk_image_new_from_pixbuf(pb);
g_object_unref(pb);
return image;
}
/************************************************************************//**
Set a GtkImage from cairo surface.
****************************************************************************/
void image_set_from_surface(GtkImage *image, cairo_surface_t *surf)
{
GdkPixbuf *pb;
pb = surface_get_pixbuf(surf,
cairo_image_surface_get_width(surf),
cairo_image_surface_get_height(surf));
gtk_image_set_from_pixbuf(image, pb);
g_object_unref(pb);
}
client/gui-gtk-4.0/sprite.h
GdkPixbuf *create_extra_pixbuf(const struct extra_type *pextra);
GtkWidget *image_new_from_surface(cairo_surface_t *surf);
void image_set_from_surface(GtkImage *image, cairo_surface_t *surf);
#endif /* FC__SPRITE_H */
    (1-1/1)