public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] Make links in about dialog launch browser/email client
@ 2007-12-21 22:17 Jaap A. Haitsma
  2007-12-22  0:16 ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: Jaap A. Haitsma @ 2007-12-21 22:17 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 80 bytes --]

Hi,

Attached patch does this. It now uses the screen of the about dialog

Jaap

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bluez-gnome-clickable.patch --]
[-- Type: text/x-patch; name=bluez-gnome-clickable.patch, Size: 4217 bytes --]

Index: analyzer/dialog.c
===================================================================
RCS file: /cvsroot/bluez/gnome/analyzer/dialog.c,v
retrieving revision 1.20
diff -u -r1.20 dialog.c
--- analyzer/dialog.c	17 Dec 2007 01:41:19 -0000	1.20
+++ analyzer/dialog.c	21 Dec 2007 22:10:38 -0000
@@ -54,11 +54,65 @@
 static void about_url_hook(GtkAboutDialog *dialog,
 					const gchar *url, gpointer data)
 {
+	GError *error = NULL;
+	gboolean ret;
+	char *cmdline;
+	GdkScreen *gscreen;
+	GtkWidget *error_dialog;
+
+	gscreen = gtk_window_get_screen (GTK_WINDOW(dialog));
+
+	cmdline = g_strconcat ("gnome-open ", url, NULL);
+	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == TRUE)
+		return;
+
+	g_error_free (error);
+	error = NULL;
+
+	cmdline = g_strconcat ("xdg-open ", url, NULL);
+	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == FALSE) {
+		error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message); 
+		gtk_dialog_run (GTK_DIALOG (error_dialog));
+		g_error_free (error);
+	}
 }
 
 static void about_email_hook(GtkAboutDialog *dialog,
 					const gchar *email, gpointer data)
 {
+	GError *error = NULL;
+	gboolean ret;
+	char *cmdline;
+	GdkScreen *gscreen;
+	GtkWidget *error_dialog;
+
+	gscreen = gtk_window_get_screen (GTK_WINDOW(dialog));
+
+	cmdline = g_strconcat ("gnome-open mailto:", email, NULL);
+	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == TRUE)
+		return;
+
+	g_error_free (error);
+	error = NULL;
+
+	cmdline = g_strconcat ("xdg-open mailto:", email, NULL);
+	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == FALSE) {
+		error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message); 
+		gtk_dialog_run (GTK_DIALOG (error_dialog));
+		g_error_free (error);
+	}
 }
 
 void show_about_dialog(void)
Index: applet/main.c
===================================================================
RCS file: /cvsroot/bluez/gnome/applet/main.c,v
retrieving revision 1.94
diff -u -r1.94 main.c
--- applet/main.c	19 Dec 2007 01:06:05 -0000	1.94
+++ applet/main.c	21 Dec 2007 22:10:38 -0000
@@ -1510,11 +1510,65 @@
 static void about_url_hook(GtkAboutDialog *dialog,
 					const gchar *url, gpointer data)
 {
+	GError *error = NULL;
+	gboolean ret;
+	char *cmdline;
+	GdkScreen *gscreen;
+	GtkWidget *error_dialog;
+
+	gscreen = gtk_window_get_screen (GTK_WINDOW(dialog));
+
+	cmdline = g_strconcat ("gnome-open ", url, NULL);
+	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == TRUE)
+		return;
+
+	g_error_free (error);
+	error = NULL;
+
+	cmdline = g_strconcat ("xdg-open ", url, NULL);
+	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == FALSE) {
+		error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message); 
+		gtk_dialog_run (GTK_DIALOG (error_dialog));
+		g_error_free (error);
+	}
 }
 
 static void about_email_hook(GtkAboutDialog *dialog,
 					const gchar *email, gpointer data)
 {
+	GError *error = NULL;
+	gboolean ret;
+	char *cmdline;
+	GdkScreen *gscreen;
+	GtkWidget *error_dialog;
+
+	gscreen = gtk_window_get_screen (GTK_WINDOW(dialog));
+
+	cmdline = g_strconcat ("gnome-open mailto:", email, NULL);
+	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == TRUE)
+		return;
+
+	g_error_free (error);
+	error = NULL;
+
+	cmdline = g_strconcat ("xdg-open mailto:", email, NULL);
+	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == FALSE) {
+		error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message); 
+		gtk_dialog_run (GTK_DIALOG (error_dialog));
+		g_error_free (error);
+	}
 }
 
 static void about_callback(GtkWidget *item, gpointer user_data)

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Bluez-devel] [PATCH] Make links in about dialog launch browser/email client
  2007-12-21 22:17 [Bluez-devel] [PATCH] Make links in about dialog launch browser/email client Jaap A. Haitsma
@ 2007-12-22  0:16 ` Marcel Holtmann
  2007-12-22 10:55   ` Jaap A. Haitsma
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2007-12-22  0:16 UTC (permalink / raw)
  To: BlueZ development

Hi Jaap,

> Attached patch does this. It now uses the screen of the about dialog

can't we have a generic do_open function and then call it from both
hooks. From a code perspective it makes it simpler.

Also what is the deal with gnome-open and xdg-open. Wouldn't it be
enough to use only xdg-open. It should be present on all major distros
by now.

