Beispiel #1
0
static void
activate (GApplication *app,
          gpointer      user_data)
{
    GtkWidget *win;
    GtkWidget *button;
    GSimpleActionGroup *doc_actions;
    GtkBuilder *builder;
    GMenuModel *doc_menu;
    GMenuModel *win_menu;
    GMenu *button_menu;
    GMenuItem *section;

    if (gtk_application_get_windows (GTK_APPLICATION (app)) != NULL)
        return;

    win = gtk_application_window_new (GTK_APPLICATION (app));

    doc_actions = g_simple_action_group_new ();
    g_action_map_add_action_entries (G_ACTION_MAP (doc_actions), doc_entries, G_N_ELEMENTS (doc_entries), win);

    g_action_map_add_action_entries (G_ACTION_MAP (win), win_entries,
                                     G_N_ELEMENTS (win_entries), win);

    builder = gtk_builder_new ();
    gtk_builder_add_from_string (builder, menu_ui, -1, NULL);

    doc_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "doc-menu"));
    win_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "win-menu"));

    button_menu = g_menu_new ();

    section = g_menu_item_new_section (NULL, doc_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "doc");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    section = g_menu_item_new_section (NULL, win_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "win");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    button = gtk_menu_button_new ();
    gtk_button_set_label (GTK_BUTTON (button), "Menu");
    gtk_widget_insert_action_group (button, "doc", G_ACTION_GROUP (doc_actions));
    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (button_menu));

    gtk_container_add (GTK_CONTAINER (win), button);
    gtk_container_set_border_width (GTK_CONTAINER (win), 12);
    gtk_widget_show_all (win);

    g_object_unref (button_menu);
    g_object_unref (doc_actions);
    g_object_unref (builder);
}
Beispiel #2
0
void
gw_application_set_win_menubar (GwApplication *application, GMenuModel *menumodel)
{
    //Sanity checks
    g_return_if_fail (application != NULL);
    g_return_if_fail (menumodel != NULL);
    if (g_menu_model_get_n_items (menumodel) == 0) return;

    //Declarations
    GMenuModel *menubar;
    gint length;

    //Initializations
    menubar = gtk_application_get_menubar (GTK_APPLICATION (application));
    g_return_if_fail (menubar != NULL);
    length = g_menu_model_get_n_items (menubar);

    //Clear the menubar
    while (length-- > 0) g_menu_remove (G_MENU (menubar), 0);

    //Add the menuitem linking the menus 
    {
      GMenuItem *menuitem = g_menu_item_new_section (NULL, menumodel);
      if (menuitem != NULL)
      {
        g_menu_append_item (G_MENU (menubar), menuitem);
        g_object_unref (menuitem); menuitem = NULL;
      }
      gw_application_add_accelerators (application, menubar);
    }
}
/*
 * The GMenu @menu is modified adding to the section @submodel_name
 * the item @item.
 */
void
nautilus_gmenu_add_item_in_submodel (GMenu       *menu,
                                     GMenuItem   *item,
                                     const gchar *submodel_name,
                                     gboolean     prepend)
{
    GMenuModel *submodel;

    g_return_if_fail (G_IS_MENU (menu));
    g_return_if_fail (G_IS_MENU_ITEM (item));

    submodel = find_gmenu_model (G_MENU_MODEL (menu), submodel_name);

    g_return_if_fail (submodel != NULL);
    if (prepend)
    {
        g_menu_prepend_item (G_MENU (submodel), item);
    }
    else
    {
        g_menu_append_item (G_MENU (submodel), item);
    }

    g_object_unref (submodel);
}
/*
 * The original GMenu is modified adding to the section @submodel_name
 * the items in @gmenu_to_merge.
 * @gmenu_to_merge should be a list of menu items.
 */
