Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » GTK+
  • » Tooltips can't be set for menubar's top level menuitem. [RSS Feed]

#1 Nov. 3, 2005 20:19:05

Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Tooltips can't be set for menubar's top level menuitem.

Hi,I'm reading a book Sam's teach yourself Gtk+ programming and trying to settooltips 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() functionwithout the use of GtkTipsQuery. I did exactly what it said and it worksonly for menuitem that are enlisted in submenu not for the toplevel menuitemin menuabar. I checked the api and it said "Tooltips can only be set onwidgets which have their own X window and receive enter and leave events. Tocheck if a widget has its own window use GTK_WIDGET_NO_WINDOW()." I testedwhether file_item(toplevel menuitem) and exit_item(Submenu's menuitem) havetheir own window with GTK_WINDOW_NO_WINDOW macro and it tested TRUE for bothof them and still tooltips can be set only for submenu's menuitem and notfor menubar's top level menuitem. I'm bit confused here. Anyone know whatshould I do or what am I doin' wrong? Thanks.Note: The code I used is listed below.

#include <gtk/gtk.h>

#define NO_SPACING 0gboolean delete_handler(GtkWidget *widget, GdkEvent *event, gpointeruser_data){
return FALSE;

void destroy_handler (GtkObject *object, gpointer user_data)

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(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*/

return 0;

gtk-list mailing list


  • Root
  • » GTK+
  • » Tooltips can't be set for menubar's top level menuitem. [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support