[GnomeMeeting-devel-list] Opening a link in gnomemeeting



Hi,

the following makes opening a link work in three cases :
- GNU/* and *BSD with gnome ;
- win32 ;
- GNU/* and *BSD.

I tested them and they work, but still a review wouldn't hurt.

Snark
diff -urN gnomemeeting.cvs/lib/Makefile.am gnomemeeting.patched/lib/Makefile.am
--- gnomemeeting.cvs/lib/Makefile.am	2005-12-12 07:54:52.000000000 +0100
+++ gnomemeeting.patched/lib/Makefile.am	2005-12-20 14:12:51.000000000 +0100
@@ -47,6 +47,17 @@
 	eggtrayicon.c
 endif
 
+libgnomemeeting_la_SOURCES += toolbox.h
+if WIN32
+libgnomemeeting_la_SOURCES += toolbox-win32.c
+else
+if DISABLE_GNOME
+libgnomemeeting_la_SOURCES += toolbox-nognome.c
+else
+libgnomemeeting_la_SOURCES += toolbox-gnome.c
+endif
+endif
+
 INCLUDES =						\
 	-DDATA_DIR=\""$(datadir)"\"			\
 	-DG_LOG_DOMAIN=\"GnomeMeeting\"		 	\
diff -urN gnomemeeting.cvs/lib/toolbox-gnome.c gnomemeeting.patched/lib/toolbox-gnome.c
--- gnomemeeting.cvs/lib/toolbox-gnome.c	1970-01-01 01:00:00.000000000 +0100
+++ gnomemeeting.patched/lib/toolbox-gnome.c	2005-12-20 14:17:57.000000000 +0100
@@ -0,0 +1,11 @@
+#include "toolbox.h"
+
+#include <gnome.h>
+
+void
+gm_open_uri (const gchar *uri)
+{
+  g_return_if_fail (uri != NULL);
+
+  gnome_url_show (uri, NULL);
+}
diff -urN gnomemeeting.cvs/lib/toolbox.h gnomemeeting.patched/lib/toolbox.h
--- gnomemeeting.cvs/lib/toolbox.h	1970-01-01 01:00:00.000000000 +0100
+++ gnomemeeting.patched/lib/toolbox.h	2005-12-20 14:13:45.000000000 +0100
@@ -0,0 +1,7 @@
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+void gm_open_uri (const gchar *);
+
+G_END_DECLS
diff -urN gnomemeeting.cvs/lib/toolbox-nognome.c gnomemeeting.patched/lib/toolbox-nognome.c
--- gnomemeeting.cvs/lib/toolbox-nognome.c	1970-01-01 01:00:00.000000000 +0100
+++ gnomemeeting.patched/lib/toolbox-nognome.c	2005-12-20 14:23:58.000000000 +0100
@@ -0,0 +1,14 @@
+#include "toolbox.h"
+
+void
+gm_open_uri (const gchar *uri)
+{
+  static gchar *command = "sensible-browser %s";
+  gchar *commandline = NULL;
+
+  g_return_if_fail (uri != NULL);
+
+  commandline = g_strdup_printf (command, uri);
+  g_spawn_command_line_async (commandline, NULL);
+  g_free (commandline);
+}
diff -urN gnomemeeting.cvs/lib/toolbox-win32.c gnomemeeting.patched/lib/toolbox-win32.c
--- gnomemeeting.cvs/lib/toolbox-win32.c	1970-01-01 01:00:00.000000000 +0100
+++ gnomemeeting.patched/lib/toolbox-win32.c	2005-12-20 14:27:28.000000000 +0100
@@ -0,0 +1,21 @@
+#include "toolbox.h"
+
+#include <windows.h>
+
+void
+gm_open_uri (const gchar *uri)
+{
+  SHELLEXECUTEINFO sinfo;
+
+  g_return_if_fail (uri != NULL);
+
+  memset (&sinfo, 0, sizeof (sinfo));
+  sinfo.cbSize = sizeof (sinfo);
+  sinfo.fMask = SEE_MASK_CLASSNAME;
+  sinfo.lpVerb = "open";
+  sinfo.lpFile = uri;
+  sinfo.nShow = SW_SHOWNORMAL;
+  sinfo.lpClass = "http";
+
+  (void)ShellExecuteEx (&sinfo); /* leave out any error */
+}
diff -ur gnomemeeting.cvs/src/chat_window.cpp gnomemeeting.patched/src/chat_window.cpp
--- gnomemeeting.cvs/src/chat_window.cpp	2005-12-12 07:54:52.000000000 +0100
+++ gnomemeeting.patched/src/chat_window.cpp	2005-12-20 14:01:27.000000000 +0100
@@ -47,6 +47,7 @@
 #include "main_window.h"
 #include "calls_history_window.h"
 #include "urlhandler.h"
