[gnome-packagekit] Use gtk_show_uri instead of deprecated gnome-open



commit f31e6b78fd1cb9b74b473017b3f2d9a31e6e7c9a
Author: Jaap A. Haitsma <jaap haitsma org>
Date:   Sun Jun 21 18:51:00 2009 +0200

    Use gtk_show_uri instead of deprecated gnome-open

 configure.ac           |    2 +-
 src/gpk-application.c  |   16 +--------------
 src/gpk-check-update.c |   16 +--------------
 src/gpk-gnome.c        |   49 ++++++++++++-----------------------------------
 src/gpk-watch.c        |   16 +--------------
 5 files changed, 17 insertions(+), 82 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2b0fedd..9f0eadb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,7 +83,7 @@ dnl - Library dependencies
 dnl ---------------------------------------------------------------------------
 PACKAGEKIT_REQUIRED=0.4.4 # when changing, nuke some compatability entries in gpk-enum.h
 GLIB_REQUIRED=2.14.0
-GTK_REQUIRED=2.15.0
+GTK_REQUIRED=2.16.0
 DBUS_REQUIRED=1.1.2
 GCONF_REQUIRED=0.22
 DBUS_GLIB_REQUIRED=0.73
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 989525d..501c55c 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -2248,7 +2248,6 @@ gpk_application_about_dialog_url_cb (GtkAboutDialog *about, const char *address,
 	GError *error = NULL;
 	gboolean ret;
 
-	char *cmdline;
 	GdkScreen *gscreen;
 	GtkWidget *error_dialog;
 	gchar *url;
@@ -2261,18 +2260,7 @@ gpk_application_about_dialog_url_cb (GtkAboutDialog *about, const char *address,
 
 	gscreen = gtk_window_get_screen (GTK_WINDOW (about));
 
-	cmdline = g_strconcat ("xdg-open ", url, NULL);
-	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-	g_free (cmdline);
-
-	if (ret)
-		goto out;
-
-	g_error_free (error);
-	error = NULL;
-	cmdline = g_strconcat ("gnome-open ", url, NULL);
-	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-	g_free (cmdline);
+	ret = gtk_show_uri (gscreen, url, gtk_get_current_event_time (), &error);
 
 	if (!ret) {
 		error_dialog = gtk_message_dialog_new (GTK_WINDOW (about),
@@ -2287,8 +2275,6 @@ gpk_application_about_dialog_url_cb (GtkAboutDialog *about, const char *address,
 		gtk_widget_destroy (error_dialog);
 		g_error_free (error);
 	}
-
-out:
 	g_free (url);
 }
 
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 3a664cd..ca12de8 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -177,7 +177,6 @@ gpk_check_update_about_dialog_url_cb (GtkAboutDialog *about, const char *address
 {
 	GError *error = NULL;
 	gboolean ret;
-	char *cmdline;
 	GdkScreen *gscreen;
 	GtkWidget *error_dialog;
 	gchar *url;
@@ -190,19 +189,7 @@ gpk_check_update_about_dialog_url_cb (GtkAboutDialog *about, const char *address
 
 	gscreen = gtk_window_get_screen (GTK_WINDOW (about));
 
-	cmdline = g_strconcat ("xdg-open ", url, NULL);
-	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-	g_free (cmdline);
-
-	if (ret)
-		goto out;
-
-	g_error_free (error);
-	error = NULL;
-
-	cmdline = g_strconcat ("gnome-open ", url, NULL);
-	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-	g_free (cmdline);
+	ret = gtk_show_uri (gscreen, url, gtk_get_current_event_time (), &error);
 
 	if (!ret) {
 		error_dialog = gtk_message_dialog_new (GTK_WINDOW (about),
@@ -218,7 +205,6 @@ gpk_check_update_about_dialog_url_cb (GtkAboutDialog *about, const char *address
 		g_error_free (error);
 	}
 
-out:
 	g_free (url);
 }
 
diff --git a/src/gpk-gnome.c b/src/gpk-gnome.c
index 3974107..04e9a55 100644
--- a/src/gpk-gnome.c
+++ b/src/gpk-gnome.c
@@ -35,16 +35,17 @@
 gboolean
 gpk_gnome_open (const gchar *url)
 {
-	gchar *data;
 	gboolean ret;
+	GError *error = NULL;
 
 	g_return_val_if_fail (url != NULL, FALSE);
 
-	data = g_strconcat ("gnome-open ", url, NULL);
-	ret = g_spawn_command_line_async (data, NULL);
-	if (!ret)
-		egg_warning ("spawn of '%s' failed", data);
-	g_free (data);
+	ret = gtk_show_uri (NULL, url, GDK_CURRENT_TIME, &error);
+
+	if (!ret) {
+		egg_warning ("spawn of '%s' failed", url);
+		g_error_free (error);
+	}
 	return ret;
 }
 
@@ -56,40 +57,17 @@ gboolean
 gpk_gnome_help (const gchar *link_id)
 {
 	GError *error = NULL;
-	gchar *command;
-	const gchar *lang;
-	gchar *uri = NULL;
-	GdkScreen *gscreen;
-	gint i;
+	gchar *uri;
 	gboolean ret = TRUE;
-	gboolean found_help_file = FALSE;
-	const gchar *const *langs = g_get_language_names ();
-
-	for (i = 0; langs[i]; i++) {
-		lang = langs[i];
-		if (strchr (lang, '.'))
-			continue;
-		uri = g_build_filename (DATADIR, "/gnome/help/gnome-packagekit/",
-					lang, "/gnome-packagekit.xml", NULL);
-		if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
-			found_help_file = TRUE;
-			break;
-		}
-		g_free (uri);
-	}
-	if (!found_help_file) {
-		egg_warning ("cant find help file");
-		return FALSE;
-	}
 
 	if (link_id)
-		command = g_strconcat ("gnome-open ghelp://", uri, "?", link_id, NULL);
+		uri = g_strconcat ("ghelp:gnome-packagekit?", link_id, NULL);
 	else
-		command = g_strconcat ("gnome-open ghelp://", uri, NULL);
-	egg_debug ("using command %s", command);
+		uri = g_strdup ("ghelp:gnome-packagekit");
+	egg_debug ("opening uri %s", uri);
+
+	gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error);
 
-	gscreen = gdk_screen_get_default ();
-	gdk_spawn_command_line_on_screen (gscreen, command, &error);
 	if (error != NULL) {
 		GtkWidget *d;
 		d = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -100,7 +78,6 @@ gpk_gnome_help (const gchar *link_id)
 		ret = FALSE;
 	}
 
-	g_free (command);
 	g_free (uri);
 	return ret;
 }
diff --git a/src/gpk-watch.c b/src/gpk-watch.c
index 4ad2f49..1657043 100644
--- a/src/gpk-watch.c
+++ b/src/gpk-watch.c
@@ -669,7 +669,6 @@ gpk_watch_about_dialog_url_cb (GtkAboutDialog *about, const char *address, gpoin
 {
 	GError *error = NULL;
 	gboolean ret;
-	char *cmdline;
 	GdkScreen *gscreen;
 	gchar *url;
 	gchar *protocol = (gchar*) data;
@@ -681,19 +680,7 @@ gpk_watch_about_dialog_url_cb (GtkAboutDialog *about, const char *address, gpoin
 
 	gscreen = gtk_window_get_screen (GTK_WINDOW (about));
 
-	cmdline = g_strconcat ("xdg-open ", url, NULL);
-	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-	g_free (cmdline);
-
-	if (ret)
-		goto out;
-
-	g_error_free (error);
-	error = NULL;
-
-	cmdline = g_strconcat ("gnome-open ", url, NULL);
-	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-	g_free (cmdline);
+	ret = gtk_show_uri (gscreen, url, gtk_get_current_event_time (), &error);
 
 	if (!ret) {
 		/* TRANSLATORS: We couldn't launch the tool, normally a packaging problem */
@@ -701,7 +688,6 @@ gpk_watch_about_dialog_url_cb (GtkAboutDialog *about, const char *address, gpoin
 		g_error_free (error);
 	}
 
-out:
 	g_free (url);
 }
 



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