[Rawstudio-commit] r2216 - trunk/src

Anders Brander anders at brander.dk
Sun Feb 22 22:14:04 CET 2009


Author: abrander
Date: 2009-02-22 22:14:03 +0100 (Sun, 22 Feb 2009)
New Revision: 2216

Modified:
   trunk/src/application.c
Log:
Added a default handler for GtkLinkButton's.

Modified: trunk/src/application.c
===================================================================
--- trunk/src/application.c	2009-02-22 19:10:44 UTC (rev 2215)
+++ trunk/src/application.c	2009-02-22 21:14:03 UTC (rev 2216)
@@ -505,6 +505,52 @@
 	exit(0);
 }
 
+#if GTK_CHECK_VERSION(2,10,0)
+/* Default handler for GtkLinkButton's -copied almost verbatim from Bond2 */
+static void runuri(GtkLinkButton *button, const gchar *link, gpointer user_data)
+{
+#ifdef WIN32
+#warning This is untested
+	gchar* argv[]= {
+		getenv("ComSpec"),
+		"/c",
+		"start",
+		"uri click", /* start needs explicit title incase link has spaces or quotes */
+		(gchar*)link,
+		NULL
+	};
+#else
+	gchar *argv[]= {
+		"gnome-open", /* this feels like cheating! */
+		(gchar *) link,
+		NULL
+		};
+#endif
+	GError *error = NULL;
+	gint status = 0;
+	gboolean res;
+
+	res = g_spawn_sync(
+		NULL /*PWD*/,
+		argv,
+		NULL /*envp*/,
+		G_SPAWN_SEARCH_PATH, /*flags*/
+		NULL, /*setup_func*/
+		NULL, /*user data for setup*/
+		NULL,
+		NULL, /* stdin/out/error */
+		&status,
+		&error);
+
+	if(!res)
+	{
+		g_error("%s: %s\n", g_quark_to_string(error->domain), error->message);
+		g_error_free(error);
+		return ;
+	}
+}
+#endif
+
 int
 main(int argc, char **argv)
 {
@@ -561,6 +607,10 @@
 
 	rs_plugin_manager_load_all_plugins();
 
+#if GTK_CHECK_VERSION(2,10,0)
+	gtk_link_button_set_uri_hook(runuri,NULL,NULL);
+#endif
+
 	if (do_test)
 		test();
 	else




More information about the Rawstudio-commit mailing list