summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/sidebarwidget.c39
-rw-r--r--src/ui/util.c11
2 files changed, 31 insertions, 19 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")) {
diff --git a/src/ui/util.c b/src/ui/util.c
index 918a0671..cb6b61ba 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -733,9 +733,11 @@ iWidget *makePreferences_Widget(void) {
733 733
734iWidget *makeBookmarkEditor_Widget(void) { 734iWidget *makeBookmarkEditor_Widget(void) {
735 iWidget *dlg = makeSheet_Widget("bmed"); 735 iWidget *dlg = makeSheet_Widget("bmed");
736 addChildFlags_Widget(dlg, 736 setId_Widget(addChildFlags_Widget(
737 iClob(new_LabelWidget(uiHeading_ColorEscape "EDIT BOOKMARK", 0, 0, NULL)), 737 dlg,
738 frameless_WidgetFlag); 738 iClob(new_LabelWidget(uiHeading_ColorEscape "EDIT BOOKMARK", 0, 0, NULL)),
739 frameless_WidgetFlag),
740 "bmed.heading");
739 iWidget *page = new_Widget(); 741 iWidget *page = new_Widget();
740 addChild_Widget(dlg, iClob(page)); 742 addChild_Widget(dlg, iClob(page));
741 setFlags_Widget(page, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 743 setFlags_Widget(page, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
@@ -744,8 +746,7 @@ iWidget *makeBookmarkEditor_Widget(void) {
744 iWidget *values = addChildFlags_Widget( 746 iWidget *values = addChildFlags_Widget(
745 page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); 747 page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag);
746 iInputWidget *inputs[4]; 748 iInputWidget *inputs[4];
747 iWidget *hd; 749 addChild_Widget(headings, iClob(makeHeading_Widget("Title:")));
748 addChild_Widget(headings, iClob(hd = makeHeading_Widget("Title:")));
749 setId_Widget(addChild_Widget(values, iClob(inputs[0] = new_InputWidget(0))), "bmed.title"); 750 setId_Widget(addChild_Widget(values, iClob(inputs[0] = new_InputWidget(0))), "bmed.title");
750 addChild_Widget(headings, iClob(makeHeading_Widget("URL:"))); 751 addChild_Widget(headings, iClob(makeHeading_Widget("URL:")));
751 setId_Widget(addChild_Widget(values, iClob(inputs[1] = new_InputWidget(0))), "bmed.url"); 752 setId_Widget(addChild_Widget(values, iClob(inputs[1] = new_InputWidget(0))), "bmed.url");