Re: [gtk-list] [gtk-1.0.6] GtkToolbar: THX



Norbert Bladt wrote:
> 
> Hi !
> 
> I did ask two questions on this list how to change a pixmap
> in a toolbar button.
> The replies I received gave me some new ideas to try.
> 
> Thanks a lot for sending this comments. I'll try both and see
> what happens and if they work.
> 
> john@giorgio.hart.bbk.ac.uk suggested to take a look at the
> testgtk notebook part. I did it. It looks promising.
> 
> Feiguin <feiguin@ifir.ifir.edu.ar> suggested a way to remove from and
> then add the item, e.g. the button, to the container, again .
> I'll try this, too.

I use gtk_pixmap_set() to change the pixmap.
The only awkward thing is getting the pixmap widget to change.

The toolbar returns the button when you add the toolbar item.
The button contains a vbox which has 2 children - the label and the pixmap
(assuming you are using standard toolbar buttons).
So you can do something like:


#ifdef GTK_HAVE_FEATURES_1_1_0
  vbox = GTK_BIN (toolbar_button)->child;
#else
  vbox = GTK_BUTTON (toolbar_button)->child;
#endif

  vbox_children = GTK_BOX (vbox)->children;

  /* Note that the label is added first in gtktoolbar.c which is why
     it is first in the list (unless you didn't set any label). */
  label = ((GtkBoxChild*)vbox_children->data)->widget;
  pixmap = ((GtkBoxChild*)vbox_children->next->data)->widget;

  gtk_pixmap_set (GTK_PIXMAP (pixmap), gdk_pixmap, mask);

Damon



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