/* common.c */ #include "common.h" /* common_new_menubar */ GtkWidget * common_new_menubar(struct _menubar * mb, gpointer data) { GtkWidget * tb_menubar; GtkWidget * menu; GtkWidget * menubar; GtkWidget * menuitem; unsigned int i; unsigned int j; struct _menu * p; tb_menubar = gtk_menu_bar_new(); for(i = 0; mb[i].name != NULL; i++) { menubar = gtk_menu_item_new_with_mnemonic(mb[i].name); menu = gtk_menu_new(); for(j = 0; mb[i].menu[j].name != NULL; j++) { p = &mb[i].menu[j]; if(p->name[0] == '\0') menuitem = gtk_separator_menu_item_new(); else if(p->stock == NULL) menuitem = gtk_menu_item_new_with_mnemonic( p->name); else menuitem = gtk_image_menu_item_new_from_stock( p->stock, NULL); if(p->callback != NULL) g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(p->callback), data); else gtk_widget_set_sensitive(menuitem, FALSE); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); } gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar), menu); gtk_menu_bar_append(GTK_MENU_BAR(tb_menubar), menubar); } return tb_menubar; }