summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-24 09:27:35 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-24 09:27:35 +0200
commitce8f6a67cb6c6fd7491d9f5ace7e9eda39a9f90c (patch)
tree527a32061b629b33a8d9d6ae5f42de42f7ebafa1
parent1a9b38025dd00d5720fa560c790603daf22b3681 (diff)
macOS: Fixed selecting scope for new identity
The selected item was not found from a native popup menu.
-rw-r--r--src/app.c23
-rw-r--r--src/ui/util.c26
-rw-r--r--src/ui/util.h1
3 files changed, 34 insertions, 16 deletions
diff --git a/src/app.c b/src/app.c
index bfac84d9..2135ec7c 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2035,9 +2035,8 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) {
2035 } 2035 }
2036 if (equal_Command(cmd, "ident.scope")) { 2036 if (equal_Command(cmd, "ident.scope")) {
2037 iLabelWidget *scope = findChild_Widget(dlg, "ident.scope"); 2037 iLabelWidget *scope = findChild_Widget(dlg, "ident.scope");
2038 setText_LabelWidget(scope, 2038 updateDropdownSelection_LabelWidget(scope, format_CStr(" arg:%d", arg_Command(cmd)));
2039 text_LabelWidget(child_Widget( 2039 updateSize_LabelWidget(scope);
2040 findChild_Widget(as_Widget(scope), "menu"), arg_Command(cmd))));
2041 arrange_Widget(findWidget_App("ident")); 2040 arrange_Widget(findWidget_App("ident"));
2042 return iTrue; 2041 return iTrue;
2043 } 2042 }
@@ -2104,19 +2103,11 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) {
2104 organization, 2103 organization,
2105 country); 2104 country);
2106 /* Use in the chosen scope. */ { 2105 /* Use in the chosen scope. */ {
2107 const iLabelWidget *scope = findChild_Widget(dlg, "ident.scope"); 2106 int selScope = 2;
2108 const iString * selLabel = text_LabelWidget(scope); 2107 const char *scopeCmd =
2109 int selScope = 0; 2108 selectedDropdownCommand_LabelWidget(findChild_Widget(dlg, "ident.scope"));
2110 iConstForEach(ObjectList, 2109 if (startsWith_CStr(scopeCmd, "ident.scope arg:")) {
2111 i, 2110 selScope = arg_Command(scopeCmd);
2112 children_Widget(findChild_Widget(constAs_Widget(scope), "menu"))) {
2113 if (isInstance_Object(i.object, &Class_LabelWidget)) {
2114 const iLabelWidget *item = i.object;
2115 if (equal_String(text_LabelWidget(item), selLabel)) {
2116 break;
2117 }
2118 selScope++;
2119 }
2120 } 2111 }
2121 const iString *docUrl = url_DocumentWidget(document_Root(dlg->root)); 2112 const iString *docUrl = url_DocumentWidget(document_Root(dlg->root));
2122 iString *useUrl = NULL; 2113 iString *useUrl = NULL;
diff --git a/src/ui/util.c b/src/ui/util.c
index efcb8b9f..912e1d37 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1298,6 +1298,32 @@ void updateDropdownSelection_LabelWidget(iLabelWidget *dropButton, const char *s
1298 } 1298 }
1299} 1299}
1300 1300
1301const char *selectedDropdownCommand_LabelWidget(const iLabelWidget *dropButton) {
1302 if (!dropButton) {
1303 return "";
1304 }
1305 iWidget *menu = findChild_Widget(constAs_Widget(dropButton), "menu");
1306 if (flags_Widget(menu) & nativeMenu_WidgetFlag) {
1307 iConstForEach(Array, i, userData_Object(menu)) {
1308 const iMenuItem *item = i.value;
1309 if (item->label && startsWithCase_CStr(item->label, "###")) {
1310 return item->command ? item->command : "";
1311 }
1312 }
1313 }
1314 else {
1315 iForEach(ObjectList, i, children_Widget(menu)) {
1316 if (isInstance_Object(i.object, &Class_LabelWidget)) {
1317 iLabelWidget *item = i.object;
1318 if (flags_Widget(i.object) & selected_WidgetFlag) {
1319 return cstr_String(command_LabelWidget(item));
1320 }
1321 }
1322 }
1323 }
1324 return "";
1325}
1326
1301/*-----------------------------------------------------------------------------------------------*/ 1327/*-----------------------------------------------------------------------------------------------*/
1302 1328
1303static iBool isTabPage_Widget_(const iWidget *tabs, const iWidget *page) { 1329static iBool isTabPage_Widget_(const iWidget *tabs, const iWidget *page) {
diff --git a/src/ui/util.h b/src/ui/util.h
index 81fb1cbd..d13d751b 100644
--- a/src/ui/util.h
+++ b/src/ui/util.h
@@ -261,6 +261,7 @@ int checkContextMenu_Widget (iWidget *, const SDL_Event *ev)
261 261
262iLabelWidget * makeMenuButton_LabelWidget (const char *label, const iMenuItem *items, size_t n); 262iLabelWidget * makeMenuButton_LabelWidget (const char *label, const iMenuItem *items, size_t n);
263void updateDropdownSelection_LabelWidget (iLabelWidget *dropButton, const char *selectedCommand); 263void updateDropdownSelection_LabelWidget (iLabelWidget *dropButton, const char *selectedCommand);
264const char * selectedDropdownCommand_LabelWidget (const iLabelWidget *dropButton);
264 265
265/*-----------------------------------------------------------------------------------------------*/ 266/*-----------------------------------------------------------------------------------------------*/
266 267