示例#1
0
static void
application_startup_cb (GApplication       *application,
                        GnomeControlCenter *shell)
{
  GMenu *menu, *section;
  GAction *action;

  action = G_ACTION (g_simple_action_new ("help", NULL));
  g_action_map_add_action (G_ACTION_MAP (application), action);
  g_signal_connect (action, "activate", G_CALLBACK (help_activated), shell);

  action = G_ACTION (g_simple_action_new ("quit", NULL));
  g_action_map_add_action (G_ACTION_MAP (application), action);
  g_signal_connect (action, "activate", G_CALLBACK (quit_activated), shell);

  menu = g_menu_new ();

  section = g_menu_new ();
  g_menu_append (section, _("Help"), "app.help");
  g_menu_append (section, _("Quit"), "app.quit");

  g_menu_append_section (menu, NULL, G_MENU_MODEL (section));

  gtk_application_set_app_menu (GTK_APPLICATION (application),
                                G_MENU_MODEL (menu));

  gtk_application_add_accelerator (GTK_APPLICATION (application),
                                   "F1", "app.help", NULL);

  /* nothing else to do here, we don't want to show a window before
   * we've looked at the commandline
   */
}
static void
gtk_application_window_update_shell_shows_menubar (GtkApplicationWindow *window,
                                                   GtkSettings          *settings)
{
  gboolean shown_by_shell;

  g_object_get (settings, "gtk-shell-shows-menubar", &shown_by_shell, NULL);

  if (shown_by_shell)
    {
      /* the shell shows it, so don't show it locally */
      if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->menubar_section)) != 0)
        g_menu_remove (window->priv->menubar_section, 0);
    }
  else
    {
      /* the shell does not show it, so make sure we show it */
      if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->menubar_section)) == 0)
        {
          GMenuModel *menubar;

          menubar = gtk_application_get_menubar (gtk_window_get_application (GTK_WINDOW (window)));

          if (menubar != NULL)
            g_menu_append_section (window->priv->menubar_section, NULL, menubar);
        }
    }
}
static void
cc_application_startup (GApplication *application)
{
  CcApplication *self = CC_APPLICATION (application);
  GMenu *menu;
  GMenu *section;
  GSimpleAction *action;

  G_APPLICATION_CLASS (cc_application_parent_class)->startup (application);

#ifdef HAVE_CHEESE
  if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
    {
      g_critical ("Unable to initialize Clutter");
      return;
    }
#endif /* HAVE_CHEESE */

  /* register a symbolic icon size for use in sidebar lists */
  gtk_icon_size_register ("cc-sidebar-list", 24, 24);

  action = g_simple_action_new ("help", NULL);
  g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
  g_signal_connect (action, "activate", G_CALLBACK (help_activated), self);
  g_object_unref (action);

  action = g_simple_action_new ("quit", NULL);
  g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
  g_signal_connect (action, "activate", G_CALLBACK (cc_application_quit), self);
  g_object_unref (action);

  /* Launch panel by id. The parameter is a (panel_id, array_of_panel_parameters)
   * tuple. The GVariant-containing array usually is just the same array of
   * strings that would be generated by passing panel-specific arguments on
   * the command line. */
  action = g_simple_action_new ("launch-panel", G_VARIANT_TYPE ("(sav)"));
  g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
  g_signal_connect (action, "activate", G_CALLBACK (launch_panel_activated), self);
  g_object_unref (action);

  menu = g_menu_new ();

  section = g_menu_new ();
  g_menu_append (section, _("Help"), "app.help");
  g_menu_append (section, _("Quit"), "app.quit");

  g_menu_append_section (menu, NULL, G_MENU_MODEL (section));

  gtk_application_set_app_menu (GTK_APPLICATION (application),
                                G_MENU_MODEL (menu));

  gtk_application_add_accelerator (GTK_APPLICATION (application),
                                   "F1", "app.help", NULL);

  self->priv->window = cc_window_new (GTK_APPLICATION (application));
}
示例#4
0
/**
 * irc_context_get_menu:
 *
 * Returns: (transfer full): New menu currently valid for context
 */
