Sat, 13 Dec 2025 12:19:55 +0100
add support for static_elements in the listview/dropdown widgets (Motif)
| ui/motif/list.c | file | annotate | diff | comparison | revisions | |
| ui/motif/menu.c | file | annotate | diff | comparison | revisions | |
| ui/motif/objs.mk | file | annotate | diff | comparison | revisions | |
| ui/motif/stock.c | file | annotate | diff | comparison | revisions | |
| ui/motif/stock.h | file | annotate | diff | comparison | revisions | |
| ui/motif/toolbar.c | file | annotate | diff | comparison | revisions | |
| ui/motif/toolkit.c | file | annotate | diff | comparison | revisions |
--- a/ui/motif/list.c Sat Dec 13 12:11:40 2025 +0100 +++ b/ui/motif/list.c Sat Dec 13 12:19:55 2025 +0100 @@ -95,6 +95,8 @@ listview->onselection = args->onselection; listview->onselectiondata = args->onselectiondata; + char **static_elements = args->static_elements; + size_t static_nelm = args->static_nelm; if(var) { UiList *list = var->value; list->obj = listview; @@ -102,6 +104,21 @@ list->getselection = ui_listview_getselection; list->setselection = ui_listview_setselection; ui_listview_update(list, 0); + } else if(static_elements && static_nelm > 0) { + XmStringTable items = calloc(static_nelm, sizeof(XmString)); + for(int i=0;i<static_nelm;i++) { + items[i] = XmStringCreateLocalized(static_elements[i]); + } + XtVaSetValues( + listview->widget, + XmNitems, items, + XmNitemCount, + static_nelm, + NULL); + for (int i=0;i<static_nelm;i++) { + XmStringFree(items[i]); + } + free(items); } XtAddCallback( @@ -316,6 +333,8 @@ listview->onselection = args->onselection; listview->onselectiondata = args->onselectiondata; + char **static_elements = args->static_elements; + size_t static_nelm = args->static_nelm; if(var) { UiList *list = var->value; list->obj = listview; @@ -323,6 +342,21 @@ list->getselection = ui_dropdown_getselection; list->setselection = ui_dropdown_setselection; ui_listview_update(list, 0); + } else if(static_elements && static_nelm > 0) { + XmStringTable items = calloc(static_nelm, sizeof(XmString)); + for(int i=0;i<static_nelm;i++) { + items[i] = XmStringCreateLocalized(static_elements[i]); + } + XtVaSetValues( + listview->widget, + XmNitems, items, + XmNitemCount, + static_nelm, + NULL); + for (int i=0;i<static_nelm;i++) { + XmStringFree(items[i]); + } + free(items); } XtAddCallback(
--- a/ui/motif/menu.c Sat Dec 13 12:11:40 2025 +0100 +++ b/ui/motif/menu.c Sat Dec 13 12:19:55 2025 +0100 @@ -33,7 +33,6 @@ #include "menu.h" #include "button.h" #include "toolkit.h" -#include "stock.h" #include "container.h" #include "../common/context.h" #include "../common/menu.h"
--- a/ui/motif/objs.mk Sat Dec 13 12:11:40 2025 +0100 +++ b/ui/motif/objs.mk Sat Dec 13 12:19:55 2025 +0100 @@ -30,7 +30,6 @@ MOTIF_OBJPRE = $(OBJ_DIR)$(MOTIF_SRC_DIR) MOTIFOBJ = toolkit.o -MOTIFOBJ += stock.o MOTIFOBJ += window.o MOTIFOBJ += widget.o MOTIFOBJ += container.o
--- a/ui/motif/stock.c Sat Dec 13 12:11:40 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2014 Olaf Wintermann. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "stock.h" -#include "../ui/properties.h" -#include <cx/hash_map.h> - -
--- a/ui/motif/stock.h Sat Dec 13 12:11:40 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2014 Olaf Wintermann. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef STOCK_H -#define STOCK_H - -#include "../ui/stock.h" - -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifdef __cplusplus -} -#endif - -#endif /* STOCK_H */ -
--- a/ui/motif/toolbar.c Sat Dec 13 12:11:40 2025 +0100 +++ b/ui/motif/toolbar.c Sat Dec 13 12:19:55 2025 +0100 @@ -33,7 +33,6 @@ #include "toolbar.h" #include "button.h" -#include "stock.h" #include "list.h" #include <cx/hash_map.h>
--- a/ui/motif/toolkit.c Sat Dec 13 12:11:40 2025 +0100 +++ b/ui/motif/toolkit.c Sat Dec 13 12:19:55 2025 +0100 @@ -34,7 +34,6 @@ #include "toolkit.h" #include "toolbar.h" #include "container.h" -#include "stock.h" #include "../common/menu.h" #include "../common/toolbar.h" #include "../common/document.h"