Re: Stock image with custom text on menu item

On Mon, 2004-07-19 at 06:02, Marisa DeMeglio wrote:
I would like to create menu items that are able to use the stock 
graphics, but with custom labels.  What is the best way to do this?

Feel free to use this function:

create_custom_menu_item_from_stock(gchar* label_text,gchar *stock_id)
  GtkWidget* menuitem;
  GtkWidget* image;
  GtkWidget* box;
  GtkWidget* label;

  menuitem = gtk_menu_item_new();
  box = gtk_hbox_new(FALSE,0);

  image = gtk_image_new_from_stock(stock_id,GTK_ICON_SIZE_BUTTON);
  label = gtk_label_new(label_text);

  gtk_box_pack_end  ((GtkBox*)box,label,FALSE,FALSE,0);

  return menuitem;

The quick response is, a GtkMenuItem is also a GtkBin that's a special
type of GtkContainer that can contain a single widget.

You can pack whatever you neeed in a single widget (meaning a
GtkContainer, usually a GtkBox) and add it to the GtkMenuItem ( you can
do it also with GtkButton - as example - because a GtkButton is also a
GtkBin so a GtkContainer).


Hope this helps.

Iago Rubio   
- Home page    * 
- Last project *         
- GPG Keyserv  * id=0x909BD4DD

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