From 3aa83c423f16b37c6efb302baa886a6741e34ade Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Fri, 19 Jun 2026 21:40:05 +0200 Subject: [PATCH] remove maximized setting from the navigation stack --- application/menu.c | 6 +++--- application/nbconfig.c | 6 +++--- application/src/notebook.rs | 21 +++++++-------------- application/src/window.rs | 2 +- application/window.c | 16 ++++++++-------- ui-rs/src/ui/toolkit.rs | 1 + ui/common/context.c | 4 +--- ui/common/document.c | 1 - 8 files changed, 24 insertions(+), 33 deletions(-) diff --git a/application/menu.c b/application/menu.c index 648ad32..a0d6449 100644 --- a/application/menu.c +++ b/application/menu.c @@ -44,10 +44,10 @@ void menu_cleanup() { void toolbar_init() { ui_toolbar_item("GoBack", .icon = UI_ICON_GO_BACK, .onclick = action_go_back); ui_toolbar_item("GoForward", .icon = UI_ICON_GO_FORWARD, .onclick = action_go_forward); - ui_toolbar_item("AddNote", .icon = UI_ICON_ADD, .onclick = action_note_new, .states = UI_GROUPS(APP_STATE_NOTEBOOK_SELECTED)); + ui_toolbar_item("AddNote", .icon = UI_ICON_ADD, .onclick = action_note_new, .states = UI_STATES(APP_STATE_NOTEBOOK_SELECTED)); - ui_toolbar_item("GoBack2", .icon = UI_ICON_GO_BACK, .onclick = action_go_back, .visibility_states = UI_GROUPS(APP_STATE_HIDE_NOTELIST)); - ui_toolbar_item("GoForward2", .icon = UI_ICON_GO_FORWARD, .onclick = action_go_forward, .visibility_states = UI_GROUPS(APP_STATE_HIDE_NOTELIST)); + ui_toolbar_item("GoBack2", .icon = UI_ICON_GO_BACK, .onclick = action_go_back, .visibility_states = UI_STATES(APP_STATE_HIDE_NOTELIST)); + ui_toolbar_item("GoForward2", .icon = UI_ICON_GO_FORWARD, .onclick = action_go_forward, .visibility_states = UI_STATES(APP_STATE_HIDE_NOTELIST)); ui_toolbar_appmenu() { ui_menuitem("New Window", .onclick = action_new_window); diff --git a/application/nbconfig.c b/application/nbconfig.c index e48c1ec..7ee1d7d 100644 --- a/application/nbconfig.c +++ b/application/nbconfig.c @@ -697,7 +697,7 @@ void notebook_config_dialog(void) { ui_button(obj, .label = "New Notebook", .onclick = nbconfig_notebooklist_add_notebook); ui_button(obj, .icon = UI_ICON_GO_UP, .onclick = nbconfig_notebooklist_move_up); ui_button(obj, .icon = UI_ICON_GO_DOWN, .onclick = nbconfig_notebooklist_move_down); - ui_button(obj, .icon = UI_ICON_DELETE, .onclick = nbconfig_notebooklist_delete); + ui_button(obj, .icon = UI_ICON_REMOVE, .onclick = nbconfig_notebooklist_delete); } UiModel *model = ui_model(obj->ctx, UI_STRING, "Notebook", -1); model->columnsize[0] = -1; @@ -743,7 +743,7 @@ void notebook_config_dialog(void) { ui_listview(obj, .list = wdata->tab3_repositories, .getvalue = repolist_get_value, .fill = TRUE, .onselection = nbconfig_repolist_onselect); ui_hbox(obj) { ui_button(obj, .icon = UI_ICON_NEW_FOLDER, .onclick = nbconfig_repolist_add); - ui_button(obj, .icon = UI_ICON_DELETE, .onclick = nbconfig_repolist_delete); + ui_button(obj, .icon = UI_ICON_REMOVE, .onclick = nbconfig_repolist_delete); } } @@ -765,7 +765,7 @@ void notebook_config_dialog(void) { ui_newline(obj); ui_rlabel(obj, .label = "Encryption key"); - ui_dropdown(obj, .list = wdata->tab3_repo_encryption_key, .states = UI_GROUPS(NBCONFIG_STATE_REPOSITORY_ENCRYPTION), .hfill = TRUE); + ui_dropdown(obj, .list = wdata->tab3_repo_encryption_key, .states = UI_STATES(NBCONFIG_STATE_REPOSITORY_ENCRYPTION), .hfill = TRUE); } } diff --git a/application/src/notebook.rs b/application/src/notebook.rs index eaa0f7a..4f8d352 100644 --- a/application/src/notebook.rs +++ b/application/src/notebook.rs @@ -129,7 +129,7 @@ impl Notebook { } } - pub fn select_note_from(&mut self, from: NoteSelectFrom, maximized: bool) -> Option<()> { + pub fn select_note_from(&mut self, from: NoteSelectFrom) -> Option<()> { let mut add_to_nav = false; let (selected_index, note) = match from { NoteSelectFrom::ListSelection(s) => { @@ -157,7 +157,7 @@ impl Notebook { let is_new = note.is_new(); let id = note.id.clone(); - let nav = NavigationItem { collection_id: self.collection_id, note_id: Some(note.id.clone()), note_maximized: maximized }; + let nav = NavigationItem { collection_id: self.collection_id, note_id: Some(note.id.clone()) }; let doc = if let Some(doc) = ¬e.model { doc.clone() } else { @@ -186,7 +186,7 @@ impl Notebook { #[action] pub fn note_selected(&mut self, event: &ActionEvent) { if let EventType::ListSelection(s) = event.event_type { - self.select_note_from(NoteSelectFrom::ListSelection(s), false); + self.select_note_from(NoteSelectFrom::ListSelection(s)); } } @@ -195,7 +195,7 @@ impl Notebook { let obj = &mut event.obj.as_mut()?; if let EventType::ListSelection(s) = event.event_type { - let result = self.select_note_from(NoteSelectFrom::ListSelection(s), true); + let result = self.select_note_from(NoteSelectFrom::ListSelection(s)); //obj.splitview_set_visible(0, false); self.view.set(1); // in case select_note_from didn't return a result, the note was already selected @@ -204,8 +204,7 @@ impl Notebook { let current = &self.selected_note.as_ref()?; let nav = NavigationItem { collection_id: self.collection_id, - note_id: Some(current.id.clone()), - note_maximized: true + note_id: Some(current.id.clone()) }; let arg: Box = Box::new(nav); @@ -227,20 +226,14 @@ impl Notebook { } #[action(NavigationItem)] - pub fn navigate_to_note(&mut self, event: &mut ActionEvent, nav: &NavigationItem) { - let Some(obj) = &mut event.obj else { - return; - }; - + pub fn navigate_to_note(&mut self, _event: &mut ActionEvent, nav: &NavigationItem) { //println!("navigate to note"); if nav.collection_id != self.collection_id { println!("invalid navigation event: notebook collection_id {} != {}", self.collection_id, nav.collection_id); return; } - self.select_note_from(NoteSelectFrom::NavigationItem(nav.clone()), false); - //obj.splitview_set_visible(0, !nav.note_maximized); - //self.view.set(nav.note_maximized as i64); + self.select_note_from(NoteSelectFrom::NavigationItem(nav.clone())); } pub fn update_note_title(&mut self, update: &NoteTitleUpdate) { diff --git a/application/src/window.rs b/application/src/window.rs index 8a25c64..d710649 100644 --- a/application/src/window.rs +++ b/application/src/window.rs @@ -212,6 +212,7 @@ pub fn create_window(app: &App, ctx: &AppContext) -> UiObject, - pub note_maximized: bool } pub enum NavDirection { diff --git a/application/window.c b/application/window.c index 6aabbb5..e4c75aa 100644 --- a/application/window.c +++ b/application/window.c @@ -106,7 +106,7 @@ void window_create() { ui_vbox(obj, .fill = TRUE) { ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE) { //ui_label(obj, .label = "Title", .vfill = TRUE); - ui_textfield(obj, .varname = "note_title", .onchange = action_note_title_changed, .hexpand = TRUE, .hfill = TRUE, .states = UI_GROUPS(APP_STATE_NOTE_SELECTED)); + ui_textfield(obj, .varname = "note_title", .onchange = action_note_title_changed, .hexpand = TRUE, .hfill = TRUE, .states = UI_STATES(APP_STATE_NOTE_SELECTED)); ui_newline(obj); } ui_hbox(obj, .style_class = "note_toolbar", .margin = 10, .spacing = 4) { @@ -120,7 +120,7 @@ void window_create() { ui_button(obj, .icon = "insert-image", .onclick = action_textnote_insertimg); ui_button(obj, .icon = "insert-link"); } - ui_hbox_w(obj, wdata->attachments, .margin = 10, .visibility_states = UI_GROUPS(APP_STATE_NOTE_HAS_ATTACHMENTS)) { + ui_hbox_w(obj, wdata->attachments, .margin = 10, .visibility_states = UI_STATES(APP_STATE_NOTE_HAS_ATTACHMENTS)) { UIWIDGET sw; ui_scrolledwindow_w(obj, sw, .name = "note_attachments_sw") { ui_itemlist(obj, .varname = "note_attachments", .container = UI_CONTAINER_HBOX, .create_ui = attachment_item, .userdata = wdata); @@ -132,10 +132,10 @@ void window_create() { #if GTK_MAJOR_VERSION >= 4 ui_customwidget(obj, editor_gtk4_workaround, wdata, .hfill = TRUE); #endif - wdata->textview = ui_textarea(obj, .varname = "note_text", .vfill = TRUE, .hfill = TRUE, .hexpand = TRUE, .vexpand = TRUE, .colspan = 2, .states = UI_GROUPS(APP_STATE_NOTE_SELECTED), .fill = UI_ON); + wdata->textview = ui_textarea(obj, .varname = "note_text", .vfill = TRUE, .hfill = TRUE, .hexpand = TRUE, .vexpand = TRUE, .colspan = 2, .states = UI_STATES(APP_STATE_NOTE_SELECTED), .fill = UI_ON); editor_init_textview(obj, ui_textarea_gettextwidget(wdata->textview)); - ui_grid(obj, .margin = 4, .columnspacing = 4, .rowspacing = 4, .def_hfill = TRUE, .def_vfill = TRUE, .visibility_states = UI_GROUPS(APP_STATE_NOTE_FIND)) { + ui_grid(obj, .margin = 4, .columnspacing = 4, .rowspacing = 4, .def_hfill = TRUE, .def_vfill = TRUE, .visibility_states = UI_STATES(APP_STATE_NOTE_FIND)) { ui_rlabel(obj, .label = "Find"); wdata->searchbar_textfield = ui_textfield(obj, .hexpand = TRUE, .onactivate = action_searchbar_next, .varname = "search"); ui_button(obj, .label = "Previous", .onclick = action_searchbar_prev); @@ -145,10 +145,10 @@ void window_create() { ui_button(obj, .icon = "window-close", .onclick = action_searchbar_close); ui_newline(obj); - ui_rlabel(obj, .label = "Replace", .visibility_states = UI_GROUPS(APP_STATE_NOTE_REPLACE)); - ui_textfield(obj, .hexpand = TRUE, .varname = "replace", .visibility_states = UI_GROUPS(APP_STATE_NOTE_REPLACE), .onactivate = action_searchbar_replace); - ui_button(obj, .label = "Replace", .visibility_states = UI_GROUPS(APP_STATE_NOTE_REPLACE), .onclick = action_searchbar_replace); - ui_button(obj, .label = "Replace All", .visibility_states = UI_GROUPS(APP_STATE_NOTE_REPLACE), .onclick = action_searchbar_replace_all); + ui_rlabel(obj, .label = "Replace", .visibility_states = UI_STATES(APP_STATE_NOTE_REPLACE)); + ui_textfield(obj, .hexpand = TRUE, .varname = "replace", .visibility_states = UI_STATES(APP_STATE_NOTE_REPLACE), .onactivate = action_searchbar_replace); + ui_button(obj, .label = "Replace", .visibility_states = UI_STATES(APP_STATE_NOTE_REPLACE), .onclick = action_searchbar_replace); + ui_button(obj, .label = "Replace All", .visibility_states = UI_STATES(APP_STATE_NOTE_REPLACE), .onclick = action_searchbar_replace_all); } } } diff --git a/ui-rs/src/ui/toolkit.rs b/ui-rs/src/ui/toolkit.rs index 4e7580d..473396e 100644 --- a/ui-rs/src/ui/toolkit.rs +++ b/ui-rs/src/ui/toolkit.rs @@ -59,6 +59,7 @@ impl Default for UiContext { } } + impl UiContext { pub fn from_ptr(ctx: *mut ffi::UiContext) -> UiContext { UiContext { diff --git a/ui/common/context.c b/ui/common/context.c index a3ae312..757056f 100644 --- a/ui/common/context.c +++ b/ui/common/context.c @@ -136,8 +136,7 @@ void uic_context_destroy(UiContext *ctx, void *document) { } uic_context_detach_all(ctx); - - printf("cxMempoolFree %p\n", ctx); + cxMempoolFree(ctx->mp); } @@ -282,7 +281,6 @@ void uic_context_detach_all(UiContext *ctx) { i = cxListIterator(ls); cx_foreach(void *, doc, i) { uic_context_detach_document(ctx, doc); - uic_send_status_change(ui_document_context(doc), NULL); } cxListFree(ls); diff --git a/ui/common/document.c b/ui/common/document.c index 6635bad..287b5b5 100644 --- a/ui/common/document.c +++ b/ui/common/document.c @@ -64,7 +64,6 @@ void ui_document_unref(void *doc) { UiContext *ctx = ui_document_context(doc); if(ctx) { if(--ctx->ref == 0) { - printf("doc destroy %p ctx %p\n", doc, ctx); uic_context_destroy(ctx, doc); } } -- 2.52.0