changeset 1118:63dd52ba9a8f

Added support for attempting to launch a browser using a newly discovered feature gtk_show_uri(). This function requires gvfs to be installed... if it isn't we will fall back to using DW_BROWSE or just firefox.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 25 Aug 2011 19:33:40 +0000
parents 9ca5de2e59f8
children e8e7f048f0b8
files gtk/dw.c gtk3/dw.c
diffstat 2 files changed, 42 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Wed Aug 10 02:36:32 2011 +0000
+++ b/gtk/dw.c	Thu Aug 25 19:33:40 2011 +0000
@@ -11163,16 +11163,28 @@
  */
 int dw_browse(char *url)
 {
-   /* Is there a way to find the webbrowser in Unix? */
-   char *execargs[3], *browser = "firefox", *tmp;
-
-   tmp = getenv( "DW_BROWSER" );
-   if(tmp) browser = tmp;
-   execargs[0] = browser;
-   execargs[1] = url;
-   execargs[2] = NULL;
-
-   return dw_exec(browser, DW_EXEC_GUI, execargs);
+#if GTK_CHECK_VERSION(2,14,0)
+   /* If possible load the URL/URI using gvfs... */
+   if(gtk_show_uri(gdk_screen_get_default(), url, GDK_CURRENT_TIME, NULL))
+   {
+      return DW_ERROR_NONE;
+   }
+   else
+#endif
+   {
+      /* Otherwise just fall back to executing firefox...
+       * or the browser defined by the DW_BROWSER variable.
+       */
+      char *execargs[3], *browser = "firefox", *tmp;
+
+      tmp = getenv( "DW_BROWSER" );
+      if(tmp) browser = tmp;
+      execargs[0] = browser;
+      execargs[1] = url;
+      execargs[2] = NULL;
+
+      return dw_exec(browser, DW_EXEC_GUI, execargs);
+   }
 }
 
 /*
--- a/gtk3/dw.c	Wed Aug 10 02:36:32 2011 +0000
+++ b/gtk3/dw.c	Thu Aug 25 19:33:40 2011 +0000
@@ -9727,16 +9727,26 @@
  */
 int dw_browse(char *url)
 {
-   /* Is there a way to find the webbrowser in Unix? */
-   char *execargs[3], *browser = "firefox", *tmp;
-
-   tmp = getenv( "DW_BROWSER" );
-   if(tmp) browser = tmp;
-   execargs[0] = browser;
-   execargs[1] = url;
-   execargs[2] = NULL;
-
-   return dw_exec(browser, DW_EXEC_GUI, execargs);
+   /* If possible load the URL/URI using gvfs... */
+   if(gtk_show_uri(gdk_screen_get_default(), url, GDK_CURRENT_TIME, NULL))
+   {
+      return DW_ERROR_NONE;
+   }
+   else
+   {
+      /* Otherwise just fall back to executing firefox...
+       * or the browser defined by the DW_BROWSER variable.
+       */
+      char *execargs[3], *browser = "firefox", *tmp;
+
+      tmp = getenv( "DW_BROWSER" );
+      if(tmp) browser = tmp;
+      execargs[0] = browser;
+      execargs[1] = url;
+      execargs[2] = NULL;
+
+      return dw_exec(browser, DW_EXEC_GUI, execargs);
+   }
 }
 
 /*