[gnome-software] Use gtk_show_uri_on_window() with newer GTK+
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Use gtk_show_uri_on_window() with newer GTK+
- Date: Wed, 8 Mar 2017 09:56:10 +0000 (UTC)
commit 72fd4f56351377b3bec9b4380cc5d09a4e391c91
Author: Kalev Lember <klember redhat com>
Date: Tue Mar 7 19:51:55 2017 +0100
Use gtk_show_uri_on_window() with newer GTK+
The gtk_show_uri() function won't work correctly inside a sandbox, and
has been deprecated in GTK+ 3.22.
src/gs-auth-dialog.c | 10 ++++++++++
src/gs-common.c | 11 -----------
src/gs-common.h | 2 --
src/gs-details-page.c | 5 +++--
src/gs-extras-page.c | 3 ++-
src/gs-search-page.c | 3 ++-
src/gs-shell.c | 25 +++++++++++++++++++++++++
src/gs-shell.h | 2 ++
src/gs-updates-page.c | 3 +--
9 files changed, 45 insertions(+), 19 deletions(-)
---
diff --git a/src/gs-auth-dialog.c b/src/gs-auth-dialog.c
index 28238b0..2aacecd 100644
--- a/src/gs-auth-dialog.c
+++ b/src/gs-auth-dialog.c
@@ -132,10 +132,20 @@ gs_auth_dialog_authenticate_cb (GObject *source,
if (url != NULL) {
g_autoptr(GError) error_local = NULL;
g_debug ("showing link in: %s", error->message);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ if (!gtk_show_uri_on_window (GTK_WINDOW (dialog),
+ url,
+ GDK_CURRENT_TIME,
+ &error)) {
+ g_warning ("failed to show URI %s: %s",
+ url, error_local->message);
+ }
+#else
if (!gtk_show_uri (NULL, url, GDK_CURRENT_TIME, &error_local)) {
g_warning ("failed to show URI %s: %s",
url, error_local->message);
}
+#endif
return;
}
diff --git a/src/gs-common.c b/src/gs-common.c
index 79d0461..c0b59f8 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -294,17 +294,6 @@ gs_app_notify_unavailable (GsApp *app, GtkWindow *parent)
}
void
-gs_app_show_url (GsApp *app, AsUrlKind kind)
-{
- const gchar *url;
- g_autoptr(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);
-}
-
-void
gs_image_set_from_pixbuf_with_scale (GtkImage *image, const GdkPixbuf *pixbuf, gint scale)
{
cairo_surface_t *surface;
diff --git a/src/gs-common.h b/src/gs-common.h
index 9d74abc..b33b8f3 100644
--- a/src/gs-common.h
+++ b/src/gs-common.h
@@ -38,8 +38,6 @@ void gs_app_notify_installed (GsApp *app);
GtkResponseType
gs_app_notify_unavailable (GsApp *app,
GtkWindow *parent);
-void gs_app_show_url (GsApp *app,
- AsUrlKind kind);
void gs_image_set_from_pixbuf_with_scale (GtkImage *image,
const GdkPixbuf *pixbuf,
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 88de446..e3d18de 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -649,7 +649,8 @@ gs_details_page_refresh_screenshots (GsDetailsPage *self)
static void
gs_details_page_website_cb (GtkWidget *widget, GsDetailsPage *self)
{
- gs_app_show_url (self->app, AS_URL_KIND_HOMEPAGE);
+ gs_shell_show_uri (self->shell,
+ gs_app_get_url (self->app, AS_URL_KIND_HOMEPAGE));
}
static void
@@ -1906,7 +1907,7 @@ gs_details_page_activate_link_cb (GtkLabel *label,
const gchar *uri,
GsDetailsPage *self)
{
- gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, NULL);
+ gs_shell_show_uri (self->shell, uri);
return TRUE;
}
diff --git a/src/gs-extras-page.c b/src/gs-extras-page.c
index 6f37ae4..8ab22ed 100644
--- a/src/gs-extras-page.c
+++ b/src/gs-extras-page.c
@@ -1050,7 +1050,8 @@ row_activated_cb (GtkListBox *list_box,
if (gs_app_get_state (app) == AS_APP_STATE_UNAVAILABLE &&
gs_app_get_url (app, AS_URL_KIND_MISSING) != NULL) {
- gs_app_show_url (app, AS_URL_KIND_MISSING);
+ gs_shell_show_uri (self->shell,
+ gs_app_get_url (app, AS_URL_KIND_MISSING));
} else {
gs_shell_show_app (self->shell, app);
}
diff --git a/src/gs-search-page.c b/src/gs-search-page.c
index 82d1a5b..b2dd5a7 100644
--- a/src/gs-search-page.c
+++ b/src/gs-search-page.c
@@ -80,7 +80,8 @@ gs_search_page_app_row_clicked_cb (GsAppRow *app_row,
self->cancellable);
return;
}
- gs_app_show_url (app, AS_URL_KIND_MISSING);
+ gs_shell_show_uri (self->shell,
+ gs_app_get_url (app, AS_URL_KIND_MISSING));
}
}
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 78c4730..a45e5a8 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1888,6 +1888,31 @@ gs_shell_show_search_result (GsShell *shell, const gchar *id, const gchar *searc
(gpointer) search, TRUE);
}
+void
+gs_shell_show_uri (GsShell *shell, const gchar *url)
+{
+ GsShellPrivate *priv = gs_shell_get_instance_private (shell);
+ g_autoptr(GError) error = NULL;
+
+#if GTK_CHECK_VERSION (3, 22, 0)
+ if (!gtk_show_uri_on_window (priv->main_window,
+ url,
+ GDK_CURRENT_TIME,
+ &error)) {
+ g_warning ("failed to show URI %s: %s",
+ url, error->message);
+ }
+#else
+ if (!gtk_show_uri (NULL,
+ url,
+ GDK_CURRENT_TIME,
+ &error)) {
+ g_warning ("failed to show URI %s: %s",
+ url, error->message);
+ }
+#endif
+}
+
static void
gs_shell_dispose (GObject *object)
{
diff --git a/src/gs-shell.h b/src/gs-shell.h
index 3820239..b3ba20e 100644
--- a/src/gs-shell.h
+++ b/src/gs-shell.h
@@ -96,6 +96,8 @@ void gs_shell_show_search_result (GsShell *shell,
void gs_shell_show_extras_search (GsShell *shell,
const gchar *mode,
gchar **resources);
+void gs_shell_show_uri (GsShell *shell,
+ const gchar *url);
void gs_shell_setup (GsShell *shell,
GsPluginLoader *plugin_loader,
GCancellable *cancellable);
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index c7137f8..e9219bb 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -1201,8 +1201,7 @@ gs_updates_page_upgrade_help_cb (GsUpgradeBanner *upgrade_banner,
/* open the link */
uri = gs_app_get_url (app, AS_URL_KIND_HOMEPAGE);
- if (!gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error))
- g_warning ("failed to open %s: %s", uri, error->message);
+ gs_shell_show_uri (self->shell, uri);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]