+#include "toolbox.h"
 
 #include <gm_conf.h>
 #include <gtk-text-tag-addon.h>
@@ -227,15 +228,6 @@
 			      gpointer);
 
 
-#ifndef DISABLE_GNOME
-/* DESCRIPTION  :  Called when an URL is clicked.
- * BEHAVIOR     :  Displays it with gnome_url_show.
- * PRE          :  /
- */
-static void open_uri_cb (const gchar *);
-#endif
-
-
 /* DESCRIPTION  :  Called when an URL is clicked.
  * BEHAVIOR     :  Set the text in the clipboard.
  * PRE          :  /
@@ -557,10 +549,8 @@
   if (gtk_text_tag_set_regex (regex_tag,
 			      "\\<(http[s]?|[s]?ftp)://[^[:blank:]]+\\>")) {
     gtk_text_tag_add_actions_to_regex (regex_tag,
-#ifndef DISABLE_GNOME
 				       _("Open URI"),
-				       open_uri_cb,
-#endif
+				       gm_open_uri,
 				       _("Copy Link Location"),
 				       copy_uri_cb,
 				       NULL);
@@ -816,17 +806,6 @@
 }
 
 
-#ifndef DISABLE_GNOME
-static void
-open_uri_cb (const gchar *uri)
-{
-  g_return_if_fail (uri != NULL);
-  
-  gnome_url_show (uri, NULL);
-}
-#endif
-
-
 static void
 copy_uri_cb (const gchar *uri)
 {
diff -ur gnomemeeting.cvs/src/druid.cpp gnomemeeting.patched/src/druid.cpp
--- gnomemeeting.cvs/src/druid.cpp	2005-12-12 07:54:53.000000000 +0100
+++ gnomemeeting.patched/src/druid.cpp	2005-12-20 14:06:03.000000000 +0100
@@ -48,6 +48,7 @@
 #include "dialog.h"
 #include "stock-icons.h"
 #include "gm_conf.h"
+#include "toolbox.h"
 
 #ifdef WIN32
 #include "winpaths.h"
@@ -1924,23 +1925,7 @@
 gnomemeeting_net_consult_cb (GtkWidget *button,
 			     gpointer data)
 {
-  gchar *url = NULL;
-
-#ifdef DISABLE_GNOME
-  gchar *command = NULL;
-#endif
-  
-  url = g_strdup ("http://sip.gnomemeeting.net";);
-  
-#ifdef DISABLE_GNOME
-  command = g_strdup_printf ("mozilla %s", url);
-  g_spawn_command_line_async (command, NULL);
-  g_free (command);
-#else
-  gnome_url_show (url, NULL);
-#endif
-
-  g_free (url);
+  gm_open_uri ("http://sip.gnomemeeting.net";);
 }
 
 
diff -ur gnomemeeting.cvs/src/tools.cpp gnomemeeting.patched/src/tools.cpp
--- gnomemeeting.cvs/src/tools.cpp	2005-12-12 07:54:52.000000000 +0100
+++ gnomemeeting.patched/src/tools.cpp	2005-12-20 14:08:25.000000000 +0100
@@ -48,6 +48,7 @@
 #include <gm_conf.h>
 #include <gnome_prefs_window.h>
 #include <dialog.h>
+#include "toolbox.h"
 
 #ifdef WIN32
 #include "winpaths.h"
@@ -228,9 +229,6 @@
   const char *password = NULL;
 
   gchar *url = NULL;
-#ifdef DISABLE_GNOME
-  gchar *command = NULL;
-#endif
 
   pc2phone_window = GnomeMeeting::Process ()->GetPC2PhoneWindow ();
   pcw = gm_pcw_get_pcw (pc2phone_window);
@@ -251,13 +249,7 @@
   else if (GPOINTER_TO_INT (data) == 2)
     url = g_strdup_printf ("https://www.diamondcard.us/exec/voip-username?accId=%s&passwordCode=%s&act=ch&spo=gnomemeeting";, account, password);
     
-#ifdef DISABLE_GNOME
-  command = g_strdup_printf ("mozilla %s", url);
-  g_spawn_command_line_async (command, NULL);
-  g_free (command);
-#else
-  gnome_url_show (url, NULL);
-#endif
+  gm_open_uri (url);
 
   g_free (url);
 }


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