diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-06 17:51:52 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-06 17:51:52 +0300 |
commit | 3f0f06f1b35b6aafaa569fed3755a76aa6bed32a (patch) | |
tree | fd277dcbd2861698cc4ac33a57c5a46507f3cc11 /src/ui/util.c | |
parent | 585cce8f501fbe86569ddd614220e977b76d57e9 (diff) |
Tabs: Changing the tab button label
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index 8a174393..a68d340d 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -340,6 +340,18 @@ iWidget *removeTabPage_Widget(iWidget *tabs, size_t index) { | |||
340 | return page; | 340 | return page; |
341 | } | 341 | } |
342 | 342 | ||
343 | iLabelWidget *tabButtonForPage_Widget_(iWidget *tabs, const iWidget *page) { | ||
344 | iWidget *buttons = findChild_Widget(tabs, "tabs.buttons"); | ||
345 | iForEach(ObjectList, i, buttons->children) { | ||
346 | iAssert(isInstance_Object(i.object, &Class_LabelWidget)); | ||
347 | iAny *label = i.object; | ||
348 | if (pointerLabel_Command(cstr_String(command_LabelWidget(label)), "page") == page) { | ||
349 | return label; | ||
350 | } | ||
351 | } | ||
352 | return NULL; | ||
353 | } | ||
354 | |||
343 | void showTabPage_Widget(iWidget *tabs, const iWidget *page) { | 355 | void showTabPage_Widget(iWidget *tabs, const iWidget *page) { |
344 | /* Select the corresponding button. */ { | 356 | /* Select the corresponding button. */ { |
345 | iWidget *buttons = findChild_Widget(tabs, "tabs.buttons"); | 357 | iWidget *buttons = findChild_Widget(tabs, "tabs.buttons"); |
@@ -364,6 +376,12 @@ void showTabPage_Widget(iWidget *tabs, const iWidget *page) { | |||
364 | } | 376 | } |
365 | } | 377 | } |
366 | 378 | ||
379 | void setTabPageLabel_Widget(iWidget *tabs, const iAnyObject *page, const iString *label) { | ||
380 | iLabelWidget *button = tabButtonForPage_Widget_(tabs, page); | ||
381 | setText_LabelWidget(button, label); | ||
382 | arrange_Widget(tabs); | ||
383 | } | ||
384 | |||
367 | const iWidget *currentTabPage_Widget(const iWidget *tabs) { | 385 | const iWidget *currentTabPage_Widget(const iWidget *tabs) { |
368 | iWidget *pages = findChild_Widget(tabs, "tabs.pages"); | 386 | iWidget *pages = findChild_Widget(tabs, "tabs.pages"); |
369 | iConstForEach(ObjectList, i, pages->children) { | 387 | iConstForEach(ObjectList, i, pages->children) { |