summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-22 22:03:03 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-22 22:03:03 +0200
commit7f7011c021bdeed29963942e3a5dc8f3361f39c4 (patch)
tree9d9f50a5ef71ccf2ce6a14fe1f755126825be46c /src/ui/sidebarwidget.c
parent90443011c98a6dc8340d2c84f1e538c7a98327f2 (diff)
Allow user to set any character as bookmark icon
The custom icons only appear in bookmark and feed lists, though.
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 24ace92a..36aa1235 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -677,12 +677,22 @@ iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *c
677 const iString *title = text_InputWidget(findChild_Widget(editor, "bmed.title")); 677 const iString *title = text_InputWidget(findChild_Widget(editor, "bmed.title"));
678 const iString *url = text_InputWidget(findChild_Widget(editor, "bmed.url")); 678 const iString *url = text_InputWidget(findChild_Widget(editor, "bmed.url"));
679 const iString *tags = text_InputWidget(findChild_Widget(editor, "bmed.tags")); 679 const iString *tags = text_InputWidget(findChild_Widget(editor, "bmed.tags"));
680 const iString *icon = collect_String(trimmed_String(
681 text_InputWidget(findChild_Widget(editor, "bmed.icon"))));
680 const iSidebarItem *item = hoverItem_ListWidget(d->list); 682 const iSidebarItem *item = hoverItem_ListWidget(d->list);
681 iAssert(item); /* hover item cannot have been changed */ 683 iAssert(item); /* hover item cannot have been changed */
682 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); 684 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
683 set_String(&bm->title, title); 685 set_String(&bm->title, title);
684 set_String(&bm->url, url); 686 set_String(&bm->url, url);
685 set_String(&bm->tags, tags); 687 set_String(&bm->tags, tags);
688 if (isEmpty_String(icon)) {
689 removeTag_Bookmark(bm, "usericon");
690 bm->icon = 0;
691 }
692 else if (!hasTag_Bookmark(bm, "usericon")) {
693 addTag_Bookmark(bm, "usericon");
694 bm->icon = first_String(icon);
695 }
686 postCommand_App("bookmarks.changed"); 696 postCommand_App("bookmarks.changed");
687 } 697 }
688 setFlags_Widget(as_Widget(d), disabled_WidgetFlag, iFalse); 698 setFlags_Widget(as_Widget(d), disabled_WidgetFlag, iFalse);
@@ -830,6 +840,10 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
830 setText_InputWidget(findChild_Widget(dlg, "bmed.title"), &bm->title); 840 setText_InputWidget(findChild_Widget(dlg, "bmed.title"), &bm->title);
831 setText_InputWidget(findChild_Widget(dlg, "bmed.url"), &bm->url); 841 setText_InputWidget(findChild_Widget(dlg, "bmed.url"), &bm->url);
832 setText_InputWidget(findChild_Widget(dlg, "bmed.tags"), &bm->tags); 842 setText_InputWidget(findChild_Widget(dlg, "bmed.tags"), &bm->tags);
843 if (hasTag_Bookmark(bm, "usericon")) {
844 setText_InputWidget(findChild_Widget(dlg, "bmed.icon"),
845 collect_String(newUnicodeN_String(&bm->icon, 1)));
846 }
833 setCommandHandler_Widget(dlg, handleBookmarkEditorCommands_SidebarWidget_); 847 setCommandHandler_Widget(dlg, handleBookmarkEditorCommands_SidebarWidget_);
834 setFocus_Widget(findChild_Widget(dlg, "bmed.title")); 848 setFocus_Widget(findChild_Widget(dlg, "bmed.title"));
835 } 849 }