Skip to content

Commit

Permalink
Move loadItemLink property to feed properties. Also fixes #1328
Browse files Browse the repository at this point in the history
  • Loading branch information
lwindolf committed Jan 2, 2024
1 parent d8f8ff9 commit 1156646
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 40 deletions.
11 changes: 0 additions & 11 deletions src/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/feed.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/feed.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
5 changes: 2 additions & 3 deletions src/itemlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand All @@ -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 {
Expand Down
6 changes: 0 additions & 6 deletions src/newsbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -73,7 +72,6 @@ newsbin_export (nodePtr node, xmlNodePtr xml, gboolean trusted)
}
}


static void
newsbin_remove (nodePtr node)
{
Expand All @@ -94,7 +92,6 @@ newsbin_render (nodePtr node)
return output;
}


static void
on_newsbin_common_btn_clicked (GtkButton *button, gpointer user_data)
{
Expand Down Expand Up @@ -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)
{
Expand Down
3 changes: 0 additions & 3 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
29 changes: 12 additions & 17 deletions src/ui/subscription_dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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"))) &&
Expand All @@ -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;
Expand Down Expand Up @@ -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")));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1156646

Please sign in to comment.