void
nautilus_gmenu_merge (GMenu       *original,
                      GMenu       *gmenu_to_merge,
                      const gchar *submodel_name,
                      gboolean     prepend)
{
    gint i, n_items;
    GMenuModel *submodel;
    GMenuItem *item;

    g_return_if_fail (G_IS_MENU (original));
    g_return_if_fail (G_IS_MENU (gmenu_to_merge));

    submodel = find_gmenu_model (G_MENU_MODEL (original), submodel_name);

    g_return_if_fail (submodel != NULL);

    n_items = g_menu_model_get_n_items (G_MENU_MODEL (gmenu_to_merge));

    for (i = 0; i < n_items; i++)
    {
        item = g_menu_item_new_from_model (G_MENU_MODEL (gmenu_to_merge), i);
        if (prepend)
        {
            g_menu_prepend_item (G_MENU (submodel), item);
        }
        else
        {
            g_menu_append_item (G_MENU (submodel), item);
        }
        g_object_unref (item);
    }

    g_object_unref (submodel);
}
Beispiel #5
0
static void
_gth_browser_update_entry_point_list (GthBrowser *browser)
{
    BrowserData  *data;
    GList        *entry_points;
    GList        *scan;

    data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
    g_return_if_fail (data != NULL);

    g_menu_remove_all (data->entry_points_menu);

    entry_points = gth_main_get_all_entry_points ();
    for (scan = entry_points; scan; scan = scan->next) {
        GthFileData *file_data = scan->data;
        GMenuItem   *item;
        char        *uri;

        item = _g_menu_item_new_for_file (file_data->file, NULL);
        uri = g_file_get_uri (file_data->file);
        g_menu_item_set_action_and_target (item, "win.go-to-location", "s", uri);
        g_menu_append_item (data->entry_points_menu, item);

        g_free (uri);
        g_object_unref (item);
    }

    _g_object_list_unref (entry_points);
}
Beispiel #6
0
static GMenu *open_btn_build_menu()
{
	GMenu *menu;
	GMenuItem *open_menu_item;
	GMenuItem *open_loc_menu_item;

	menu = g_menu_new();

	open_menu_item = g_menu_item_new(_("_Open"), "app.open");

	open_loc_menu_item
		= g_menu_item_new(_("Open _Location"), "app.openloc");

	g_menu_append_item(menu, open_menu_item);
	g_menu_append_item(menu, open_loc_menu_item);

	return menu;
}
static void
impl_activate (EogWindowActivatable *activatable)
{
	const gchar * const accel_keys[] = { "W", NULL };
	EogFitToWidthPlugin *plugin = EOG_FIT_TO_WIDTH_PLUGIN (activatable);
	GMenu *model, *menu;
	GMenuItem *item;
	GSimpleAction *action;
	GAction *ref_action;

	model= eog_window_get_gear_menu_section (plugin->window,
						 "plugins-section");

	g_return_if_fail (G_IS_MENU (model));

	/* Setup and inject action */
	action = g_simple_action_new (EOG_FIT_TO_WIDTH_PLUGIN_ACTION, NULL);
	g_signal_connect(action, "activate",
			 G_CALLBACK (fit_to_width_cb), plugin->window);
	g_action_map_add_action (G_ACTION_MAP (plugin->window),
				 G_ACTION (action));

	/* Bind to the zoom-normal action's enabled property to only enable
	 * fit-to-width zooming if zooming is generally enabled */
	ref_action = g_action_map_lookup_action (G_ACTION_MAP (plugin->window),
						 "zoom-normal");
	if (ref_action)
		g_object_bind_property (ref_action, "enabled",
					action, "enabled",
					G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
	g_object_unref (action);

	/* Append entry to the window's gear menu */
	menu = g_menu_new ();
	g_menu_append (menu, _("Fit to width"),
		       "win." EOG_FIT_TO_WIDTH_PLUGIN_ACTION);

	item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu));
	g_menu_item_set_attribute (item, "id",
				   "s", EOG_FIT_TO_WIDTH_PLUGIN_MENU_ID);
	g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON,
				   "s", "zoom-fit-best-symbolic");
	g_menu_append_item (model, item);
	g_object_unref (item);

	g_object_unref (menu);

	/* Define accelerator keys */
	gtk_application_set_accels_for_action (GTK_APPLICATION (EOG_APP),
					       "win." EOG_FIT_TO_WIDTH_PLUGIN_ACTION,
					       accel_keys);
}
static void
menu_append_hidden (GMenu      *menu,
		    const char *label,
		    const char *detailed_action)
{
	GMenuItem *item;

	item = g_menu_item_new (label, detailed_action);
	g_menu_item_set_attribute_value (item, "hidden-when",
					 g_variant_new_string ("action-disabled"));
	g_menu_append_item (menu, item);
	g_object_unref (item);
}
Beispiel #9
0
static void
eog_reload_plugin_activate (EogWindowActivatable *activatable)
{
	const gchar * const accel_keys[] = { "R", NULL };
	EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (activatable);
	GMenu *model, *menu;
	GMenuItem *item;
	GSimpleAction *action;

	eog_debug (DEBUG_PLUGINS);

	model= eog_window_get_gear_menu_section (plugin->window,
						 "plugins-section");

	g_return_if_fail (G_IS_MENU (model));

	/* Setup and inject action */
	action = g_simple_action_new (EOG_RELOAD_PLUGIN_ACTION, NULL);
	g_signal_connect(action, "activate",
			 G_CALLBACK (reload_cb), plugin->window);
	g_action_map_add_action (G_ACTION_MAP (plugin->window),
				 G_ACTION (action));
	g_object_unref (action);

	g_signal_connect (G_OBJECT (eog_window_get_thumb_view (plugin->window)),
			  "selection-changed",
			  G_CALLBACK (_selection_changed_cb),
			  plugin);
	eog_reload_plugin_update_action_state (plugin);

	/* Append entry to the window's gear menu */
	menu = g_menu_new ();
	g_menu_append (menu, _("Reload Image"),
		       "win." EOG_RELOAD_PLUGIN_ACTION);

	item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu));
	g_menu_item_set_attribute (item, "id",
				   "s", EOG_RELOAD_PLUGIN_MENU_ID);
	g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON,
				   "s", "view-refresh-symbolic");
	g_menu_append_item (model, item);
	g_object_unref (item);

	g_object_unref (menu);

	/* Define accelerator keys */
	gtk_application_set_accels_for_action (GTK_APPLICATION (EOG_APP),
					       "win." EOG_RELOAD_PLUGIN_ACTION,
					       accel_keys);
}
Beispiel #10
0
static GMenu *build_app_menu()
{
	GMenu *menu;
	GMenu *top_section;
	GMenu *bottom_section;
	GMenuItem *pref_menu_item;
	GMenuItem *about_menu_item;
	GMenuItem *quit_menu_item;

	menu = g_menu_new();
	top_section = g_menu_new();
	bottom_section = g_menu_new();
	pref_menu_item = g_menu_item_new(_("_Preferences"), "app.pref");
	about_menu_item = g_menu_item_new(_("_About"), "app.about");
	quit_menu_item = g_menu_item_new(_("_Quit"), "app.quit");

	g_menu_append_section(menu, NULL, G_MENU_MODEL(top_section));
	g_menu_append_section(menu, NULL, G_MENU_MODEL(bottom_section));
	g_menu_append_item(top_section, pref_menu_item);
	g_menu_append_item(bottom_section, about_menu_item);
	g_menu_append_item(bottom_section, quit_menu_item);

	return menu;
}
Beispiel #11
0
static gboolean mouse_press_handler(	GtkWidget *widget,
					GdkEvent *event,
					gpointer data )
{
	GdkEventButton *btn_event = (GdkEventButton *)event;
	gboolean handled;

	handled = (	btn_event->type == GDK_BUTTON_PRESS &&
			btn_event->button == 3 );

	if(handled)
	{
		GMenu *menu;
		GMenuItem *add_menu_item;
		GMenuItem *loop_menu_item;
		GtkWidget *ctx_menu;

		menu = g_menu_new();
		add_menu_item = g_menu_item_new(_("_Add…"), "app.open(true)");
		loop_menu_item = g_menu_item_new(_("Loop"), "app.loop");

		g_menu_append_item(menu, add_menu_item);
		g_menu_append_item(menu, loop_menu_item);
		g_menu_freeze(menu);

		ctx_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));

		gtk_menu_attach_to_widget(GTK_MENU(ctx_menu), widget, NULL);
		gtk_widget_show_all(ctx_menu);

		gtk_menu_popup(	GTK_MENU(ctx_menu), NULL, NULL, NULL, NULL,
				btn_event->button, btn_event->time );
	}

	return handled;
}
int
main (int argc, char **argv)
{
  IndicatorTestService indicator = { 0 };
  GMenuItem *item;
  GMenu *submenu;
  GActionEntry entries[] = {
    { "_header", NULL, NULL, "{'label': <'Test'>,"
                             " 'icon': <'indicator-test'>,"
                             " 'accessible-desc': <'Test indicator'> }", NULL },
    { "show", activate_show, NULL, NULL, NULL }
  };
  GMainLoop *loop;

  indicator.actions = g_simple_action_group_new ();
  g_simple_action_group_add_entries (indicator.actions, entries, G_N_ELEMENTS (entries), NULL);

  submenu = g_menu_new ();
  g_menu_append (submenu, "Show", "indicator.show");
  item = g_menu_item_new (NULL, "indicator._header");
  g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.root");
  g_menu_item_set_submenu (item, G_MENU_MODEL (submenu));
  indicator.menu = g_menu_new ();
  g_menu_append_item (indicator.menu, item);

  g_bus_own_name (G_BUS_TYPE_SESSION,
                  "com.canonical.indicator.test",
                  G_BUS_NAME_OWNER_FLAGS_NONE,
                  bus_acquired,
                  NULL,
                  name_lost,
                  &indicator,
                  NULL);

  loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (loop);

  g_object_unref (submenu);
  g_object_unref (item);
  g_object_unref (indicator.actions);
  g_object_unref (indicator.menu);
  g_object_unref (loop);

  return 0;
}
Beispiel #13
0
static void
update_system_bookmark_list_from_content (GthBrowser *browser,
        const char *content)
{
    BrowserData   *data;
    char        **lines;
    int           i;

    data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
    g_return_if_fail (data != NULL);

    lines = g_strsplit (content, "\n", -1);
    for (i = 0; lines[i] != NULL; i++) {
        char      **line;
        char       *uri;
        GFile      *file;
        char       *name;
        GMenuItem  *item;

        line = g_strsplit (lines[i], " ", 2);
        uri = line[0];
        if (uri == NULL) {
            g_strfreev (line);
            continue;
        }

        file = g_file_new_for_uri (uri);
        name = g_strdup (strchr (lines[i], ' '));
        if (name == NULL)
            name = _g_file_get_display_name (file);
        if (name == NULL)
            name = g_file_get_parse_name (file);
        item = _g_menu_item_new_for_file (file, name);
        g_menu_item_set_action_and_target (item, "win.go-to-location", "s", uri);
        g_menu_append_item (data->system_bookmarks_menu, item);

        g_object_unref (item);
        g_free (name);
        g_object_unref (file);
        g_strfreev (line);
    }

    g_strfreev (lines);
}
Beispiel #14
0
static void
enable_plugin (const gchar *name)
{
  GMenuModel *plugin_menu;
  GAction *action;

  g_print ("Enabling '%s' plugin\n", name);

  action = (GAction *)g_simple_action_new (name, NULL);
  g_signal_connect (action, "activate", G_CALLBACK (plugin_action), (gpointer)name);
  g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()), action);
  g_print ("Actions of '%s' plugin added\n", name);
  g_object_unref (action);

  plugin_menu = find_plugin_menu ();
  if (plugin_menu)
    {
      GMenu *section;
      GMenuItem *item;
      gchar *label;
      gchar *action_name;

      section = g_menu_new ();
      label = g_strdup_printf ("Turn text %s", name);
      action_name = g_strconcat ("app.", name, NULL);
      g_menu_insert (section, 0, label, action_name);
      g_free (label);
      g_free (action_name);
      item = g_menu_item_new_section (NULL, (GMenuModel*)section);
      g_menu_item_set_attribute (item, "id", "s", name);
      g_menu_append_item (G_MENU (plugin_menu), item);
      g_object_unref (item);
      g_object_unref (section);
      g_print ("Menus of '%s' plugin added\n", name);
    }
  else
    g_warning ("Plugin menu not found\n");

  if (g_strcmp0 (name, "red") == 0)
    is_red_plugin_enabled = TRUE;
  else
    is_black_plugin_enabled = TRUE;
}
Beispiel #15
0
static void
populate_mime_handlers (GMenu         *menu,
                        GbProjectFile *project_file)
{
  g_autofree gchar *content_type = NULL;
  GList *list;
  GList *iter;
  GFile *file;

  g_assert (G_IS_MENU (menu));
  g_assert (GB_IS_PROJECT_FILE (project_file));

  g_menu_remove_all (menu);

  file = gb_project_file_get_file (project_file);
  if (file == NULL)
    return;

  content_type = get_content_type (file);
  if (content_type == NULL)
    return;

  list = g_app_info_get_all_for_type (content_type);

  for (iter = list; iter; iter = iter->next)
    {
      g_autoptr(GMenuItem) menu_item = NULL;
      g_autofree gchar *detailed_action = NULL;
      GAppInfo *app_info = iter->data;
      const gchar *display_name;
      const gchar *app_id;

      display_name = g_app_info_get_display_name (app_info);
      app_id = g_app_info_get_id (app_info);

      detailed_action = g_strdup_printf ("project-tree.open-with('%s')", app_id);
      menu_item = g_menu_item_new (display_name, detailed_action);

      g_menu_append_item (menu, menu_item);
    }

  g_list_free_full (list, g_object_unref);
}
static void
photos_base_model_refresh (PhotosBaseModel *self)
{
  PhotosBaseModelPrivate *priv = self->priv;
  GHashTable *objects;
  GHashTableIter hash_iter;
  GMenu *section;
  GObject *object;
  const gchar *action_id;
  const gchar *id;
  const gchar *title;

  g_menu_remove_all (priv->model);

  title = photos_base_manager_get_title (priv->mngr);
  action_id = photos_base_manager_get_action_id (priv->mngr);

  section = g_menu_new ();
  g_menu_append_section (priv->model, title, G_MENU_MODEL (section));

  objects = photos_base_manager_get_objects (priv->mngr);

  g_hash_table_iter_init (&hash_iter, objects);
  while (g_hash_table_iter_next (&hash_iter, (gpointer *) &id, (gpointer *) &object))
    {
      GMenuItem *menu_item;
      GVariant *target_value;
      gchar *name;

      g_object_get (object, "name", &name, NULL);

      menu_item = g_menu_item_new (name, NULL);
      target_value = g_variant_new ("s", id);
      g_menu_item_set_action_and_target_value (menu_item, action_id, target_value);
      g_menu_append_item (section, menu_item);

      g_free (name);
    }

  g_object_unref (section);
}
Beispiel #17
0
static void
impl_activate (EogWindowActivatable *activatable)
{
	EogPostrPlugin *plugin = EOG_POSTR_PLUGIN (activatable);
	GMenu *model, *menu;
	GMenuItem *item;
	GSimpleAction *action;

	eog_debug (DEBUG_PLUGINS);

	g_return_if_fail (plugin->window != NULL);

	model= eog_window_get_gear_menu_section (plugin->window,
						 "plugins-section");

	g_return_if_fail (G_IS_MENU (model));

	/* Setup and inject action */
	action = g_simple_action_new (EOG_POSTR_PLUGIN_ACTION, NULL);
	g_signal_connect(action, "activate",
			 G_CALLBACK (postr_cb), plugin->window);
	g_action_map_add_action (G_ACTION_MAP (plugin->window),
				 G_ACTION (action));
	g_object_unref (action);

	/* Append entry to the window's gear menu */
	menu = g_menu_new ();
	g_menu_append (menu, _("Upload to Flickr"),
		       "win." EOG_POSTR_PLUGIN_ACTION);

	item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu));
	g_menu_item_set_attribute (item, "id",
				   "s", EOG_POSTR_PLUGIN_MENU_ID);
	g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON,
				   "s", "postr");
	g_menu_append_item (model, item);
	g_object_unref (item);

	g_object_unref (menu);

}
static void
impl_activate (PeasActivatable *plugin)
{
	GtkWindow *window;
	TotemSkiptoPlugin *pi = TOTEM_SKIPTO_PLUGIN (plugin);
	TotemSkiptoPluginPrivate *priv = pi->priv;
	GMenu *menu;
	GMenuItem *item;

	priv->totem = g_object_get_data (G_OBJECT (plugin), "object");
	priv->handler_id_stream_length = g_signal_connect (G_OBJECT (priv->totem),
				"notify::stream-length",
				G_CALLBACK (property_notify_cb),
				pi);
	priv->handler_id_seekable = g_signal_connect (G_OBJECT (priv->totem),
				"notify::seekable",
				G_CALLBACK (property_notify_cb),
				pi);

	/* Key press handler */
	window = totem_object_get_main_window (priv->totem);
	priv->handler_id_key_press = g_signal_connect (G_OBJECT(window),
				"key-press-event",
				G_CALLBACK (on_window_key_press_event),
				pi);
	g_object_unref (window);

	/* Install the menu */
	priv->action = g_simple_action_new ("skip-to", NULL);
	g_signal_connect (G_OBJECT (priv->action), "activate",
			  G_CALLBACK (skip_to_action_callback), plugin);
	g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->action));

	menu = totem_object_get_menu_section (priv->totem, "skipto-placeholder");
	item = g_menu_item_new (_("_Skip To…"), "app.skip-to");
	g_menu_item_set_attribute (item, "accel", "s", "<Ctrl>K");
	g_menu_append_item (G_MENU (menu), item);

	totem_skipto_update_from_state (priv->totem, pi);
}
Beispiel #19
0
static void
ephy_notebook_rebuild_tab_menu (EphyNotebook *notebook)
{
  GMenuItem *item;
  const char *text;
  char *ellipsized_text;
  int num_pages;
  GtkWidget *window;
  GActionGroup *group;
  GAction *action;
  gint current_page;

  g_menu_remove_all (notebook->tab_menu);

  num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));

  /* TODO: Add favicon as well. Will have to ditch GMenu. :( */
  for (int i = 0; i < num_pages; i++) {
    text = get_nth_tab_label_text (GTK_NOTEBOOK (notebook), i);
    ellipsized_text = ellipsize_tab_label (text);
    item = g_menu_item_new (ellipsized_text, NULL);
    g_menu_item_set_action_and_target (item, "win.show-tab", "u", (guint)i, NULL);
    g_menu_append_item (notebook->tab_menu, item);
    g_free (ellipsized_text);
    g_object_unref (item);
  }

  current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
  if (current_page < 0)
    return;

  window = gtk_widget_get_toplevel (GTK_WIDGET (notebook));
  group = gtk_widget_get_action_group (window, "win");
  /* Is window being destroyed? */
  if (group == NULL)
    return;

  action = g_action_map_lookup_action (G_ACTION_MAP (group), "show-tab");
  g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_uint32 ((guint32)current_page));
}
void
nautilus_gmenu_replace_section (GMenu       *menu,
				const gchar *section_id,
				GMenuModel  *section)
{
	GMenuModel *orig_section;
	GMenuItem *item;
	gint idx;

	orig_section = find_gmenu_model (G_MENU_MODEL (menu), section_id);
	g_return_if_fail (orig_section != NULL);

	g_menu_remove_all (G_MENU (orig_section));

	for (idx = 0; idx < g_menu_model_get_n_items (section); idx++) {
		item = g_menu_item_new_from_model (section, idx);
		g_menu_append_item (G_MENU (orig_section), item);
		g_object_unref (item);
	}

	g_object_unref (orig_section);
}
/**
 * rb_source_search_add_to_menu:
 * @menu: #GMenu instance to populate
 * @action_namespace: muxer namespace for the action ("app" or "win")
 * @action: search action to attach the menu item to
 * @name: name of the search instance to add
 *
 * Adds a registered search instance to a search menu.
 */