GMenuModel *
irc_context_get_menu (IrcContext *self)
{
	GMenuModel *menu = IRC_CONTEXT_GET_IFACE(self)->get_menu(self);

	// Always have a close entry
	GMenu *shared_menu = g_menu_new ();
	const char *id = irc_context_get_id (self);
  	g_autofree char *action = g_strdup_printf ("context.close('%s')", id);
	g_menu_append (shared_menu, _("Close"), action);

	g_menu_append_section (G_MENU(menu), NULL, G_MENU_MODEL(shared_menu));
	return menu;
}
static void 
gcal_application_set_app_menu (GApplication *app)
{
  GcalApplicationPrivate *priv;

  GMenu *app_menu;
  GMenu *view_as;
  GSimpleAction *about;
  GSimpleAction *quit;

  g_return_if_fail (GCAL_IS_APPLICATION (app));
  priv = GCAL_APPLICATION (app)->priv;

  app_menu = g_menu_new ();

  priv->view = g_simple_action_new_stateful (
      "view",
      G_VARIANT_TYPE_STRING,
      g_settings_get_value (priv->settings, "active-view"));

  g_signal_connect (priv->view,
                    "activate",
                    G_CALLBACK (gcal_application_change_view),
                    app);
  g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (priv->view));

  view_as = g_menu_new ();
  g_menu_append (view_as, _("Weeks"), "app.view::week");
  g_menu_append (view_as, _("Months"), "app.view::month");

  g_menu_append_section (app_menu, _("View as"), G_MENU_MODEL (view_as));

  about = g_simple_action_new ("about", NULL);
  g_signal_connect (about,
                    "activate",
                    G_CALLBACK (gcal_application_show_about),
                    app);
  g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (about));
  g_menu_append (app_menu, _("About"), "app.about");

  quit = g_simple_action_new ("quit", NULL);
  g_signal_connect (quit,
                    "activate",
                    G_CALLBACK (gcal_application_quit),
                    app);
  g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (quit));
  g_menu_append (app_menu, _("Quit"), "app.quit");

  gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (app_menu));
}
示例#6
0
static void
gtk_application_menu_changed_quartz (GObject    *object,
                                     GParamSpec *pspec,
                                     gpointer    user_data)
{
  GtkApplication *application = GTK_APPLICATION (object);
  GMenu *combined;

  combined = g_menu_new ();
  g_menu_append_submenu (combined, "Application", gtk_application_get_app_menu (application));
  g_menu_append_section (combined, NULL, gtk_application_get_menubar (application));

  gtk_quartz_set_main_menu (G_MENU_MODEL (combined), G_ACTION_OBSERVABLE (application->priv->muxer));
}
static void
gtk_application_window_update_menubar (GtkApplicationWindow *window)
{
  gboolean should_have_menubar;
  gboolean have_menubar;

  have_menubar = window->priv->menubar != NULL;

  should_have_menubar = window->priv->show_menubar &&
                        (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->app_menu_section)) ||
                         g_menu_model_get_n_items (G_MENU_MODEL (window->priv->menubar_section)));

  if (have_menubar && !should_have_menubar)
    {
      gtk_widget_unparent (window->priv->menubar);
      window->priv->menubar = NULL;

      gtk_widget_queue_resize (GTK_WIDGET (window));
    }

  if (!have_menubar && should_have_menubar)
    {
      GMenu *combined;

      combined = g_menu_new ();
      g_menu_append_section (combined, NULL, G_MENU_MODEL (window->priv->app_menu_section));
      g_menu_append_section (combined, NULL, G_MENU_MODEL (window->priv->menubar_section));

      window->priv->menubar = gtk_menu_bar_new_from_model (G_MENU_MODEL (combined));
      gtk_widget_set_parent (window->priv->menubar, GTK_WIDGET (window));
      gtk_widget_show_all (window->priv->menubar);
      g_object_unref (combined);

      gtk_widget_queue_resize (GTK_WIDGET (window));
    }
}
示例#8
0
文件: main.c 项目: gnarula/gnome-mpv
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;
}
示例#9
0
文件: main.c 项目: credmon/libreport
static void
startup_wizard(GApplication *app,
                gpointer user_data)
{
    g_action_map_add_action_entries(G_ACTION_MAP (app),
            app_entries, G_N_ELEMENTS (app_entries),
            app);

    GMenu *app_menu = g_menu_new();
    g_menu_append(app_menu, _("Preferences"), "app.preferences");

    GMenu *service_app_menu_sec = g_menu_new();
    g_menu_append(service_app_menu_sec, _("Quit"), "app.quit");
    g_menu_append_section(app_menu, /*no title*/NULL, G_MENU_MODEL(service_app_menu_sec));

    gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL(app_menu));
}
示例#10
0
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);
}
示例#11
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);
    }
}
示例#12
0
/*********************************************************************** Menu */
void
bmd_construct_menu (GtkApplication *app, gpointer data)
{
	GtkWidget *headerbar;
	// the application menu displayed in the GNOME panel
	GMenu *appmenu;
	GMenu *editmenu;

	GtkWidget *openbutton;
	GtkWidget *savebutton;

	// the menu displayed as a popover below the gears button
	GMenu *gearmenu;
	GtkWidget *gearmenubutton;
	GtkWidget *gearicon;

	bmd_widgets *a = (bmd_widgets *) data;

	// define keyboard accelerators
	const gchar *open_accels[2] = { "<Ctrl>O", NULL };
	const gchar *save_accels[2] = { "<Ctrl>S", NULL };
	const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
	const gchar *add_accels[2] = { "<Ctrl>A", NULL };
	const gchar *del_accels[2] = { "<Ctrl>D", NULL };
	const gchar *find_accels[2] = { "<Ctrl>F", NULL };
	const gchar *help_accels[2] = { "F1", NULL };

	// create and fill in the application menu in the GNOME panel
	appmenu = g_menu_new();
	g_menu_append (appmenu, "About", "app.about");
	g_menu_append (appmenu, "Help", "app.help");
	g_menu_append (appmenu, "_Quit", "app.quit");
	gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (appmenu));
	g_object_unref (appmenu);

	// create a headerbar
	headerbar = gtk_header_bar_new ();
	gtk_widget_show (headerbar);
	gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "Book Management");
	gtk_header_bar_set_subtitle (GTK_HEADER_BAR (headerbar), "Simple Demo Application");
	gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), TRUE);
	gtk_window_set_titlebar (GTK_WINDOW (a->window), headerbar);

	// create an OPEN button, add it to the headerbar and connect the callbacks
	openbutton = gtk_button_new_with_label ("Open");
	gtk_header_bar_pack_start (GTK_HEADER_BAR (headerbar), openbutton);
	gtk_actionable_set_action_name (GTK_ACTIONABLE (openbutton), "app.open");

	// create the gear menu button
	gearmenubutton = gtk_menu_button_new();
	gearicon = gtk_image_new_from_icon_name ("emblem-system-symbolic",
						 GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_button_set_image (GTK_BUTTON (gearmenubutton), gearicon);
	gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), gearmenubutton);
	// create a menu for the gear button
	gearmenu = g_menu_new();
	g_menu_append (gearmenu, "Save As ...", "app.saveAs");
	editmenu = g_menu_new();
	g_menu_append (editmenu, "_Find", "app.find");
	g_menu_append (editmenu, "_Add", "app.add");
	g_menu_append (editmenu, "_Delete", "app.delete");
	g_menu_append_section (gearmenu, NULL, G_MENU_MODEL (editmenu));
	gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (gearmenubutton),
					G_MENU_MODEL (gearmenu));
	g_object_unref (editmenu);
	g_object_unref (gearmenu);

	// create an SAVE button, add it to the headerbar and connect the callbacks
	savebutton = gtk_button_new_with_label ("Save");
	gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), savebutton);
	gtk_actionable_set_action_name (GTK_ACTIONABLE (savebutton), "app.save");

	// connect keyboard accelerators
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.open", open_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.save", save_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.quit", quit_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.add", add_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.delete", del_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.find", find_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.help", help_accels);
}
/*********************************************************************** Menu */
void
bmd_construct_menu (GtkApplication *app, gpointer data)
{
	GtkWidget *menubar;
	GMenu *menu, *filemenu, *editmenu, *helpmenu, *savemenu, *quitmenu;

	bmd_widgets *a = (bmd_widgets *) data;

	// define keyboard accelerators
	const gchar *open_accels[2] = { "<Ctrl>O", NULL };
	const gchar *save_accels[2] = { "<Ctrl>S", NULL };
	const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
	const gchar *add_accels[2] = { "<Ctrl>A", NULL };
	const gchar *del_accels[2] = { "<Ctrl>D", NULL };
	const gchar *find_accels[2] = { "<Ctrl>F", NULL };
	const gchar *help_accels[2] = { "F1", NULL };

	/* map app entries to actions using the global structure */
	g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries,
					 G_N_ELEMENTS (app_entries), (gpointer) a);

	/* create the menu */
	menu = g_menu_new();

	/* create the File menu */
	filemenu = g_menu_new();
	g_menu_append (filemenu, "_Open", "app.open");
	savemenu = g_menu_new();
	g_menu_append (savemenu, "_Save", "app.save");
	g_menu_append (savemenu, "Save As ...", "app.saveAs");
	g_menu_append_section (filemenu, NULL, G_MENU_MODEL (savemenu));
	quitmenu = g_menu_new();
	g_menu_append (quitmenu, "_Quit", "app.quit");
	g_menu_append_section (filemenu, NULL, G_MENU_MODEL (quitmenu));
	g_menu_insert_submenu (menu, 0, "_File", G_MENU_MODEL (filemenu));
	g_object_unref (savemenu);
	g_object_unref (quitmenu);
	g_object_unref (filemenu);

	/* create the Edit menu */
	editmenu = g_menu_new();
	g_menu_append (editmenu, "_Find", "app.find");
	g_menu_append (editmenu, "_Add", "app.add");
	g_menu_append (editmenu, "_Delete", "app.delete");
	g_menu_append_submenu (menu, "_Edit", G_MENU_MODEL (editmenu));
	g_object_unref (editmenu);

	/* create the Help menu */
	helpmenu = g_menu_new();
	g_menu_append (helpmenu, "About", "app.about");
	g_menu_append (helpmenu, "Help", "app.help");
	g_menu_append_submenu (menu, "_Help", G_MENU_MODEL (helpmenu));
	g_object_unref (helpmenu);

	/* create a menu bar and add the above menus */
	menubar = gtk_menu_bar_new_from_model (G_MENU_MODEL (menu));
	gtk_box_pack_start (GTK_BOX (a->box), menubar, FALSE, FALSE, 0);

	/* connect keyboard accelerators */
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.open", open_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.save", save_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.quit", quit_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.add", add_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.delete", del_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.find", find_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.help", help_accels);
}
示例#14
0
文件: start.c 项目: y20k/ezeedo
/**
 * Sets up the application when it first starts
 */
