[ekiga] Moved gm_open_uri to the platform code, and got rid of the toolbox code in the process



commit c283cfc011618a960372cca5ae5af0a9a483e169
Author: Julien Puydt <jpuydt free fr>
Date:   Sun Jan 13 23:15:22 2013 +0100

    Moved gm_open_uri to the platform code, and got rid of the toolbox code in the process

 lib/Makefile.am                             |    6 +-
 lib/engine/components/opal/opal-account.cpp |    2 +-
 lib/engine/gui/gtk-core/form-dialog-gtk.cpp |    2 +-
 lib/engine/gui/gtk-frontend/chat-area.cpp   |    2 +-
 lib/gmconf/gmconf-glib.c                    |    1 -
 lib/platform/platform.c                     |   77 +++++++++++++
 lib/platform/platform.h                     |   11 ++-
 lib/toolbox.c                               |  161 ---------------------------
 lib/toolbox.h                               |   55 ---------
 src/Makefile.am                             |    3 +-
 src/gui/assistant.cpp                       |    2 +-
 11 files changed, 94 insertions(+), 228 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5d835dc..8a53bf8 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,7 +1,6 @@
 stacklib_LTLIBRARIES = libekiga.la
 stacklib_dir = $(stacklibdir)
 
-libekiga_la_SOURCES =
 libekiga_la_LDFLAGS = $(STACKLIB_LDFLAGS) $(BOOST_LIBS) $(GLIB_LIBS) $(XML_LIBS) $(GTK_LIBS)
 
 if !WIN32
@@ -17,6 +16,7 @@ INCLUDES = \
 	-I$(top_srcdir)/lib \
 	-I$(top_srcdir)/lib/gmconf \
 	-I$(top_srcdir)/lib/gui \
+	-I$(top_srcdir)/lib/platform \
 	-I$(top_srcdir)/lib/engine \
 	-I$(top_srcdir)/lib/engine/account \
 	-I$(top_srcdir)/lib/engine/addressbook \
@@ -63,9 +63,7 @@ components_dir = $(top_srcdir)/lib/engine/components
 # Sources out of this directory
 ##
 
-libekiga_la_SOURCES += \
-	$(top_srcdir)/lib/toolbox.h \
-	$(top_srcdir)/lib/toolbox.c
+libekiga_la_SOURCES =
 
 EXTRA_DIST =
 
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index dac5f8e..cc28c71 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -53,7 +53,7 @@
 
 #include "opal-account.h"
 #include "form-request-simple.h"
-#include "toolbox.h"
+#include "platform.h"
 
 #include "presence-core.h"
 #include "personal-details.h"
diff --git a/lib/engine/gui/gtk-core/form-dialog-gtk.cpp b/lib/engine/gui/gtk-core/form-dialog-gtk.cpp
index 079c694..bb5082b 100644
--- a/lib/engine/gui/gtk-core/form-dialog-gtk.cpp
+++ b/lib/engine/gui/gtk-core/form-dialog-gtk.cpp
@@ -39,7 +39,7 @@
 #include <iostream>
 #include <glib/gi18n.h>
 
