[gnome-shell] extensions-tool: Implement list command
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] extensions-tool: Implement list command
- Date: Wed, 21 Aug 2019 16:38:52 +0000 (UTC)
commit ac4b88f25d277d157f677cb4f238ad696d41e19f
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Aug 27 05:34:27 2018 +0200
extensions-tool: Implement list command
Seeing at a glance which extensions are installed is surely useful,
so add a corresponding command.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1234
src/extensions-tool/command-list.c | 92 +++++++++++++++++++++++++++++++++++++
src/extensions-tool/commands.h | 1 +
src/extensions-tool/main.c | 3 ++
src/extensions-tool/meson-src.build | 1 +
src/extensions-tool/meson.build | 1 +
5 files changed, 98 insertions(+)
---
diff --git a/src/extensions-tool/command-list.c b/src/extensions-tool/command-list.c
new file mode 100644
index 0000000000..e97360de20
--- /dev/null
+++ b/src/extensions-tool/command-list.c
@@ -0,0 +1,92 @@
+/* command-list.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+
+static gboolean
+list_extensions (void)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GVariant) response = NULL;
+ g_autoptr (GVariant) extensions = NULL;
+ g_autoptr (GError) error = NULL;
+ GVariantIter iter;
+ GVariant *value;
+ char *uuid;
+
+ proxy = get_shell_proxy (&error);
+ if (proxy == NULL)
+ return FALSE;
+
+ response = g_dbus_proxy_call_sync (proxy,
+ "ListExtensions",
+ NULL,
+ 0,
+ -1,
+ NULL,
+ &error);
+ if (response == NULL)
+ return FALSE;
+
+ extensions = g_variant_get_child_value (response, 0);
+
+ g_variant_iter_init (&iter, extensions);
+ while (g_variant_iter_loop (&iter, "{s@a{sv}}", &uuid, &value))
+ g_print ("%s\n", uuid);
+
+ return TRUE;
+}
+
+int
+handle_list (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+
+ g_set_prgname ("gnome-extensions list");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("List installed extensions"));
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (argc > 1)
+ {
+ show_help (context, _("Unknown arguments"));
+ return 1;
+ }
+
+ return list_extensions () ? 0 : 2;
+}
diff --git a/src/extensions-tool/commands.h b/src/extensions-tool/commands.h
index f2b4c712f0..fc40e5c732 100644
--- a/src/extensions-tool/commands.h
+++ b/src/extensions-tool/commands.h
@@ -26,6 +26,7 @@ G_BEGIN_DECLS
int handle_enable (int argc, char *argv[], gboolean do_help);
int handle_disable (int argc, char *argv[], gboolean do_help);
+int handle_list (int argc, char *argv[], gboolean do_help);
int handle_create (int argc, char *argv[], gboolean do_help);
G_END_DECLS
diff --git a/src/extensions-tool/main.c b/src/extensions-tool/main.c
index 19c331112b..f40091d2c0 100644
--- a/src/extensions-tool/main.c
+++ b/src/extensions-tool/main.c
@@ -100,6 +100,7 @@ usage (void)
g_printerr (" version %s\n", _("Print version"));
g_printerr (" enable %s\n", _("Enable extension"));
g_printerr (" disable %s\n", _("Disable extension"));
+ g_printerr (" list %s\n", _("List extensions"));
g_printerr (" create %s\n", _("Create extension"));
g_printerr ("\n");
g_printerr (_("Use %s to get detailed help.\n"), "“gnome-extensions help COMMAND”");
@@ -158,6 +159,8 @@ main (int argc, char *argv[])
return handle_enable (argc, argv, do_help);
else if (g_str_equal (command, "disable"))
return handle_disable (argc, argv, do_help);
+ else if (g_str_equal (command, "list"))
+ return handle_list (argc, argv, do_help);
else if (g_str_equal (command, "create"))
return handle_create (argc, argv, do_help);
else
diff --git a/src/extensions-tool/meson-src.build b/src/extensions-tool/meson-src.build
index d11a75ba2d..21d70a39f8 100644
--- a/src/extensions-tool/meson-src.build
+++ b/src/extensions-tool/meson-src.build
@@ -3,6 +3,7 @@ sources = [
'command-create.c',
'command-disable.c',
'command-enable.c',
+ 'command-list.c',
'common.h',
'main.c'
]
diff --git a/src/extensions-tool/meson.build b/src/extensions-tool/meson.build
index 35d5245b5e..8e8f818cb8 100644
--- a/src/extensions-tool/meson.build
+++ b/src/extensions-tool/meson.build
@@ -12,6 +12,7 @@ sources = [
'command-create.c',
'command-disable.c',
'command-enable.c',
+ 'command-list.c',
'main.c'
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]