]> uap-core.de Git - note.git/commitdiff
add APP_STATE_NOTEBOOK_SELECTED UI state, make AddNote button only enabled, when...
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 25 Feb 2025 20:35:40 +0000 (21:35 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 25 Feb 2025 20:35:40 +0000 (21:35 +0100)
application/application.h
application/menu.c
application/types.c
application/window.c

index e46198c8020f5e82bcb6c51fbc287ffdb0465caf..21cfd86c0071966d03bc2a342381f2d9f4a195ff 100644 (file)
@@ -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
     
index 760cdc8b5a8847bd2bbca0c99d530a7558c47233..ee5dcba35170af234987ccea81fe4e219e313f3c 100644 (file)
@@ -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);
index 1bdc526085d386aee49e947c47f71931a386bbc2..7f5c563fb4cd90ed90e3add64c68c5e6b6b67b5f 100644 (file)
@@ -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
+}
index 323bad50b78636a8151c5502d55f043507d6676b..84e3230879ecf7abbebbb2bcdeea8455255681c0 100644 (file)
@@ -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