diff options
-rw-r--r-- | src/app.c | 16 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 7 | ||||
-rw-r--r-- | src/ui/documentwidget.h | 1 | ||||
-rw-r--r-- | src/ui/util.c | 27 |
4 files changed, 34 insertions, 17 deletions
@@ -912,6 +912,12 @@ static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) { | |||
912 | return iTrue; | 912 | return iTrue; |
913 | } | 913 | } |
914 | if (equal_Command(cmd, "feedcfg.accept")) { | 914 | if (equal_Command(cmd, "feedcfg.accept")) { |
915 | iString *feedTitle = | ||
916 | collect_String(copy_String(text_InputWidget(findChild_Widget(dlg, "feedcfg.title")))); | ||
917 | trim_String(feedTitle); | ||
918 | if (isEmpty_String(feedTitle)) { | ||
919 | return iTrue; | ||
920 | } | ||
915 | int id = argLabel_Command(cmd, "bmid"); | 921 | int id = argLabel_Command(cmd, "bmid"); |
916 | const iBool headings = isSelected_Widget(findChild_Widget(dlg, "feedcfg.type.headings")); | 922 | const iBool headings = isSelected_Widget(findChild_Widget(dlg, "feedcfg.type.headings")); |
917 | const iString *tags = collectNewFormat_String("subscribed%s", headings ? " headings" : ""); | 923 | const iString *tags = collectNewFormat_String("subscribed%s", headings ? " headings" : ""); |
@@ -920,7 +926,7 @@ static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) { | |||
920 | const iString *url = url_DocumentWidget(document_App()); | 926 | const iString *url = url_DocumentWidget(document_App()); |
921 | add_Bookmarks(d->bookmarks, | 927 | add_Bookmarks(d->bookmarks, |
922 | url, | 928 | url, |
923 | bookmarkTitle_DocumentWidget(document_App()), | 929 | feedTitle, |
924 | tags, | 930 | tags, |
925 | siteIcon_GmDocument(document_DocumentWidget(document_App()))); | 931 | siteIcon_GmDocument(document_DocumentWidget(document_App()))); |
926 | if (numSubs == 0) { | 932 | if (numSubs == 0) { |
@@ -931,6 +937,7 @@ static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) { | |||
931 | else { | 937 | else { |
932 | iBookmark *bm = get_Bookmarks(d->bookmarks, id); | 938 | iBookmark *bm = get_Bookmarks(d->bookmarks, id); |
933 | if (bm) { | 939 | if (bm) { |
940 | set_String(&bm->title, feedTitle); | ||
934 | set_String(&bm->tags, tags); | 941 | set_String(&bm->tags, tags); |
935 | } | 942 | } |
936 | } | 943 | } |
@@ -1288,11 +1295,8 @@ iBool handleCommand_App(const char *cmd) { | |||
1288 | uint32_t id = findUrl_Bookmarks(d->bookmarks, url); | 1295 | uint32_t id = findUrl_Bookmarks(d->bookmarks, url); |
1289 | const iBookmark *bm = id ? get_Bookmarks(d->bookmarks, id) : NULL; | 1296 | const iBookmark *bm = id ? get_Bookmarks(d->bookmarks, id) : NULL; |
1290 | iWidget * dlg = makeFeedSettings_Widget(id); | 1297 | iWidget * dlg = makeFeedSettings_Widget(id); |
1291 | setText_LabelWidget(findChild_Widget(dlg, "feedcfg.title"), | 1298 | setText_InputWidget(findChild_Widget(dlg, "feedcfg.title"), |
1292 | collectNewFormat_String( | 1299 | bm ? &bm->title : feedTitle_DocumentWidget(document_App())); |
1293 | uiHeading_ColorEscape "%s", | ||
1294 | bm ? cstr_String(&bm->title) | ||
1295 | : cstr_String(bookmarkTitle_DocumentWidget(document_App())))); | ||
1296 | setFlags_Widget(findChild_Widget(dlg, | 1300 | setFlags_Widget(findChild_Widget(dlg, |
1297 | hasTag_Bookmark(bm, "headings") ? "feedcfg.type.headings" | 1301 | hasTag_Bookmark(bm, "headings") ? "feedcfg.type.headings" |
1298 | : "feedcfg.type.gemini"), | 1302 | : "feedcfg.type.gemini"), |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 96440feb..3f952411 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -3021,6 +3021,13 @@ const iGmDocument *document_DocumentWidget(const iDocumentWidget *d) { | |||
3021 | return d->doc; | 3021 | return d->doc; |
3022 | } | 3022 | } |
3023 | 3023 | ||
3024 | const iString *feedTitle_DocumentWidget(const iDocumentWidget *d) { | ||
3025 | if (!isEmpty_String(title_GmDocument(d->doc))) { | ||
3026 | return title_GmDocument(d->doc); | ||
3027 | } | ||
3028 | return bookmarkTitle_DocumentWidget(d); | ||
3029 | } | ||
3030 | |||
3024 | const iString *bookmarkTitle_DocumentWidget(const iDocumentWidget *d) { | 3031 | const iString *bookmarkTitle_DocumentWidget(const iDocumentWidget *d) { |
3025 | iStringArray *title = iClob(new_StringArray()); | 3032 | iStringArray *title = iClob(new_StringArray()); |
3026 | if (!isEmpty_String(title_GmDocument(d->doc))) { | 3033 | if (!isEmpty_String(title_GmDocument(d->doc))) { |
diff --git a/src/ui/documentwidget.h b/src/ui/documentwidget.h index 5a3125af..55c0a6ed 100644 --- a/src/ui/documentwidget.h +++ b/src/ui/documentwidget.h | |||
@@ -41,6 +41,7 @@ const iString * url_DocumentWidget (const iDocumentWidget *); | |||
41 | iBool isRequestOngoing_DocumentWidget (const iDocumentWidget *); | 41 | iBool isRequestOngoing_DocumentWidget (const iDocumentWidget *); |
42 | const iGmDocument * document_DocumentWidget (const iDocumentWidget *); | 42 | const iGmDocument * document_DocumentWidget (const iDocumentWidget *); |
43 | const iString * bookmarkTitle_DocumentWidget (const iDocumentWidget *); | 43 | const iString * bookmarkTitle_DocumentWidget (const iDocumentWidget *); |
44 | const iString * feedTitle_DocumentWidget (const iDocumentWidget *); | ||
44 | 45 | ||
45 | void setUrl_DocumentWidget (iDocumentWidget *, const iString *url); | 46 | void setUrl_DocumentWidget (iDocumentWidget *, const iString *url); |
46 | void setUrlFromCache_DocumentWidget (iDocumentWidget *, const iString *url, iBool isFromCache); | 47 | void setUrlFromCache_DocumentWidget (iDocumentWidget *, const iString *url, iBool isFromCache); |
diff --git a/src/ui/util.c b/src/ui/util.c index d5bddda9..d9997004 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1249,7 +1249,9 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) { | |||
1249 | iWidget *dlg = makeSheet_Widget("feedcfg"); | 1249 | iWidget *dlg = makeSheet_Widget("feedcfg"); |
1250 | setId_Widget(addChildFlags_Widget( | 1250 | setId_Widget(addChildFlags_Widget( |
1251 | dlg, | 1251 | dlg, |
1252 | iClob(new_LabelWidget(uiHeading_ColorEscape "FEED SETTINGS", NULL)), | 1252 | iClob(new_LabelWidget(bookmarkId ? uiHeading_ColorEscape "FEED SETTINGS" |
1253 | : uiHeading_ColorEscape "SUBSCRIBE TO PAGE", | ||
1254 | NULL)), | ||
1253 | frameless_WidgetFlag), | 1255 | frameless_WidgetFlag), |
1254 | "feedcfg.heading"); | 1256 | "feedcfg.heading"); |
1255 | iWidget *page = new_Widget(); | 1257 | iWidget *page = new_Widget(); |
@@ -1259,27 +1261,30 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) { | |||
1259 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | 1261 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); |
1260 | iWidget *values = addChildFlags_Widget( | 1262 | iWidget *values = addChildFlags_Widget( |
1261 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | 1263 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); |
1262 | addChild_Widget(headings, iClob(makeHeading_Widget("Feed title:"))); | 1264 | addChild_Widget(headings, iClob(makeHeading_Widget("Title:"))); |
1263 | setId_Widget( | 1265 | iInputWidget *input = new_InputWidget(0); |
1264 | addChildFlags_Widget(values, iClob(new_LabelWidget("", NULL)), frameless_WidgetFlag), | 1266 | setId_Widget(addChild_Widget(values, iClob(input)), "feedcfg.title"); |
1265 | "feedcfg.title"); | ||
1266 | addChild_Widget(headings, iClob(makeHeading_Widget("Entry type:"))); | 1267 | addChild_Widget(headings, iClob(makeHeading_Widget("Entry type:"))); |
1267 | iWidget *types = new_Widget(); { | 1268 | iWidget *types = new_Widget(); { |
1268 | addRadioButton_(types, "feedcfg.type.gemini", "YYYY-MM-DD", "feedcfg.type arg:0"); | 1269 | addRadioButton_(types, "feedcfg.type.gemini", "YYYY-MM-DD Links", "feedcfg.type arg:0"); |
1269 | addRadioButton_(types, "feedcfg.type.headings", "New Headings", "feedcfg.type arg:1"); | 1270 | addRadioButton_(types, "feedcfg.type.headings", "New Headings", "feedcfg.type arg:1"); |
1270 | } | 1271 | } |
1271 | addChildFlags_Widget(values, iClob(types), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | 1272 | addChildFlags_Widget(values, iClob(types), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); |
1272 | iWidget *div = new_Widget(); { | 1273 | iWidget *div = new_Widget(); { |
1273 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 1274 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); |
1274 | addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); | 1275 | addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); |
1275 | setId_Widget(addChild_Widget( | 1276 | setId_Widget(addChild_Widget(div, |
1276 | div, | 1277 | iClob(newKeyMods_LabelWidget( |
1277 | iClob(newKeyMods_LabelWidget( | 1278 | bookmarkId ? uiTextCaution_ColorEscape "Save Settings" |
1278 | uiTextCaution_ColorEscape "Save Settings", SDLK_RETURN, KMOD_PRIMARY, | 1279 | : uiTextCaution_ColorEscape "Subscribe", |
1279 | format_CStr("feedcfg.accept bmid:%d", bookmarkId)))), | 1280 | SDLK_RETURN, |
1281 | KMOD_PRIMARY, | ||
1282 | format_CStr("feedcfg.accept bmid:%d", bookmarkId)))), | ||
1280 | "feedcfg.save"); | 1283 | "feedcfg.save"); |
1281 | } | 1284 | } |
1282 | addChild_Widget(dlg, iClob(div)); | 1285 | addChild_Widget(dlg, iClob(div)); |
1286 | arrange_Widget(dlg); | ||
1287 | as_Widget(input)->rect.size.x = 100 * gap_UI - headings->rect.size.x; | ||
1283 | addChild_Widget(get_Window()->root, iClob(dlg)); | 1288 | addChild_Widget(get_Window()->root, iClob(dlg)); |
1284 | centerSheet_Widget(dlg); | 1289 | centerSheet_Widget(dlg); |
1285 | return dlg; | 1290 | return dlg; |