From 7d96e0b0d6db5ecffce8f05837afda2d8aa7cca5 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Mon, 1 Feb 2010 22:29:27 +0100 Subject: [PATCH] Support opening the Maemo browser for URLs --- src/he/he-about-dialog.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/he/he-about-dialog.c b/src/he/he-about-dialog.c index eab055b..4e7f397 100644 --- a/src/he/he-about-dialog.c +++ b/src/he/he-about-dialog.c @@ -39,6 +39,8 @@ #include +#include + #include "he-about-dialog.h" #define HE_ABOUT_DIALOG_GET_PRIVATE(obj) \ @@ -73,6 +75,8 @@ static void he_about_dialog_init (HeAboutDialog * fd); static void he_about_dialog_show (GtkWidget *widget); static void he_about_dialog_destroy (GtkObject *object); +void open_webbrowser(const gchar* url); + static gpointer parent_class = NULL; GType G_GNUC_CONST @@ -214,18 +218,16 @@ void he_about_dialog_response (GtkDialog *dialog, gint response_id, HeAboutDialog* ad) { HeAboutDialogPrivate *priv = HE_ABOUT_DIALOG_GET_PRIVATE (ad); - guint32 now = gtk_get_current_event_time(); - GError* error = NULL; switch (response_id) { case HE_ABOUT_RESPONSE_WEBSITE: - gtk_show_uri(NULL, priv->website_url, now, &error); + open_webbrowser(priv->website_url); break; case HE_ABOUT_RESPONSE_BUGTRACKER: - gtk_show_uri(NULL, priv->bugtracker_url, now, &error); + open_webbrowser(priv->bugtracker_url); break; case HE_ABOUT_RESPONSE_DONATE: - gtk_show_uri(NULL, priv->donate_url, now, &error); + open_webbrowser(priv->donate_url); break; default: /* Dialog closed - do nothing */ @@ -233,6 +235,31 @@ he_about_dialog_response (GtkDialog *dialog, gint response_id, HeAboutDialog* ad } } +void +open_webbrowser(const gchar* url) +{ + DBusGConnection *connection; + GError *error = NULL; + DBusGProxy *proxy; + + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (connection == NULL) { + /* FIXME: Should show error with URL to user */ + g_error_free(error); + return; + } + + proxy = dbus_g_proxy_new_for_name(connection, + "com.nokia.osso_browser", + "/com/nokia/osso_browser/request", + "com.nokia.osso_browser"); + + if (!dbus_g_proxy_call(proxy, "load_url", &error, G_TYPE_STRING, url, + G_TYPE_INVALID, G_TYPE_INVALID)) { + /* FIXME: Should show error with URL to user */ + g_error_free(error); + } +} /* ------------------------------ PUBLIC METHODS ---------------------------- */ -- 2.11.4.GIT