--- raeddit-02.c 2009-09-01 20:19:07.000000000 -0400 +++ raeddit-03.c 2009-09-01 20:22:00.000000000 -0400 @@ -3,10 +3,11 @@ compile with: - gcc `pkg-config --cflags --libs glib-2.0 hildon-1 json-glib-1.0 libcurl dbus-glib-1` raeddit-02.c greddit.c -o raeddit-02 + gcc `pkg-config --cflags --libs glib-2.0 hildon-1 json-glib-1.0 libcurl dbus-glib-1` raeddit-03.c greddit.c -o raeddit-03 */ #include #include +#include #include #include #include @@ -28,6 +29,45 @@ gtk_widget_destroy (GTK_WIDGET (note)); } +static void +launch_browser (char *url) +{ + DBusGConnection *connection; + GError *error = NULL; + + DBusGProxy *proxy; + + connection = dbus_g_bus_get (DBUS_BUS_SESSION, + &error); + if (connection == NULL) + { + show_message (error->message); + 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"); + + error = NULL; + if (!dbus_g_proxy_call (proxy, "load_url", &error, + G_TYPE_STRING, url, + G_TYPE_INVALID, + G_TYPE_INVALID)) + { + show_message (error->message); + g_error_free (error); + } +} + +static void +visit_site (gpointer button, gpointer data) +{ + launch_browser ((char *) data); +} + int main(int argc, char **argv) { @@ -64,6 +104,8 @@ HILDON_BUTTON_ARRANGEMENT_VERTICAL, title, subtitle); + g_signal_connect (button, "clicked", G_CALLBACK (visit_site), post->url); + gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0); g_free (title0);