tags:

views:

14

answers:

2

Hi,

I have a GtkButton inside a GtkHButtonBox that doesn't show the image I'm adding to it. It just shows the text. Here's the code:

GtkImage *image = (GtkImage *) gtk_image_new_from_file("Gateway-LT21-netbook-2-540x359");
GtkButton *button = (GtkButton *) gtk_button_new_with_label("test");
gtk_button_set_image(button, (GtkWidget *) image);

Is there something I'm missing?

A: 

gtk_widget_show(GTK_WIDGET(image))?

ptomato
+1  A: 

Make sure that the "gtk-button-images" setting is set to true.

GtkSettings *default_settings = gtk_settings_get_default();
g_object_set(default_settings, "gtk-button-images", TRUE, NULL); 

Note: This should follow the construction of the first window (and of course precede the main loop).

If I'm not mistaken, this is a rather recent change in Gnome - for some reason, they decided for icons not to appear on buttons as default (this also seems to apply to the standard MS Windows theme).

Greg S
Is this setting going to work for all the windows and dialogs?
gvalero87
@gvalero87: yes, this works application-wide.
Greg S
What if I just want to show the image of one button and not all?
gvalero87