From: Olaf Wintermann Date: Wed, 30 Apr 2025 18:26:34 +0000 (+0200) Subject: implement button for inserting ordered lists X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=8c35399945ec535f11d3c09d3f1890558a27971a;p=note.git implement button for inserting ordered lists --- diff --git a/application/gtk-text.c b/application/gtk-text.c index 6308980..f876044 100644 --- a/application/gtk-text.c +++ b/application/gtk-text.c @@ -1243,7 +1243,7 @@ void editor_insert_list_element(NoteEditor *editor, GtkTextIter *iter, const cha elm->str = strdup("•"); } else { char buf[32]; - snprintf(buf, 32, "%d", num); + snprintf(buf, 32, "%d.", num+1); elm->str = strdup(buf); } diff --git a/application/window.c b/application/window.c index fcc1dd3..8cfe55d 100644 --- a/application/window.c +++ b/application/window.c @@ -83,8 +83,8 @@ void window_create() { ui_togglebutton(obj, .icon = "format-text-italic", .varname = "note_textnote_emphasis", .onchange = action_textnote_style_emphasis); ui_togglebutton(obj, .icon = "format-text-underline", .varname = "note_textnote_underline", .onchange = action_textnote_style_underline); ui_togglebutton(obj, .label = "code", .varname = "note_textnote_code", .onchange = action_textnote_style_code); - ui_button(obj, .icon = "view-list-bullet", .onclick = action_textnote_insertlist); - ui_button(obj, .icon = "view-list-ordered"); + ui_button(obj, .icon = "view-list-bullet", .onclick = action_textnote_insertlist, .onclickdata = ACTION_DATA_INSERT_LIST_UNORDERED); + ui_button(obj, .icon = "view-list-ordered", .onclick = action_textnote_insertlist, .onclickdata = ACTION_DATA_INSERT_LIST_ORDERED); ui_button(obj, .icon = "insert-image"); ui_button(obj, .icon = "insert-link"); } @@ -391,9 +391,10 @@ void action_textnote_insertlist(UiEvent *event, void *userdata) { if(event->set) { return; } + intptr_t ordered = (intptr_t)userdata; MainWindow *window = event->window; NotebookModel *notebook = window->current_notebook; if(notebook && notebook->current_note && notebook->current_note->model) { - note_insert_list(notebook->current_note->model, FALSE); + note_insert_list(notebook->current_note->model, (UiBool)ordered); } } diff --git a/application/window.h b/application/window.h index a5bde01..4ce670e 100644 --- a/application/window.h +++ b/application/window.h @@ -36,6 +36,9 @@ extern "C" { #endif +#define ACTION_DATA_INSERT_LIST_ORDERED (void*)(intptr_t)1 +#define ACTION_DATA_INSERT_LIST_UNORDERED (void*)(intptr_t)0 + void window_create(); MainWindow* window_init_data(UiObject *obj);