[gnome-control-center] shell: Add --list command-line option



commit 7c3d27f3a097182840ed4872e1418d3ecbd3ec08
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jan 10 17:14:47 2013 +0100

    shell: Add --list command-line option
    
    https://bugzilla.gnome.org/show_bug.cgi?id=655418

 man/gnome-control-center.xml |    7 +++++++
 shell/cc-panel-loader.c      |   12 ++++++++++++
 shell/cc-panel-loader.h      |    1 +
 shell/control-center.c       |   18 ++++++++++++++++++
 4 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/man/gnome-control-center.xml b/man/gnome-control-center.xml
index d7b3083..321f8e4 100644
--- a/man/gnome-control-center.xml
+++ b/man/gnome-control-center.xml
@@ -309,6 +309,13 @@
                         </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>
 
                                 <listitem><para>Opens the overview.</para></listitem>
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index ce19bef..0c699d3 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -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)
 {
diff --git a/shell/cc-panel-loader.h b/shell/cc-panel-loader.h
index d450ea5..bee1657 100644
--- a/shell/cc-panel-loader.h
+++ b/shell/cc-panel-loader.h
@@ -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);
diff --git a/shell/control-center.c b/shell/control-center.c
index c93a128..c082aa9 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]