[gnome-software/wip/rancell/ubuntu-3-20-rebase: 27/28] Add a --details-pkg option that allows showing app details keyed by package name



commit 1809a7b78922b97925b64d0807bcaefd2a8c81fe
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Apr 26 11:12:37 2016 +0200

    Add a --details-pkg option that allows showing app details keyed by package name

 src/gs-application.c  |   32 +++++++++++++++++++++++++++++---
 src/gs-shell-search.c |    4 +++-
 src/gs-shell.c        |    8 --------
 src/gs-shell.h        |    2 --
 4 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 33177b2..57ad217 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -98,7 +98,9 @@ gs_application_init (GsApplication *application)
                { "search", '\0', 0, G_OPTION_ARG_STRING, NULL,
                  _("Search for applications"), _("SEARCH") },
                { "details", '\0', 0, G_OPTION_ARG_STRING, NULL,
-                 _("Show application details"), _("ID") },
+                 _("Show application details (using application ID)"), _("ID") },
+               { "details-pkg", '\0', 0, G_OPTION_ARG_STRING, NULL,
+                 _("Show application details (using package name)"), _("PKGNAME") },
                { "local-filename", '\0', 0, G_OPTION_ARG_FILENAME, NULL,
                  _("Open a local package file"), _("FILENAME") },
                { "verbose", '\0', 0, G_OPTION_ARG_NONE, NULL,
@@ -592,8 +594,26 @@ details_activated (GSimpleAction *action,
        g_variant_get (parameter, "(&s&s)", &id, &search);
        if (search != NULL && search[0] != '\0')
                gs_shell_show_search_result (app->shell, id, search);
-       else
-               gs_shell_show_details (app->shell, id);
+       else {
+               g_autoptr (GsApp) a = NULL;
+               a = gs_app_new (id);
+               gs_shell_show_app (app->shell, a);
+       }
+}
+
+static void
+details_pkg_activated (GSimpleAction *action,
+                      GVariant      *parameter,
+                      gpointer       data)
+{
+       GsApplication *app = GS_APPLICATION (data);
+       g_autoptr (GsApp) a = NULL;
+
+       initialize_ui_and_present_window (app);
+
+       a = gs_app_new (NULL);
+       gs_app_add_source (a, g_variant_get_string (parameter, NULL));
+       gs_shell_show_app (app->shell, a);
 }
 
 static void
@@ -777,6 +797,7 @@ static int
 gs_application_handle_local_options (GApplication *app, GVariantDict *options)
 {
        const gchar *id;
+       const gchar *pkgname;
        const gchar *local_filename;
        const gchar *mode;
        const gchar *search;
@@ -821,6 +842,11 @@ gs_application_handle_local_options (GApplication *app, GVariantDict *options)
                                                "details",
                                                g_variant_new ("(ss)", id, ""));
                return 0;
+       } else if (g_variant_dict_lookup (options, "details-pkg", "&s", &pkgname)) {
+               g_action_group_activate_action (G_ACTION_GROUP (app),
+                                               "details-pkg",
+                                               g_variant_new_string (pkgname));
+               return 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-search.c b/src/gs-shell-search.c
index 45017a1..1cb0e37 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -134,7 +134,9 @@ gs_shell_search_get_search_cb (GObject *source_object,
        }
 
        if (self->appid_to_show != NULL) {
-               gs_shell_show_details (self->shell, self->appid_to_show);
+               g_autoptr (GsApp) a = NULL;
+               a = gs_app_new (self->appid_to_show);
+               gs_shell_show_app (self->shell, a);
                g_clear_pointer (&self->appid_to_show, g_free);
        }
 }
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 67b124d..2920010 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -947,14 +947,6 @@ gs_shell_show_search_result (GsShell *shell, const gchar *id, const gchar *searc
        gs_shell_change_mode (shell, GS_SHELL_MODE_SEARCH, NULL, NULL, TRUE);
 }
 
-void
-gs_shell_show_details (GsShell *shell, const gchar *id)
-{
-       g_autoptr(GsApp) app = NULL;
-       app = gs_app_new (id);
-       gs_shell_show_app (shell, app);
-}
-
 /**
  * gs_shell_dispose:
  **/
diff --git a/src/gs-shell.h b/src/gs-shell.h
index 4a68228..356ce01 100644
--- a/src/gs-shell.h
+++ b/src/gs-shell.h
@@ -82,8 +82,6 @@ void           gs_shell_show_filename         (GsShell        *shell,
 void            gs_shell_show_search_result    (GsShell        *shell,
                                                 const gchar    *id,
                                                 const gchar    *search);
-void            gs_shell_show_details          (GsShell        *shell,
-                                                const gchar    *id);
 void            gs_shell_show_extras_search    (GsShell        *shell,
                                                 const gchar    *mode,
                                                 gchar          **resources);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]