[gnome-control-center/gbsneto/interactive-test-panels: 7/13] panel-loader: Simplify listing panels



commit ef67271250a5193b78f62482d698c617c6cee985
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Nov 7 20:25:30 2018 -0200

    panel-loader: Simplify listing panels
    
    Instead of enumerating them, putting that in a GList, then
    iterating the GList printing the panel names, simply print
    them while enumerating.

 shell/cc-application.c  | 10 +---------
 shell/cc-panel-loader.c | 11 ++++++-----
 shell/cc-panel-loader.h |  2 +-
 3 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/shell/cc-application.c b/shell/cc-application.c
index 08b27000e..67beb383c 100644
--- a/shell/cc-application.c
+++ b/shell/cc-application.c
@@ -125,15 +125,7 @@ cc_application_handle_local_options (GApplication *application,
 
   if (g_variant_dict_contains (options, "list"))
     {
-      g_autoptr(GList) panels = NULL;
-      g_autoptr(GList) l = NULL;
-
-      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);
-
+      cc_panel_loader_list_panels ();
       return 0;
     }
 
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index 42334e23b..8ce95372e 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -23,6 +23,7 @@
 
 #include <string.h>
 #include <gio/gdesktopappinfo.h>
+#include <glib/gi18n.h>
 
 #include "cc-panel.h"
 #include "cc-panel-loader.h"
@@ -236,14 +237,14 @@ cc_panel_loader_fill_model (CcShellModel *model)
 #endif
 }
 
-GList *
-cc_panel_loader_get_panels (void)
+void
+cc_panel_loader_list_panels (void)
 {
-  GList *l = NULL;
   guint i;
 
+  g_print ("%s\n", _("Available panels:"));
+
   for (i = 0; i < G_N_ELEMENTS (default_panels); i++)
-    l = g_list_prepend (l, (gpointer) default_panels[i].name);
+    g_print ("\t%s\n", default_panels[i].name);
 
-  return g_list_reverse (l);
 }
diff --git a/shell/cc-panel-loader.h b/shell/cc-panel-loader.h
index 84feee549..f9847600e 100644
--- a/shell/cc-panel-loader.h
+++ b/shell/cc-panel-loader.h
@@ -40,7 +40,7 @@ typedef struct
 } CcPanelLoaderVtable;
 
 void     cc_panel_loader_fill_model     (CcShellModel  *model);
-GList   *cc_panel_loader_get_panels     (void);
+void     cc_panel_loader_list_panels    (void);
 CcPanel *cc_panel_loader_load_by_name   (CcShell       *shell,
                                          const char    *name,
                                          GVariant      *parameters);


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