# HG changeset patch # User Olaf Wintermann # Date 1399800933 -7200 # Node ID e4198fc2ead4977adc1ef99e10307db9eef2a63f # Parent 3e8b5c9b4033918af1d159ba1d69502baaf53508 fixed list, text and added ui_close (Motif) diff -r 3e8b5c9b4033 -r e4198fc2ead4 ui/motif/container.c --- a/ui/motif/container.c Sun May 11 10:41:29 2014 +0200 +++ b/ui/motif/container.c Sun May 11 11:35:33 2014 +0200 @@ -63,7 +63,7 @@ XtSetArg(args[0], XmNshadowType, XmSHADOW_ETCHED_OUT); XtSetArg(args[1], XmNshadowThickness, 0); Widget sidebar = XmCreateFrame(pane, "sidebar", args, 2); - //XtManageChild(sidebar); + XtManageChild(sidebar); UiObject *left = uic_object_new(obj, sidebar); left->container = ui_frame_container(left, sidebar); diff -r 3e8b5c9b4033 -r e4198fc2ead4 ui/motif/list.c --- a/ui/motif/list.c Sun May 11 10:41:29 2014 +0200 +++ b/ui/motif/list.c Sun May 11 11:35:33 2014 +0200 @@ -47,21 +47,14 @@ UIWIDGET ui_listview_var(UiObject *obj, UiListPtr *list, ui_model_getvalue_f getvalue, ui_callback f, void *udata) { UiList *ls = list->list; - //int count; - //XmStringTable items = ui_create_stringlist(list->list, getvalue, &count); - int count = list->list->count(list->list); - XmStringTable items = (XmStringTable)XtMalloc(count * sizeof(XmString)); - void *data = list->list->first(list->list); - for(int i=0;ilist->next(list->list); - } + int count; + XmStringTable items = ui_create_stringlist(list->list, getvalue, &count); Arg args[8]; int n = 0; XtSetArg(args[n], XmNitemCount, count); n++; - XtSetArg(args[n], XmNitems, NULL); + XtSetArg(args[n], XmNitems, count == 0 ? NULL : items); n++; UiContainer *ct = uic_get_current_container(obj); @@ -142,7 +135,12 @@ view->getvalue, &count); - XtVaSetValues(view->widget, XmNitems, items, XmNitemCount, count, NULL); + XtVaSetValues( + view->widget, + XmNitems, count == 0 ? NULL : items, + XmNitemCount, + count, + NULL); for (int i=0;ivalue) { + XmTextSetString(text_area, value->value); + } + value->set = ui_textarea_set; value->get = ui_textarea_get; value->getsubstr = ui_textarea_getsubstr; diff -r 3e8b5c9b4033 -r e4198fc2ead4 ui/motif/toolbar.c --- a/ui/motif/toolbar.c Sun May 11 10:41:29 2014 +0200 +++ b/ui/motif/toolbar.c Sun May 11 11:35:33 2014 +0200 @@ -191,7 +191,8 @@ XmString label = XmStringCreateLocalized(item->label); XtSetArg(args[0], XmNlabelString, label); XtSetArg(args[1], XmNshadowThickness, 1); - Widget button = XmCreatePushButton(parent, "toolbar_button", args, 2); + XtSetArg(args[2], XmNtraversalOn, FALSE); + Widget button = XmCreatePushButton(parent, "toolbar_button", args, 3); XmStringFree(label); @@ -224,8 +225,8 @@ XmString label = XmStringCreateLocalized(stock_item->label); XtSetArg(args[0], XmNlabelString, label); XtSetArg(args[1], XmNshadowThickness, 1); - //XtSetArg(args[2], XmNhighlightThickness, 0); - Widget button = XmCreatePushButton(parent, "toolbar_button", args, 2); + XtSetArg(args[2], XmNtraversalOn, FALSE); + Widget button = XmCreatePushButton(parent, "toolbar_button", args, 3); XmStringFree(label); @@ -256,8 +257,9 @@ XmString label = XmStringCreateLocalized(item->label); XtSetArg(args[0], XmNlabelString, label); XtSetArg(args[1], XmNshadowThickness, 1); - XtSetArg(args[2], XmNindicatorOn, XmINDICATOR_NONE); - Widget button = XmCreateToggleButton(parent, "toolbar_toggle_button", args, 3); + XtSetArg(args[2], XmNtraversalOn, FALSE); + XtSetArg(args[3], XmNindicatorOn, XmINDICATOR_NONE); + Widget button = XmCreateToggleButton(parent, "toolbar_toggle_button", args, 4); XmStringFree(label); diff -r 3e8b5c9b4033 -r e4198fc2ead4 ui/motif/toolkit.c --- a/ui/motif/toolkit.c Sun May 11 10:41:29 2014 +0200 +++ b/ui/motif/toolkit.c Sun May 11 11:35:33 2014 +0200 @@ -83,7 +83,12 @@ fprintf(stderr, "UiError: Cannot create event pipe\n"); exit(-1); } - XtAppAddInput(app, event_pipe[0], XtInputReadMask, input_proc, NULL); + XtAppAddInput( + app, + event_pipe[0], + (XtPointer)XtInputReadMask, + input_proc, + NULL); } char* ui_appname() { @@ -111,6 +116,10 @@ uic_store_app_properties(); } +void ui_exit_mainloop() { + XtAppSetExitFlag(app); +} + void ui_secondary_event_loop(int *loop) { while(*loop && !XtAppGetExitFlag(app)) { XEvent event; @@ -124,9 +133,8 @@ XtRealizeWidget(obj->widget); } -void ui_close(UiObject *obj) { - // TODO -} +// implemented in window.c +//void ui_close(UiObject *obj) void ui_set_enabled(UIWIDGET widget, int enabled) { XtSetSensitive(widget, enabled); diff -r 3e8b5c9b4033 -r e4198fc2ead4 ui/motif/toolkit.h --- a/ui/motif/toolkit.h Sun May 11 10:41:29 2014 +0200 +++ b/ui/motif/toolkit.h Sun May 11 11:35:33 2014 +0200 @@ -54,6 +54,8 @@ void *finish_data; } UiJob; +void ui_exit_mainloop(); + void ui_set_active_window(Widget w); Widget ui_get_active_window(); diff -r 3e8b5c9b4033 -r e4198fc2ead4 ui/motif/window.c --- a/ui/motif/window.c Sun May 11 10:41:29 2014 +0200 +++ b/ui/motif/window.c Sun May 11 11:35:33 2014 +0200 @@ -44,7 +44,7 @@ static void window_close_handler(Widget window, void *udata, void *cdata) { nwindows--; if(nwindows == 0) { - exit(0); + ui_exit_mainloop(); } } @@ -128,6 +128,11 @@ return obj; } +void ui_close(UiObject *obj) { + XtDestroyWidget(obj->widget); + window_close_handler(obj->widget, obj, NULL); +} + typedef struct FileDialogData { int running; char *file;