shell: Add --list command-line option

https://bugzilla.gnome.org/show_bug.cgi?id=655418
This commit is contained in:
Bastien Nocera 2013-01-10 17:14:47 +01:00
parent 1e85647bc5
commit 7c3d27f3a0
4 changed files with 38 additions and 0 deletions

View file

@ -308,6 +308,13 @@
<listitem><para>Enables verbose mode.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-l</option>, <option>--list</option></term>
<listitem><para>Lists the available panels
and exits.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-o</option>, <option>--overview</option></term>

View file

@ -94,6 +94,18 @@ static struct {
static GHashTable *panel_types;
GList *
cc_panel_loader_get_panels (void)
{
GList *l = NULL;
guint i;
for (i = 0; i < G_N_ELEMENTS (all_panels); i++)
l = g_list_prepend (l, (gpointer) all_panels[i].name);
return g_list_reverse (l);
}
static int
parse_categories (GDesktopAppInfo *app)
{

View file

@ -29,6 +29,7 @@
G_BEGIN_DECLS
void cc_panel_loader_fill_model (CcShellModel *model);
GList *cc_panel_loader_get_panels (void);
CcPanel *cc_panel_loader_load_by_name (CcShell *shell,
const char *name,
const char **argv);

View file

@ -25,6 +25,7 @@
#include <stdlib.h>
#include "gnome-control-center.h"
#include "cc-panel-loader.h"
#include <gtk/gtk.h>
#include <string.h>
@ -58,12 +59,14 @@ static gboolean verbose = FALSE;
static gboolean show_help = FALSE;
static gboolean show_help_gtk = FALSE;
static gboolean show_help_all = FALSE;
static gboolean list_panels = FALSE;
const GOptionEntry all_options[] = {
{ "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Enable verbose mode"), NULL },
{ "overview", 'o', 0, G_OPTION_ARG_NONE, &show_overview, N_("Show the overview"), NULL },
{ "search", 's', 0, G_OPTION_ARG_STRING, &search_str, N_("Search for the string"), "SEARCH" },
{ "list", 'l', 0, G_OPTION_ARG_NONE, &list_panels, N_("List possible panel names and exit"), NULL },
{ "help", 'h', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help, N_("Show help options"), NULL },
{ "help-all", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help_all, N_("Show help options"), NULL },
{ "help-gtk", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help_gtk, N_("Show help options"), NULL },
@ -121,6 +124,21 @@ application_command_line_cb (GApplication *application,
return 0;
}
if (list_panels)
{
GList *panels, *l;
panels = cc_panel_loader_get_panels ();
g_print ("%s\n", _("Available panels:"));
for (l = panels; l != NULL; l = l->next)
g_print ("\t%s\n", (char *) l->data);
g_list_free (panels);
return 0;
}
g_option_context_free (context);
#ifdef HAVE_CHEESE