[gnome-power-manager] use gtk_show_uri i.s.o. gnome-open



commit e8ac3a921ce4acffb3212c088a43870d7e40da5a
Author: Jaap A. Haitsma <jaap haitsma org>
Date:   Sun Jun 21 22:43:03 2009 +0200

    use gtk_show_uri i.s.o. gnome-open

 src/gpm-common.c |   56 ++++++++++++-----------------------------------------
 src/gpm-notify.c |   16 +--------------
 2 files changed, 14 insertions(+), 58 deletions(-)
---
diff --git a/src/gpm-common.c b/src/gpm-common.c
index 5cdd091..7d613be 100644
--- a/src/gpm-common.c
+++ b/src/gpm-common.c
@@ -126,53 +126,23 @@ void
 gpm_help_display (const gchar *link_id)
 {
 	GError *error = NULL;
-	char *command;
-	const char *lang;
-	char *uri = NULL;
-	GdkScreen *gscreen;
-
-	int i;
-
-	const char * 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-power-manager/",
-					lang,
-				       "/gnome-power-manager.xml",
-					NULL);
-					
-		if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
-                    break;
-		}
-	}
-	
-	if (link_id) {
-		command = g_strconcat ("gnome-open ghelp://", uri, "?", link_id, NULL);
-	} else {
-		command = g_strconcat ("gnome-open ghelp://", uri,  NULL);
-	}
+	gchar *uri;
+
+	if (link_id)
+		uri = g_strconcat ("ghelp:cheese?", link_id, NULL);
+	else
+		uri = g_strdup ("ghelp:cheese");
+
+	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,
-				GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
-				"%s", error->message);
-		gtk_dialog_run(GTK_DIALOG(d));
-		gtk_widget_destroy(d);
-		g_error_free(error);
+		d = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+					    GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG(d));
+		gtk_widget_destroy (d);
+		g_error_free (error);
 	}
-
-	g_free (command);
 	g_free (uri);
 }
 
diff --git a/src/gpm-notify.c b/src/gpm-notify.c
index e8ff539..a6e22a0 100644
--- a/src/gpm-notify.c
+++ b/src/gpm-notify.c
@@ -216,7 +216,6 @@ notify_general_clicked_cb (NotifyNotification *libnotify,
 {
 	gboolean ret;
 	GError *error = NULL;
- 	char *cmdline;
 	GdkScreen *gscreen;
 	GtkWidget *error_dialog;
 
@@ -230,21 +229,8 @@ notify_general_clicked_cb (NotifyNotification *libnotify,
 	}
 	if (strcmp (action, "visit-website") == 0) {
 		egg_debug ("autovisit website %s", notify->priv->internet_url);
-		error = NULL;
 
- 		cmdline = g_strconcat ("gnome-open ", notify->priv->internet_url, NULL);
-		ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-		g_free (cmdline);
-
-		if (ret)
-			return;
-
-		g_error_free (error);
-		error = NULL;
-
- 		cmdline = g_strconcat ("xdg-open ", notify->priv->internet_url, NULL);
-		ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-		g_free (cmdline);
+		ret = gtk_show_uri (gscreen, notify->priv->internet_url, gtk_get_current_event_time (), &error);
 
 		if (!ret) {
 			error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message); 



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