summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-06 17:51:52 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-06 17:51:52 +0300
commit3f0f06f1b35b6aafaa569fed3755a76aa6bed32a (patch)
treefd277dcbd2861698cc4ac33a57c5a46507f3cc11 /src
parent585cce8f501fbe86569ddd614220e977b76d57e9 (diff)
Tabs: Changing the tab button label
Diffstat (limited to 'src')
-rw-r--r--src/ui/util.c18
-rw-r--r--src/ui/util.h1
2 files changed, 19 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
343iLabelWidget *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
343void showTabPage_Widget(iWidget *tabs, const iWidget *page) { 355void 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
379void 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
367const iWidget *currentTabPage_Widget(const iWidget *tabs) { 385const 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) {
diff --git a/src/ui/util.h b/src/ui/util.h
index a23f84c1..1f35b8e8 100644
--- a/src/ui/util.h
+++ b/src/ui/util.h
@@ -100,6 +100,7 @@ void prependTabPage_Widget (iWidget *tabs, iWidget *page, const char *l
100iWidget * tabPage_Widget (iWidget *tabs, size_t index); 100iWidget * tabPage_Widget (iWidget *tabs, size_t index);
101iWidget * removeTabPage_Widget (iWidget *tabs, size_t index); /* returns the page */ 101iWidget * removeTabPage_Widget (iWidget *tabs, size_t index); /* returns the page */
102void showTabPage_Widget (iWidget *tabs, const iWidget *page); 102void showTabPage_Widget (iWidget *tabs, const iWidget *page);
103void setTabPageLabel_Widget (iWidget *tabs, const iAnyObject *page, const iString *label);
103const iWidget *currentTabPage_Widget(const iWidget *tabs); 104const iWidget *currentTabPage_Widget(const iWidget *tabs);
104size_t tabCount_Widget (const iWidget *tabs); 105size_t tabCount_Widget (const iWidget *tabs);
105 106