From 74457cfd753a6e466ce0348bb40165759c5248e2 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Fri, 14 Aug 2009 23:28:18 +0200 Subject: [PATCH] Always show news feed icon, and show URI if no aggregator was specified --- midori/midori-browser.c | 18 ++++++++++++++++-- midori/midori-view.c | 8 +++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index fd2dbca2..56736771 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -3227,8 +3227,22 @@ _action_location_secondary_icon_released (GtkAction* action, const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view)); if (gtk_window_get_focus (GTK_WINDOW (browser)) == widget) _action_location_submit_uri (action, uri, FALSE, browser); - else if (g_object_get_data (G_OBJECT (view), "news-feeds")) - sokoke_spawn_program (browser->news_aggregator, uri, TRUE); + else if ((uri = g_object_get_data (G_OBJECT (view), "news-feeds"))) + { + if (browser->news_aggregator && *browser->news_aggregator) + sokoke_spawn_program (browser->news_aggregator, uri, TRUE); + else + { + GtkWidget* dialog = gtk_message_dialog_new ( + GTK_WINDOW (browser), 0, GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, "%s", _("New feed")); + gtk_message_dialog_format_secondary_text ( + GTK_MESSAGE_DIALOG (dialog), "%s", uri); + gtk_widget_show (dialog); + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (gtk_widget_destroy), dialog); + } + } else _action_location_submit_uri (action, uri, FALSE, browser); } diff --git a/midori/midori-view.c b/midori/midori-view.c index 812a6cd1..f7b2248e 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -847,7 +847,7 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view, g_object_notify (G_OBJECT (view), "progress"); midori_view_update_load_status (view, MIDORI_LOAD_FINISHED); - if (view->news_aggregator && *view->news_aggregator) + if (1) { JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); /* This snippet joins the available news feeds into a string like this: @@ -861,6 +861,7 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view, "feeds (document.getElementsByTagName ('link'))", NULL); gchar** items = g_strsplit (value, ",", 0); guint i = 0; + gchar* default_uri = NULL; katze_array_clear (view->news_feeds); if (items != NULL) @@ -873,12 +874,13 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view, NULL); katze_array_add_item (view->news_feeds, item); g_object_unref (item); + if (!default_uri) + default_uri = g_strdup (parts ? *parts : NULL); g_strfreev (parts); i++; } g_strfreev (items); - g_object_set_data (G_OBJECT (view), "news-feeds", - value && *value ? (void*)1 : (void*)0); + g_object_set_data_full (G_OBJECT (view), "news-feeds", default_uri, g_free); g_free (value); /* Ensure load-status is notified again, whether it changed or not */ g_object_notify (G_OBJECT (view), "load-status"); -- 2.39.5