summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-27 13:51:58 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-27 13:51:58 +0300
commita50e235a03884ff2aef9d40bd67e2398b65eddf1 (patch)
treec8c7ace3eaec6cc1d09ed8878bdf0883f8330d35 /src/ui/sidebarwidget.c
parent18dcb69f7a225a9d175c00a956fa132299689a6e (diff)
SidebarWidget: Editing folder names
Use the regular bookmark editor but hide the Special Tags section, and disable all but the Title for now.
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c70
1 files changed, 43 insertions, 27 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 72205912..aaa6e9e9 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -994,22 +994,24 @@ iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *c
994 iAssert(item); /* hover item cannot have been changed */ 994 iAssert(item); /* hover item cannot have been changed */
995 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); 995 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
996 set_String(&bm->title, title); 996 set_String(&bm->title, title);
997 set_String(&bm->url, url); 997 if (!isFolder_Bookmark(bm)) {
998 set_String(&bm->tags, tags); 998 set_String(&bm->url, url);
999 if (isEmpty_String(icon)) { 999 set_String(&bm->tags, tags);
1000 removeTag_Bookmark(bm, userIcon_BookmarkTag); 1000 if (isEmpty_String(icon)) {
1001 bm->icon = 0; 1001 removeTag_Bookmark(bm, userIcon_BookmarkTag);
1002 } 1002 bm->icon = 0;
1003 else { 1003 }
1004 addTagIfMissing_Bookmark(bm, userIcon_BookmarkTag); 1004 else {
1005 bm->icon = first_String(icon); 1005 addTagIfMissing_Bookmark(bm, userIcon_BookmarkTag);
1006 } 1006 bm->icon = first_String(icon);
1007 addOrRemoveTag_Bookmark(bm, homepage_BookmarkTag, 1007 }
1008 isSelected_Widget(findChild_Widget(editor, "bmed.tag.home"))); 1008 addOrRemoveTag_Bookmark(bm, homepage_BookmarkTag,
1009 addOrRemoveTag_Bookmark(bm, remoteSource_BookmarkTag, 1009 isSelected_Widget(findChild_Widget(editor, "bmed.tag.home")));
1010 isSelected_Widget(findChild_Widget(editor, "bmed.tag.remote"))); 1010 addOrRemoveTag_Bookmark(bm, remoteSource_BookmarkTag,
1011 addOrRemoveTag_Bookmark(bm, linkSplit_BookmarkTag, 1011 isSelected_Widget(findChild_Widget(editor, "bmed.tag.remote")));
1012 isSelected_Widget(findChild_Widget(editor, "bmed.tag.linksplit"))); 1012 addOrRemoveTag_Bookmark(bm, linkSplit_BookmarkTag,
1013 isSelected_Widget(findChild_Widget(editor, "bmed.tag.linksplit")));
1014 }
1013 postCommand_App("bookmarks.changed"); 1015 postCommand_App("bookmarks.changed");
1014 } 1016 }
1015 setupSheetTransition_Mobile(editor, iFalse); 1017 setupSheetTransition_Mobile(editor, iFalse);
@@ -1280,18 +1282,32 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
1280 setId_Widget(dlg, format_CStr("bmed.%s", cstr_String(id_Widget(w)))); 1282 setId_Widget(dlg, format_CStr("bmed.%s", cstr_String(id_Widget(w))));
1281 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); 1283 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
1282 setText_InputWidget(findChild_Widget(dlg, "bmed.title"), &bm->title); 1284 setText_InputWidget(findChild_Widget(dlg, "bmed.title"), &bm->title);
1283 setText_InputWidget(findChild_Widget(dlg, "bmed.url"), &bm->url); 1285 iInputWidget *urlInput = findChild_Widget(dlg, "bmed.url");
1284 setText_InputWidget(findChild_Widget(dlg, "bmed.tags"), &bm->tags); 1286 iInputWidget *tagsInput = findChild_Widget(dlg, "bmed.tags");
1285 if (hasTag_Bookmark(bm, userIcon_BookmarkTag)) { 1287 iInputWidget *iconInput = findChild_Widget(dlg, "bmed.icon");
1286 setText_InputWidget(findChild_Widget(dlg, "bmed.icon"), 1288 iWidget * homeTag = findChild_Widget(dlg, "bmed.tag.home");
1287 collect_String(newUnicodeN_String(&bm->icon, 1))); 1289 iWidget * remoteSourceTag = findChild_Widget(dlg, "bmed.tag.remote");
1290 iWidget * linkSplitTag = findChild_Widget(dlg, "bmed.tag.linksplit");
1291 if (!isFolder_Bookmark(bm)) {
1292 setText_InputWidget(urlInput, &bm->url);
1293 setText_InputWidget(tagsInput, &bm->tags);
1294 if (hasTag_Bookmark(bm, userIcon_BookmarkTag)) {
1295 setText_InputWidget(iconInput,
1296 collect_String(newUnicodeN_String(&bm->icon, 1)));
1297 }
1298 setToggle_Widget(homeTag, hasTag_Bookmark(bm, homepage_BookmarkTag));
1299 setToggle_Widget(remoteSourceTag, hasTag_Bookmark(bm, remoteSource_BookmarkTag));
1300 setToggle_Widget(linkSplitTag, hasTag_Bookmark(bm, linkSplit_BookmarkTag));
1301 }
1302 else {
1303 setFlags_Widget(findChild_Widget(dlg, "bmed.special"),
1304 hidden_WidgetFlag | disabled_WidgetFlag,
1305 iTrue);
1306 iAnyObject *notNeeded[] = { urlInput, tagsInput, iconInput, NULL };
1307 iForIndices(i, notNeeded) {
1308 setFlags_Widget(notNeeded[i], disabled_WidgetFlag, iTrue);
1309 }
1288 } 1310 }
1289 setToggle_Widget(findChild_Widget(dlg, "bmed.tag.home"),
1290 hasTag_Bookmark(bm, homepage_BookmarkTag));
1291 setToggle_Widget(findChild_Widget(dlg, "bmed.tag.remote"),
1292 hasTag_Bookmark(bm, remoteSource_BookmarkTag));
1293 setToggle_Widget(findChild_Widget(dlg, "bmed.tag.linksplit"),
1294 hasTag_Bookmark(bm, linkSplit_BookmarkTag));
1295 setCommandHandler_Widget(dlg, handleBookmarkEditorCommands_SidebarWidget_); 1311 setCommandHandler_Widget(dlg, handleBookmarkEditorCommands_SidebarWidget_);
1296 setFocus_Widget(findChild_Widget(dlg, "bmed.title")); 1312 setFocus_Widget(findChild_Widget(dlg, "bmed.title"));
1297 } 1313 }