[gnome-software/wip/rancell/3-20-enhancements] Add a --details-pkg option that allows showing app details keyed by package name



commit d98166ae9be6354596870f66ff87a79583d1f828
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  |   33 ++++++++++++++++++++++++++++++---
 src/gs-shell-search.c |    4 +++-
 src/gs-shell.c        |    8 --------
 src/gs-shell.h        |    2 --
 4 files changed, 33 insertions(+), 14 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index ed33f87..470280c 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,
@@ -559,8 +561,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
@@ -654,6 +674,7 @@ static GActionEntry actions[] = {
        { "set-mode", set_mode_activated, "s", NULL, NULL },
        { "search", search_activated, "s", NULL, NULL },
        { "details", details_activated, "(ss)", NULL, NULL },
+       { "details-pkg", details_pkg_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 },
@@ -721,6 +742,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;
@@ -765,6 +787,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 c082035..37aa466 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -935,14 +935,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]