Re: Stock image with custom text on menu item



W liście z pon, 19-07-2004, godz. 10:37, Iago Rubio pisze: 
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:

GtkWidget*
create_custom_menu_item_from_stock(gchar* label_text,gchar *stock_id)
{
[snip]
  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).

See:
http://developer.gnome.org/doc/API/2.0/gtk/GtkMenuItem.html
http://developer.gnome.org/doc/API/2.0/gtk/GtkBin.html
http://developer.gnome.org/doc/API/2.0/gtk/GtkContainer.html

Better use GtkImageMenuItem, since AFAICT the above code won't respect
user's settings regarding icons visibility in menu. To set image on
GtkImageMenuItem, you can use gtk_image_menu_item_set_image(), obtained
through gtk_image_new_from_stock(). Further details, as always, are
available through DevHelp :)

Cheers,
Maciej

-- 
"Tautologizm to coś tautologicznego"
     Mathrick <mathrick swat pl>
       http://mathrick.blog.pl




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