extensions-tool/list: Allow filtering by (in)active state
This brings back the filtering that the `--enable`/`--disable` flags used to do, which can be useful as well. For instance $ gnome-extensions list --active to show all extensions currently in use, or $ gnome-extensions list --enabled --inactive for extensions that are inactive despite being enabled. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7004 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3073>
This commit is contained in:
parent
3ed3b5587b
commit
35f6111ec9
@ -100,6 +100,12 @@ Displays a list of installed extensions.
|
||||
*--disabled*;;
|
||||
Include disabled extensions
|
||||
|
||||
*--active*;;
|
||||
Only include extensions in active state
|
||||
|
||||
*--inactive*;;
|
||||
Only include extensions in inactive state
|
||||
|
||||
*--prefs*;;
|
||||
Only include extensions with preferences
|
||||
|
||||
|
@ -32,8 +32,10 @@ typedef enum {
|
||||
LIST_FLAGS_SYSTEM = 1 << 1,
|
||||
LIST_FLAGS_ENABLED = 1 << 2,
|
||||
LIST_FLAGS_DISABLED = 1 << 3,
|
||||
LIST_FLAGS_NO_PREFS = 1 << 4,
|
||||
LIST_FLAGS_NO_UPDATES = 1 << 5,
|
||||
LIST_FLAGS_ACTIVE = 1 << 4,
|
||||
LIST_FLAGS_INACTIVE = 1 << 5,
|
||||
LIST_FLAGS_NO_PREFS = 1 << 6,
|
||||
LIST_FLAGS_NO_UPDATES = 1 << 7,
|
||||
} ListFilterFlags;
|
||||
|
||||
static gboolean
|
||||
@ -71,13 +73,14 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
|
||||
while (g_variant_iter_loop (&iter, "{s@a{sv}}", &uuid, &value))
|
||||
{
|
||||
g_autoptr (GVariantDict) info = NULL;
|
||||
double type;
|
||||
double type, state;
|
||||
gboolean has_prefs;
|
||||
gboolean has_update;
|
||||
gboolean enabled;
|
||||
|
||||
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, "enabled", "b", &enabled);
|
||||
g_variant_dict_lookup (info, "hasPrefs", "b", &has_prefs);
|
||||
g_variant_dict_lookup (info, "hasUpdate", "b", &has_update);
|
||||
@ -94,6 +97,12 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
|
||||
if (!enabled && (filter & LIST_FLAGS_DISABLED) == 0)
|
||||
continue;
|
||||
|
||||
if (state == STATE_ACTIVE && (filter & LIST_FLAGS_ACTIVE) == 0)
|
||||
continue;
|
||||
|
||||
if (state != STATE_ACTIVE && (filter & LIST_FLAGS_INACTIVE) == 0)
|
||||
continue;
|
||||
|
||||
if (!has_prefs && (filter & LIST_FLAGS_NO_PREFS) == 0)
|
||||
continue;
|
||||
|
||||
@ -121,6 +130,8 @@ handle_list (int argc, char *argv[], gboolean do_help)
|
||||
gboolean system = FALSE;
|
||||
gboolean enabled = FALSE;
|
||||
gboolean disabled = FALSE;
|
||||
gboolean active = FALSE;
|
||||
gboolean inactive = FALSE;
|
||||
gboolean has_prefs = FALSE;
|
||||
gboolean has_updates = FALSE;
|
||||
GOptionEntry entries[] = {
|
||||
@ -136,6 +147,12 @@ 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 = "active",
|
||||
.arg = G_OPTION_ARG_NONE, .arg_data = &active,
|
||||
.description = _("Show extensions in active state") },
|
||||
{ .long_name = "inactive",
|
||||
.arg = G_OPTION_ARG_NONE, .arg_data = &inactive,
|
||||
.description = _("Show extensions in inactive state") },
|
||||
{ .long_name = "prefs",
|
||||
.arg = G_OPTION_ARG_NONE, .arg_data = &has_prefs,
|
||||
.description = _("Show extensions with preferences") },
|
||||
@ -186,6 +203,12 @@ handle_list (int argc, char *argv[], gboolean do_help)
|
||||
if (disabled || !enabled)
|
||||
flags |= LIST_FLAGS_DISABLED;
|
||||
|
||||
if (active || !inactive)
|
||||
flags |= LIST_FLAGS_ACTIVE;
|
||||
|
||||
if (inactive || !active)
|
||||
flags |= LIST_FLAGS_INACTIVE;
|
||||
|
||||
if (!has_prefs)
|
||||
flags |= LIST_FLAGS_NO_PREFS;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user