[gnome-software] Add an --interaction option
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add an --interaction option
- Date: Tue, 13 Dec 2016 15:39:40 +0000 (UTC)
commit 654b0e59cf1ab0e2dba15e299878f03cf045d508
Author: Joaquim Rocha <jrocha endlessm com>
Date: Tue Dec 13 13:40:16 2016 +0100
Add an --interaction option
This option is currently only used together with the --install option
and allows to specify several levels of interaction:
* full: Open the window in the app's details page (so the intallation
progress is shown);
* notify: If the window is hidden by the time the installation is
finished, then show a desktop notification but never show the UI;
* none: Just install the application, no notification nor UI will be
shown.
src/gs-application.c | 35 ++++++++++++++++++++++++++++++-----
src/gs-page.c | 10 ++++++++--
src/gs-page.h | 7 ++++---
src/gs-shell-details.c | 6 ++++--
src/gs-shell-extras.c | 3 ++-
src/gs-shell-overview.c | 1 +
src/gs-shell-search.c | 7 +++++--
src/gs-shell.c | 4 ++--
src/gs-shell.h | 12 ++++++++++--
9 files changed, 66 insertions(+), 19 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index f592d49..418e03c 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -109,6 +109,9 @@ gs_application_init (GsApplication *application)
_("Install the application (using application ID)"), _("ID") },
{ "local-filename", '\0', 0, G_OPTION_ARG_FILENAME, NULL,
_("Open a local package file"), _("FILENAME") },
+ { "interaction", '\0', 0, G_OPTION_ARG_STRING, NULL,
+ _("The kind of interaction expected for this action: either "
+ "'none', 'notify', or 'full'"), NULL },
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, NULL,
_("Show verbose debugging information"), NULL },
{ "profile", 0, 0, G_OPTION_ARG_NONE, NULL,
@@ -568,15 +571,19 @@ install_activated (GSimpleAction *action,
{
GsApplication *app = GS_APPLICATION (data);
const gchar *id;
+ GsShellInteraction interaction;
g_autoptr (GsApp) a = NULL;
- g_variant_get (parameter, "&s", &id);
+ g_variant_get (parameter, "(&su)", &id, &interaction);
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);
+ if (interaction == GS_SHELL_INTERACTION_FULL)
+ initialize_ui_and_present_window (app, NULL);
+ else
+ gs_application_initialize_ui (app);
a = gs_app_new_from_unique_id (id);
if (a == NULL) {
@@ -584,7 +591,7 @@ install_activated (GSimpleAction *action,
return;
}
- gs_shell_install (app->shell, a);
+ gs_shell_install (app->shell, a, interaction);
}
static void
@@ -686,7 +693,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 },
+ { "install", install_activated, "(su)", 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 },
@@ -793,6 +800,16 @@ gs_application_dispose (GObject *object)
G_OBJECT_CLASS (gs_application_parent_class)->dispose (object);
}
+static GsShellInteraction
+get_page_interaction_from_string (const gchar *interaction)
+{
+ if (g_strcmp0 (interaction, "notify") == 0)
+ return GS_SHELL_INTERACTION_NOTIFY;
+ else if (g_strcmp0 (interaction, "none") == 0)
+ return GS_SHELL_INTERACTION_NONE;
+ return GS_SHELL_INTERACTION_FULL;
+}
+
static int
gs_application_handle_local_options (GApplication *app, GVariantDict *options)
{
@@ -854,9 +871,17 @@ gs_application_handle_local_options (GApplication *app, GVariantDict *options)
g_variant_new_string (pkgname));
rc = 0;
} else if (g_variant_dict_lookup (options, "install", "&s", &id)) {
+ GsShellInteraction interaction = GS_SHELL_INTERACTION_FULL;
+ const gchar *str_interaction = NULL;
+
+ if (g_variant_dict_lookup (options, "interaction", "&s",
+ &str_interaction))
+ interaction = get_page_interaction_from_string (str_interaction);
+
g_action_group_activate_action (G_ACTION_GROUP (app),
"install",
- g_variant_new ("s", id));
+ g_variant_new ("(su)", id,
+ interaction));
rc = 0;
} else if (g_variant_dict_lookup (options, "local-filename", "^&ay", &local_filename)) {
g_action_group_activate_action (G_ACTION_GROUP (app),
diff --git a/src/gs-page.c b/src/gs-page.c
index d1ed817..69424b2 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -49,6 +49,7 @@ typedef struct {
gulong notify_quirk_id;
GtkWidget *button_install;
GsPluginAction action;
+ GsShellInteraction interaction;
} GsPageHelper;
static void
@@ -177,7 +178,8 @@ gs_page_app_installed_cb (GObject *source,
/* only show this if the window is not active */
if (gs_app_is_installed (helper->app) &&
helper->action == GS_PLUGIN_ACTION_INSTALL &&
- !gs_shell_is_active (priv->shell))
+ !gs_shell_is_active (priv->shell) &&
+ ((helper->interaction) & GS_SHELL_INTERACTION_NOTIFY) != 0)
gs_app_notify_installed (helper->app);
if (gs_app_is_installed (helper->app) &&
@@ -272,7 +274,10 @@ gs_page_set_header_end_widget (GsPage *page, GtkWidget *widget)
}
void
-gs_page_install_app (GsPage *page, GsApp *app, GCancellable *cancellable)
+gs_page_install_app (GsPage *page,
+ GsApp *app,
+ GsShellInteraction interaction,
+ GCancellable *cancellable)
{
GsPagePrivate *priv = gs_page_get_instance_private (page);
GsPageHelper *helper;
@@ -290,6 +295,7 @@ gs_page_install_app (GsPage *page, GsApp *app, GCancellable *cancellable)
helper->app = g_object_ref (app);
helper->page = g_object_ref (page);
helper->cancellable = g_object_ref (cancellable);
+ helper->interaction = interaction;
gs_plugin_loader_app_action_async (priv->plugin_loader,
app,
helper->action,
diff --git a/src/gs-page.h b/src/gs-page.h
index 1f6b59c..13d2fa7 100644
--- a/src/gs-page.h
+++ b/src/gs-page.h
@@ -54,9 +54,10 @@ void gs_page_set_header_start_widget (GsPage *page,
GtkWidget *gs_page_get_header_end_widget (GsPage *page);
void gs_page_set_header_end_widget (GsPage *page,
GtkWidget *widget);
-void gs_page_install_app (GsPage *page,
- GsApp *app,
- GCancellable *cancellable);
+void gs_page_install_app (GsPage *page,
+ GsApp *app,
+ GsShellInteraction interaction,
+ GCancellable *cancellable);
void gs_page_remove_app (GsPage *page,
GsApp *app,
GCancellable *cancellable);
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 882c177..a21f28f 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1653,7 +1653,8 @@ gs_shell_details_app_install_button_cb (GtkWidget *widget, GsShellDetails *self)
return;
}
- gs_page_install_app (GS_PAGE (self), self->app, self->cancellable);
+ gs_page_install_app (GS_PAGE (self), self->app, GS_SHELL_INTERACTION_FULL,
+ self->cancellable);
}
static void
@@ -1673,7 +1674,8 @@ gs_shell_details_addon_selected_cb (GsAppAddonRow *row,
case AS_APP_STATE_UPDATABLE:
case AS_APP_STATE_UPDATABLE_LIVE:
if (gs_app_addon_row_get_selected (row)) {
- gs_page_install_app (GS_PAGE (self), addon, self->cancellable);
+ gs_page_install_app (GS_PAGE (self), addon, GS_SHELL_INTERACTION_FULL,
+ self->cancellable);
} else {
gs_page_remove_app (GS_PAGE (self), addon, self->cancellable);
/* make sure the addon checkboxes are synced if the
diff --git a/src/gs-shell-extras.c b/src/gs-shell-extras.c
index 12e2dee..1d796b4 100644
--- a/src/gs-shell-extras.c
+++ b/src/gs-shell-extras.c
@@ -264,7 +264,8 @@ app_row_button_clicked_cb (GsAppRow *app_row,
app = gs_app_row_get_app (app_row);
if (gs_app_get_state (app) == AS_APP_STATE_AVAILABLE ||
gs_app_get_state (app) == AS_APP_STATE_AVAILABLE_LOCAL)
- gs_page_install_app (GS_PAGE (self), app, self->search_cancellable);
+ gs_page_install_app (GS_PAGE (self), app, GS_SHELL_INTERACTION_FULL,
+ self->search_cancellable);
else if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED)
gs_page_remove_app (GS_PAGE (self), app, self->search_cancellable);
else
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index e2eaa42..28f7318 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -681,6 +681,7 @@ g_shell_overview_get_sources_cb (GsPluginLoader *plugin_loader,
if (g_settings_get_boolean (priv->settings, "show-nonfree-software")) {
if (gs_app_get_state (app) == AS_APP_STATE_AVAILABLE) {
gs_page_install_app (GS_PAGE (self), app,
+ GS_SHELL_INTERACTION_FULL,
priv->cancellable);
}
} else {
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index 168e186..0820ebd 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -70,12 +70,15 @@ gs_shell_search_app_row_clicked_cb (GsAppRow *app_row,
GsApp *app;
app = gs_app_row_get_app (app_row);
if (gs_app_get_state (app) == AS_APP_STATE_AVAILABLE)
- gs_page_install_app (GS_PAGE (self), app, self->cancellable);
+ gs_page_install_app (GS_PAGE (self), app, GS_SHELL_INTERACTION_FULL,
+ self->cancellable);
else if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED)
gs_page_remove_app (GS_PAGE (self), app, self->cancellable);
else if (gs_app_get_state (app) == AS_APP_STATE_UNAVAILABLE) {
if (gs_app_get_url (app, AS_URL_KIND_MISSING) == NULL) {
- gs_page_install_app (GS_PAGE (self), app, self->cancellable);
+ gs_page_install_app (GS_PAGE (self), app,
+ GS_SHELL_INTERACTION_FULL,
+ self->cancellable);
return;
}
gs_app_show_url (app, AS_URL_KIND_MISSING);
diff --git a/src/gs-shell.c b/src/gs-shell.c
index a269aa3..148c617 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1740,13 +1740,13 @@ gs_shell_get_mode_string (GsShell *shell)
}
void
-gs_shell_install (GsShell *shell, GsApp *app)
+gs_shell_install (GsShell *shell, GsApp *app, GsShellInteraction interaction)
{
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,
+ gs_page_install_app (GS_PAGE (priv->shell_details), app, interaction,
priv->cancellable);
}
diff --git a/src/gs-shell.h b/src/gs-shell.h
index 7e9e62c..1341584 100644
--- a/src/gs-shell.h
+++ b/src/gs-shell.h
@@ -56,6 +56,13 @@ typedef enum {
GS_SHELL_MODE_LAST
} GsShellMode;
+typedef enum {
+ GS_SHELL_INTERACTION_NONE = (0u),
+ GS_SHELL_INTERACTION_NOTIFY = (1u << 0),
+ GS_SHELL_INTERACTION_FULL = (1u << 1) | GS_SHELL_INTERACTION_NOTIFY,
+ GS_SHELL_INTERACTION_LAST
+} GsShellInteraction;
+
GsShell *gs_shell_new (void);
void gs_shell_activate (GsShell *shell);
void gs_shell_profile_dump (GsShell *shell);
@@ -73,8 +80,9 @@ 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_install (GsShell *shell,
+ GsApp *app,
+ GsShellInteraction interaction);
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]