/** * gnome_popup_menu_append: * @popup: An existing popup menu. * @uiinfo: A #GnomeUIInfo array describing new menu elements. * * Appends the menu items in @uiinfo the @popup menu. */ void gnome_popup_menu_append (GtkWidget *popup, GnomeUIInfo *uiinfo) { GnomeUIBuilderData uibdata; gint length; g_return_if_fail (uiinfo != NULL); uibdata.connect_func = popup_connect_func; uibdata.data = NULL; uibdata.is_interp = TRUE; uibdata.relay_func = NULL; uibdata.destroy_func = NULL; for (length = 0; uiinfo[length].type != GNOME_APP_UI_ENDOFINFO; length++) if (uiinfo[length].type == GNOME_APP_UI_ITEM_CONFIGURABLE) gnome_app_ui_configure_configurable (uiinfo + length); global_menushell_hack = popup; gnome_app_fill_menu_custom (GTK_MENU_SHELL (popup), uiinfo, &uibdata, gtk_menu_get_accel_group(GTK_MENU(popup)), FALSE, 0); global_menushell_hack = NULL; }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_menu_item_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean input_label = TRUE, input_rest = TRUE; GtkAccelGroup *accel_group; guint key; GdkModifierType modifiers; /* We only support loading the properties here. */ if (data->action != GB_LOADING) return; #ifdef USE_GNOME /* Check for a stock menu item. */ if (glade_project_get_gnome_support (data->project)) { GnomeUIInfo *uiinfo; gchar *stock_item; GtkWidget *label; gint stock_item_index; stock_item = gb_widget_input_string (data, "stock_item"); if (stock_item && stock_item[0]) { /* Special case for the NEW_SUBTREE. */ if (!strcmp (stock_item, "GNOMEUIINFO_MENU_NEW_SUBTREE")) { stock_item_index = GladeStockMenuItemNew; } else { stock_item_index = glade_util_string_array_index (GladeStockMenuItemSymbols, GladeStockMenuItemSize, stock_item); } if (stock_item_index != -1) { uiinfo = &GladeStockMenuItemValues[stock_item_index]; if (uiinfo->type == GNOME_APP_UI_ITEM_CONFIGURABLE) gnome_app_ui_configure_configurable (uiinfo); /* Note that we don't have to worry about the pixmap, since if it had a pixmap it would be a GtkImageMenuItem. */ label = gtk_accel_label_new (""); gtk_label_set_text_with_mnemonic (GTK_LABEL (label), uiinfo->label); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), widget); gtk_container_add (GTK_CONTAINER (widget), label); /* Add the configured accelerator key. */ if (uiinfo->accelerator_key != 0 && widget->parent && GTK_IS_MENU (widget->parent)) { accel_group = GTK_MENU (widget->parent)->accel_group; gtk_widget_add_accelerator (widget, "activate", accel_group, uiinfo->accelerator_key, uiinfo->ac_mods, GTK_ACCEL_VISIBLE); } /* Remember the index of the stock item. */ gtk_object_set_data (GTK_OBJECT (widget), GladeMenuItemStockIndexKey, GINT_TO_POINTER (stock_item_index)); /* The 'New' item can have a label. The rest can't. */ if (stock_item_index != GladeStockMenuItemNew) input_label = FALSE; input_rest = FALSE; } else { #ifdef FIXME load_add_error_message_with_tag (data, GLADE_LINE_PROPERTY, _("Invalid stock menu item"), "stock_item", stock_item); #endif } } } #endif if (input_label) gb_widget_input_child_label (widget, data, Label); if (input_rest) { /* FIXME: should this be somewhere else? */ /* If we are loading, install the 'activate' accelerator, if it has one, so that is is visible. */ if (data->action == GB_LOADING && widget->parent && GTK_IS_MENU (widget->parent)) { int i; for (i = 0; i < data->widget_info->n_accels; i++) { if (!strcmp (data->widget_info->accels[i].signal, "activate")) { key = data->widget_info->accels[i].key; modifiers = data->widget_info->accels[i].modifiers; accel_group = GTK_MENU (widget->parent)->accel_group; gtk_widget_add_accelerator (widget, "activate", accel_group, key, modifiers, GTK_ACCEL_VISIBLE); break; } } } } }