summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 99768b13..a02294dc 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -416,17 +416,12 @@ iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *c
416 const iString *title = text_InputWidget(findChild_Widget(editor, "bmed.title")); 416 const iString *title = text_InputWidget(findChild_Widget(editor, "bmed.title"));
417 const iString *url = text_InputWidget(findChild_Widget(editor, "bmed.url")); 417 const iString *url = text_InputWidget(findChild_Widget(editor, "bmed.url"));
418 const iString *tags = text_InputWidget(findChild_Widget(editor, "bmed.tags")); 418 const iString *tags = text_InputWidget(findChild_Widget(editor, "bmed.tags"));
419 if (!cmp_String(id_Widget(editor), "bmed.create")) { 419 const iSidebarItem *item = hoverItem_SidebarWidget_(d);
420 add_Bookmarks(bookmarks_App(), url, title, tags, 0x1f310); 420 iAssert(item); /* hover item cannot have been changed */
421 } 421 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
422 else { 422 set_String(&bm->title, title);
423 const iSidebarItem *item = hoverItem_SidebarWidget_(d); 423 set_String(&bm->url, url);
424 iAssert(item); /* hover item cannot have been changed */ 424 set_String(&bm->tags, tags);
425 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
426 set_String(&bm->title, title);
427 set_String(&bm->url, url);
428 set_String(&bm->tags, tags);
429 }
430 postCommand_App("bookmarks.changed"); 425 postCommand_App("bookmarks.changed");
431 } 426 }
432 setFlags_Widget(as_Widget(d), disabled_WidgetFlag, iFalse); 427 setFlags_Widget(as_Widget(d), disabled_WidgetFlag, iFalse);
@@ -556,16 +551,10 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
556 else if (equal_Command(cmd, "history.addbookmark")) { 551 else if (equal_Command(cmd, "history.addbookmark")) {
557 const iSidebarItem *item = hoverItem_SidebarWidget_(d); 552 const iSidebarItem *item = hoverItem_SidebarWidget_(d);
558 if (!isEmpty_String(&item->url)) { 553 if (!isEmpty_String(&item->url)) {
559 iWidget *dlg = makeBookmarkEditor_Widget(); 554 makeBookmarkCreation_Widget(
560 setId_Widget(dlg, "bmed.create"); 555 &item->url,
561 setTextCStr_LabelWidget(findChild_Widget(dlg, "bmed.heading"), 556 collect_String(newRange_String(urlHost_String(&item->url))),
562 uiHeading_ColorEscape "ADD BOOKMARK"); 557 0x1f310 /* globe */);
563 iUrl parts;
564 init_Url(&parts, &item->url);
565 setTextCStr_InputWidget(findChild_Widget(dlg, "bmed.title"),
566 cstr_Rangecc(parts.host));
567 setText_InputWidget(findChild_Widget(dlg, "bmed.url"), &item->url);
568 setCommandHandler_Widget(dlg, handleBookmarkEditorCommands_SidebarWidget_);
569 } 558 }
570 } 559 }
571 else if (equal_Command(cmd, "history.clear")) { 560 else if (equal_Command(cmd, "history.clear")) {