Add News Aggregator preference

The program set here is called if the user clicks on the news feed
icon, with the address of the current website as argument.

For example liferea-add-feed works like that.
This commit is contained in:
Christian Dywan 2009-04-14 19:44:48 +02:00
parent 5d360b065b
commit a9863cfb40
4 changed files with 62 additions and 7 deletions

View file

@ -85,6 +85,7 @@ struct _MidoriBrowser
gboolean show_statusbar;
gboolean progress_in_location;
gboolean remember_last_visited_pages;
gchar* news_aggregator;
};
#if HAVE_HILDON
@ -303,7 +304,8 @@ _midori_browser_update_interface (MidoriBrowser* browser)
katze_throbber_set_animated (KATZE_THROBBER (browser->throbber), loading);
action = _action_by_name (browser, "Location");
if (g_object_get_data (G_OBJECT (view), "news-feeds"))
if (browser->news_aggregator && *browser->news_aggregator
&& g_object_get_data (G_OBJECT (view), "news-feeds"))
midori_location_action_set_secondary_icon (
MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
else
@ -2573,9 +2575,8 @@ _action_location_secondary_icon_released (GtkAction* action,
if ((view = midori_browser_get_current_tab (browser)))
{
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
/* FIXME: Support a user chosen feed reader */
if (1)
sokoke_spawn_program ("liferea-add-feed", uri);
if (browser->news_aggregator && *browser->news_aggregator)
sokoke_spawn_program (browser->news_aggregator, uri);
}
}
@ -4309,6 +4310,8 @@ midori_browser_finalize (GObject* object)
katze_object_assign (browser->net, NULL);
katze_assign (browser->news_aggregator, NULL);
G_OBJECT_CLASS (midori_browser_parent_class)->finalize (object);
}
@ -4434,6 +4437,8 @@ _midori_browser_update_settings (MidoriBrowser* browser)
gint default_width, default_height;
KatzeItem* item;
g_free (browser->news_aggregator);
g_object_get (browser->settings,
"remember-last-window-size", &remember_last_window_size,
"last-window-width", &last_window_width,
@ -4455,6 +4460,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
"close-buttons-on-tabs", &close_buttons_on_tabs,
"progress-in-location", &browser->progress_in_location,
"remember-last-visited-pages", &browser->remember_last_visited_pages,
"news-aggregator", &browser->news_aggregator,
NULL);
screen = gtk_window_get_screen (GTK_WINDOW (browser));
@ -4546,6 +4552,10 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
browser->progress_in_location = g_value_get_boolean (&value);
else if (name == g_intern_string ("remember-last-visited-pages"))
browser->remember_last_visited_pages = g_value_get_boolean (&value);
else if (name == g_intern_string ("news-aggregator"))
{
katze_assign (browser->news_aggregator, g_value_dup_string (&value));
}
else if (!g_object_class_find_property (G_OBJECT_GET_CLASS (web_settings),
name))
g_warning (_("Unexpected setting '%s'"), name);

View file

@ -421,7 +421,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
button = katze_property_proxy (settings, "show-crash-dialog", NULL);
SPANNED_ADD (button, 0, 2, 2, 3);
FRAME_NEW (_("Transfers"));
TABLE_NEW (3, 2);
TABLE_NEW (4, 2);
#if WEBKIT_CHECK_VERSION (1, 1, 3)
label = katze_property_label (settings, "download-folder");
INDENTED_ADD (label, 0, 1, 0, 1);
@ -456,6 +456,20 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (proxy_download_manager_icon_cb), button);
FILLED_ADD (hbox, 1, 2, 2, 3);
label = katze_property_label (settings, "news-aggregator");
INDENTED_ADD (label, 0, 1, 3, 4);
hbox = gtk_hbox_new (FALSE, 4);
button = gtk_image_new ();
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (button),
GTK_ICON_SIZE_MENU, &icon_width, &icon_height);
gtk_widget_set_size_request (button, icon_width, icon_height);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 4);
entry = katze_property_proxy (settings, "news-aggregator", NULL);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
proxy_download_manager_icon_cb (entry, NULL, GTK_IMAGE (button));
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (proxy_download_manager_icon_cb), button);
FILLED_ADD (hbox, 1, 2, 3, 4);
/* Page "Appearance" */
PAGE_NEW (GTK_STOCK_SELECT_FONT, _("Appearance"));

