hi, had a look at your situation and can report at least why it's happening: - the reason that the tooltip is not working in your example is because a submenu has been added. if you comment out the gtk_menu_item_set_submenu() (and corresponding gtk_menu_append() calls), you see that the tooltip works on the "File" menu item. include the gtk_menu_item_set_submenu() call again and it stops working. my conclusion would be, then, that adding a submenu to a menu file item changes its characteristics such that tooltips are no longer renderable. though a more in-depth explanation will need to come from someone more closely involved in gtk+ widget design, not me. whether this is intended behaviour, i also cannot comment. maybe someone else would like to? cheers, richard > > Hi, > I'm reading a book Sam's teach yourself Gtk+ programming and trying to set > tooltips for menubar's toplevel menuitem which in this case is file_item. > the book states that I can set tooltips with gtk_tooltips_set_tip() > function > without the use of GtkTipsQuery. I did exactly what it said and it works > only for menuitem that are enlisted in submenu not for the toplevel > menuitem > in menuabar. I checked the api and it said "Tooltips can only be set on > widgets which have their own X window and receive enter and leave events. > To > check if a widget has its own window use GTK_WIDGET_NO_WINDOW()." I tested > whether file_item(toplevel menuitem) and exit_item(Submenu's menuitem) > have > their own window with GTK_WINDOW_NO_WINDOW macro and it tested TRUE for > both > of them and still tooltips can be set only for submenu's menuitem and not > for menubar's top level menuitem. I'm bit confused here. Anyone know what > should I do or what am I doin' wrong? Thanks. > > > Note: The code I used is listed below. > > > > > > > > > #include <gtk/gtk.h> > > #define NONHOMOGENEOUS FALSE > #define NO_SPACING 0 > > > > > gboolean delete_handler(GtkWidget *widget, GdkEvent *event, gpointer > user_data) > { > return FALSE; > } > > > void destroy_handler (GtkObject *object, gpointer user_data) > { > gtk_main_quit(); > } > > > int main(int argc, char *argv[]) > { > GtkWidget *top_window, *vbox, *label; > GtkWidget *menu_bar, *file_item, *file_menu, *separator, *exit_item; > > GtkTooltips *tooltips; > > /* 1)Initialize the environement*/ > gtk_init(&argc, &argv); > > > > /* 2)Create widgets and show attributes*/ > top_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > vbox = gtk_vbox_new(NONHOMOGENEOUS, NO_SPACING); > label = gtk_label_new("GTK+ is fun."); > > menu_bar = gtk_menu_bar_new(); > file_item = gtk_menu_item_new_with_label("File"); > file_menu = gtk_menu_new(); > separator = gtk_menu_item_new(); > exit_item = gtk_menu_item_new_with_label("Exit"); > > tooltips = gtk_tooltips_new(); > > > > > /* 2b)Show attributes */ > gtk_window_set_title(GTK_WINDOW (top_window), "Test"); > gtk_widget_set_size_request(label, 200, 200); > > > /* 3)Register siganls */ > g_signal_connect(G_OBJECT(top_window), "delete-event", > G_CALLBACK(delete_handler), NULL); > g_signal_connect(G_OBJECT(top_window), "destroy", > G_CALLBACK(destroy_handler), NULL); > g_signal_connect(G_OBJECT(exit_item), "activate", > G_CALLBACK(destroy_handler), NULL); > > > > > > /* 4)Create instance hierarchy*/ > gtk_box_pack_start_defaults(GTK_BOX(vbox), menu_bar); > gtk_box_pack_start_defaults(GTK_BOX(vbox), label); > > > gtk_menu_bar_append(GTK_MENU_BAR(menu_bar), file_item); > > gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), file_menu); > > gtk_menu_append(GTK_MENU(file_menu), separator); > gtk_menu_append(GTK_MENU(file_menu), exit_item); > gtk_container_add(GTK_CONTAINER(top_window), vbox); > > > > /*5)Show widgets*/ > gtk_widget_show(file_item); > gtk_widget_show(separator); > gtk_widget_show(exit_item); > > gtk_widget_show(menu_bar); > gtk_widget_show(label); > gtk_widget_show(vbox); > gtk_widget_show(top_window); > > gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), file_item, "Filetoshow", > NULL); > gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), exit_item, "Exit", NULL); > gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), label, "Exit", NULL); > > > /*6)Process signals*/ > gtk_main(); > > > /*7)Quitting*/ > return 0; > } > > > _______________________________________________ > > gtk-list@xxxxxxxxx > http://mail.gnome.org/mailman/listinfo/gtk-list _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list