]> uap-core.de Git - note.git/commitdiff
implement button for inserting ordered lists
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Wed, 30 Apr 2025 18:26:34 +0000 (20:26 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Wed, 30 Apr 2025 18:26:34 +0000 (20:26 +0200)
application/gtk-text.c
application/window.c
application/window.h

index 6308980d0e24fdf1ab3d9a3851cea4c464805ab1..f876044bf5a1f69940501882ca3f3ed8d377c265 100644 (file)
@@ -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);
     }
     
index fcc1dd363942928249a4c108bcc1b40f2817e01d..8cfe55df7d51f2310d1dbb936bebef0f0ce95f21 100644 (file)
@@ -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);
     }
 }
index a5bde01ac9c4275a47bc83e9d7b560a9fdec132d..4ce670e6eec74a8f280abd62d8fb1396285f9777 100644 (file)
@@ -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);