aboutsummaryrefslogtreecommitdiff
path: root/examples_library/theme.c
diff options
context:
space:
mode:
authorAlfonso Siciliano <alfsiciliano@gmail.com>2022-01-28 08:14:55 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2022-01-28 08:14:55 +0000
commit02db4a1234b3bd9cf153e567827fd387cf91bfb2 (patch)
tree6a8d148a11a4a9d58ba1adb078d72e491339652b /examples_library/theme.c
parent77a55d2c3b4dd48a9a608736a9ba7ebce700bae1 (diff)
Diffstat (limited to 'examples_library/theme.c')
-rw-r--r--examples_library/theme.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/examples_library/theme.c b/examples_library/theme.c
index 305692d39cff..fb09aa1d1b24 100644
--- a/examples_library/theme.c
+++ b/examples_library/theme.c
@@ -16,47 +16,60 @@
int main()
{
- int output;
+ int output, focusitem;
struct bsddialog_conf conf;
enum bsddialog_default_theme theme;
- struct bsddialog_menuitem items[4] = {
- {"", false, 0, "Dialog", "Current dialog theme", "BSDDIALOG_THEME_DIALOG" },
- {"", false, 0, "BSDDialog", "Future default theme", "BSDDIALOG_THEME_DEFAULT"},
- {"", false, 0, "BlackWhite","Black and White theme", "BSDDIALOG_THEME_BLACKWHITE"},
- {"", false, 0, "Quit", "Exit", "Quit or Cancel to exit" }
+ struct bsddialog_menuitem items[5] = {
+ {"", false, 0, "Default", "dialog-like",
+ "BSDDIALOG_THEME_DEFAULT" },
+ {"", false, 0, "Dialog", "dialog clone",
+ "BSDDIALOG_THEME_DIALOG" },
+ {"", false, 0, "BSDDialog", "new theme",
+ "BSDDIALOG_THEME_BSDDIALOG" },
+ {"", false, 0, "BlackWhite","black and white",
+ "BSDDIALOG_THEME_BLACKWHITE" },
+ {"", false, 0, "Quit", "Exit", "Quit or Cancel to exit" }
};
+ if (bsddialog_init() == BSDDIALOG_ERROR) {
+ printf("Error: %s\n", bsddialog_geterror());
+ return (1);
+ }
+
bsddialog_initconf(&conf);
- conf.title = " Theme ";
-
- if (bsddialog_init() == BSDDIALOG_ERROR)
- return BSDDIALOG_ERROR;
- while (true) {
- bsddialog_backtitle(&conf, "Theme Example");
+ bsddialog_backtitle(&conf, "Theme Example");
- output = bsddialog_menu(&conf, "Choose theme", 15, 40, 4, 4, items, NULL);
+ conf.title = " Theme ";
+ focusitem = -1;
+ while (true) {
+ output = bsddialog_menu(&conf, "Choose theme", 15, 40, 5, 5,
+ items, &focusitem);
- if (output != BSDDIALOG_OK || items[3].on)
+ if (output != BSDDIALOG_OK || items[4].on)
break;
if (items[0].on) {
- theme = BSDDIALOG_THEME_DIALOG;
- conf.menu.default_item = items[0].name;
+ theme = BSDDIALOG_THEME_DEFAULT;
+ focusitem = 0;
}
else if (items[1].on) {
- theme = BSDDIALOG_THEME_BSDDIALOG;
- conf.menu.default_item = items[1].name;
+ theme = BSDDIALOG_THEME_DIALOG;
+ focusitem = 1;
}
else if (items[2].on) {
+ theme = BSDDIALOG_THEME_BSDDIALOG;
+ focusitem = 2;
+ }
+ else if (items[3].on) {
theme = BSDDIALOG_THEME_BLACKWHITE;
- conf.menu.default_item = items[2].name;
+ focusitem = 3;
}
bsddialog_set_default_theme(theme);
}
- bsddialog_end();
+ bsddialog_end();
- return output;
-}
+ return (output);
+} \ No newline at end of file