-#include "toolbox.h"
+#include "platform.h"
 #include "form-dialog-gtk.h"
 
 /*
diff --git a/lib/engine/gui/gtk-frontend/chat-area.cpp b/lib/engine/gui/gtk-frontend/chat-area.cpp
index 9811378..930d210 100644
--- a/lib/engine/gui/gtk-frontend/chat-area.cpp
+++ b/lib/engine/gui/gtk-frontend/chat-area.cpp
@@ -45,7 +45,7 @@
 #include "gm-smiley-chooser-button.h"
 
 #include "gm-smileys.h"
-#include "toolbox.h"
+#include "platform.h"
 
 #include <string.h>
 #include <stdarg.h>
diff --git a/lib/gmconf/gmconf-glib.c b/lib/gmconf/gmconf-glib.c
index b2dfe64..fc4f18f 100644
--- a/lib/gmconf/gmconf-glib.c
+++ b/lib/gmconf/gmconf-glib.c
@@ -43,7 +43,6 @@
 #include <string.h>
 #include <sys/stat.h>
 
-#include "toolbox.h"
 #include "gmconf.h"
 
 #ifdef WIN32
diff --git a/lib/platform/platform.c b/lib/platform/platform.c
index 7a422b8..5a47208 100644
--- a/lib/platform/platform.c
+++ b/lib/platform/platform.c
@@ -48,6 +48,12 @@ static gchar *sysconfdir = NULL;
 static gchar *datadir = NULL;
 #endif
 
+#ifndef WIN32
+#include <gtk/gtk.h>
+#else
+#include <windows.h>
+#endif
+
 void
 gm_platform_init ()
 {
@@ -80,3 +86,74 @@ win32_datadir ()
   return datadir;
 }
 #endif
+
+#ifndef WIN32
+static void
+gm_open_uri_fallback (const gchar *uri)
+{
+  gchar *commandline = NULL;
+  gboolean success = FALSE;
+
+  if (!success && g_getenv("KDE_FULL_SESSION") != NULL) {
+
+    commandline = g_strdup_printf ("kfmclient exec %s", uri);
+    success = g_spawn_command_line_async (commandline, NULL);
+    g_free (commandline);
+  }
+
+  if (!success) {
+
+    commandline = g_strdup_printf ("sensible-browser %s", uri);
+    success = g_spawn_command_line_async (commandline, NULL);
+    g_free (commandline);
+  }
+
+  if (!success) {
+
+    commandline = g_strdup_printf ("firefox %s", uri);
+    success = g_spawn_command_line_async (commandline, NULL);
+    g_free (commandline);
+  }
+
+  if (!success) {
+
+    commandline = g_strdup_printf ("konqueror %s", uri);
+    success = g_spawn_command_line_async (commandline, NULL);
+    g_free (commandline);
+  }
+}
+
+void
+gm_open_uri (const gchar *uri)
+{
+  GError *error = NULL;
+
+  g_return_if_fail (uri != NULL);
+
+  if (!gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error)) {
+    g_error_free (error);
+    gm_open_uri_fallback (uri);
+  }
+}
+
+#else
+
+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 */
+}
+
+#endif
diff --git a/lib/platform/platform.h b/lib/platform/platform.h
index 64faaf5..46605dd 100644
--- a/lib/platform/platform.h
+++ b/lib/platform/platform.h
@@ -1,6 +1,6 @@
 
 /* Ekiga -- A VoIP and Video-Conferencing application
- * Copyright (C) 2000-2009 Damien Sandras <dsandras seconix com>
+ * Copyright (C) 2000-2013 Damien Sandras <dsandras seconix com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
  *                         platform.h  -  description
  *                         ------------------------------------------
  *   begin                : written in 2006 by Julien Puydt
- *   copyright            : (c) 2006-2007 by Julien Puydt
+ *   copyright            : (c) 2006-2013 by Julien Puydt
  *   description          : interface for the annoying platforms workarounds
  *
  */
@@ -46,6 +46,13 @@ void gm_platform_init ();
 
 void gm_platform_shutdown ();
 
+/* DESCRIPTION  : /
+ * BEHAVIOR     : Allows to open an uri in a browser,
+ * 		  in a system-agnostic way
+ * PRE		: Requires a non-NULL uri.
+ */
+void gm_open_uri (const gchar* uri);
+
 G_END_DECLS
 
 #endif
diff --git a/src/Makefile.am b/src/Makefile.am
index a5374a3..a6120e1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,6 +2,7 @@ INCLUDES = \
 	-I$(top_srcdir)/lib				\
 	-I$(top_srcdir)/lib/gmconf			\
 	-I$(top_srcdir)/lib/gui				\
+	-I$(top_srcdir)/lib/platform			\
 	-I$(top_srcdir)/lib/engine/			\
 	-I$(top_srcdir)/lib/engine/framework		\
 	-I$(top_srcdir)/lib/engine/gui/gtk-frontend	\
@@ -53,7 +54,7 @@ ekiga_SOURCES =
 nodist_ekiga_SOURCES =
 
 # Graphical User Interface
-ekiga_SOURCES =			\
+ekiga_SOURCES +=			\
 	gui/assistant.h			\
 	gui/assistant.cpp		\
 	gui/conf.h			\
diff --git a/src/gui/assistant.cpp b/src/gui/assistant.cpp
index 1ed0dd5..5d15a45 100644
--- a/src/gui/assistant.cpp
+++ b/src/gui/assistant.cpp
@@ -44,7 +44,7 @@
 
 #include "ekiga.h"
 #include "gmconf.h"
-#include "toolbox.h"
+#include "platform.h"
 #include "assistant.h"
 #include "default_devices.h"
 



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