From b693524b2a13de0394aacf11c40a4e5dc33e50f9 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Tue, 25 Feb 2025 21:35:40 +0100 Subject: [PATCH] add APP_STATE_NOTEBOOK_SELECTED UI state, make AddNote button only enabled, when a Notebook is selected --- application/application.h | 3 ++- application/menu.c | 2 +- application/types.c | 2 +- application/window.c | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/application/application.h b/application/application.h index e46198c..21cfd86 100644 --- a/application/application.h +++ b/application/application.h @@ -38,7 +38,8 @@ extern "C" { #endif -#define APP_STATE_NOTE_SELECTED 100 +#define APP_STATE_NOTEBOOK_SELECTED 100 +#define APP_STATE_NOTE_SELECTED 110 // typedefs for NotebookModel and NoteModel are in types.h diff --git a/application/menu.c b/application/menu.c index 760cdc8..ee5dcba 100644 --- a/application/menu.c +++ b/application/menu.c @@ -33,7 +33,7 @@ void menu_init() { } void toolbar_init() { - ui_toolbar_item("AddNote", .icon = UI_ICON_ADD, .onclick = action_note_new); + ui_toolbar_item("AddNote", .icon = UI_ICON_ADD, .onclick = action_note_new, .groups = UI_GROUPS(APP_STATE_NOTEBOOK_SELECTED)); ui_toolbar_add_default("AddNote", UI_TOOLBAR_LEFT); diff --git a/application/types.c b/application/types.c index 1bdc526..7f5c563 100644 --- a/application/types.c +++ b/application/types.c @@ -77,4 +77,4 @@ void register_types() { dbuClassAdd(repository_class, Repository, default_key); dbuClassAdd(repository_class, Repository, authmethod); dbuClassAdd(repository_class, Repository, encryption); -} \ No newline at end of file +} diff --git a/application/window.c b/application/window.c index 323bad5..84e3230 100644 --- a/application/window.c +++ b/application/window.c @@ -180,6 +180,7 @@ void action_notebook_selected(UiEvent *event, void *userdata) { Collection *collection = data->row_data; printf("notebook selected: %s\n", collection->name); + ui_set_group(event->obj->ctx, APP_STATE_NOTEBOOK_SELECTED); if(window->current_notebook && window->current_notebook->collection == collection) { return; // notebook already selected -- 2.43.5