extensions-tool: Add option to list updates
Now that we support extension updates, it may be useful to list pending updates from the command line. It's easy enough to support, so add a corresponding option to the list command. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/988
This commit is contained in:
parent
dee738e24f
commit
224ab2e543
@ -96,6 +96,9 @@ Displays a list of installed extensions.
|
|||||||
*--prefs*;;
|
*--prefs*;;
|
||||||
Only include extensions with preferences
|
Only include extensions with preferences
|
||||||
|
|
||||||
|
*--updates*;;
|
||||||
|
Only include extensions with pending updates
|
||||||
|
|
||||||
*-d*;;
|
*-d*;;
|
||||||
*--details*;;
|
*--details*;;
|
||||||
Show some extra information for each extension
|
Show some extra information for each extension
|
||||||
|
@ -32,7 +32,8 @@ typedef enum {
|
|||||||
LIST_FLAGS_SYSTEM = 1 << 1,
|
LIST_FLAGS_SYSTEM = 1 << 1,
|
||||||
LIST_FLAGS_ENABLED = 1 << 2,
|
LIST_FLAGS_ENABLED = 1 << 2,
|
||||||
LIST_FLAGS_DISABLED = 1 << 3,
|
LIST_FLAGS_DISABLED = 1 << 3,
|
||||||
LIST_FLAGS_NO_PREFS = 1 << 4
|
LIST_FLAGS_NO_PREFS = 1 << 4,
|
||||||
|
LIST_FLAGS_NO_UPDATES = 1 << 5,
|
||||||
} ListFilterFlags;
|
} ListFilterFlags;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -69,11 +70,13 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
|
|||||||
g_autoptr (GVariantDict) info = NULL;
|
g_autoptr (GVariantDict) info = NULL;
|
||||||
double type, state;
|
double type, state;
|
||||||
gboolean has_prefs;
|
gboolean has_prefs;
|
||||||
|
gboolean has_update;
|
||||||
|
|
||||||
info = g_variant_dict_new (value);
|
info = g_variant_dict_new (value);
|
||||||
g_variant_dict_lookup (info, "type", "d", &type);
|
g_variant_dict_lookup (info, "type", "d", &type);
|
||||||
g_variant_dict_lookup (info, "state", "d", &state);
|
g_variant_dict_lookup (info, "state", "d", &state);
|
||||||
g_variant_dict_lookup (info, "hasPrefs", "b", &has_prefs);
|
g_variant_dict_lookup (info, "hasPrefs", "b", &has_prefs);
|
||||||
|
g_variant_dict_lookup (info, "hasUpdate", "b", &has_update);
|
||||||
|
|
||||||
if (type == TYPE_USER && (filter & LIST_FLAGS_USER) == 0)
|
if (type == TYPE_USER && (filter & LIST_FLAGS_USER) == 0)
|
||||||
continue;
|
continue;
|
||||||
@ -90,6 +93,9 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
|
|||||||
if (!has_prefs && (filter & LIST_FLAGS_NO_PREFS) == 0)
|
if (!has_prefs && (filter & LIST_FLAGS_NO_PREFS) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!has_update && (filter & LIST_FLAGS_NO_UPDATES) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (needs_newline)
|
if (needs_newline)
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
|
|
||||||
@ -112,6 +118,7 @@ handle_list (int argc, char *argv[], gboolean do_help)
|
|||||||
gboolean enabled = FALSE;
|
gboolean enabled = FALSE;
|
||||||
gboolean disabled = FALSE;
|
gboolean disabled = FALSE;
|
||||||
gboolean has_prefs = FALSE;
|
gboolean has_prefs = FALSE;
|
||||||
|
gboolean has_updates = FALSE;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{ .long_name = "user",
|
{ .long_name = "user",
|
||||||
.arg = G_OPTION_ARG_NONE, .arg_data = &user,
|
.arg = G_OPTION_ARG_NONE, .arg_data = &user,
|
||||||
@ -128,6 +135,9 @@ handle_list (int argc, char *argv[], gboolean do_help)
|
|||||||
{ .long_name = "prefs",
|
{ .long_name = "prefs",
|
||||||
.arg = G_OPTION_ARG_NONE, .arg_data = &has_prefs,
|
.arg = G_OPTION_ARG_NONE, .arg_data = &has_prefs,
|
||||||
.description = _("Show extensions with preferences") },
|
.description = _("Show extensions with preferences") },
|
||||||
|
{ .long_name = "updates",
|
||||||
|
.arg = G_OPTION_ARG_NONE, .arg_data = &has_updates,
|
||||||
|
.description = _("Show extensions with updates") },
|
||||||
{ .long_name = "details", .short_name = 'd',
|
{ .long_name = "details", .short_name = 'd',
|
||||||
.arg = G_OPTION_ARG_NONE, .arg_data = &details,
|
.arg = G_OPTION_ARG_NONE, .arg_data = &details,
|
||||||
.description = _("Print extension details") },
|
.description = _("Print extension details") },
|
||||||
@ -174,6 +184,9 @@ handle_list (int argc, char *argv[], gboolean do_help)
|
|||||||
if (!has_prefs)
|
if (!has_prefs)
|
||||||
flags |= LIST_FLAGS_NO_PREFS;
|
flags |= LIST_FLAGS_NO_PREFS;
|
||||||
|
|
||||||
|
if (!has_updates)
|
||||||
|
flags |= LIST_FLAGS_NO_UPDATES;
|
||||||
|
|
||||||
return list_extensions (flags, details ? DISPLAY_DETAILED
|
return list_extensions (flags, details ? DISPLAY_DETAILED
|
||||||
: DISPLAY_ONELINE) ? 0 : 2;
|
: DISPLAY_ONELINE) ? 0 : 2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user