diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-28 07:55:21 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-28 07:55:21 +0300 |
commit | 9d66bec7f60a9767b7ec0acac747dbfecc87899c (patch) | |
tree | 8ee2c768f4db81a2bf877efa4992387f686f4d18 /src/ui/window.c | |
parent | ea7cc3847d1e4101478137779ecd43cca2218cd7 (diff) |
macOS: Recreate menus after language changes
IssueID #192
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index 9b132da1..a3675ae5 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -320,6 +320,24 @@ static const iMenuItem helpMenuItems_[] = { | |||
320 | { "${menu.aboutpages}", 0, 0, "!open url:about:about" }, | 320 | { "${menu.aboutpages}", 0, 0, "!open url:about:about" }, |
321 | { "${menu.debug}", 0, 0, "!open url:about:debug" }, | 321 | { "${menu.debug}", 0, 0, "!open url:about:debug" }, |
322 | }; | 322 | }; |
323 | |||
324 | static void insertMacMenus_(void) { | ||
325 | insertMenuItems_MacOS("${menu.title.file}", 1, fileMenuItems_, iElemCount(fileMenuItems_)); | ||
326 | insertMenuItems_MacOS("${menu.title.edit}", 2, editMenuItems_, iElemCount(editMenuItems_)); | ||
327 | insertMenuItems_MacOS("${menu.title.view}", 3, viewMenuItems_, iElemCount(viewMenuItems_)); | ||
328 | insertMenuItems_MacOS("${menu.title.bookmarks}", 4, bookmarksMenuItems_, iElemCount(bookmarksMenuItems_)); | ||
329 | insertMenuItems_MacOS("${menu.title.identity}", 5, identityMenuItems_, iElemCount(identityMenuItems_)); | ||
330 | insertMenuItems_MacOS("${menu.title.help}", 7, helpMenuItems_, iElemCount(helpMenuItems_)); | ||
331 | } | ||
332 | |||
333 | static void removeMacMenus_(void) { | ||
334 | removeMenu_MacOS(7); | ||
335 | removeMenu_MacOS(5); | ||
336 | removeMenu_MacOS(4); | ||
337 | removeMenu_MacOS(3); | ||
338 | removeMenu_MacOS(2); | ||
339 | removeMenu_MacOS(1); | ||
340 | } | ||
323 | #endif | 341 | #endif |
324 | 342 | ||
325 | #if defined (iPlatformAppleMobile) | 343 | #if defined (iPlatformAppleMobile) |
@@ -1055,12 +1073,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
1055 | setAlignVisually_LabelWidget(navMenu, iTrue); | 1073 | setAlignVisually_LabelWidget(navMenu, iTrue); |
1056 | setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu"); | 1074 | setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu"); |
1057 | #else | 1075 | #else |
1058 | insertMenuItems_MacOS("${menu.title.file}", 1, fileMenuItems_, iElemCount(fileMenuItems_)); | 1076 | insertMacMenus_(); |
1059 | insertMenuItems_MacOS("${menu.title.edit}", 2, editMenuItems_, iElemCount(editMenuItems_)); | ||
1060 | insertMenuItems_MacOS("${menu.title.view}", 3, viewMenuItems_, iElemCount(viewMenuItems_)); | ||
1061 | insertMenuItems_MacOS("${menu.title.bookmarks}", 4, bookmarksMenuItems_, iElemCount(bookmarksMenuItems_)); | ||
1062 | insertMenuItems_MacOS("${menu.title.identity}", 5, identityMenuItems_, iElemCount(identityMenuItems_)); | ||
1063 | insertMenuItems_MacOS("${menu.title.help}", 7, helpMenuItems_, iElemCount(helpMenuItems_)); | ||
1064 | #endif | 1077 | #endif |
1065 | } | 1078 | } |
1066 | /* Tab bar. */ { | 1079 | /* Tab bar. */ { |
@@ -1821,6 +1834,11 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
1821 | updateMetrics_Window_(d); | 1834 | updateMetrics_Window_(d); |
1822 | } | 1835 | } |
1823 | if (isCommand_UserEvent(&event, "lang.changed")) { | 1836 | if (isCommand_UserEvent(&event, "lang.changed")) { |
1837 | #if defined (iPlatformAppleDesktop) | ||
1838 | /* Retranslate the menus. */ | ||
1839 | removeMacMenus_(); | ||
1840 | insertMacMenus_(); | ||
1841 | #endif | ||
1824 | invalidate_Window_(d); | 1842 | invalidate_Window_(d); |
1825 | arrange_Widget(d->root); | 1843 | arrange_Widget(d->root); |
1826 | } | 1844 | } |