add ui_motif_get_app()

Tue, 28 Oct 2025 21:13:35 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 28 Oct 2025 21:13:35 +0100
changeset 882
75de79b155e3
parent 881
e0bbf466915f
child 883
e7af67e32691

add ui_motif_get_app()

application/demo_bindings.c file | annotate | diff | comparison | revisions
ui/motif/toolkit.c file | annotate | diff | comparison | revisions
ui/motif/toolkit.h file | annotate | diff | comparison | revisions
--- a/application/demo_bindings.c	Tue Oct 28 14:25:46 2025 +0100
+++ b/application/demo_bindings.c	Tue Oct 28 21:13:35 2025 +0100
@@ -65,10 +65,18 @@
     if(event->document) {
         ui_detach_document(event->obj->ctx, event->document);
     }
+    printf("selection: %d\n", event->intval);
     Document *doc = ui_list_get(wdata->doclist, event->intval);
     if(doc) {
+        char *s1 = ui_get(doc->id);
+        char *s2 = ui_get(doc->name);
+        printf("doc %s - %s\n", s1, s2);
         ui_attach_document(event->obj->ctx, doc);
+        
     }
+    //UiListSelection sel = ui_list_getselection(wdata->doclist);
+    //printf("sel: %d\n", sel.rows[0]);
+    //ui_listselection_free(sel);
 }
 
 void* doclist_get_value(void *elm, int col) {
@@ -92,7 +100,7 @@
         ui_llabel(obj, .varname = "name");
         ui_newline(obj);
         
-        ui_combobox(obj, .varname = "doclist", .colspan = 2, .onactivate = switch_document, .getvalue = doclist_get_value);
+        ui_combobox(obj, .varname = "doclist", .colspan = 2, .onactivate = switch_document, .getvalue = doclist_get_value, .colspan = 2, .hfill = TRUE);
         ui_newline(obj);
         
         ui_frame(obj, .label = "Document", .colspan = 2, .fill = TRUE) {
@@ -108,6 +116,7 @@
         ui_list_append(wdata->doclist, doc);
     }
     ui_list_update(wdata->doclist);
+    ui_list_setselection(wdata->doclist, 0);
     Document *doc = ui_list_get(wdata->doclist, 0);
     ui_attach_document(obj->ctx, doc);
     
--- a/ui/motif/toolkit.c	Tue Oct 28 14:25:46 2025 +0100
+++ b/ui/motif/toolkit.c	Tue Oct 28 21:13:35 2025 +0100
@@ -120,6 +120,10 @@
     return application_name;
 }
 
+XtAppContext ui_motif_get_app(void) {
+    return app;
+}
+
 Display* ui_motif_get_display() {
     return display;
 }
--- a/ui/motif/toolkit.h	Tue Oct 28 14:25:46 2025 +0100
+++ b/ui/motif/toolkit.h	Tue Oct 28 21:13:35 2025 +0100
@@ -84,6 +84,7 @@
 
 void ui_exit_mainloop();
 
+XtAppContext ui_motif_get_app(void);
 Display* ui_motif_get_display(void);
 
 void ui_set_active_window(Widget w);

mercurial