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



commit 4648a832dcd97f2d199cf3678e5514ed2419f9ae
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 b3bdfa0..3cad725 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,
@@ -598,8 +600,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
@@ -783,6 +803,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;
@@ -827,6 +848,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 220bfa8..a3ef887 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 8212f1e..b268f12 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -950,14 +950,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]