[gnome-software/wip/temp/ubuntu-xenial-rebased-corrected: 312/331] Add a --details-pkg option that allows showing app details keyed by package name



commit 6f7312e79cf0ec6fe7c6f344295bba70c2fde111
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 ce13352..2533128 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,
@@ -672,8 +674,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
@@ -768,6 +788,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 },
@@ -835,6 +856,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;
@@ -879,6 +901,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 ebbbf74..c6ab940 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 73319a8..ab09c4a 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -936,14 +936,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]