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);
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;
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);
}
}
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);
}
}
}
}
- 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) => {
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 {
#[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));
}
}
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
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<dyn Any> = Box::new(nav);
}
#[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) {
}
let notebook_doc = nb.get_doc(&e.data.backend);
+ e.obj.splitview_set_visible(0, true);
e.obj.ctx.attach(¬ebook_doc);
e.data.selected_notebook = Some(notebook_doc);
//e.obj.splitview_set_visible(0, !nav.note_maximized);
pub struct NavigationItem {
pub collection_id: i32,
pub note_id: Option<NoteId>,
- pub note_maximized: bool
}
pub enum NavDirection {
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) {
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);
#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);
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);
}
}
}
}
}
+
impl UiContext {
pub fn from_ptr(ctx: *mut ffi::UiContext) -> UiContext {
UiContext {
}
uic_context_detach_all(ctx);
-
- printf("cxMempoolFree %p\n", ctx);
+
cxMempoolFree(ctx->mp);
}
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);
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);
}
}