void
rb_source_search_add_to_menu (GMenu *menu, const char *action_namespace, GAction *action, const char *name)
{
	GMenuItem *item;
	RBSourceSearch *search;
	char *action_name;
       
	search = rb_source_search_get_by_name (name);
	g_assert (search != NULL);

	if (action_namespace != NULL) {
		action_name = g_strdup_printf ("%s.%s", action_namespace, g_action_get_name (action));
	} else {
		action_name = g_strdup (g_action_get_name (action));
	}

	item = g_menu_item_new (rb_source_search_get_description (search), NULL);
	g_menu_item_set_action_and_target (item, action_name, "s", name);
	g_menu_append_item (menu, item);

	g_free (action_name);
}
Beispiel #22
0
static void
eog_zoom_entry_populate_free_zoom_section (EogZoomEntry *zoom_entry)
{
	guint   i;

	for (i = 0; i < G_N_ELEMENTS (zoom_levels); i++) {
		GMenuItem *item;
		gchar *name;


		if (zoom_levels[i] > EOG_SCROLL_VIEW_MAX_ZOOM_FACTOR)
			break;

		name = eog_zoom_entry_format_zoom_value (zoom_levels[i]);

		item = g_menu_item_new (name, NULL);
		g_menu_item_set_action_and_target (item, "win.zoom-set",
		                                   "d", zoom_levels[i]);
		g_menu_append_item (G_MENU (zoom_entry->priv->zoom_free_section), item);
		g_object_unref (item);
		g_free (name);
	}
}
Beispiel #23
0
static void
photos_base_model_refresh (PhotosBaseModel *self)
{
  g_autoptr (GMenu) section = NULL;
  const gchar *action_id;
  const gchar *title;
  guint i;
  guint n_items;

  g_menu_remove_all (self->model);

  title = photos_base_manager_get_title (self->mngr);
  action_id = photos_base_manager_get_action_id (self->mngr);

  section = g_menu_new ();
  g_menu_append_section (self->model, title, G_MENU_MODEL (section));

  n_items = g_list_model_get_n_items (G_LIST_MODEL (self->mngr));
  for (i = 0; i < n_items; i++)
    {
      g_autoptr (GMenuItem) menu_item = NULL;
      g_autoptr (GObject) object = NULL;
      const gchar *id;
      g_autofree gchar *name = NULL;

      object = g_list_model_get_object (G_LIST_MODEL (self->mngr), i);
      if (!photos_filterable_is_search_criterion (PHOTOS_FILTERABLE (object)))
        continue;

      id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
      g_object_get (object, "name", &name, NULL);

      menu_item = g_menu_item_new (name, NULL);
      g_menu_item_set_action_and_target (menu_item, action_id, "s", id);
      g_menu_append_item (section, menu_item);
    }
}
Beispiel #24
0
static void
_gth_browser_update_bookmark_list (GthBrowser *browser)
{
    BrowserData    *data;
    GBookmarkFile  *bookmarks;
    char          **uris;
    int             i;

    data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
    g_return_if_fail (data != NULL);

    g_menu_remove_all (data->bookmarks_menu);

    bookmarks = gth_main_get_default_bookmarks ();
    uris = g_bookmark_file_get_uris (bookmarks, NULL);

    for (i = 0; uris[i] != NULL; i++) {
        GFile     *file;
        char      *name;
        GMenuItem *item;

        file = g_file_new_for_uri (uris[i]);
        name = g_bookmark_file_get_title (bookmarks, uris[i], NULL);
        item = _g_menu_item_new_for_file (file, name);
        g_menu_item_set_action_and_target (item, "win.go-to-location", "s", uris[i]);
        g_menu_append_item (data->bookmarks_menu, item);

        g_object_unref (item);
        g_free (name);
        g_object_unref (file);
    }

    _gth_browser_update_system_bookmark_list (browser);

    g_strfreev (uris);
}
Beispiel #25
0
static void
fill_open_with_menu (GtkTreeView *view, GtkBuilder *builder, GtkTreePath *path)
{
    GtkTreeModel *model = gtk_tree_view_get_model (view);
    if (!model) {
        return;
    }
    GtkTreeIter iter;
    if (!gtk_tree_model_get_iter(model, &iter, path)) {
        return;
    }
    DatabaseSearchEntry *entry = (DatabaseSearchEntry *)iter.user_data;
    if (!entry) {
        return;
    }

    BTreeNode * node = db_search_entry_get_node (entry);

    GList *app_list = NULL;
    char *content_type = NULL;

    if (node->is_dir) {
        content_type = g_content_type_from_mime_type ("inode/directory");
    }
    else {
        content_type = g_content_type_guess (node->name, NULL, 0, NULL);
    }

    if (!content_type) {
        goto clean_up;
    }

    app_list = g_app_info_get_all_for_type (content_type);
    if (!app_list) {
        goto clean_up;
    }

    GMenu *menu_mime = G_MENU (gtk_builder_get_object (builder,
                                                       "fsearch_listview_menu_open_with_mime_section"));

    for (GList *list_iter = app_list; list_iter; list_iter = list_iter->next) {
        GAppInfo *app_info = list_iter->data;
        const char *display_name = g_app_info_get_display_name (app_info);
        const char *app_id = g_app_info_get_id (app_info);

        char detailed_action[1024] = "";
        snprintf (detailed_action, sizeof (detailed_action), "win.open_with('%s')", app_id);

        GMenuItem *menu_item = g_menu_item_new (display_name, detailed_action);
        g_menu_item_set_icon (menu_item, g_app_info_get_icon (app_info));
        g_menu_append_item (menu_mime, menu_item);
        g_object_unref (menu_item);
    }

clean_up:
    if (content_type) {
        g_free (content_type);
        content_type = NULL;
    }
    if (app_list) {
        g_list_free_full (app_list, g_object_unref);
        app_list = NULL;
    }
}
int
main (int argc, char **argv)
{
    IndicatorTestService indicator = { 0 };
    indicator.action_delay = -1;
    indicator.change_interval = -1;
    GMenuItem *item;
    GMenu *submenu;
    GActionEntry entries[] = {
        { "_header", NULL, NULL, "{'title': <'Test'>,"
                                 " 'label': <'Test'>,"
                                 " 'visible': <true>,"
                                 " 'accessible-desc': <'Test indicator'> }", NULL },
        { "action.show", activate_show, NULL, NULL, NULL },
        { "action.switch", activate_switch, NULL, "true", NULL },
        { "action.checkbox", activate_switch, NULL, "true", NULL },
        { "action.accessPoint", activate_switch, NULL, "false", NULL },
        { "action.slider", NULL, NULL, "0.5", change_slider }
    };
    GMainLoop *loop;

    int help = 0;
    if (argc > 1)
    {
        int i;
        for (i = 1; i < argc; i++) {
            const char *arg = argv[i];

            if (arg[0] == '-') {
                switch (arg[1])
                {
                    case 't':
                    {
                        arg += 2;
                        if (!arg[0] && i < argc-1) {
                            i++;
                            int delay = -1;

                            if (sscanf(argv[i], "%d", &delay) == 1) {
                                indicator.action_delay = delay;
                            } else {
                                printf("Invalid action delay value: %s\n", argv[i]);
                                help = 1;
                            }
                        } else {
                            printf("Invalid action delay value: %s\n", argv[i]);
                            help = 1;
                        }
                        break;
                    }

                    case 'c':
                    {
                        arg += 2;
                        if (!arg[0] && i < argc-1) {
                            i++;
                            int interval = -1;

                            if (sscanf(argv[i], "%d", &interval) == 1) {
                                indicator.change_interval = interval;
                            } else {
                                printf("Invalid change interval value: %s\n", argv[i]);
                                help = 1;
                            }
                        } else {
                            printf("Invalid change interval value: %s\n", argv[i]);
                            help = 1;
                        }
                        break;
                    }

                    case 'h':
                        help = 1;
                        break;
                }
            }
        }
    }

    if (help) {
        printf("Usage: %s [<options>]\n"
               "  -t DELAY               Action activation delay\n"
               "  -c CHANGE_INTERVAL     Interval to change action values\n"
               "  -h                     Show this help text\n"
               , argv[0]);
        return 0;
    }

    indicator.actions = g_simple_action_group_new ();
    g_action_map_add_action_entries (G_ACTION_MAP (indicator.actions), entries, G_N_ELEMENTS (entries), &indicator);

    submenu = g_menu_new ();
    g_menu_append (submenu, "Show", "indicator.action.show");

    // Switch
    item = g_menu_item_new("Switch", "indicator.action.switch");
    g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.switch");
    g_menu_append_item(submenu, item);

    // Checkbox
    item = g_menu_item_new("Checkbox", "indicator.action.checkbox");
    g_menu_append_item(submenu, item);

    // Slider
    item = g_menu_item_new("Slider", "indicator.action.slider");
    g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.slider");
    g_menu_append_item(submenu, item);

    // Access Point
    item = g_menu_item_new("Access Point", "indicator.action.accessPoint");
    g_menu_item_set_attribute (item, "x-canonical-type", "s", "unity.widgets.systemsettings.tablet.accesspoint");
    g_menu_append_item(submenu, item);


    item = g_menu_item_new (NULL, "indicator._header");
    g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.root");
    g_menu_item_set_submenu (item, G_MENU_MODEL (submenu));
    indicator.menu = g_menu_new ();
    g_menu_append_item (indicator.menu, item);

    g_bus_own_name (G_BUS_TYPE_SESSION,
                    "com.canonical.indicator.mock",
                    G_BUS_NAME_OWNER_FLAGS_NONE,
                    bus_acquired,
                    NULL,
                    name_lost,
                    &indicator,
                    NULL);

    loop = g_main_loop_new (NULL, FALSE);

    if (indicator.change_interval != -1) {
        g_timeout_add(indicator.change_interval, change_interval,  &indicator);
    }

    g_main_loop_run (loop);

    g_object_unref (submenu);
    g_object_unref (item);
    g_object_unref (indicator.actions);
    g_object_unref (indicator.menu);
    g_object_unref (loop);

    return 1;
}
Beispiel #27
0
static GMenu *menu_btn_build_menu()
{
	GMenu *menu;
	GMenu *playlist_submenu;
	GMenu *sub_submenu;
	GMenu *view_submenu;
	GMenuItem *playlist_section;
	GMenuItem *sub_section;
	GMenuItem *view_section;
	GMenuItem *load_sub_menu_item;
	GMenuItem *playlist_toggle_menu_item;
	GMenuItem *playlist_save_menu_item;
	GMenuItem *fullscreen_menu_item;
	GMenuItem *normal_size_menu_item;
	GMenuItem *double_size_menu_item;
	GMenuItem *half_size_menu_item;

	menu = g_menu_new();
	playlist_submenu = g_menu_new();
	sub_submenu = g_menu_new();
	view_submenu = g_menu_new();

	playlist_section
		= g_menu_item_new_section(NULL, G_MENU_MODEL(playlist_submenu));

	sub_section
		= g_menu_item_new_section(NULL, G_MENU_MODEL(sub_submenu));

	view_section
		= g_menu_item_new_section(NULL, G_MENU_MODEL(view_submenu));

	playlist_toggle_menu_item
		= g_menu_item_new(_("_Toggle Playlist"), "app.playlist_toggle");

	playlist_save_menu_item
		= g_menu_item_new(_("_Save Playlist"), "app.playlist_save");

	load_sub_menu_item
		= g_menu_item_new(_("_Load Subtitle"), "app.loadsub");

	fullscreen_menu_item
		= g_menu_item_new(_("_Fullscreen"), "app.fullscreen");

	normal_size_menu_item
		= g_menu_item_new(_("_Normal Size"), "app.normalsize");

	double_size_menu_item
		= g_menu_item_new(_("_Double Size"), "app.doublesize");

	half_size_menu_item
		= g_menu_item_new(_("_Half Size"), "app.halfsize");

	g_menu_append_item(playlist_submenu, playlist_toggle_menu_item);
	g_menu_append_item(playlist_submenu, playlist_save_menu_item);
	g_menu_append_item(sub_submenu, load_sub_menu_item);
	g_menu_append_item(view_submenu, fullscreen_menu_item);
	g_menu_append_item(view_submenu, normal_size_menu_item);
	g_menu_append_item(view_submenu, double_size_menu_item);
	g_menu_append_item(view_submenu, half_size_menu_item);

	g_menu_append_item(menu, playlist_section);
	g_menu_append_item(menu, sub_section);
	g_menu_append_item(menu, view_section);

	return menu;
}
Beispiel #28
0
static void
impl_activate (PeasActivatable *plugin)
{
	TotemMoviePropertiesPlugin *pi;
	TotemObject *totem;
	GtkWindow *parent;
	GMenu *menu;
	GMenuItem *item;

	pi = TOTEM_MOVIE_PROPERTIES_PLUGIN (plugin);
	totem = g_object_get_data (G_OBJECT (plugin), "object");

	pi->priv->props = bacon_video_widget_properties_new ();
	gtk_widget_show (pi->priv->props);
	gtk_widget_set_sensitive (pi->priv->props, FALSE);

	parent = totem_object_get_main_window (totem);
	pi->priv->dialog = gtk_dialog_new_with_buttons (_("Properties"),
							parent,
							GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
							NULL,
							GTK_RESPONSE_CLOSE,
							NULL);
	g_object_unref (parent);
	g_signal_connect (pi->priv->dialog, "delete-event",
			  G_CALLBACK (gtk_widget_hide_on_delete), NULL);
	g_signal_connect (pi->priv->dialog, "response",
			  G_CALLBACK (gtk_widget_hide_on_delete), NULL);
	gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (pi->priv->dialog))),
			   pi->priv->props);

	/* Properties action */
	pi->priv->props_action = g_simple_action_new ("properties", NULL);
	g_signal_connect (G_OBJECT (pi->priv->props_action), "activate",
			  G_CALLBACK (properties_action_cb), pi);
	g_action_map_add_action (G_ACTION_MAP (totem), G_ACTION (pi->priv->props_action));
	gtk_application_add_accelerator (GTK_APPLICATION (totem),
					 "<Primary>p",
					 "app.properties",
					 NULL);
	/* FIXME: Handle GDK_KEY_View */

	/* Install the menu */
	menu = totem_object_get_menu_section (totem, "properties-placeholder");
	item = g_menu_item_new (_("_Properties"), "app.properties");
	g_menu_item_set_attribute (item, "accel", "s", "<Primary>p");
	g_menu_append_item (G_MENU (menu), item);
	g_object_unref (item);

	g_signal_connect (G_OBJECT (totem),
			  "file-opened",
			  G_CALLBACK (totem_movie_properties_plugin_file_opened),
			  plugin);
	g_signal_connect (G_OBJECT (totem),
			  "file-closed",
			  G_CALLBACK (totem_movie_properties_plugin_file_closed),
			  plugin);
	g_signal_connect (G_OBJECT (totem),
			  "metadata-updated",
			  G_CALLBACK (totem_movie_properties_plugin_metadata_updated),
			  plugin);
	pi->priv->handler_id_stream_length = g_signal_connect (G_OBJECT (totem),
							       "notify::stream-length",
							       G_CALLBACK (stream_length_notify_cb),
							       plugin);
}
static void rotation_plugin_real_activate (PeasActivatable* base) {
	RotationPlugin * self;
	TotemObject* t = NULL;
	GObject* _tmp0_ = NULL;
	GObject* _tmp1_ = NULL;
	gchar* mrl = NULL;
	TotemObject* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	GMenu* menu = NULL;
	TotemObject* _tmp4_ = NULL;
	GMenu* _tmp5_ = NULL;
	GMenu* _tmp6_ = NULL;
	TotemObject* _tmp7_ = NULL;
	GtkWidget* _tmp8_ = NULL;
	BaconVideoWidget* _tmp9_ = NULL;
	GSimpleAction* _tmp10_ = NULL;
	GSimpleAction* _tmp11_ = NULL;
	TotemObject* _tmp12_ = NULL;
	GSimpleAction* _tmp13_ = NULL;
	TotemObject* _tmp14_ = NULL;
	GSimpleAction* _tmp15_ = NULL;
	GSimpleAction* _tmp16_ = NULL;
	TotemObject* _tmp17_ = NULL;
	GSimpleAction* _tmp18_ = NULL;
	TotemObject* _tmp19_ = NULL;
	GMenuItem* item = NULL;
	const gchar* _tmp20_ = NULL;
	GMenuItem* _tmp21_ = NULL;
	GMenuItem* _tmp22_ = NULL;
	GMenu* _tmp23_ = NULL;
	GMenuItem* _tmp24_ = NULL;
	const gchar* _tmp25_ = NULL;
	GMenuItem* _tmp26_ = NULL;
	GMenuItem* _tmp27_ = NULL;
	GMenu* _tmp28_ = NULL;
	GMenuItem* _tmp29_ = NULL;
	const gchar* _tmp30_ = NULL;
	const gchar* _tmp33_ = NULL;
	TotemObject* _tmp35_ = NULL;
	TotemObject* _tmp36_ = NULL;
	self = (RotationPlugin*) base;
	g_object_get ((PeasActivatable*) self, "object", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	t = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, totem_object_get_type (), TotemObject);
	_tmp2_ = t;
	_tmp3_ = totem_object_get_current_mrl (_tmp2_);
	mrl = _tmp3_;
	_tmp4_ = t;
	_tmp5_ = totem_object_get_menu_section (_tmp4_, "rotation-placeholder");
	_tmp6_ = _g_object_ref0 (_tmp5_);
	menu = _tmp6_;
	_tmp7_ = t;
	_tmp8_ = totem_object_get_video_widget (_tmp7_);
	_tmp9_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, BACON_TYPE_VIDEO_WIDGET) ? ((BaconVideoWidget*) _tmp8_) : NULL;
	if (_tmp9_ == NULL) {
		_g_object_unref0 (_tmp8_);
	}
	_g_object_unref0 (self->priv->bvw);
	self->priv->bvw = _tmp9_;
	_tmp10_ = g_simple_action_new ("rotate-left", NULL);
	_g_object_unref0 (self->priv->rotate_left_action);
	self->priv->rotate_left_action = _tmp10_;
	_tmp11_ = self->priv->rotate_left_action;
	g_signal_connect_object (_tmp11_, "activate", (GCallback) _rotation_plugin_cb_rotate_left_g_simple_action_activate, self, 0);
	_tmp12_ = t;
	_tmp13_ = self->priv->rotate_left_action;
	g_action_map_add_action ((GActionMap*) _tmp12_, (GAction*) _tmp13_);
	_tmp14_ = t;
	gtk_application_add_accelerator ((GtkApplication*) _tmp14_, "<Primary><Shift>R", "app.rotate-left", NULL);
	_tmp15_ = g_simple_action_new ("rotate-right", NULL);
	_g_object_unref0 (self->priv->rotate_right_action);
	self->priv->rotate_right_action = _tmp15_;
	_tmp16_ = self->priv->rotate_right_action;
	g_signal_connect_object (_tmp16_, "activate", (GCallback) _rotation_plugin_cb_rotate_right_g_simple_action_activate, self, 0);
	_tmp17_ = t;
	_tmp18_ = self->priv->rotate_right_action;
	g_action_map_add_action ((GActionMap*) _tmp17_, (GAction*) _tmp18_);
	_tmp19_ = t;
	gtk_application_add_accelerator ((GtkApplication*) _tmp19_, "<Primary>R", "app.rotate-right", NULL);
	_tmp20_ = _ ("_Rotate ↷");
	_tmp21_ = g_menu_item_new (_tmp20_, "app.rotate-right");
	item = _tmp21_;
	_tmp22_ = item;
	g_menu_item_set_attribute (_tmp22_, "accel", "s", "<Primary>R", NULL);
	_tmp23_ = menu;
	_tmp24_ = item;
	g_menu_append_item (_tmp23_, _tmp24_);
	_tmp25_ = _ ("Rotate ↶");
	_tmp26_ = g_menu_item_new (_tmp25_, "app.rotate-left");
	_g_object_unref0 (item);
	item = _tmp26_;
	_tmp27_ = item;
	g_menu_item_set_attribute (_tmp27_, "accel", "s", "<Primary><Shift>R", NULL);
	_tmp28_ = menu;
	_tmp29_ = item;
	g_menu_append_item (_tmp28_, _tmp29_);
	_tmp30_ = mrl;
	if (_tmp30_ == NULL) {
		GSimpleAction* _tmp31_ = NULL;
		GSimpleAction* _tmp32_ = NULL;
		_tmp31_ = self->priv->rotate_right_action;
		g_simple_action_set_enabled (_tmp31_, FALSE);
		_tmp32_ = self->priv->rotate_left_action;
		g_simple_action_set_enabled (_tmp32_, FALSE);
	}
	_tmp33_ = mrl;
	if (_tmp33_ != NULL) {
		const gchar* _tmp34_ = NULL;
		_tmp34_ = mrl;
		rotation_plugin_try_restore_state (self, _tmp34_, ____lambda6__gasync_ready_callback, g_object_ref (self));
	}
	_tmp35_ = t;
	g_signal_connect_object (_tmp35_, "file-closed", (GCallback) _rotation_plugin_cb_file_closed_totem_object_file_closed, self, 0);
	_tmp36_ = t;
	g_signal_connect_object (_tmp36_, "file-opened", (GCallback) _rotation_plugin_cb_file_opened_totem_object_file_opened, self, 0);
	_g_object_unref0 (item);
	_g_object_unref0 (menu);
	_g_free0 (mrl);
	_g_object_unref0 (t);
}
Beispiel #30
0
GMenu *build_full_menu()
{
	GMenu *menu;
	GMenu *file_menu;
	GMenu *edit_menu;
	GMenu *view_menu;
	GMenu *help_menu;
	GMenuItem *file_menu_item;
	GMenuItem *open_menu_item;
	GMenuItem *quit_menu_item;
	GMenuItem *open_loc_menu_item;
	GMenuItem *save_playlist_menu_item;
	GMenuItem *edit_menu_item;
	GMenuItem *load_sub_menu_item;
	GMenuItem *pref_menu_item;
	GMenuItem *view_menu_item;
	GMenuItem *playlist_menu_item;
	GMenuItem *fullscreen_menu_item;
	GMenuItem *normal_size_menu_item;
	GMenuItem *double_size_menu_item;
	GMenuItem *half_size_menu_item;
	GMenuItem *help_menu_item;
	GMenuItem *about_menu_item;

	menu = g_menu_new();

	/* File */
	file_menu = g_menu_new();

	file_menu_item
		= g_menu_item_new_submenu
			(_("_File"), G_MENU_MODEL(file_menu));

	open_menu_item = g_menu_item_new(_("_Open"), "app.open(false)");
	quit_menu_item = g_menu_item_new(_("_Quit"), "app.quit");

	open_loc_menu_item
		= g_menu_item_new(_("Open _Location"), "app.openloc");

	save_playlist_menu_item
		= g_menu_item_new(_("_Save Playlist"), "app.playlist_save");

	/* Edit */
	edit_menu = g_menu_new();

	edit_menu_item
		= g_menu_item_new_submenu
			(_("_Edit"), G_MENU_MODEL(edit_menu));

	load_sub_menu_item
		= g_menu_item_new(_("_Load Subtitle"), "app.loadsub");

	pref_menu_item
		= g_menu_item_new(_("_Preferences"), "app.pref");

	/* View */
	view_menu = g_menu_new();

	view_menu_item
		= g_menu_item_new_submenu
			(_("_View"), G_MENU_MODEL(view_menu));

	playlist_menu_item
		= g_menu_item_new(_("_Toggle Playlist"), "app.playlist_toggle");

	fullscreen_menu_item
		= g_menu_item_new(_("_Fullscreen"), "app.fullscreen");

	normal_size_menu_item
		= g_menu_item_new(_("_Normal Size"), "app.normalsize");

	double_size_menu_item
		= g_menu_item_new(_("_Double Size"), "app.doublesize");

	half_size_menu_item
		= g_menu_item_new(_("_Half Size"), "app.halfsize");

	/* Help */
	help_menu = g_menu_new();

	help_menu_item
		= g_menu_item_new_submenu
			(_("_Help"), G_MENU_MODEL(help_menu));

	about_menu_item = g_menu_item_new(_("_About"), "app.about");

	g_menu_append_item(menu, file_menu_item);
	g_menu_append_item(file_menu, open_menu_item);
	g_menu_append_item(file_menu, open_loc_menu_item);
	g_menu_append_item(file_menu, save_playlist_menu_item);
	g_menu_append_item(file_menu, quit_menu_item);

	g_menu_append_item(menu, edit_menu_item);
	g_menu_append_item(edit_menu, load_sub_menu_item);
	g_menu_append_item(edit_menu, pref_menu_item);

	g_menu_append_item(menu, view_menu_item);
	g_menu_append_item(view_menu, playlist_menu_item);
	g_menu_append_item(view_menu, fullscreen_menu_item);
	g_menu_append_item(view_menu, normal_size_menu_item);
	g_menu_append_item(view_menu, double_size_menu_item);
	g_menu_append_item(view_menu, half_size_menu_item);

	g_menu_append_item(menu, help_menu_item);
	g_menu_append_item(help_menu, about_menu_item);

	return menu;
}