changeset 22208:c77098cebf23

Use xdg-open instead of gnome-open, if possible. We might want to use xdg-open on other DEs too, because apparently it knows about KDE and XFCE and things. We might even be able to get rid of our browser prefs tab on those too.
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 26 Jan 2008 16:17:36 +0000
parents b52f690502a4
children a276345c21a0
files pidgin/gtknotify.c pidgin/gtkprefs.c
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtknotify.c	Sat Jan 26 03:53:18 2008 +0000
+++ b/pidgin/gtknotify.c	Sat Jan 26 16:17:36 2008 +0000
@@ -1058,7 +1058,12 @@
 	/* if they are running gnome, use the gnome web browser */
 	if (purple_running_gnome() == TRUE)
 	{
-		command = g_strdup_printf("gnome-open %s", escaped);
+		char *tmp = g_find_program_in_path("xdg-open");
+		if (tmp == NULL)
+			command = g_strdup_printf("gnome-open %s", escaped);
+		else
+			command = g_strdup_printf("xdg-open %s", escaped);
+		g_free(tmp);
 	}
 	else if (purple_running_osx() == TRUE)
 	{
@@ -1074,6 +1079,10 @@
 		else
 			command = g_strdup_printf("%s %s", web_browser, escaped);
 	}
+	else if (!strcmp(web_browser, "xdg-open"))
+	{
+		command = g_strdup_printf("xdg-open %s", escaped);
+	}
 	else if (!strcmp(web_browser, "gnome-open"))
 	{
 		command = g_strdup_printf("gnome-open %s", escaped);
--- a/pidgin/gtkprefs.c	Sat Jan 26 03:53:18 2008 +0000
+++ b/pidgin/gtkprefs.c	Sat Jan 26 16:17:36 2008 +0000
@@ -1369,6 +1369,7 @@
 		{N_("Netscape"), "netscape"},
 		{N_("Mozilla"), "mozilla"},
 		{N_("Konqueror"), "kfmclient"},
+		{N_("Desktop Default"), "xdg-open"},
 		{N_("GNOME Default"), "gnome-open"},
 		{N_("Galeon"), "galeon"},
 		{N_("Firefox"), "firefox"},
@@ -1391,6 +1392,14 @@
 			browsers = g_list_prepend(browsers, (gpointer)_(possible_browsers[i].name));
 			if(browser_setting && !strcmp(possible_browsers[i].command, browser_setting))
 				browser_setting = NULL;
+			/* If xdg-open is valid, prefer it over gnome-open and skip forward */
+			if(!strcmp(possible_browsers[i].command, "xdg-open")) {
+				if (browser_setting && !strcmp("gnome-open", browser_setting)) {
+					purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/browser", possible_browsers[i].command);
+					browser_setting = NULL;
+				}
+				i++;
+			}
 		}
 	}