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, 31 insertions, 0 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 3463f1a5..20e43153 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -332,6 +332,7 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
332 iRegExp *homeTag = iClob(new_RegExp("\\b" homepage_BookmarkTag "\\b", caseSensitive_RegExpOption)); 332 iRegExp *homeTag = iClob(new_RegExp("\\b" homepage_BookmarkTag "\\b", caseSensitive_RegExpOption));
333 iRegExp *subTag = iClob(new_RegExp("\\b" subscribed_BookmarkTag "\\b", caseSensitive_RegExpOption)); 333 iRegExp *subTag = iClob(new_RegExp("\\b" subscribed_BookmarkTag "\\b", caseSensitive_RegExpOption));
334 iRegExp *remoteSourceTag = iClob(new_RegExp("\\b" remoteSource_BookmarkTag "\\b", caseSensitive_RegExpOption)); 334 iRegExp *remoteSourceTag = iClob(new_RegExp("\\b" remoteSource_BookmarkTag "\\b", caseSensitive_RegExpOption));
335 iRegExp *remoteTag = iClob(new_RegExp("\\b" remote_BookmarkTag "\\b", caseSensitive_RegExpOption));
335 iRegExp *linkSplitTag = iClob(new_RegExp("\\b" linkSplit_BookmarkTag "\\b", caseSensitive_RegExpOption)); 336 iRegExp *linkSplitTag = iClob(new_RegExp("\\b" linkSplit_BookmarkTag "\\b", caseSensitive_RegExpOption));
336 iConstForEach(PtrArray, i, list_Bookmarks(bookmarks_App(), cmpTree_Bookmark_, NULL, NULL)) { 337 iConstForEach(PtrArray, i, list_Bookmarks(bookmarks_App(), cmpTree_Bookmark_, NULL, NULL)) {
337 const iBookmark *bm = i.ptr; 338 const iBookmark *bm = i.ptr;
@@ -352,6 +353,10 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
352 appendChar_String(&item->meta, 0x1f3e0); 353 appendChar_String(&item->meta, 0x1f3e0);
353 } 354 }
354 init_RegExpMatch(&m); 355 init_RegExpMatch(&m);
356 if (matchString_RegExp(remoteTag, &bm->tags, &m)) {
357 item->listItem.isDraggable = iFalse;
358 }
359 init_RegExpMatch(&m);
355 if (matchString_RegExp(remoteSourceTag, &bm->tags, &m)) { 360 if (matchString_RegExp(remoteSourceTag, &bm->tags, &m)) {
356 appendChar_String(&item->meta, 0x2913); 361 appendChar_String(&item->meta, 0x2913);
357 item->isBold = iTrue; 362 item->isBold = iTrue;
@@ -555,6 +560,7 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
555#endif 560#endif
556 arrange_Widget(d->actions); 561 arrange_Widget(d->actions);
557 arrange_Widget(as_Widget(d)); 562 arrange_Widget(as_Widget(d));
563 updateMouseHover_ListWidget(d->list);
558} 564}
559 565
560static void updateItemHeight_SidebarWidget_(iSidebarWidget *d) { 566static void updateItemHeight_SidebarWidget_(iSidebarWidget *d) {
@@ -1000,6 +1006,19 @@ static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *
1000 return iFalse; 1006 return iFalse;
1001} 1007}
1002 1008
1009static void bookmarkMoved_SidebarWidget_(iSidebarWidget *d, size_t index, size_t beforeIndex) {
1010 const iSidebarItem *movingItem = item_ListWidget(d->list, index);
1011 const iBool isLast = (beforeIndex == numItems_ListWidget(d->list));
1012 const iSidebarItem *dstItem = item_ListWidget(d->list,
1013 isLast ? numItems_ListWidget(d->list) - 1
1014 : beforeIndex);
1015 const iBookmark *dst = get_Bookmarks(bookmarks_App(), dstItem->id);
1016 reorder_Bookmarks(bookmarks_App(), movingItem->id, dst->order + (isLast ? 1 : 0));
1017 updateItems_SidebarWidget_(d);
1018 /* Don't confuse the user: keep the dragged item in hover state. */
1019 setHoverItem_ListWidget(d->list, index < beforeIndex ? beforeIndex - 1 : beforeIndex);
1020}
1021
1003static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) { 1022static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) {
1004 iWidget *w = as_Widget(d); 1023 iWidget *w = as_Widget(d);
1005 /* Handle commands. */ 1024 /* Handle commands. */
@@ -1107,6 +1126,18 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
1107 d, pointerLabel_Command(cmd, "item"), argU32Label_Command(cmd, "arg")); 1126 d, pointerLabel_Command(cmd, "item"), argU32Label_Command(cmd, "arg"));
1108 return iTrue; 1127 return iTrue;
1109 } 1128 }
1129 else if (isCommand_Widget(w, ev, "list.dragged")) {
1130 iAssert(d->mode == bookmarks_SidebarMode);
1131 if (hasLabel_Command(cmd, "before")) {
1132 bookmarkMoved_SidebarWidget_(d,
1133 argU32Label_Command(cmd, "arg"),
1134 argU32Label_Command(cmd, "before"));
1135 }
1136 else {
1137 /* Dragged onto a folder. */
1138 }
1139 return iTrue;
1140 }
1110 else if (isCommand_Widget(w, ev, "menu.closed")) { 1141 else if (isCommand_Widget(w, ev, "menu.closed")) {
1111 // invalidateItem_ListWidget(d->list, d->contextIndex); 1142 // invalidateItem_ListWidget(d->list, d->contextIndex);
1112 } 1143 }