void
startup (GApplication *app,
         gpointer      user_data)
{
    // get ezeedo from user data
    ezeedo_wrapper_structure *ezeedo;
    ezeedo = user_data;

    // define widgets
    GMenu *menu;
    GMenu *section;

    // define actions
    GSimpleAction *preferences_action;
    GSimpleAction *quit_action;

    // create application menu
    menu = g_menu_new ();

    // create section
    section = g_menu_new ();

    // contruct application menu
    g_menu_append         (section,
                           "About",
                           "win.about");
    g_menu_append         (section,
                           "Quit",
                           "app.quit");
    g_menu_append         (menu,
                           "Preferences",
                           "app.preferences");
    g_menu_append_section (menu,
                           NULL,
                           G_MENU_MODEL (section));

    // create actions
    preferences_action = g_simple_action_new ("preferences",
                                              NULL);
    g_signal_connect (preferences_action, "activate",
                      G_CALLBACK(show_preferences_dialog), ezeedo);
    g_action_map_add_action (G_ACTION_MAP(app),
                             G_ACTION(preferences_action));

    // activate ctrl-q
    const gchar* quit_accels[2] = { "<Ctrl>Q", NULL };
    gtk_application_set_accels_for_action (GTK_APPLICATION(app),
                                           "app.quit",
                                           quit_accels);

    quit_action = g_simple_action_new ("quit",
                                       NULL);
    g_signal_connect        (quit_action, "activate",
                             G_CALLBACK (quit_application), ezeedo);
    g_action_map_add_action (G_ACTION_MAP(app),
                             G_ACTION(quit_action));

    // Set menu for the overall application
    gtk_application_set_app_menu (GTK_APPLICATION(app),
                                  G_MENU_MODEL(menu));

    return;
}
static void
impl_constructed (GObject *object)
{
	RBGenericPlayerSource *source;
	RBGenericPlayerSourcePrivate *priv;
	RhythmDBEntryType *entry_type;
	char **playlist_formats;
	char **output_formats;
	char *mount_name;
	RBShell *shell;
	GFile *root;
	GFileInfo *info;
	GError *error = NULL;
	char *label;
	char *fullname;
	char *name;

	RB_CHAIN_GOBJECT_METHOD (rb_generic_player_source_parent_class, constructed, object);
	source = RB_GENERIC_PLAYER_SOURCE (object);

	priv = GET_PRIVATE (source);

	rb_device_source_set_display_details (RB_DEVICE_SOURCE (source));

	g_object_get (source,
		      "shell", &shell,
		      "entry-type", &entry_type,
		      "name", &name,
		      NULL);

	g_object_get (shell, "db", &priv->db, NULL);

	priv->import_errors = rb_import_errors_source_new (shell,
							   priv->error_type,
							   entry_type,
							   priv->ignore_type);


	priv->new_playlist_action_name = g_strdup_printf ("generic-player-%p-playlist-new", source);
	fullname = g_strdup_printf ("app.%s", priv->new_playlist_action_name);

	label = g_strdup_printf (_("New Playlist on %s"), name);

	rb_application_add_plugin_menu_item (RB_APPLICATION (g_application_get_default ()),
					     "display-page-add-playlist",
					     priv->new_playlist_action_name,
					     g_menu_item_new (label, fullname));
	g_free (fullname);
	g_free (label);
	g_free (name);

	root = g_mount_get_root (priv->mount);
	mount_name = g_mount_get_name (priv->mount);

	info = g_file_query_filesystem_info (root, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, NULL, &error);
	if (error != NULL) {
		rb_debug ("error querying filesystem info for %s: %s", mount_name, error->message);
		g_error_free (error);
		priv->read_only = FALSE;
	} else {
		priv->read_only = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY);
		g_object_unref (info);
	}

	g_free (mount_name);
	g_object_unref (root);

	g_object_get (priv->device_info, "playlist-formats", &playlist_formats, NULL);
	if ((priv->read_only == FALSE) && playlist_formats != NULL && g_strv_length (playlist_formats) > 0) {
		RBDisplayPageModel *model;
		GMenu *playlist_menu;
		GMenuModel *playlists;

		priv->new_playlist_action = g_simple_action_new (priv->new_playlist_action_name, NULL);
		g_signal_connect (priv->new_playlist_action, "activate", G_CALLBACK (new_playlist_action_cb), source);
		g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()), G_ACTION (priv->new_playlist_action));

		g_object_get (shell, "display-page-model", &model, NULL);
		playlists = rb_display_page_menu_new (model,
						      RB_DISPLAY_PAGE (source),
						      RB_TYPE_GENERIC_PLAYER_PLAYLIST_SOURCE,
						      "app.playlist-add-to");
		g_object_unref (model);

		playlist_menu = g_menu_new ();
		g_menu_append (playlist_menu, _("Add to New Playlist"), priv->new_playlist_action_name);
		g_menu_append_section (playlist_menu, NULL, playlists);

		g_object_set (source, "playlist-menu", playlist_menu, NULL);
	}
	g_strfreev (playlist_formats);
	g_object_unref (entry_type);

	g_object_get (priv->device_info, "output-formats", &output_formats, NULL);
	if (output_formats != NULL) {
		GstEncodingTarget *target;
		int i;

		target = gst_encoding_target_new ("generic-player", "device", "", NULL);
		for (i = 0; output_formats[i] != NULL; i++) {
			const char *media_type = rb_gst_mime_type_to_media_type (output_formats[i]);
			if (media_type != NULL) {
				GstEncodingProfile *profile;
				profile = rb_gst_get_encoding_profile (media_type);
				if (profile != NULL) {
					gst_encoding_target_add_profile (target, profile);
				}
			}
		}
		g_object_set (source, "encoding-target", target, NULL);
	}
	g_strfreev (output_formats);

	g_object_unref (shell);
}