void _HYConsoleWindow::_SetMenuBar(void) { if (menu_items && !gtk_item_factory_get_item(menu_items,"<HY_WINDOW>/Analysis")) { gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Open"); gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Close"); gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Switch to console"); gtk_item_factory_create_items (menu_items, sizeof (hyphy_console_window_menu_file) / sizeof (hyphy_console_window_menu_file[0]), hyphy_console_window_menu_file, this); GtkMenu * fileMenu = GTK_MENU (gtk_item_factory_get_widget (menu_items, "<HY_WINDOW>/File")); gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/New"), 0); gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/Open"), 1); gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/sep1"), 2); gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Clear"), true); gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Select All"), true); gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,21), false); gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,22), false); gtk_widget_set_sensitive(gtk_item_factory_get_item (menu_items,"<HY_WINDOW>/Analysis/Results"), false); gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,30), false); for (long counter=0; counter<availablePostProcessors.countitems(); counter++) { _String * postItem = (_String*)(*(_List*)availablePostProcessors(counter))(0); if (!postItem->Equal (&menuSeparator)) { postItem = (_String*)(*(_List*)availablePostProcessors(counter))(1); _String tryFileName (*postItem); FILE * tryFile = doFileOpen (tryFileName.getStr(), "r"); if (tryFile) { fclose(tryFile); } else { availablePostProcessors.Delete(counter); counter--; } } } if (availablePostProcessors.lLength) { long sepCount = 0; for (long counter=0; counter<availablePostProcessors.countitems(); counter++) { _String * postItem = (_String*)(*(_List*)availablePostProcessors(counter))(0), chopped = _String("/Analysis/Results/")&*postItem; if (postItem->Equal (&menuSeparator)) { GtkItemFactoryEntry aProcEntry = {NULL,NULL,NULL,0,"<Separator>"}; chopped = chopped & sepCount++; aProcEntry.path = chopped.sData; gtk_item_factory_create_items (menu_items, 1, &aProcEntry, this); } else { GtkItemFactoryEntry aProcEntry = {NULL,NULL,hyphy_menu_item_callback,1000+counter,"<Item>"}; aProcEntry.path = chopped.sData; gtk_item_factory_create_items (menu_items, 1, &aProcEntry, this); } } } } }
static void menu_reorder (GtkMenu *menu, GtkWidget *item, int pos) { if (pos == 0xffff) /* outbound.c uses this default */ return; if (pos < 0) /* position offset from end/bottom */ gtk_menu_reorder_child (menu, item, (g_list_length (GTK_MENU_SHELL (menu)->children) + pos) - 1); else gtk_menu_reorder_child (menu, item, pos); }
void sc_gui_create_edit_menu(void) { sc_info->edit_menu = ui_image_menu_item_new(GTK_STOCK_SPELL_CHECK, _("Spelling Suggestions")); gtk_container_add(GTK_CONTAINER(geany->main_widgets->editor_menu), sc_info->edit_menu); gtk_menu_reorder_child(GTK_MENU(geany->main_widgets->editor_menu), sc_info->edit_menu, 0); sc_info->edit_menu_sep = gtk_separator_menu_item_new(); gtk_container_add(GTK_CONTAINER(geany->main_widgets->editor_menu), sc_info->edit_menu_sep); gtk_menu_reorder_child(GTK_MENU(geany->main_widgets->editor_menu), sc_info->edit_menu_sep, 1); gtk_widget_show_all(sc_info->edit_menu); }
void tray_menu_move_down_preset(preset *ps, gint index) { GList *menuitems; GtkWidget *menuitem; menuitems = gtk_container_get_children (GTK_CONTAINER (tray_menu)); g_assert(index < g_list_length (menuitems)); menuitem = g_list_nth_data (menuitems, index); gtk_menu_reorder_child (GTK_MENU (tray_menu), menuitem, GPOINTER_TO_INT (index - 1)); g_signal_connect (menuitem, "activate", G_CALLBACK (preset_menuitem_activate_cb), GINT_TO_POINTER (index - 1)); menuitems = gtk_container_get_children (GTK_CONTAINER (tray_menu)); menuitem = g_list_nth_data (menuitems, index); g_signal_connect (menuitem, "activate", G_CALLBACK (preset_menuitem_activate_cb), GINT_TO_POINTER (index)); }
void _HYModelWindow::_SetMenuBar(void) { if (menu_items && !gtk_item_factory_get_item(menu_items,"<HY_WINDOW>/Model")) { gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Save"); gtk_item_factory_create_items (menu_items, sizeof (hyphy_parameter_model_window_menu) / sizeof (hyphy_parameter_model_window_menu[0]), hyphy_parameter_model_window_menu, this); GtkMenu * fileMenu = GTK_MENU (gtk_item_factory_get_widget (menu_items, "<HY_WINDOW>/File")); gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/Save"), 0); for (long k=0; k<rateOptions.lLength; k++) { _String *thisItem = (_String*)rateOptions (k), chopped, type = "<CheckItem>"; GtkItemFactoryEntry aProcEntry = {NULL,NULL,(GtkItemFactoryCallback)hyphy_menu_item_callback,HY_MDL_WIN32_MENU_BASE+100+k,type.sData}; chopped = _String("/Model/Rate variation/")&*thisItem; aProcEntry.path = chopped.sData; gtk_item_factory_create_items (menu_items, 1, &aProcEntry, this); } gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget_by_action(menu_items,HY_MDL_WIN32_MENU_BASE+100+rateChoice)), true); gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Copy"), true); gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Select All"), true); } }
static VALUE rg_reorder_child(VALUE self, VALUE child, VALUE position) { gtk_menu_reorder_child(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), NUM2INT(position)); return self; }
/* When one of the children move we need to react to that and move it on the GTK side as well. */ static void root_child_moved (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newposition, guint oldposition, DbusmenuGtkMenu * menu) { #ifdef MASSIVEDEBUGGING g_debug("Root child moved"); #endif DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); gtk_menu_reorder_child(GTK_MENU(menu), GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)), dbusmenu_menuitem_get_position_realized(child, root)); return; }
void _HYChartWindow::_SetMenuBar(void) { if (menu_items && !gtk_item_factory_get_widget(menu_items,"<HY_WINDOW>/Chart")) { gtk_item_factory_create_items (menu_items, sizeof (hyphy_char_window_menu) / sizeof (hyphy_char_window_menu[0]), hyphy_char_window_menu, this); GtkMenu *fileMenu = GTK_MENU(gtk_item_factory_get_widget(menu_items,"<HY_WINDOW>/File")); gtk_menu_reorder_child(fileMenu,gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_FILE+3),1); gtk_menu_reorder_child(fileMenu,gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_FILE+4),2); gtk_menu_reorder_child(fileMenu,gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_FILE+5),4); gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_EDIT+1),true); gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_EDIT+3),true); gtk_widget_set_sensitive(gtk_item_factory_get_widget_by_action(menu_items,HY_WINDOW_MENU_ID_EDIT+5),true); /*InsertMenu (saveMenu, 0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+1, "Save &Chart\tCtrl-S"); InsertMenu (saveMenu, 0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+3, "Save &Graphic"); InsertMenu (saveMenu, 0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+4, "Save &Table"); InsertMenu (printMenu, 0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+2, "Print &Graphic\tCtrl-P"); InsertMenu (printMenu, 0xFFFFFFFF, MF_BYPOSITION|MF_STRING, HY_WINDOW_MENU_ID_FILE+5, "Print &Data");*/ for (long k=0; k<chartProcessors.lLength; k++) { _String *thisItem = (_String*)chartProcessors (k), chopped = thisItem->Cut (thisItem->FindBackwards ('/',0,-1)+1,-1), type = "<Item>"; GtkItemFactoryEntry aProcEntry = {NULL,NULL,(GtkItemFactoryCallback)hyphy_menu_item_callback,HY_CHART_WIN32_MENU_BASE+5+k,type.sData}; chopped = _String("/Chart/Data Processing/")&chopped; aProcEntry.path = chopped.sData; gtk_item_factory_create_items (menu_items, 1, &aProcEntry, this); } //ModifyMenu (chartMenu, 0, MF_BYPOSITION|MF_POPUP, (UINT) saveMenu , "&Save"); //ModifyMenu (chartMenu, 1, MF_BYPOSITION|MF_POPUP, (UINT) printMenu , "&Print"); } }
int clip_GTK_MENUREORDERCHILD(ClipMachine * ClipMachineMemory) { C_widget *cmnu = _fetch_cw_arg(ClipMachineMemory); C_widget *cwid = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); int position = _clip_parni(ClipMachineMemory, 3); CHECKCWID(cmnu, GTK_IS_MENU); CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType); CHECKCWID(cwid, GTK_IS_WIDGET); CHECKOPT(3, NUMERIC_type_of_ClipVarType); gtk_menu_reorder_child(GTK_MENU(cmnu->widget), cwid->widget, position); return 0; err: return 1; }
/* Called when the child is realized, and thus has all of its properties and GTK-isms. We can put it in our menu here. */ static void child_realized (DbusmenuMenuitem * child, gpointer userdata) { #ifdef MASSIVEDEBUGGING g_debug("Root child realized"); #endif g_return_if_fail(DBUSMENU_IS_GTKMENU(userdata)); DbusmenuGtkMenu * menu = DBUSMENU_GTKMENU(userdata); DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); GtkWidget * child_widget = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)); if (child_widget != NULL) { gtk_menu_shell_append(GTK_MENU_SHELL(menu), child_widget); gtk_menu_reorder_child(GTK_MENU(menu), child_widget, dbusmenu_menuitem_get_position_realized(child, dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client)))); } else { g_warning("Child is realized, but doesn't have a GTK Widget!"); } return; }
/** * gimp_unit_menu_set_unit: * @menu: The unit menu you want to set the unit for. * @unit: The new unit. * * Sets a new #GimpUnit for the specified #GimpUnitMenu. **/ void gimp_unit_menu_set_unit (GimpUnitMenu *menu, GimpUnit unit) { GtkWidget *menuitem = NULL; GList *items; gint user_unit; g_return_if_fail (GIMP_IS_UNIT_MENU (menu)); g_return_if_fail (((unit >= GIMP_UNIT_PIXEL) && ((unit > GIMP_UNIT_PIXEL) || menu->show_pixels) && (unit < gimp_unit_get_number_of_units ())) || ((unit == GIMP_UNIT_PERCENT) && menu->show_percent)); if (unit == menu->unit) return; items = GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu)->children; user_unit = (GIMP_UNIT_END + (((menu->show_pixels || menu->show_percent) ? 2 : 0) + ((menu->show_pixels && menu->show_percent) ? 1 : 0))); if ((unit >= GIMP_UNIT_END) && (unit != GIMP_UNIT_PERCENT)) { gchar *string; if ((g_list_length (items) - 3) >= user_unit) { gtk_widget_destroy (GTK_WIDGET (g_list_nth_data (items, user_unit - 1))); gtk_widget_destroy (GTK_WIDGET (g_list_nth_data (items, user_unit - 1))); } menuitem = gtk_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu), menuitem); gtk_widget_set_sensitive (menuitem, FALSE); gtk_menu_reorder_child (GTK_MENU (GTK_OPTION_MENU (menu)->menu), menuitem, user_unit - 1); gtk_widget_show (menuitem); string = gimp_unit_format_string (menu->format, unit); menuitem = gtk_menu_item_new_with_label (string); g_free (string); gtk_menu_shell_append (GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu), menuitem); g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu", GINT_TO_POINTER (unit)); gtk_menu_reorder_child (GTK_MENU (GTK_OPTION_MENU (menu)->menu), menuitem, user_unit); gtk_widget_show (menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (gimp_unit_menu_callback), menu); } menu->unit = unit; gtk_option_menu_set_history (GTK_OPTION_MENU (menu), (unit == GIMP_UNIT_PIXEL) ? 0 : ((unit == GIMP_UNIT_PERCENT) ? (menu->show_pixels ? 1 : 0) : (((menu->show_pixels || menu->show_percent) ? 2 : 0) + ((menu->show_pixels && menu->show_percent) ? 1 : 0) + ((unit < GIMP_UNIT_END) ? (unit - 1) : GIMP_UNIT_END)))); g_signal_emit (menu, gimp_unit_menu_signals[UNIT_CHANGED], 0); }