# HG changeset patch # User Olaf Wintermann # Date 1780423977 -7200 # Node ID 881dfcf46cd6d83a6e74fa8fc9b83838d5b7b23f # Parent 9811e27e0889ffdaf75dc18573119611b79a6df7 add ui_icon_name diff -r 9811e27e0889 -r 881dfcf46cd6 ui/common/Makefile --- a/ui/common/Makefile Tue Jun 02 19:48:15 2026 +0200 +++ b/ui/common/Makefile Tue Jun 02 20:12:57 2026 +0200 @@ -63,6 +63,10 @@ common/action.h $(CC) -o $@ $(CFLAGS) -I../ucx $(SHLIB_CFLAGS) $(TK_CFLAGS) -c $< +$(COMMON_OBJPRE)uic_icons$(OBJ_EXT): common/icons.c common/icons.h \ + common/../ui/icons.h common/../ui/toolkit.h + $(CC) -o $@ $(CFLAGS) -I../ucx $(SHLIB_CFLAGS) $(TK_CFLAGS) -c $< + $(COMMON_OBJPRE)uic_menu$(OBJ_EXT): common/menu.c common/menu.h \ common/../ui/menu.h common/../ui/toolkit.h $(CC) -o $@ $(CFLAGS) -I../ucx $(SHLIB_CFLAGS) $(TK_CFLAGS) -c $< diff -r 9811e27e0889 -r 881dfcf46cd6 ui/common/icons.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/common/icons.c Tue Jun 02 20:12:57 2026 +0200 @@ -0,0 +1,49 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2026 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 "icons.h" + +const char* ui_icon_name(enum UiIconId icon_id) { + switch(icon_id) { + case UI_ICON_ID_HOME : return UI_ICON_HOME; + case UI_ICON_ID_NEW_WINDOW : return UI_ICON_NEW_WINDOW; + case UI_ICON_ID_REFRESH : return UI_ICON_REFRESH; + case UI_ICON_ID_NEW_FOLDER : return UI_ICON_NEW_FOLDER; + case UI_ICON_ID_ADD : return UI_ICON_ADD; + case UI_ICON_ID_UPLOAD : return UI_ICON_UPLOAD; + case UI_ICON_ID_SAVE_LOCAL : return UI_ICON_SAVE_LOCAL; + case UI_ICON_ID_DELETE : return UI_ICON_DELETE; + case UI_ICON_ID_DOCK_LEFT : return UI_ICON_DOCK_LEFT; + case UI_ICON_ID_DOCK_RIGHT : return UI_ICON_DOCK_RIGHT; + case UI_ICON_ID_GO_BACK : return UI_ICON_GO_BACK; + case UI_ICON_ID_GO_FORWARD : return UI_ICON_GO_FORWARD; + case UI_ICON_ID_GO_UP : return UI_ICON_GO_UP; + case UI_ICON_ID_GO_DOWN : return UI_ICON_GO_DOWN; + } + return NULL; +} diff -r 9811e27e0889 -r 881dfcf46cd6 ui/common/icons.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/common/icons.h Tue Jun 02 20:12:57 2026 +0200 @@ -0,0 +1,44 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2026 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 UIC_ICONS_H +#define UIC_ICONS_H + +#include "../ui/icons.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* UIC_ICONS_H */ + diff -r 9811e27e0889 -r 881dfcf46cd6 ui/common/objs.mk --- a/ui/common/objs.mk Tue Jun 02 19:48:15 2026 +0200 +++ b/ui/common/objs.mk Tue Jun 02 20:12:57 2026 +0200 @@ -45,6 +45,7 @@ COMMON_OBJ += wrapper$(OBJ_EXT) COMMON_OBJ += utils$(OBJ_EXT) COMMON_OBJ += message$(OBJ_EXT) +COMMON_OBJ += icons$(OBJ_EXT) TOOLKITOBJS += $(COMMON_OBJ:%=$(COMMON_OBJPRE)uic_%) TOOLKITSOURCE += $(COMMON_OBJ:%$(OBJ_EXT)=common/%.c) diff -r 9811e27e0889 -r 881dfcf46cd6 ui/gtk/icon.c --- a/ui/gtk/icon.c Tue Jun 02 19:48:15 2026 +0200 +++ b/ui/gtk/icon.c Tue Jun 02 20:12:57 2026 +0200 @@ -123,6 +123,8 @@ char *path = g_file_get_path(file); if(!path) { icon = ui_icon("application-x-generic", size); + } else { + g_free(path); } #else if(!icon) { @@ -143,6 +145,7 @@ GError *error = NULL; char *path = g_file_get_path(file); icon->pixbuf = gdk_pixbuf_new_from_file(path, &error); + g_free(path); } return icon->pixbuf; } diff -r 9811e27e0889 -r 881dfcf46cd6 ui/gtk/list.c --- a/ui/gtk/list.c Tue Jun 02 19:48:15 2026 +0200 +++ b/ui/gtk/list.c Tue Jun 02 20:12:57 2026 +0200 @@ -260,7 +260,7 @@ } else if(type == UI_BOOL_EDITABLE) { GtkWidget *checkbox = gtk_check_button_new(); gtk_list_item_set_child(item, checkbox); - }else { + } else { GtkWidget *label = gtk_label_new(NULL); gtk_label_set_xalign(GTK_LABEL(label), 0); gtk_list_item_set_child(item, label); @@ -351,6 +351,7 @@ } case UI_STRING: { gtk_label_set_label(GTK_LABEL(child), data); + gtk_label_set_ellipsize(GTK_LABEL(child), PANGO_ELLIPSIZE_END); if(freevalue) { free(data); } diff -r 9811e27e0889 -r 881dfcf46cd6 ui/ui/icons.h --- a/ui/ui/icons.h Tue Jun 02 19:48:15 2026 +0200 +++ b/ui/ui/icons.h Tue Jun 02 20:12:57 2026 +0200 @@ -54,7 +54,24 @@ #endif /* UI_GTK */ +#ifdef UI_QT +#define UI_ICON_HOME "go-home" +#define UI_ICON_NEW_WINDOW "list-add" +#define UI_ICON_REFRESH "view-refresh" +#define UI_ICON_NEW_FOLDER "folder-new" +#define UI_ICON_ADD "document-new" +#define UI_ICON_UPLOAD "document-open" +#define UI_ICON_SAVE_LOCAL "document-save-as" +#define UI_ICON_DELETE "edit-delete" +#define UI_ICON_DOCK_LEFT "" +#define UI_ICON_DOCK_RIGHT "" +#define UI_ICON_GO_BACK "go-previous" +#define UI_ICON_GO_FORWARD "go-next" +#define UI_ICON_GO_UP "go-up" +#define UI_ICON_GO_DOWN "go-down" + +#endif /* UI_QT */ #ifdef UI_WINUI @@ -94,6 +111,61 @@ #endif /* UI_COCOA */ +#ifdef UI_MOTIF + +#define UI_ICON_HOME "" +#define UI_ICON_NEW_WINDOW "" +#define UI_ICON_REFRESH "" +#define UI_ICON_NEW_FOLDER "" +#define UI_ICON_ADD "" +#define UI_ICON_UPLOAD "" +#define UI_ICON_SAVE_LOCAL "" +#define UI_ICON_DELETE "" +#define UI_ICON_DOCK_LEFT "" +#define UI_ICON_DOCK_RIGHT "" +#define UI_ICON_GO_BACK "" +#define UI_ICON_GO_FORWARD "" +#define UI_ICON_GO_UP "" +#define UI_ICON_GO_DOWN "" + +#endif /* UI_MOTIF */ + +#ifdef UI_WIN32 + +#define UI_ICON_HOME "" +#define UI_ICON_NEW_WINDOW "" +#define UI_ICON_REFRESH "" +#define UI_ICON_NEW_FOLDER "" +#define UI_ICON_ADD "" +#define UI_ICON_UPLOAD "" +#define UI_ICON_SAVE_LOCAL "" +#define UI_ICON_DELETE "" +#define UI_ICON_DOCK_LEFT "" +#define UI_ICON_DOCK_RIGHT "" +#define UI_ICON_GO_BACK "" +#define UI_ICON_GO_FORWARD "" +#define UI_ICON_GO_UP "" +#define UI_ICON_GO_DOWN "" + +#endif /* UI_MOTIF */ + + +enum UiIconId { + UI_ICON_ID_HOME = 0, + UI_ICON_ID_NEW_WINDOW, + UI_ICON_ID_REFRESH, + UI_ICON_ID_NEW_FOLDER, + UI_ICON_ID_ADD, + UI_ICON_ID_UPLOAD, + UI_ICON_ID_SAVE_LOCAL, + UI_ICON_ID_DELETE, + UI_ICON_ID_DOCK_LEFT, + UI_ICON_ID_DOCK_RIGHT, + UI_ICON_ID_GO_BACK, + UI_ICON_ID_GO_FORWARD, + UI_ICON_ID_GO_UP, + UI_ICON_ID_GO_DOWN +}; UIEXPORT UiIcon* ui_icon(const char* name, size_t size); UIEXPORT UiIcon* ui_icon_unscaled(const char *name, int size); @@ -104,6 +176,8 @@ UIEXPORT UiIcon* ui_fileicon(size_t size); +UIEXPORT const char* ui_icon_name(enum UiIconId icon_id); + #ifdef __cplusplus } #endif