diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-10 08:07:56 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-10 08:07:56 +0300 |
commit | 2acabec65b8af9a87a822c2171fdcce2fb4dfec7 (patch) | |
tree | 3aeb3f7d9ffbc34d158e28b0bbe353b79be8f823 /src/ui/util.c | |
parent | aeaf46c5ac708bc225ea4095b7ce8fc607c74867 (diff) |
Feeds: Added option to ignore web links
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index 0e079efb..ab799a36 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -2782,27 +2782,27 @@ static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) { | |||
2782 | } | 2782 | } |
2783 | int id = argLabel_Command(cmd, "bmid"); | 2783 | int id = argLabel_Command(cmd, "bmid"); |
2784 | const iBool headings = isSelected_Widget(findChild_Widget(dlg, "feedcfg.type.headings")); | 2784 | const iBool headings = isSelected_Widget(findChild_Widget(dlg, "feedcfg.type.headings")); |
2785 | const iString *tags = collectNewFormat_String("subscribed%s", headings ? " headings" : ""); | 2785 | const iBool ignoreWeb = isSelected_Widget(findChild_Widget(dlg, "feedcfg.ignoreweb")); |
2786 | if (!id) { | 2786 | if (!id) { |
2787 | const size_t numSubs = numSubscribed_Feeds(); | 2787 | const size_t numSubs = numSubscribed_Feeds(); |
2788 | const iString *url = url_DocumentWidget(document_App()); | 2788 | const iString *url = url_DocumentWidget(document_App()); |
2789 | add_Bookmarks(bookmarks_App(), | 2789 | id = add_Bookmarks(bookmarks_App(), |
2790 | url, | 2790 | url, |
2791 | feedTitle, | 2791 | feedTitle, |
2792 | tags, | 2792 | NULL, |
2793 | siteIcon_GmDocument(document_DocumentWidget(document_App()))); | 2793 | siteIcon_GmDocument(document_DocumentWidget(document_App()))); |
2794 | if (numSubs == 0) { | 2794 | if (numSubs == 0) { |
2795 | /* Auto-refresh after first addition. */ | 2795 | /* Auto-refresh after first addition. */ |
2796 | /* TODO: Also when settings changed? */ | ||
2796 | postCommand_App("feeds.refresh"); | 2797 | postCommand_App("feeds.refresh"); |
2797 | } | 2798 | } |
2798 | } | 2799 | } |
2799 | else { | 2800 | iBookmark *bm = get_Bookmarks(bookmarks_App(), id); |
2800 | iBookmark *bm = get_Bookmarks(bookmarks_App(), id); | 2801 | iAssert(bm); |
2801 | if (bm) { | 2802 | set_String(&bm->title, feedTitle); |
2802 | set_String(&bm->title, feedTitle); | 2803 | addOrRemoveTag_Bookmark(bm, subscribed_BookmarkTag, iTrue); |
2803 | set_String(&bm->tags, tags); | 2804 | addOrRemoveTag_Bookmark(bm, headings_BookmarkTag, headings); |
2804 | } | 2805 | addOrRemoveTag_Bookmark(bm, ignoreWeb_BookmarkTag, ignoreWeb); |
2805 | } | ||
2806 | postCommand_App("bookmarks.changed"); | 2806 | postCommand_App("bookmarks.changed"); |
2807 | setupSheetTransition_Mobile(dlg, iFalse); | 2807 | setupSheetTransition_Mobile(dlg, iFalse); |
2808 | destroy_Widget(dlg); | 2808 | destroy_Widget(dlg); |
@@ -2831,6 +2831,7 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) { | |||
2831 | { format_CStr("title id:feedcfg.heading text:%s", headingText) }, | 2831 | { format_CStr("title id:feedcfg.heading text:%s", headingText) }, |
2832 | { "input id:feedcfg.title text:${dlg.feed.title}" }, | 2832 | { "input id:feedcfg.title text:${dlg.feed.title}" }, |
2833 | { "radio id:dlg.feed.entrytype", 0, 0, (const void *) typeItems }, | 2833 | { "radio id:dlg.feed.entrytype", 0, 0, (const void *) typeItems }, |
2834 | { "toggle id:feedcfg.ignoreweb text:${dlg.feed.ignoreweb}" }, | ||
2834 | { NULL } | 2835 | { NULL } |
2835 | }, actions, iElemCount(actions)); | 2836 | }, actions, iElemCount(actions)); |
2836 | } | 2837 | } |
@@ -2849,6 +2850,8 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) { | |||
2849 | addRadioButton_(types, "feedcfg.type.headings", "${dlg.feed.type.headings}", "feedcfg.type arg:1"); | 2850 | addRadioButton_(types, "feedcfg.type.headings", "${dlg.feed.type.headings}", "feedcfg.type arg:1"); |
2850 | } | 2851 | } |
2851 | addChildFlags_Widget(values, iClob(types), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | 2852 | addChildFlags_Widget(values, iClob(types), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); |
2853 | addChild_Widget(headings, iClob(makeHeading_Widget("${dlg.feed.ignoreweb}"))); | ||
2854 | addChild_Widget(values, iClob(makeToggle_Widget("feedcfg.ignoreweb"))); | ||
2852 | iWidget *buttons = | 2855 | iWidget *buttons = |
2853 | addChild_Widget(dlg, iClob(makeDialogButtons_Widget(actions, iElemCount(actions)))); | 2856 | addChild_Widget(dlg, iClob(makeDialogButtons_Widget(actions, iElemCount(actions)))); |
2854 | setId_Widget(child_Widget(buttons, childCount_Widget(buttons) - 1), "feedcfg.save"); | 2857 | setId_Widget(child_Widget(buttons, childCount_Widget(buttons) - 1), "feedcfg.save"); |
@@ -2867,6 +2870,8 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) { | |||
2867 | : "feedcfg.type.gemini"), | 2870 | : "feedcfg.type.gemini"), |
2868 | selected_WidgetFlag, | 2871 | selected_WidgetFlag, |
2869 | iTrue); | 2872 | iTrue); |
2873 | setToggle_Widget(findChild_Widget(dlg, "feedcfg.ignoreweb"), | ||
2874 | hasTag_Bookmark(bm, ignoreWeb_BookmarkTag)); | ||
2870 | setCommandHandler_Widget(dlg, handleFeedSettingCommands_); | 2875 | setCommandHandler_Widget(dlg, handleFeedSettingCommands_); |
2871 | } | 2876 | } |
2872 | setupSheetTransition_Mobile(dlg, incoming_TransitionFlag); | 2877 | setupSheetTransition_Mobile(dlg, incoming_TransitionFlag); |