From 115664641d03f04f6a9eeb88ed1b8e8899f31ac0 Mon Sep 17 00:00:00 2001 From: Lars Windolf Date: Tue, 2 Jan 2024 23:00:46 +0100 Subject: [PATCH] Move loadItemLink property to feed properties. Also fixes #1328 --- src/export.c | 11 ----------- src/feed.c | 8 ++++++++ src/feed.h | 1 + src/itemlist.c | 5 ++--- src/newsbin.c | 6 ------ src/node.h | 3 --- src/ui/subscription_dialog.c | 29 ++++++++++++----------------- 7 files changed, 23 insertions(+), 40 deletions(-) diff --git a/src/export.c b/src/export.c index 486ab9887..5f23786ad 100644 --- a/src/export.c +++ b/src/export.c @@ -91,9 +91,6 @@ export_append_node_tag (nodePtr node, gpointer userdata) if (FALSE == node->sortReversed) xmlNewProp (childNode, BAD_CAST"sortReversed", BAD_CAST"false"); - - if (node->loadItemLink) - xmlNewProp (childNode, BAD_CAST"loadItemLink", BAD_CAST"true"); } /* 2. add node type specific stuff */ @@ -291,14 +288,6 @@ import_parse_outline (xmlNodePtr cur, nodePtr parentNode, gboolean trusted) xmlFree (sortStr); } - /* auto item link loading flag */ - tmp = (gchar *)xmlGetProp (cur, BAD_CAST"loadItemLink"); - if (tmp) { - if (!xmlStrcmp ((xmlChar *)tmp, BAD_CAST"true")) - node->loadItemLink = TRUE; - xmlFree (tmp); - } - /* expansion state */ if (xmlHasProp (cur, BAD_CAST"expanded")) node->expanded = TRUE; diff --git a/src/feed.c b/src/feed.c index d92b51ae3..f1c45fe25 100644 --- a/src/feed.c +++ b/src/feed.c @@ -98,6 +98,11 @@ feed_import (nodePtr node, nodePtr parent, xmlNodePtr xml, gboolean trusted) feed->html5Extract = TRUE; xmlFree (tmp); + tmp = xmlGetProp (xml, BAD_CAST"loadItemLink"); + if (tmp && !xmlStrcmp ((xmlChar *)tmp, BAD_CAST"true")) + feed->loadItemLink = TRUE; + xmlFree (tmp); + title = xmlGetProp (xml, BAD_CAST"title"); if (!title || !xmlStrcmp (title, BAD_CAST"")) { if (title) @@ -145,6 +150,9 @@ feed_export (nodePtr node, xmlNodePtr xml, gboolean trusted) if (feed->html5Extract) xmlNewProp (xml, BAD_CAST"html5Extract", BAD_CAST"true"); + + if (feed->loadItemLink) + xmlNewProp (xml, BAD_CAST"loadItemLink", BAD_CAST"true"); } if (node->subscription) diff --git a/src/feed.h b/src/feed.h index 7aaa7aa81..d98c9fd0d 100644 --- a/src/feed.h +++ b/src/feed.h @@ -61,6 +61,7 @@ typedef struct feed { gboolean markAsRead; /**< if TRUE downloaded items are automatically marked as read */ gboolean html5Extract; /**< if TRUE try to fetch extra content via HTML5 / Google AMP */ gboolean alwaysShowInReduced; /**< for newsbins only, if TRUE always show when using reduced feed list */ + gboolean loadItemLink; /*<< if TRUE do automatically load the item link into the HTML pane */ } *feedPtr; /** diff --git a/src/itemlist.c b/src/itemlist.c index 209e73d5f..6328e3855 100644 --- a/src/itemlist.c +++ b/src/itemlist.c @@ -545,8 +545,7 @@ itemlist_update_item (itemPtr item) void itemlist_selection_changed (itemPtr item) { - - if (0 == itemlist->priv->loading) { + if (0 == itemlist->priv->loading) { /* folder&vfolder postprocessing to remove/filter unselected items no more matching the display rules because they have changed state */ itemlist_check_for_deferred_action (); @@ -563,7 +562,7 @@ itemlist_selection_changed (itemPtr item) item_set_read_state (item, TRUE); itemview_set_mode (ITEMVIEW_SINGLE_ITEM); - if (node->loadItemLink && (link = item_make_link (item))) { + if (IS_FEED(node) && ((feedPtr)node->data)->loadItemLink && (link = item_make_link (item))) { itemview_launch_URL (link, TRUE /* force internal */); g_free (link); } else { diff --git a/src/newsbin.c b/src/newsbin.c index 175a5e92b..e65629e5d 100644 --- a/src/newsbin.c +++ b/src/newsbin.c @@ -61,7 +61,6 @@ newsbin_import (nodePtr node, nodePtr parent, xmlNodePtr cur, gboolean trusted) newsbin_list = g_slist_append(newsbin_list, node); } - static void newsbin_export (nodePtr node, xmlNodePtr xml, gboolean trusted) { @@ -73,7 +72,6 @@ newsbin_export (nodePtr node, xmlNodePtr xml, gboolean trusted) } } - static void newsbin_remove (nodePtr node) { @@ -94,7 +92,6 @@ newsbin_render (nodePtr node) return output; } - static void on_newsbin_common_btn_clicked (GtkButton *button, gpointer user_data) { @@ -150,21 +147,18 @@ ui_newsbin_common (nodePtr node) return TRUE; } - static gboolean ui_newsbin_add (void) { return ui_newsbin_common(NULL); } - static void ui_newsbin_properties (nodePtr node) { ui_newsbin_common(node); } - void on_action_copy_to_newsbin (GSimpleAction *action, GVariant *parameter, gpointer user_data) { diff --git a/src/node.h b/src/node.h index 9d0c32349..6075ccb4e 100644 --- a/src/node.h +++ b/src/node.h @@ -65,9 +65,6 @@ typedef struct node { nodeViewSortType sortColumn; /*<< Node specific item view sort attribute. */ gboolean sortReversed; /*<< Sort in the reverse order? */ - /* rendering behaviour of this node */ - gboolean loadItemLink; /*<< if TRUE do automatically load the item link into the HTML pane */ - /* current state of this node */ gboolean needsUpdate; /*<< if TRUE: the item list has changed and the nodes feed list representation needs to be updated */ gboolean needsRecount; /*<< if TRUE: the number of unread/total items is currently unknown and needs recounting */ diff --git a/src/ui/subscription_dialog.c b/src/ui/subscription_dialog.c index 6068790bb..33447cd32 100644 --- a/src/ui/subscription_dialog.c +++ b/src/ui/subscription_dialog.c @@ -77,14 +77,12 @@ struct _SubscriptionPropDialog { struct _NewSubscriptionDialog { GObject parentInstance; - subscriptionPtr subscription; /** used only for "properties" dialog */ dialogData ui_data; }; struct _SimpleSubscriptionDialog { GObject parentInstance; - subscriptionPtr subscription; /** used only for "properties" dialog */ dialogData ui_data; }; @@ -196,9 +194,6 @@ on_propdialog_response (GtkDialog *dialog, /* "General" */ node_set_title(node, gtk_entry_get_text(GTK_ENTRY(spd->ui_data.feedNameEntry))); - /* Source */ - newSource = ui_subscription_dialog_decode_source(&(spd->ui_data)); - /* Filter handling */ newFilter = gtk_entry_get_text (GTK_ENTRY (liferea_dialog_lookup (spd->ui_data.dialog, "filterEntry"))); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->ui_data.dialog, "filterCheckbox"))) && @@ -215,8 +210,9 @@ on_propdialog_response (GtkDialog *dialog, } } - /* if URL has changed... */ - if (strcmp(newSource, subscription_get_source(subscription))) { + /* "Source" (if URL has changed...) */ + newSource = ui_subscription_dialog_decode_source(&(spd->ui_data)); + if (newSource && !g_str_equal (newSource, subscription_get_source (subscription))) { subscription_set_source(subscription, newSource); subscription_set_discontinued (subscription, FALSE); needsUpdate = TRUE; @@ -258,7 +254,7 @@ on_propdialog_response (GtkDialog *dialog, /* "Advanced" options */ feed->encAutoDownload = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "enclosureDownloadCheck"))); - node->loadItemLink = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "loadItemLinkCheck"))); + feed->loadItemLink = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "loadItemLinkCheck"))); feed->ignoreComments = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "ignoreCommentFeeds"))); feed->markAsRead = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "markAsReadCheck"))); feed->html5Extract = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "html5ExtractCheck"))); @@ -502,7 +498,7 @@ subscription_prop_dialog_load (SubscriptionPropDialog *spd, /* Advanced */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->ui_data.dialog, "enclosureDownloadCheck")), feed->encAutoDownload); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->ui_data.dialog, "loadItemLinkCheck")), node->loadItemLink); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->ui_data.dialog, "loadItemLinkCheck")), feed->loadItemLink); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->ui_data.dialog, "ignoreCommentFeeds")), feed->ignoreComments); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->ui_data.dialog, "markAsReadCheck")), feed->markAsRead); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->ui_data.dialog, "html5ExtractCheck")), feed->html5Extract); @@ -655,13 +651,11 @@ new_subscription_dialog_init (NewSubscriptionDialog *nsd) gtk_widget_show_all (newdialog); } -static NewSubscriptionDialog * -ui_complex_subscription_dialog_new (void) +int +ui_complex_subscription_dialog_cb (gpointer userdata) { - NewSubscriptionDialog *nsd; - - nsd = NEW_SUBSCRIPTION_DIALOG (g_object_new (NEW_SUBSCRIPTION_DIALOG_TYPE, NULL)); - return nsd; + (void) NEW_SUBSCRIPTION_DIALOG (g_object_new (NEW_SUBSCRIPTION_DIALOG_TYPE, NULL)); + return FALSE; } /* simple "New" dialog */ @@ -698,8 +692,9 @@ on_simple_newdialog_response (GtkDialog *dialog, gint response_id, gpointer user g_free (source); } - if (response_id == GTK_RESPONSE_APPLY) /* misused for "Advanced" */ - ui_complex_subscription_dialog_new (); + /* APPLY code misused for "Advanced" */ + if (response_id == GTK_RESPONSE_APPLY) + g_idle_add (ui_complex_subscription_dialog_cb, NULL); g_object_unref (ssd); }