From 114e52a60c789c5d1d885a994e8e1bd002b7cc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Fri, 30 Oct 2020 15:03:09 +0200 Subject: [PATCH 1/1] Updating LabelWidget command key If the key bindings have a key for a command, LabelWidget will use it. --- src/ui/keys.c | 12 +++---- src/ui/keys.h | 10 ++++++ src/ui/labelwidget.c | 60 ++++++++++++++++++++++++----------- src/ui/labelwidget.h | 9 +++--- src/ui/listwidget.h | 2 +- src/ui/sidebarwidget.c | 8 ++--- src/ui/util.c | 71 +++++++++++++++++++++--------------------- src/ui/window.c | 5 +-- 8 files changed, 104 insertions(+), 73 deletions(-) diff --git a/src/ui/keys.c b/src/ui/keys.c index 4d52b0a4..85304ef7 100644 --- a/src/ui/keys.c +++ b/src/ui/keys.c @@ -27,14 +27,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include iDeclareType(Keys) -iDeclareType(Binding) - -struct Impl_Binding { - int key; - int mods; - iString command; - iString label; -}; static int cmp_Binding_(const void *a, const void *b) { const iBinding *d = a, *other = b; @@ -151,3 +143,7 @@ iBool processEvent_Keys(const SDL_Event *ev) { } return iFalse; } + +const iBinding *findCommand_Keys(const char *command) { + return findCommand_Keys_(&keys_, command); +} diff --git a/src/ui/keys.h b/src/ui/keys.h index 157ddea5..0892bd81 100644 --- a/src/ui/keys.h +++ b/src/ui/keys.h @@ -43,6 +43,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ # define byLine_KeyModifier 0 #endif +iDeclareType(Binding) + +struct Impl_Binding { + int key; + int mods; + iString command; + iString label; +}; + void init_Keys (void); void deinit_Keys (void); @@ -51,6 +60,7 @@ void save_Keys (const char *saveDir); void bind_Keys (const char *command, int key, int mods); void setLabel_Keys (const char *command, const char *label); +const iBinding *findCommand_Keys (const char *command); //const iString * label_Keys (const char *command); //const char * shortcutLabel_Keys (const char *command); diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 0555bc4d..b4ba79fe 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c @@ -26,6 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "paint.h" #include "app.h" #include "util.h" +#include "keys.h" iLocalDef iInt2 padding_(int flags) { return init_I2(flags & tight_WidgetFlag ? 3 * gap_UI / 2 : (3 * gap_UI), gap_UI); @@ -43,8 +44,8 @@ struct Impl_LabelWidget { }; iDefineObjectConstructionArgs(LabelWidget, - (const char *label, int key, int kmods, const char *cmd), - label, key, kmods, cmd) + (const char *label, const char *cmd), + label, cmd) static iBool checkModifiers_(int have, int req) { return keyMods_Sym(req) == keyMods_Sym(have); @@ -60,11 +61,26 @@ static void trigger_LabelWidget_(const iLabelWidget *d) { } } +static void updateKey_LabelWidget_(iLabelWidget *d) { + if (!isEmpty_String(&d->command)) { + const iBinding *bind = findCommand_Keys(cstr_String(&d->command)); + if (bind) { + d->key = bind->key; + d->kmods = bind->mods; + } + } +} + static iBool processEvent_LabelWidget_(iLabelWidget *d, const SDL_Event *ev) { iWidget *w = &d->widget; if (isCommand_UserEvent(ev, "metrics.changed")) { updateSize_LabelWidget(d); } + else if (isCommand_UserEvent(ev, "bindings.changed")) { + /* Update the key used to trigger this label. */ + updateKey_LabelWidget_(d); + return iFalse; + } if (!isEmpty_String(&d->command)) { switch (processEvent_Click(&d->click, ev)) { case started_ClickResult: @@ -229,6 +245,18 @@ static void draw_LabelWidget_(const iLabelWidget *d) { unsetClip_Paint(&p); } +static void sizeChanged_LabelWidget_(iLabelWidget *d) { + iWidget *w = as_Widget(d); + if (flags_Widget(w) & wrapText_WidgetFlag) { + if (flags_Widget(w) & fixedHeight_WidgetFlag) { + /* Calculate a new height based on the wrapping. */ + w->rect.size.y = advanceWrapRange_Text( + d->font, innerBounds_Widget(w).size.x, range_String(&d->label)) + .y; + } + } +} + void updateSize_LabelWidget(iLabelWidget *d) { iWidget *w = as_Widget(d); const int flags = flags_Widget(w); @@ -249,19 +277,7 @@ void updateSize_LabelWidget(iLabelWidget *d) { } } -static void sizeChanged_LabelWidget_(iLabelWidget *d) { - iWidget *w = as_Widget(d); - if (flags_Widget(w) & wrapText_WidgetFlag) { - if (flags_Widget(w) & fixedHeight_WidgetFlag) { - /* Calculate a new height based on the wrapping. */ - w->rect.size.y = advanceWrapRange_Text( - d->font, innerBounds_Widget(w).size.x, range_String(&d->label)) - .y; - } - } -} - -void init_LabelWidget(iLabelWidget *d, const char *label, int key, int kmods, const char *cmd) { +void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { init_Widget(&d->widget); d->font = uiLabel_FontId; initCStr_String(&d->label, label); @@ -271,12 +287,13 @@ void init_LabelWidget(iLabelWidget *d, const char *label, int key, int kmods, co else { init_String(&d->command); } - d->key = key; - d->kmods = kmods; + d->key = 0; + d->kmods = 0; init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); setFlags_Widget(&d->widget, hover_WidgetFlag, d->click.button != 0); d->alignVisual = iFalse; updateSize_LabelWidget(d); + updateKey_LabelWidget_(d); } void deinit_LabelWidget(iLabelWidget *d) { @@ -321,8 +338,15 @@ const iString *command_LabelWidget(const iLabelWidget *d) { return &d->command; } +iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command) { + iLabelWidget *d = new_LabelWidget(label, command); + d->key = key; + d->kmods = kmods; + return d; +} + iLabelWidget *newColor_LabelWidget(const char *text, int color) { - iLabelWidget *d = new_LabelWidget(format_CStr("%s%s", escape_Color(color), text), 0, 0, NULL); + iLabelWidget *d = new_LabelWidget(format_CStr("%s%s", escape_Color(color), text), NULL); setFlags_Widget(as_Widget(d), frameless_WidgetFlag, iTrue); return d; } diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h index c55ecd08..066c9b33 100644 --- a/src/ui/labelwidget.h +++ b/src/ui/labelwidget.h @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "widget.h" iDeclareWidgetClass(LabelWidget) -iDeclareObjectConstructionArgs(LabelWidget, const char *label, int key, int kmods, const char *command) +iDeclareObjectConstructionArgs(LabelWidget, const char *label, const char *command) void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); void setFont_LabelWidget (iLabelWidget *, int fontId); @@ -41,13 +41,14 @@ void updateTextCStr_LabelWidget (iLabelWidget *, const char *text); /* not r const iString *label_LabelWidget (const iLabelWidget *); const iString *command_LabelWidget (const iLabelWidget *); -iLabelWidget *newColor_LabelWidget(const char *text, int color); +iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command); +iLabelWidget *newColor_LabelWidget (const char *text, int color); iLocalDef iLabelWidget *newEmpty_LabelWidget(void) { - return new_LabelWidget("", 0, 0, NULL); + return new_LabelWidget("", NULL); } iLocalDef iLabelWidget *newIcon_LabelWidget(const char *label, int key, int kmods, const char *command) { - iLabelWidget *d = new_LabelWidget(label, key, kmods, command); + iLabelWidget *d = newKeyMods_LabelWidget(label, key, kmods, command); setAlignVisually_LabelWidget(d, iTrue); return d; } diff --git a/src/ui/listwidget.h b/src/ui/listwidget.h index 3e1c6777..da6303e9 100644 --- a/src/ui/listwidget.h +++ b/src/ui/listwidget.h @@ -73,6 +73,6 @@ size_t itemIndex_ListWidget (const iListWidget *, iInt2 pos) const iAnyObject * constItem_ListWidget (const iListWidget *, size_t index); const iAnyObject * constHoverItem_ListWidget (const iListWidget *); -iLocalDef isEmpty_ListWidget(const iListWidget *d) { return numItems_ListWidget(d) == 0; } +iLocalDef iBool isEmpty_ListWidget(const iListWidget *d) { return numItems_ListWidget(d) == 0; } iBool isMouseDown_ListWidget (const iListWidget *); diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index f089f48d..d6292f5b 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c @@ -252,18 +252,16 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { iWidget *div = makeVDiv_Widget(); setPadding_Widget(div, 3 * gap_UI, 0, 3 * gap_UI, 2 * gap_UI); addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); /* pad */ - iLabelWidget *msg = new_LabelWidget("No Identities", 0, 0, NULL); + iLabelWidget *msg = new_LabelWidget("No Identities", NULL); setFont_LabelWidget(msg, uiLabelLarge_FontId); addChildFlags_Widget(div, iClob(msg), frameless_WidgetFlag); addChild_Widget(div, iClob(makePadding_Widget(3 * gap_UI))); - addChild_Widget(div, iClob(new_LabelWidget("New Identity...", 0, 0, "ident.new"))); + addChild_Widget(div, iClob(new_LabelWidget("New Identity...", "ident.new"))); addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); /* pad */ addChildFlags_Widget( div, iClob(new_LabelWidget("See " uiTextStrong_ColorEscape "Help" uiText_ColorEscape " for more information about TLS client certificates.", - 0, - 0, "!open newtab:1 gotoheading:Identities url:about:help")), frameless_WidgetFlag | fixedHeight_WidgetFlag | wrapText_WidgetFlag); addChild_Widget(d->blank, iClob(div)); @@ -336,7 +334,7 @@ void init_SidebarWidget(iSidebarWidget *d) { d->modeButtons[i] = addChildFlags_Widget( buttons, iClob( - new_LabelWidget(tightModeLabels_[i], 0, 0, format_CStr("sidebar.mode arg:%d", i))), + new_LabelWidget(tightModeLabels_[i], format_CStr("sidebar.mode arg:%d", i))), frameless_WidgetFlag); d->maxButtonLabelWidth = iMaxi(d->maxButtonLabelWidth, diff --git a/src/ui/util.c b/src/ui/util.c index 16dea8d9..3c40d4a5 100644 --- a/src/ui/util.c +++ b/src/ui/util.c @@ -319,7 +319,7 @@ iWidget *makePadding_Widget(int size) { } iLabelWidget *makeHeading_Widget(const char *text) { - iLabelWidget *heading = new_LabelWidget(text, 0, 0, NULL); + iLabelWidget *heading = new_LabelWidget(text, NULL); setFlags_Widget(as_Widget(heading), frameless_WidgetFlag | fixedSize_WidgetFlag, iTrue); setBackgroundColor_Widget(as_Widget(heading), none_ColorId); return heading; @@ -338,7 +338,7 @@ iWidget *makeHDiv_Widget(void) { } iWidget *addAction_Widget(iWidget *parent, int key, int kmods, const char *command) { - iLabelWidget *action = new_LabelWidget("", key, kmods, command); + iLabelWidget *action = newKeyMods_LabelWidget("", key, kmods, command); setSize_Widget(as_Widget(action), zero_I2()); addChildFlags_Widget(parent, iClob(action), hidden_WidgetFlag); return as_Widget(action); @@ -394,7 +394,7 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { else { iLabelWidget *label = addChildFlags_Widget( menu, - iClob(new_LabelWidget(item->label, item->key, item->kmods, item->command)), + iClob(newKeyMods_LabelWidget(item->label, item->key, item->kmods, item->command)), frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag); updateSize_LabelWidget(label); /* drawKey was set */ } @@ -462,7 +462,7 @@ int checkContextMenu_Widget(iWidget *menu, const SDL_Event *ev) { } iLabelWidget *makeMenuButton_LabelWidget(const char *label, const iMenuItem *items, size_t n) { - iLabelWidget *button = new_LabelWidget(label, 0, 0, "menu.open"); + iLabelWidget *button = new_LabelWidget(label, "menu.open"); iWidget *menu = makeMenu_Widget(as_Widget(button), items, n); setId_Widget(menu, "menu"); return button; @@ -538,7 +538,7 @@ static void addTabPage_Widget_(iWidget *tabs, enum iWidgetAddPos addPos, iWidget iWidget * buttons = findChild_Widget(tabs, "tabs.buttons"); iWidget * button = addChildPos_Widget( buttons, - iClob(new_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))), + iClob(newKeyMods_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))), addPos); setFlags_Widget(buttons, hidden_WidgetFlag, iFalse); setFlags_Widget(button, selected_WidgetFlag, isSel); @@ -732,7 +732,7 @@ void makeFilePath_Widget(iWidget * parent, iWidget *dlg = makeSheet_Widget(command); setCommandHandler_Widget(dlg, filePathHandler_); addChild_Widget(parent, iClob(dlg)); - addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag); + addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0))); if (initialPath) { setText_InputWidget(input, collect_String(makeRelative_Path(initialPath))); @@ -742,8 +742,8 @@ void makeFilePath_Widget(iWidget * parent, addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); iWidget *div = new_Widget(); { setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); - addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "filepath.cancel"))); - addChild_Widget(div, iClob(new_LabelWidget(acceptLabel, SDLK_RETURN, 0, "filepath.accept"))); + addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "filepath.cancel"))); + addChild_Widget(div, iClob(newKeyMods_LabelWidget(acceptLabel, SDLK_RETURN, 0, "filepath.accept"))); } addChild_Widget(dlg, iClob(div)); centerSheet_Widget(dlg); @@ -818,10 +818,10 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con addChild_Widget(parent, iClob(dlg)); } setId_Widget( - addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag), + addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag), "valueinput.title"); setId_Widget( - addChildFlags_Widget(dlg, iClob(new_LabelWidget(prompt, 0, 0, NULL)), frameless_WidgetFlag), + addChildFlags_Widget(dlg, iClob(new_LabelWidget(prompt, NULL)), frameless_WidgetFlag), "valueinput.prompt"); iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0))); if (initialValue) { @@ -832,12 +832,13 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); iWidget *div = new_Widget(); { setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); - addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); - addChild_Widget(div, - iClob(new_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK", - SDLK_RETURN, - 0, - "valueinput.accept"))); + addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); + addChild_Widget( + div, + iClob(newKeyMods_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK", + SDLK_RETURN, + 0, + "valueinput.accept"))); } addChild_Widget(dlg, iClob(div)); centerSheet_Widget(dlg); @@ -874,15 +875,15 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, const char *lab processEvents_App(postedEventsOnly_AppEventMode); iWidget *dlg = makeSheet_Widget(""); setCommandHandler_Widget(dlg, messageHandler_); - addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag); - addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, 0, 0, NULL)), frameless_WidgetFlag); + addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); + addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, NULL)), frameless_WidgetFlag); addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); iWidget *div = new_Widget(); { setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); for (size_t i = 0; i < count; ++i) { /* The last one is the default option. */ const int key = (i == count - 1 ? SDLK_RETURN : 0); - addChild_Widget(div, iClob(new_LabelWidget(labels[i], key, 0, commands[i]))); + addChild_Widget(div, iClob(newKeyMods_LabelWidget(labels[i], key, 0, commands[i]))); } } addChild_Widget(dlg, iClob(div)); @@ -912,7 +913,7 @@ static iBool toggleHandler_(iWidget *d, const char *cmd) { } iWidget *makeToggle_Widget(const char *id) { - iWidget *toggle = as_Widget(new_LabelWidget("YES", 0, 0, "toggle")); /* "YES" for sizing */ + iWidget *toggle = as_Widget(new_LabelWidget("YES", "toggle")); /* "YES" for sizing */ setId_Widget(toggle, id); updateTextCStr_LabelWidget((iLabelWidget *) toggle, "NO"); /* actual initial value */ setCommandHandler_Widget(toggle, toggleHandler_); @@ -950,7 +951,7 @@ static void expandInputFieldWidth_(iInputWidget *input) { static void addRadioButton_(iWidget *parent, const char *id, const char *label, const char *cmd) { setId_Widget( - addChildFlags_Widget(parent, iClob(new_LabelWidget(label, 0, 0, cmd)), radio_WidgetFlag), + addChildFlags_Widget(parent, iClob(new_LabelWidget(label, cmd)), radio_WidgetFlag), id); } @@ -969,7 +970,7 @@ static void addFontButtons_(iWidget *parent, const char *id) { iWidget *makePreferences_Widget(void) { iWidget *dlg = makeSheet_Widget("prefs"); addChildFlags_Widget(dlg, - iClob(new_LabelWidget(uiHeading_ColorEscape "PREFERENCES", 0, 0, NULL)), + iClob(new_LabelWidget(uiHeading_ColorEscape "PREFERENCES", NULL)), frameless_WidgetFlag); iWidget *tabs = makeTabs_Widget(dlg); setId_Widget(tabs, "prefs.tabs"); @@ -988,10 +989,10 @@ iWidget *makePreferences_Widget(void) { addChild_Widget(headings, iClob(makeHeading_Widget("Theme:"))); iWidget *themes = new_Widget(); /* Themes. */ { - setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure Black", 0, 0, "theme.set arg:0"))), "prefs.theme.0"); - setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Dark", 0, 0, "theme.set arg:1"))), "prefs.theme.1"); - setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Light", 0, 0, "theme.set arg:2"))), "prefs.theme.2"); - setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure White", 0, 0, "theme.set arg:3"))), "prefs.theme.3"); + setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure Black", "theme.set arg:0"))), "prefs.theme.0"); + setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Dark", "theme.set arg:1"))), "prefs.theme.1"); + setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Light", "theme.set arg:2"))), "prefs.theme.2"); + setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure White", "theme.set arg:3"))), "prefs.theme.3"); } addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); addChild_Widget(headings, iClob(makeHeading_Widget("Retain window size:"))); @@ -1084,7 +1085,7 @@ iWidget *makePreferences_Widget(void) { } iWidget *div = new_Widget(); { setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); - addChild_Widget(div, iClob(new_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))); + addChild_Widget(div, iClob(newKeyMods_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))); } addChild_Widget(dlg, iClob(div)); addAction_Widget(dlg, prevTab_KeyShortcut, "tabs.prev"); @@ -1098,7 +1099,7 @@ iWidget *makeBookmarkEditor_Widget(void) { iWidget *dlg = makeSheet_Widget("bmed"); setId_Widget(addChildFlags_Widget( dlg, - iClob(new_LabelWidget(uiHeading_ColorEscape "EDIT BOOKMARK", 0, 0, NULL)), + iClob(new_LabelWidget(uiHeading_ColorEscape "EDIT BOOKMARK", NULL)), frameless_WidgetFlag), "bmed.heading"); iWidget *page = new_Widget(); @@ -1121,10 +1122,10 @@ iWidget *makeBookmarkEditor_Widget(void) { } iWidget *div = new_Widget(); { setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); - addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); + addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); addChild_Widget( div, - iClob(new_LabelWidget( + iClob(newKeyMods_LabelWidget( uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept"))); } addChild_Widget(dlg, iClob(div)); @@ -1165,7 +1166,7 @@ iWidget *makeBookmarkCreation_Widget(const iString *url, const iString *title, i setId_Widget( addChildFlags_Widget( dlg, - iClob(new_LabelWidget(cstrCollect_String(newUnicodeN_String(&icon, 1)), 0, 0, NULL)), + iClob(new_LabelWidget(cstrCollect_String(newUnicodeN_String(&icon, 1)), NULL)), collapse_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag), "bmed.icon"); setCommandHandler_Widget(dlg, handleBookmarkCreationCommands_SidebarWidget_); @@ -1176,14 +1177,14 @@ iWidget *makeIdentityCreation_Widget(void) { iWidget *dlg = makeSheet_Widget("ident"); setId_Widget(addChildFlags_Widget( dlg, - iClob(new_LabelWidget(uiHeading_ColorEscape "NEW IDENTITY", 0, 0, NULL)), + iClob(new_LabelWidget(uiHeading_ColorEscape "NEW IDENTITY", NULL)), frameless_WidgetFlag), "ident.heading"); iWidget *page = new_Widget(); addChildFlags_Widget( dlg, iClob( - new_LabelWidget("Creating a 2048-bit self-signed RSA certificate.", 0, 0, NULL)), + new_LabelWidget("Creating a 2048-bit self-signed RSA certificate.", NULL)), frameless_WidgetFlag); addChild_Widget(dlg, iClob(page)); setFlags_Widget(page, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); @@ -1214,10 +1215,10 @@ iWidget *makeIdentityCreation_Widget(void) { } iWidget *div = new_Widget(); { setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); - addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); + addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); addChild_Widget( div, - iClob(new_LabelWidget( + iClob(newKeyMods_LabelWidget( uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept"))); } addChild_Widget(dlg, iClob(div)); diff --git a/src/ui/window.c b/src/ui/window.c index fe731ecf..3ec4ff4f 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -388,7 +388,7 @@ static void setupUserInterface_Window(iWindow *d) { addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); /* Download progress indicator is inside the input field, but hidden normally. */ setPadding_Widget(as_Widget(url),0, 0, gap_UI * 1, 0); - iLabelWidget *progress = new_LabelWidget(uiTextCaution_ColorEscape "00.000 MB", 0, 0, NULL); + iLabelWidget *progress = new_LabelWidget(uiTextCaution_ColorEscape "00.000 MB", NULL); setId_Widget(as_Widget(progress), "document.progress"); setAlignVisually_LabelWidget(progress, iTrue); shrink_Rect(&as_Widget(progress)->rect, init_I2(0, gap_UI)); @@ -448,7 +448,7 @@ static void setupUserInterface_Window(iWindow *d) { setBackgroundColor_Widget(searchBar, uiBackground_ColorId); setCommandHandler_Widget(searchBar, handleSearchBarCommands_); addChildFlags_Widget( - searchBar, iClob(new_LabelWidget("\U0001f50d Text", 0, 0, NULL)), frameless_WidgetFlag); + searchBar, iClob(new_LabelWidget("\U0001f50d Text", NULL)), frameless_WidgetFlag); iInputWidget *input = new_InputWidget(0); setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag), "find.input"); @@ -597,6 +597,7 @@ void init_Window(iWindow *d, iRect rect) { setId_Widget(d->root, "root"); init_Text(d->render); setupUserInterface_Window(d); + postCommand_App("bindings.changed"); /* update from bindings */ updateRootSize_Window_(d); } -- 2.34.1