[gnome-shell] extensions-tool: Add '--prefs' list option



commit d9fa3890794390416dc07fd8833afd9a621aaded
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jan 11 12:18:14 2019 +0100

    extensions-tool: Add '--prefs' list option
    
    We are about to add a 'prefs' command for launching an extension's
    preference dialog. As that command only makes sense for extensions
    that actually have preferences, shell completion should filter the
    list of extensions accordingly. To allow that, add an appropriate
    list option.
    
    https://gitlab.gnome.org/fmuellner/gnome-extensions-tool/merge_requests/2
    https://gitlab.gnome.org/GNOME/gnome-shell/issues/1234

 src/extensions-tool/command-list.c           | 15 ++++++++++++++-
 src/extensions-tool/man/gnome-extensions.txt |  3 +++
 2 files changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/extensions-tool/command-list.c b/src/extensions-tool/command-list.c
index 0313cd93c1..b5cee59230 100644
--- a/src/extensions-tool/command-list.c
+++ b/src/extensions-tool/command-list.c
@@ -31,7 +31,8 @@ typedef enum {
   LIST_FLAGS_USER     = 1 << 0,
   LIST_FLAGS_SYSTEM   = 1 << 1,
   LIST_FLAGS_ENABLED  = 1 << 2,
-  LIST_FLAGS_DISABLED = 1 << 3
+  LIST_FLAGS_DISABLED = 1 << 3,
+  LIST_FLAGS_NO_PREFS = 1 << 4
 } ListFilterFlags;
 
 static gboolean
@@ -67,10 +68,12 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
     {
       g_autoptr (GVariantDict) info = NULL;
       double type, state;
+      gboolean has_prefs;
 
       info = g_variant_dict_new (value);
       g_variant_dict_lookup (info, "type", "d", &type);
       g_variant_dict_lookup (info, "state", "d", &state);
+      g_variant_dict_lookup (info, "hasPrefs", "b", &has_prefs);
 
       if (type == TYPE_USER && (filter & LIST_FLAGS_USER) == 0)
         continue;
@@ -84,6 +87,9 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
       if (state != STATE_ENABLED && (filter & LIST_FLAGS_DISABLED) == 0)
         continue;
 
+      if (!has_prefs && (filter & LIST_FLAGS_NO_PREFS) == 0)
+        continue;
+
       if (needs_newline)
         g_print ("\n");
 
@@ -105,6 +111,7 @@ handle_list (int argc, char *argv[], gboolean do_help)
   gboolean system = FALSE;
   gboolean enabled = FALSE;
   gboolean disabled = FALSE;
+  gboolean has_prefs = FALSE;
   GOptionEntry entries[] = {
     { .long_name = "user",
       .arg = G_OPTION_ARG_NONE, .arg_data = &user,
@@ -118,6 +125,9 @@ handle_list (int argc, char *argv[], gboolean do_help)
     { .long_name = "disabled",
       .arg = G_OPTION_ARG_NONE, .arg_data = &disabled,
       .description = _("Show disabled extensions") },
+    { .long_name = "prefs",
+      .arg = G_OPTION_ARG_NONE, .arg_data = &has_prefs,
+      .description = _("Show extensions with preferences") },
     { .long_name = "details", .short_name = 'd',
       .arg = G_OPTION_ARG_NONE, .arg_data = &details,
       .description = _("Print extension details") },
@@ -161,6 +171,9 @@ handle_list (int argc, char *argv[], gboolean do_help)
   if (disabled || !enabled)
     flags |= LIST_FLAGS_DISABLED;
 
+  if (!has_prefs)
+    flags |= LIST_FLAGS_NO_PREFS;
+
   return list_extensions (flags, details ? DISPLAY_DETAILED
                                          : DISPLAY_ONELINE) ? 0 : 2;
 }
diff --git a/src/extensions-tool/man/gnome-extensions.txt b/src/extensions-tool/man/gnome-extensions.txt
index c362e4d0af..e782103fd6 100644
--- a/src/extensions-tool/man/gnome-extensions.txt
+++ b/src/extensions-tool/man/gnome-extensions.txt
@@ -81,6 +81,9 @@ Displays a list of installed extensions.
   *--disabled*;;
     Include disabled extensions
 
+  *--prefs*;;
+    Only include extensions with preferences
+
   *-d*;;
   *--details*;;
     Show some extra information for each extension


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