emote2ss

Animated webp to spritesheets converting tool
git clone git://bsandro.tech/emote2ss
Log | Files | Refs | README | LICENSE

commit 7745e1a47059c54e3dec5a271ce31f6b119cc961
parent d74a4e3bac06ffb9df754d1c61dbe091bf468a23
Author: bsandro <email@bsandro.tech>
Date:   Tue, 22 Apr 2025 23:55:42 +0300

Always open a home directory by default

Diffstat:
Mgui/ui.c | 23++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/gui/ui.c b/gui/ui.c @@ -7,7 +7,7 @@ #include "spritesheet.h" static int cols = 1; -static volatile UIWindow *modal_win = NULL; +static UIWindow *modal_win = NULL; static UIImageDisplay *img_disp = NULL; static UILabel *lbl_header = NULL; static Animation *img = NULL; @@ -49,7 +49,7 @@ UIWindow * MainWindowCreate(const char *wname, int w, int h) { UIButton *btnsave = UIButtonCreate(&panelh->e, 0, "Save", -1); btnsave->e.messageUser = ButtonSaveEvent; btnsave->e.cp = win; - UIButton *btn_exit = UIButtonCreate(&panelh->e, 0, "Close", -1); + UIButton *btn_exit = UIButtonCreate(&panelh->e, 0, "Exit", -1); btn_exit->e.messageUser = ButtonCloseEvent; img_disp = UIImageDisplayCreate(&panelv->e, UI_ELEMENT_V_FILL|UI_ELEMENT_H_FILL|UI_IMAGE_DISPLAY_INTERACTIVE|_UI_IMAGE_DISPLAY_ZOOM_FIT, NULL, 0, 0, 0); @@ -62,7 +62,7 @@ UIWindow * MainWindowCreate(const char *wname, int w, int h) { int WinModalEvent(UIElement *element, UIMessage msg, int di, void *dp) { if (msg==UI_MSG_DESTROY) { //printf("modal bye\n"); - assert(element==modal_win); + assert(element==(UIElement *)modal_win); modal_win = NULL; } return 0; @@ -188,7 +188,7 @@ int TableEvent(UIElement *element, UIMessage msg, int di, void *dp) { filelist = NULL; selected = -1; UIElement *el = table->e.children; - printf("child %p\n", el); + printf("child %p\n", el); while (el!=NULL) { printf("child %p\n", el); } @@ -222,7 +222,7 @@ void ShowModalWindow(UIWindow *parent, const char *def_dir, const char *def_file UITextbox *filename_input = UITextboxCreate(&panel_top->e, UI_ELEMENT_TAB_STOP|UI_ELEMENT_H_FILL); - printf("path_input: %p\nfilename_input: %p\n", path_input, filename_input); + printf("path_input: %p (%s)\nfilename_input: %p (%s)\n", path_input, def_dir, filename_input, def_file); if (def_file!=NULL) { UITextboxReplace(filename_input, def_file, -1, false); } @@ -236,9 +236,14 @@ void ShowModalWindow(UIWindow *parent, const char *def_dir, const char *def_file UITable *table = UITableCreate(&panel_out->e, UI_ELEMENT_V_FILL, "Directory"); table->itemCount = 1; // at least '..' element // @todo setting the initial directory this way is 100% trashcan - char *init_path = (char *)malloc(2*sizeof(char)); - init_path[0] = '.'; - init_path[1] = '\0'; + char *init_path = NULL; + if (def_dir==NULL) { + init_path = malloc(sizeof(char)*2); + init_path[0] = '.'; + init_path[1] = '\0'; + } else { + init_path = strdup(def_dir); + } table->e.cp = (void *)init_path; table->e.messageUser = TableEvent; UITableResizeColumns(table); @@ -248,7 +253,7 @@ void ShowModalWindow(UIWindow *parent, const char *def_dir, const char *def_file } int ButtonSaveEvent(UIElement *element, UIMessage msg, int di, void *dp) { - if (msg==UI_MSG_CLICKED) { + if (msg==UI_MSG_CLICKED && img!=NULL) { // printf("save button clicked\n"); char fname[strlen(img->filename)+7]; int n = snprintf(fname, NAME_MAX, "atlas_%s", img->filename);