[gnome-software] Add an --install CLI option
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add an --install CLI option
- Date: Tue, 13 Dec 2016 15:39:35 +0000 (UTC)
commit 91f225a355cd83096b6605120e9d85b82f0ba894
Author: Joaquim Rocha <jrocha endlessm com>
Date: Mon Dec 12 21:25:28 2016 +0100
Add an --install CLI option
This option allows GNOME Sofware to be started directly into installing
the given application while displaying its details page.
src/gs-application.c | 34 ++++++++++++++++++++++++++++++++++
src/gs-shell.c | 11 +++++++++++
src/gs-shell.h | 2 ++
3 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 91adf6c..f592d49 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -105,6 +105,8 @@ gs_application_init (GsApplication *application)
_("Show application details (using application ID)"), _("ID") },
{ "details-pkg", '\0', 0, G_OPTION_ARG_STRING, NULL,
_("Show application details (using package name)"), _("PKGNAME") },
+ { "install", '\0', 0, G_OPTION_ARG_STRING, NULL,
+ _("Install the application (using application ID)"), _("ID") },
{ "local-filename", '\0', 0, G_OPTION_ARG_FILENAME, NULL,
_("Open a local package file"), _("FILENAME") },
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, NULL,
@@ -560,6 +562,32 @@ details_pkg_activated (GSimpleAction *action,
}
static void
+install_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer data)
+{
+ GsApplication *app = GS_APPLICATION (data);
+ const gchar *id;
+ g_autoptr (GsApp) a = NULL;
+
+ g_variant_get (parameter, "&s", &id);
+ if (!as_utils_unique_id_valid (id)) {
+ g_warning ("Need to use a valid unique-id: %s", id);
+ return;
+ }
+
+ initialize_ui_and_present_window (app, NULL);
+
+ a = gs_app_new_from_unique_id (id);
+ if (a == NULL) {
+ g_warning ("Could not create app from unique-id: %s", id);
+ return;
+ }
+
+ gs_shell_install (app->shell, a);
+}
+
+static void
filename_activated (GSimpleAction *action,
GVariant *parameter,
gpointer data)
@@ -658,6 +686,7 @@ static GActionEntry actions[] = {
{ "search", search_activated, "s", NULL, NULL },
{ "details", details_activated, "(ss)", NULL, NULL },
{ "details-pkg", details_pkg_activated, "s", NULL, NULL },
+ { "install", install_activated, "s", NULL, NULL },
{ "filename", filename_activated, "(s)", NULL, NULL },
{ "launch", launch_activated, "s", NULL, NULL },
{ "show-offline-update-error", show_offline_updates_error, NULL, NULL, NULL },
@@ -824,6 +853,11 @@ gs_application_handle_local_options (GApplication *app, GVariantDict *options)
"details-pkg",
g_variant_new_string (pkgname));
rc = 0;
+ } else if (g_variant_dict_lookup (options, "install", "&s", &id)) {
+ g_action_group_activate_action (G_ACTION_GROUP (app),
+ "install",
+ g_variant_new ("s", id));
+ rc = 0;
} else if (g_variant_dict_lookup (options, "local-filename", "^&ay", &local_filename)) {
g_action_group_activate_action (G_ACTION_GROUP (app),
"filename",
diff --git a/src/gs-shell.c b/src/gs-shell.c
index f4add93..a269aa3 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1740,6 +1740,17 @@ gs_shell_get_mode_string (GsShell *shell)
}
void
+gs_shell_install (GsShell *shell, GsApp *app)
+{
+ GsShellPrivate *priv = gs_shell_get_instance_private (shell);
+ save_back_entry (shell);
+ gs_shell_change_mode (shell, GS_SHELL_MODE_DETAILS,
+ (gpointer) app, TRUE);
+ gs_page_install_app (GS_PAGE (priv->shell_details), app,
+ priv->cancellable);
+}
+
+void
gs_shell_show_installed_updates (GsShell *shell)
{
GsShellPrivate *priv = gs_shell_get_instance_private (shell);
diff --git a/src/gs-shell.h b/src/gs-shell.h
index a2989f0..7e9e62c 100644
--- a/src/gs-shell.h
+++ b/src/gs-shell.h
@@ -73,6 +73,8 @@ void gs_shell_modal_dialog_present (GsShell *shell,
GtkDialog *dialog);
GsShellMode gs_shell_get_mode (GsShell *shell);
const gchar *gs_shell_get_mode_string (GsShell *shell);
+void gs_shell_install (GsShell *shell,
+ GsApp *app);
void gs_shell_show_installed_updates(GsShell *shell);
void gs_shell_show_sources (GsShell *shell);
void gs_shell_show_app (GsShell *shell,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]