summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-01-02 17:14:39 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-01-02 17:16:31 +0200
commit2e856e7f61acba9beed83f80e1304252baad2e98 (patch)
treee552e96ed63cb99b04ffc31f1e2a656282d675e8 /src/ui/sidebarwidget.c
parent58df7a9d4878a4bea820ef576da7f049e28e8c21 (diff)
Bookmarks: Remote bookmarks grouped under source
Rather than mix remote bookmarks with local ones, group them under the source bookmark in "pseudo-folder" fashion. The source is shown as bold.
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 317e74bd..e28f86f9 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -52,6 +52,7 @@ struct Impl_SidebarItem {
52 uint32_t id; 52 uint32_t id;
53 int indent; 53 int indent;
54 iChar icon; 54 iChar icon;
55 iBool isBold;
55 iString label; 56 iString label;
56 iString meta; 57 iString meta;
57 iString url; 58 iString url;
@@ -62,6 +63,7 @@ void init_SidebarItem(iSidebarItem *d) {
62 d->id = 0; 63 d->id = 0;
63 d->indent = 0; 64 d->indent = 0;
64 d->icon = 0; 65 d->icon = 0;
66 d->isBold = iFalse;
65 init_String(&d->label); 67 init_String(&d->label);
66 init_String(&d->meta); 68 init_String(&d->meta);
67 init_String(&d->url); 69 init_String(&d->url);
@@ -106,7 +108,23 @@ static iBool isResizing_SidebarWidget_(const iSidebarWidget *d) {
106} 108}
107 109
108static int cmpTitle_Bookmark_(const iBookmark **a, const iBookmark **b) { 110static int cmpTitle_Bookmark_(const iBookmark **a, const iBookmark **b) {
109 return cmpStringCase_String(&(*a)->title, &(*b)->title); 111 const iBookmark *bm1 = *a, *bm2 = *b;
112 if (bm2->sourceId == id_Bookmark(bm1)) {
113 return -1;
114 }
115 if (bm1->sourceId == id_Bookmark(bm2)) {
116 return 1;
117 }
118 if (bm1->sourceId == bm2->sourceId) {
119 return cmpStringCase_String(&bm1->title, &bm2->title);
120 }
121 if (bm1->sourceId) {
122 bm1 = get_Bookmarks(bookmarks_App(), bm1->sourceId);
123 }
124 if (bm2->sourceId) {
125 bm2 = get_Bookmarks(bookmarks_App(), bm2->sourceId);
126 }
127 return cmpStringCase_String(&bm1->title, &bm2->title);
110} 128}
111 129
112static void updateItems_SidebarWidget_(iSidebarWidget *d) { 130static void updateItems_SidebarWidget_(iSidebarWidget *d) {
@@ -220,6 +238,7 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
220 init_RegExpMatch(&m); 238 init_RegExpMatch(&m);
221 if (matchString_RegExp(remoteSourceTag, &bm->tags, &m)) { 239 if (matchString_RegExp(remoteSourceTag, &bm->tags, &m)) {
222 appendChar_String(&item->meta, 0x2913); 240 appendChar_String(&item->meta, 0x2913);
241 item->isBold = iTrue;
223 } 242 }
224 } 243 }
225 addItem_ListWidget(d->list, item); 244 addItem_ListWidget(d->list, item);
@@ -1132,8 +1151,8 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1132 const int itemHeight = height_Rect(itemRect); 1151 const int itemHeight = height_Rect(itemRect);
1133 const int iconColor = isHover ? (isPressing ? uiTextPressed_ColorId : uiIconHover_ColorId) 1152 const int iconColor = isHover ? (isPressing ? uiTextPressed_ColorId : uiIconHover_ColorId)
1134 : uiIcon_ColorId; 1153 : uiIcon_ColorId;
1135 const int font = uiContent_FontId; 1154 const int font = d->isBold ? uiContentBold_FontId : uiContent_FontId;
1136 int bg = uiBackground_ColorId; 1155 int bg = uiBackground_ColorId;
1137 if (isHover) { 1156 if (isHover) {
1138 bg = isPressing ? uiBackgroundPressed_ColorId 1157 bg = isPressing ? uiBackgroundPressed_ColorId
1139 : uiBackgroundFramelessHover_ColorId; 1158 : uiBackgroundFramelessHover_ColorId;