summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-20 17:58:12 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-20 17:58:12 +0300
commit648ddbf3d118d28a20027b8c5dd074494c53b90a (patch)
tree26338d050940ba5df559ee966d4e20476e3e71fe /src/ui/sidebarwidget.c
parentde978eb32636804038567dcaaba4a9eebf24dc1c (diff)
SidebarWidget: Creating a bookmark from history
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index f7730394..1fb50f87 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -388,15 +388,23 @@ void setWidth_SidebarWidget(iSidebarWidget *d, int width) {
388} 388}
389 389
390iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *cmd) { 390iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *cmd) {
391 iSidebarWidget *d = findWidget_App("sidebar");
392 if (equal_Command(cmd, "bmed.accept") || equal_Command(cmd, "cancel")) { 391 if (equal_Command(cmd, "bmed.accept") || equal_Command(cmd, "cancel")) {
392 iSidebarWidget *d = findWidget_App("sidebar");
393 if (equal_Command(cmd, "bmed.accept")) { 393 if (equal_Command(cmd, "bmed.accept")) {
394 const iSidebarItem *item = hoverItem_SidebarWidget_(d); 394 const iString *title = text_InputWidget(findChild_Widget(editor, "bmed.title"));
395 iAssert(item); /* hover item cannot have been changed */ 395 const iString *url = text_InputWidget(findChild_Widget(editor, "bmed.url"));
396 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); 396 const iString *tags = text_InputWidget(findChild_Widget(editor, "bmed.tags"));
397 set_String(&bm->title, text_InputWidget(findChild_Widget(editor, "bmed.title"))); 397 if (!cmp_String(id_Widget(editor), "bmed.create")) {
398 set_String(&bm->url, text_InputWidget(findChild_Widget(editor, "bmed.url"))); 398 add_Bookmarks(bookmarks_App(), url, title, tags, 0x1f310);
399 set_String(&bm->tags, text_InputWidget(findChild_Widget(editor, "bmed.tags"))); 399 }
400 else {
401 const iSidebarItem *item = hoverItem_SidebarWidget_(d);
402 iAssert(item); /* hover item cannot have been changed */
403 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
404 set_String(&bm->title, title);
405 set_String(&bm->url, url);
406 set_String(&bm->tags, tags);
407 }
400 postCommand_App("bookmarks.changed"); 408 postCommand_App("bookmarks.changed");
401 } 409 }
402 setFlags_Widget(as_Widget(d), disabled_WidgetFlag, iFalse); 410 setFlags_Widget(as_Widget(d), disabled_WidgetFlag, iFalse);
@@ -526,13 +534,16 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
526 else if (equal_Command(cmd, "history.addbookmark")) { 534 else if (equal_Command(cmd, "history.addbookmark")) {
527 const iSidebarItem *item = hoverItem_SidebarWidget_(d); 535 const iSidebarItem *item = hoverItem_SidebarWidget_(d);
528 if (!isEmpty_String(&item->url)) { 536 if (!isEmpty_String(&item->url)) {
529 /* TODO: Open the bookmark editor dialog. */ 537 iWidget *dlg = makeBookmarkEditor_Widget();
530 /*add_Bookmarks(bookmarks_App(), 538 setId_Widget(dlg, "bmed.create");
531 &item->url, 539 setTextCStr_LabelWidget(findChild_Widget(dlg, "bmed.heading"),
532 urlHost_String(&item->url), 540 uiHeading_ColorEscape "ADD BOOKMARK");
533 collectNew_String(), 541 iUrl parts;
534 0x1f310); 542 init_Url(&parts, &item->url);
535 postCommand_App("bookmarks.changed");*/ 543 setTextCStr_InputWidget(findChild_Widget(dlg, "bmed.title"),
544 cstr_Rangecc(parts.host));
545 setText_InputWidget(findChild_Widget(dlg, "bmed.url"), &item->url);
546 setCommandHandler_Widget(dlg, handleBookmarkEditorCommands_SidebarWidget_);
536 } 547 }
537 } 548 }
538 else if (equal_Command(cmd, "history.clear")) { 549 else if (equal_Command(cmd, "history.clear")) {