View file

@ -63,6 +63,7 @@ struct _MidoriView
/* KatzeArray* news_feeds; */
gchar* download_manager;
gchar* news_aggregator;
gboolean middle_click_opens_selection;
gboolean open_tabs_in_the_background;
gboolean close_buttons_on_tabs;
@ -664,8 +665,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);
/* FIXME: Do this conditional on whether there's a custom feed reader */
if (1)
if (view->news_aggregator && *view->news_aggregator)
{
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
gchar* value = sokoke_js_script_eval (js_context,
@ -1359,6 +1359,7 @@ midori_view_init (MidoriView* view)
view->item = NULL;
view->download_manager = NULL;
view->news_aggregator = NULL;
view->web_view = NULL;
/* Adjustments are not created automatically */
@ -1387,6 +1388,7 @@ midori_view_finalize (GObject* object)
katze_object_assign (view->item, NULL);
katze_assign (view->download_manager, NULL);
katze_assign (view->news_aggregator, NULL);
katze_object_assign (view->net, NULL);
@ -1509,6 +1511,7 @@ _midori_view_update_settings (MidoriView* view)
g_object_get (view->settings,
"download-manager", &view->download_manager,
"news-aggregator", &view->news_aggregator,
"zoom-text-and-images", &zoom_text_and_images,
"close-buttons-on-tabs", &view->close_buttons_on_tabs,
"open-new-pages-in", &view->open_new_pages_in,
@ -1538,6 +1541,10 @@ midori_view_settings_notify_cb (MidoriWebSettings* settings,
{
katze_assign (view->download_manager, g_value_dup_string (&value));
}
else if (name == g_intern_string ("news-aggregator"))
{
katze_assign (view->news_aggregator, g_value_dup_string (&value));
}
else if (name == g_intern_string ("zoom-text-and-images"))
{
if (view->web_view)

View file

@ -51,6 +51,7 @@ struct _MidoriWebSettings
gchar* download_folder;
gchar* download_manager;
gchar* text_editor;
gchar* news_aggregator;
gchar* location_entry_search;
MidoriPreferredEncoding preferred_encoding;
@ -119,6 +120,7 @@ enum
PROP_DOWNLOAD_FOLDER,
PROP_DOWNLOAD_MANAGER,
PROP_TEXT_EDITOR,
PROP_NEWS_AGGREGATOR,
PROP_LOCATION_ENTRY_SEARCH,
PROP_PREFERRED_ENCODING,
@ -580,6 +582,22 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
NULL,
flags));
/**
* MidoriWebSettings:news-aggregator:
*
* An external news aggregator.
*
* Since: 0.1.6
*/
g_object_class_install_property (gobject_class,
PROP_NEWS_AGGREGATOR,
g_param_spec_string (
"news-aggregator",
_("News Aggregator"),
_("An external news aggregator"),
NULL,
flags));
g_object_class_install_property (gobject_class,
PROP_LOCATION_ENTRY_SEARCH,
g_param_spec_string (
@ -1046,6 +1064,9 @@ midori_web_settings_set_property (GObject* object,
case PROP_TEXT_EDITOR:
katze_assign (web_settings->text_editor, g_value_dup_string (value));
break;
case PROP_NEWS_AGGREGATOR:
katze_assign (web_settings->news_aggregator, g_value_dup_string (value));
break;
case PROP_LOCATION_ENTRY_SEARCH:
katze_assign (web_settings->location_entry_search, g_value_dup_string (value));
break;
@ -1239,6 +1260,9 @@ midori_web_settings_get_property (GObject* object,
case PROP_TEXT_EDITOR:
g_value_set_string (value, web_settings->text_editor);
break;
case PROP_NEWS_AGGREGATOR:
g_value_set_string (value, web_settings->news_aggregator);
break;
case PROP_LOCATION_ENTRY_SEARCH:
g_value_set_string (value, web_settings->location_entry_search);
break;