Coding style wise, please don't put a space between the function name
and the "(". I know it is unusual for GNOME stuff, but this one follows
the kernel coding style like all bluez-* packages. Also please respect
the 80 characters width rule. Meaning break long functions calls to
multiple lines.

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Bluez-devel] [PATCH] Make links in about dialog launch browser/email client
  2007-12-22  0:16 ` Marcel Holtmann
@ 2007-12-22 10:55   ` Jaap A. Haitsma
  0 siblings, 0 replies; 3+ messages in thread
From: Jaap A. Haitsma @ 2007-12-22 10:55 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

On Dec 22, 2007 1:16 AM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Jaap,
>
> > Attached patch does this. It now uses the screen of the about dialog
>
> can't we have a generic do_open function and then call it from both
> hooks. From a code perspective it makes it simpler.
>
> Also what is the deal with gnome-open and xdg-open. Wouldn't it be
> enough to use only xdg-open. It should be present on all major distros
> by now.
>
> Coding style wise, please don't put a space between the function name
> and the "(". I know it is unusual for GNOME stuff, but this one follows
> the kernel coding style like all bluez-* packages. Also please respect
> the 80 characters width rule. Meaning break long functions calls to
> multiple lines.
>
Marcel,

Thanks for the review. Updated patch attached

Jaap

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bluez-gnome-clickable2.patch --]
[-- Type: text/x-patch; name=bluez-gnome-clickable2.patch, Size: 2837 bytes --]

Index: analyzer/dialog.c
===================================================================
RCS file: /cvsroot/bluez/gnome/analyzer/dialog.c,v
retrieving revision 1.21
diff -u -r1.21 dialog.c
--- analyzer/dialog.c	22 Dec 2007 00:09:15 -0000	1.21
+++ analyzer/dialog.c	22 Dec 2007 10:53:52 -0000
@@ -49,14 +49,45 @@
 	gtk_widget_destroy(dialog);
 }
 
+static void open_url(const char *url, GdkScreen *screen)
+{
+	GError *error = NULL;
+	gboolean ret;
+	char *cmdline;
+	GtkWidget *error_dialog;
+
+	cmdline = g_strconcat("xdg-open ", url, NULL);
+	ret = gdk_spawn_command_line_on_screen(screen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == FALSE) {
+		error_dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, 
+				GTK_MESSAGE_INFO, GTK_BUTTONS_OK, 
+				"Failed to show url %s", error->message); 
+		gtk_dialog_run(GTK_DIALOG (error_dialog));
+		g_error_free(error);
+	}
+}
+
 static void about_url_hook(GtkAboutDialog *dialog,
 					const gchar *url, gpointer data)
 {
+	GdkScreen *gscreen;
+
+	gscreen = gtk_window_get_screen(GTK_WINDOW(dialog));
+	open_url(url, gscreen);
 }
 
 static void about_email_hook(GtkAboutDialog *dialog,
 					const gchar *email, gpointer data)
 {
+	char *url;
+	GdkScreen *gscreen;
+
+	gscreen = gtk_window_get_screen(GTK_WINDOW(dialog));
+	url = g_strconcat ("mailto:", email, NULL);
+	open_url(url, gscreen);
+	g_free (url);
 }
 
 void show_about_dialog(void)
Index: applet/main.c
===================================================================
RCS file: /cvsroot/bluez/gnome/applet/main.c,v
retrieving revision 1.95
diff -u -r1.95 main.c
--- applet/main.c	22 Dec 2007 00:09:15 -0000	1.95
+++ applet/main.c	22 Dec 2007 10:53:52 -0000
@@ -1501,14 +1501,45 @@
 	gtk_widget_destroy(dialog);
 }
 
+static void open_url(const char *url, GdkScreen *screen)
+{
+	GError *error = NULL;
+	gboolean ret;
+	char *cmdline;
+	GtkWidget *error_dialog;
+
+	cmdline = g_strconcat("xdg-open ", url, NULL);
+	ret = gdk_spawn_command_line_on_screen(screen, cmdline, &error);
+	g_free (cmdline);
+
+	if (ret == FALSE) {
+		error_dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, 
+				GTK_MESSAGE_INFO, GTK_BUTTONS_OK, 
+				"Failed to show url %s", error->message); 
+		gtk_dialog_run(GTK_DIALOG (error_dialog));
+		g_error_free(error);
+	}
+}
+
 static void about_url_hook(GtkAboutDialog *dialog,
 					const gchar *url, gpointer data)
 {
+	GdkScreen *gscreen;
+
+	gscreen = gtk_window_get_screen(GTK_WINDOW(dialog));
+	open_url(url, gscreen);
 }
 
 static void about_email_hook(GtkAboutDialog *dialog,
 					const gchar *email, gpointer data)
 {
+	char *url;
+	GdkScreen *gscreen;
+
+	gscreen = gtk_window_get_screen(GTK_WINDOW(dialog));
+	url = g_strconcat ("mailto:", email, NULL);
+	open_url(url, gscreen);
+	g_free (url);
 }
 
 static void about_callback(GtkWidget *item, gpointer user_data)

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-12-22 10:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-21 22:17 [Bluez-devel] [PATCH] Make links in about dialog launch browser/email client Jaap A. Haitsma
2007-12-22  0:16 ` Marcel Holtmann
2007-12-22 10:55   ` Jaap A. Haitsma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox