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 Thu 30 Oct 2014, 10:31
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 Posts_count  
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_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_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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