Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 28 Jul 2014, 02:28
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkImageMenuItem - how do i set an image (SOLVED)
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Fri 30 Jul 2010, 06:17    Post subject:  GtkImageMenuItem - how do i set an image (SOLVED)  

I would like to add a custom icon to the menu in my firewallstate tray app and can't get my head around how to assign an image.

I checked the gtk status commands but I am not sure how to implement a custom icon.

Anyone ?? below is menu entry for a single item, note the GTK_STOCK_PREFERENCES that needs to be an icon file pointer.

iconw needs to be ' gtk_image_menu_item_set_image ' but how to point to the file?

Code:

GtkWidget *menu, *menuitem, *label, *iconw ;
        menu = gtk_menu_new();
                               
        label = gtk_image_menu_item_new_with_label("Set time and date");
       iconw = gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(label), iconw);
       gtk_menu_shell_append(GTK_MENU_SHELL(menu), label);

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool
Back to top
View user's profile Send private message Visit poster's website 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Fri 30 Jul 2010, 07:40    Post subject:  

OK, I had this wrong, I needed to load from file and then set the image.

This works:-

Code:
GtkWidget *menu, *menuitem, *label, *iconw, *image, *sep  ;
        menu = gtk_menu_new();

label = gtk_image_menu_item_new_with_label("Firewall ON/OFF");
       image= gtk_image_new_from_file ("/usr/local/lib/X11/mini-icons/mini-firewall.xpm");
       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(label), image);
       gtk_menu_shell_append(GTK_MENU_SHELL(menu), label);
       g_signal_connect(label, "activate", (GCallback) onoff_window, status_icon); 

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0394s ][ Queries: 11 (0.0033s) ][ GZIP on ]