summaryrefslogtreecommitdiff
path: root/src/ui/lookupwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/lookupwidget.c')
-rw-r--r--src/ui/lookupwidget.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/ui/lookupwidget.c b/src/ui/lookupwidget.c
index 284d518e..1975610e 100644
--- a/src/ui/lookupwidget.c
+++ b/src/ui/lookupwidget.c
@@ -77,6 +77,7 @@ struct Impl_LookupItem {
77 iLookupResult *result; 77 iLookupResult *result;
78 int font; 78 int font;
79 int fg; 79 int fg;
80 iString icon;
80 iString text; 81 iString text;
81 iString command; 82 iString command;
82}; 83};
@@ -86,6 +87,10 @@ static void init_LookupItem(iLookupItem *d, const iLookupResult *res) {
86 d->result = res ? copy_LookupResult(res) : NULL; 87 d->result = res ? copy_LookupResult(res) : NULL;
87 d->font = uiContent_FontId; 88 d->font = uiContent_FontId;
88 d->fg = uiText_ColorId; 89 d->fg = uiText_ColorId;
90 init_String(&d->icon);
91 if (res && res->icon) {
92 appendChar_String(&d->icon, res->icon);
93 }
89 init_String(&d->text); 94 init_String(&d->text);
90 init_String(&d->command); 95 init_String(&d->command);
91} 96}
@@ -93,6 +98,7 @@ static void init_LookupItem(iLookupItem *d, const iLookupResult *res) {
93static void deinit_LookupItem(iLookupItem *d) { 98static void deinit_LookupItem(iLookupItem *d) {
94 deinit_String(&d->command); 99 deinit_String(&d->command);
95 deinit_String(&d->text); 100 deinit_String(&d->text);
101 deinit_String(&d->icon);
96 delete_LookupResult(d->result); 102 delete_LookupResult(d->result);
97} 103}
98 104
@@ -110,11 +116,20 @@ static void draw_LookupItem_(iLookupItem *d, iPaint *p, iRect rect, const iListW
110 ? permanent_ColorId | (isPressing || isCursor ? uiTextPressed_ColorId 116 ? permanent_ColorId | (isPressing || isCursor ? uiTextPressed_ColorId
111 : uiTextFramelessHover_ColorId) 117 : uiTextFramelessHover_ColorId)
112 : d->fg; 118 : d->fg;
113 const iInt2 size = measure_Text(d->font, cstr_String(&d->text)); 119 const iInt2 size = measureRange_Text(d->font, range_String(&d->text));
114 iInt2 pos = init_I2(left_Rect(rect) + 3 * gap_UI, mid_Rect(rect).y - size.y / 2); 120 iInt2 pos = init_I2(left_Rect(rect) + 3 * gap_UI, mid_Rect(rect).y - size.y / 2);
115 if (d->listItem.isSeparator) { 121 if (d->listItem.isSeparator) {
116 pos.y = bottom_Rect(rect) - lineHeight_Text(d->font); 122 pos.y = bottom_Rect(rect) - lineHeight_Text(d->font);
117 } 123 }
124 if (!isEmpty_String(&d->icon)) {
125 const iRect iconRect = { pos, init_I2(gap_UI * 5, height_Rect(rect)) };
126 const iInt2 iconSize = measureRange_Text(d->font, range_String(&d->icon));
127 drawRange_Text(d->font,
128 addX_I2(pos, width_Rect(iconRect) / 2 - iconSize.x / 2),
129 fg,
130 range_String(&d->icon));
131 pos.x += width_Rect(iconRect) + gap_UI;
132 }
118 drawRange_Text(d->font, pos, fg, range_String(&d->text)); 133 drawRange_Text(d->font, pos, fg, range_String(&d->text));
119} 134}
120 135
@@ -203,9 +218,8 @@ static void searchBookmarks_LookupJob_(iLookupJob *d) {
203 res->type = bookmark_LookupResultType; 218 res->type = bookmark_LookupResultType;
204 res->when = bm->when; 219 res->when = bm->when;
205 res->relevance = bookmarkRelevance_LookupJob_(d, bm); 220 res->relevance = bookmarkRelevance_LookupJob_(d, bm);
206 appendChar_String(&res->label, bm->icon); 221 res->icon = bm->icon;
207 appendChar_String(&res->label, ' '); 222 set_String(&res->label, &bm->title);
208 append_String(&res->label, &bm->title);
209 set_String(&res->url, &bm->url); 223 set_String(&res->url, &bm->url);
210 pushBack_PtrArray(&d->results, res); 224 pushBack_PtrArray(&d->results, res);
211 } 225 }
@@ -226,11 +240,8 @@ static void searchFeeds_LookupJob_(iLookupJob *d) {
226 res->relevance = relevance; 240 res->relevance = relevance;
227 set_String(&res->url, &entry->url); 241 set_String(&res->url, &entry->url);
228 set_String(&res->meta, &bm->title); 242 set_String(&res->meta, &bm->title);
229 if (bm->icon) { 243 set_String(&res->label, &entry->title);
230 appendChar_String(&res->label, bm->icon); 244 res->icon = bm->icon;
231 appendChar_String(&res->label, ' ');
232 }
233 append_String(&res->label, &entry->title);
234 pushBack_PtrArray(&d->results, res); 245 pushBack_PtrArray(&d->results, res);
235 } 246 }
236 } 247 }
@@ -285,10 +296,9 @@ static void searchIdentities_LookupJob_(iLookupJob *d) {
285 iLookupResult *res = new_LookupResult(); 296 iLookupResult *res = new_LookupResult();
286 res->type = identity_LookupResultType; 297 res->type = identity_LookupResultType;
287 res->relevance = identityRelevance_LookupJob_(d, identity); 298 res->relevance = identityRelevance_LookupJob_(d, identity);
288 appendChar_String(&res->label, identity->icon); 299 res->icon = identity->icon;
289 appendChar_String(&res->label, ' ');
290 iString *cn = subject_TlsCertificate(identity->cert); 300 iString *cn = subject_TlsCertificate(identity->cert);
291 append_String(&res->label, cn); 301 set_String(&res->label, cn);
292 delete_String(cn); 302 delete_String(cn);
293 set_String(&res->meta, 303 set_String(&res->meta,
294 collect_String( 304 collect_String(