[gnome-software: 4/10] Factor out gs_app_show_url



commit 02fb18bad35aabe2f05dff6cf68e584d449dff38
Author: Kalev Lember <kalevlember gmail com>
Date:   Thu Feb 5 14:01:54 2015 +0100

    Factor out gs_app_show_url

 src/gs-shell-details.c |    6 +-----
 src/gs-shell-search.c  |   16 +---------------
 src/gs-utils.c         |   11 +++++++++++
 src/gs-utils.h         |    2 ++
 4 files changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 2d02b43..95bce63 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -447,12 +447,8 @@ static void
 gs_shell_details_website_cb (GtkWidget *widget, GsShellDetails *shell_details)
 {
        GsShellDetailsPrivate *priv = shell_details->priv;
-       const gchar *url;
-       _cleanup_error_free_ GError *error = NULL;
 
-       url = gs_app_get_url (priv->app, AS_URL_KIND_HOMEPAGE);
-       if (!gtk_show_uri (NULL, url, GDK_CURRENT_TIME, &error))
-               g_warning ("spawn of '%s' failed: %s", url, error->message);
+       gs_app_show_url (priv->app, AS_URL_KIND_HOMEPAGE);
 }
 
 /**
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index 7e461ab..ba0f5a7 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -197,20 +197,6 @@ gs_shell_search_app_install (GsShellSearch *shell_search, GsApp *app)
 }
 
 /**
- * gs_shell_search_show_missing_url:
- **/
-static void
-gs_shell_search_show_missing_url (GsApp *app)
-{
-       const gchar *url;
-       _cleanup_error_free_ GError *error = NULL;
-
-       url = gs_app_get_url (app, AS_URL_KIND_MISSING);
-       if (!gtk_show_uri (NULL, url, GDK_CURRENT_TIME, &error))
-               g_warning ("spawn of '%s' failed", url);
-}
-
-/**
  * gs_shell_search_install_unavailable_app:
  **/
 static void
@@ -254,7 +240,7 @@ gs_shell_search_app_row_clicked_cb (GsAppRow *app_row,
                        gs_shell_search_install_unavailable_app (shell_search, app);
                        return;
                }
-               gs_shell_search_show_missing_url (app);
+               gs_app_show_url (app, AS_URL_KIND_MISSING);
        }
 }
 
diff --git a/src/gs-utils.c b/src/gs-utils.c
index a76d5d3..ff95211 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -308,6 +308,17 @@ gs_app_notify_unavailable (GsApp *app, GtkWindow *parent)
        return gs_app_notify_unavailable_other (app, parent);
 }
 
+void
+gs_app_show_url (GsApp *app, AsUrlKind kind)
+{
+       const gchar *url;
+       _cleanup_error_free_ GError *error = NULL;
+
+       url = gs_app_get_url (app, kind);
+       if (!gtk_show_uri (NULL, url, GDK_CURRENT_TIME, &error))
+               g_warning ("spawn of '%s' failed", url);
+}
+
 guint
 gs_string_replace (GString *string, const gchar *search, const gchar *replace)
 {
diff --git a/src/gs-utils.h b/src/gs-utils.h
index a92f670..fddc874 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -42,6 +42,8 @@ void   gs_app_notify_failed_modal     (GsApp          *app,
 GtkResponseType
        gs_app_notify_unavailable       (GsApp          *app,
                                         GtkWindow      *parent);
+void    gs_app_show_url                (GsApp          *app,
+                                        AsUrlKind       kind);
 
 guint   gs_string_replace              (GString        *string,
                                         const gchar    *search,


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