summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-09 11:35:03 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-09 11:35:03 +0200
commitc17fe5ed17c906b0c0bc21e07d87d281d04e10e6 (patch)
tree98a0102066ecb14354ea6f161bed17211de6edf7 /src/ui/util.c
parentf969ea2d93208bcc99eb9e513275686dfee5108a (diff)
UploadWidget: Improved Identity dropdown
Better colors, keep the menu button fixed-height.
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 21067bf4..73fafe84 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1327,6 +1327,12 @@ const iString *removeMenuItemLabelPrefixes_String(const iString *d) {
1327 return collect_String(str); 1327 return collect_String(str);
1328} 1328}
1329 1329
1330static const iString *replaceNewlinesWithDash_(const iString *str) {
1331 iString *mod = copy_String(str);
1332 replace_String(mod, "\n", " ");
1333 return collect_String(mod);
1334}
1335
1330void updateDropdownSelection_LabelWidget(iLabelWidget *dropButton, const char *selectedCommand) { 1336void updateDropdownSelection_LabelWidget(iLabelWidget *dropButton, const char *selectedCommand) {
1331 if (!dropButton) { 1337 if (!dropButton) {
1332 return; 1338 return;
@@ -1337,8 +1343,9 @@ void updateDropdownSelection_LabelWidget(iLabelWidget *dropButton, const char *s
1337 iMenuItem *item = findNativeMenuItem_Widget(menu, selectedCommand); 1343 iMenuItem *item = findNativeMenuItem_Widget(menu, selectedCommand);
1338 if (item) { 1344 if (item) {
1339 setSelected_NativeMenuItem(item, iTrue); 1345 setSelected_NativeMenuItem(item, iTrue);
1340 updateText_LabelWidget( 1346 updateText_LabelWidget(dropButton,
1341 dropButton, removeMenuItemLabelPrefixes_String(collectNewCStr_String(item->label))); 1347 replaceNewlinesWithDash_(removeMenuItemLabelPrefixes_String(
1348 collectNewCStr_String(item->label))));
1342 checkIcon_LabelWidget(dropButton); 1349 checkIcon_LabelWidget(dropButton);
1343 } 1350 }
1344 return; 1351 return;
@@ -1349,7 +1356,8 @@ void updateDropdownSelection_LabelWidget(iLabelWidget *dropButton, const char *s
1349 const iBool isSelected = endsWith_String(command_LabelWidget(item), selectedCommand); 1356 const iBool isSelected = endsWith_String(command_LabelWidget(item), selectedCommand);
1350 setFlags_Widget(as_Widget(item), selected_WidgetFlag, isSelected); 1357 setFlags_Widget(as_Widget(item), selected_WidgetFlag, isSelected);
1351 if (isSelected) { 1358 if (isSelected) {
1352 updateText_LabelWidget(dropButton, sourceText_LabelWidget(item)); 1359 updateText_LabelWidget(dropButton,
1360 replaceNewlinesWithDash_(text_LabelWidget(item)));
1353 checkIcon_LabelWidget(dropButton); 1361 checkIcon_LabelWidget(dropButton);
1354 } 1362 }
1355 } 1363 }