problem with stock icons



Hi!

I'm quite new to GTK2 and have a small problem which I will try to decribe
with the following sample source:

#include <gtk/gtk.h>
#include <gtk/gtkimage.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkcontainer.h>

int main (int argc, char *argv[]) {
gtk_init (&argc, &argv);
GtkWidget *w;
GtkWidget *box;
GtkWidget *button1;
GtkWidget *button2;
GtkWidget *image1;
GtkWidget *image2;
GdkPixbuf *pixbuf;
GdkPixbuf *tmp;

w = gtk_window_new (GTK_WINDOW_TOPLEVEL);

button1 = gtk_button_new ();
tmp = gtk_widget_render_icon (w, GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU, NULL);
pixbuf = gdk_pixbuf_scale_simple (tmp, 10, 50, GDK_INTERP_BILINEAR);
g_object_unref (tmp);
image1 = gtk_image_new_from_pixbuf (pixbuf);

button2 = gtk_button_new ();
image2 = gtk_image_new_from_stock (GTK_STOCK_GO_UP,
GTK_ICON_SIZE_MENU);

box = gtk_hbox_new (0, 0);

gtk_container_add (GTK_CONTAINER (button1), image1);
gtk_container_add (GTK_CONTAINER (button2), image2);
gtk_container_add (GTK_CONTAINER (box), button1);
gtk_container_add (GTK_CONTAINER (box), button2);
gtk_container_add (GTK_CONTAINER (w), box);

g_signal_connect (G_OBJECT (button1), "clicked", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show_all (w);
gtk_main ();
}

If I change the gtk2 theme on the fly (I tried it with 2 different
session managers, one of them ROX-Session), only image2 gets the new
stock icon, but not image1. If I restart the app, both images have the
same new icon.

I hope someone can point to to the problem or can explain the
difference, cause I couldn't find it via the API reference (maybe I
don't know the right keyword to search for).

I' am using gtk 2.2.1-4 on RedHat 9.

Thanks,

Andre



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]