# HG changeset patch # User Olaf Wintermann # Date 1728232986 -7200 # Node ID 9c25e2616bfae4cb9a921a7ffff0d6af01a487ec # Parent 2f71f4ee247a6fbceb3ac218f901e4e42d2a18a3 fix startup in case the dav config doesn't exist diff -r 2f71f4ee247a -r 9c25e2616bfa application/config.c --- a/application/config.c Sun Oct 06 18:18:04 2024 +0200 +++ b/application/config.c Sun Oct 06 18:43:06 2024 +0200 @@ -118,42 +118,47 @@ return cx_mutstrn(buf.space, buf.size); } -int load_config(DavContext* ctx) { +int load_config(DavContext *ctx) { context = ctx; // TODO: free the config somewhere repos = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16); keys = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16); - - char* pwfile = util_concat_path(ENV_HOME, ".dav/secrets.crypt"); + + char *pwfile = util_concat_path(ENV_HOME, ".dav/secrets.crypt"); pstore = pwdstore_open(pwfile); free(pwfile); - - char* file = util_concat_path(ENV_HOME, ".dav/config.xml"); - + + char *file = util_concat_path(ENV_HOME, ".dav/config.xml"); + struct stat s; - if (stat(file, &s)) { - switch (errno) { - case ENOENT: { - return 0; - } - default: { - perror("Cannot load config.xml"); - } + if(stat(file, &s)) { + switch(errno) { + case ENOENT: { + davconfig = dav_config_new(NULL); + return 0; + } + default: { + perror("Cannot load config.xml"); + } } return 1; } - + cxmutstr config_content = config_load_file(file); int config_error; davconfig = dav_config_load(config_content, &config_error); free(config_content.ptr); free(file); - - if (!davconfig) { + + if(!davconfig) { fprintf(stderr, "Cannot load config.xml\n"); return 1; } - + + if(dav_config_register_namespaces(davconfig, ctx)) { + return 1; + } + return dav_config_register_keys(davconfig, ctx, load_key_file); } diff -r 2f71f4ee247a -r 9c25e2616bfa ui/gtk/image.c --- a/ui/gtk/image.c Sun Oct 06 18:18:04 2024 +0200 +++ b/ui/gtk/image.c Sun Oct 06 18:43:06 2024 +0200 @@ -117,7 +117,7 @@ } UiIcon* ui_fileicon(size_t size) { - return ui_icon("application-x-generic", size); + return ui_icon("file", size); } UiIcon* ui_icon_unscaled(const char *name, int size) { diff -r 2f71f4ee247a -r 9c25e2616bfa ui/gtk/list.c --- a/ui/gtk/list.c Sun Oct 06 18:18:04 2024 +0200 +++ b/ui/gtk/list.c Sun Oct 06 18:43:06 2024 +0200 @@ -114,20 +114,24 @@ case UI_ICON_TEXT_FREE: { UiIcon *icon = data; #if GTK_MAJOR_VERSION >= 4 - GValue iconvalue = G_VALUE_INIT; - g_value_init(&iconvalue, G_TYPE_OBJECT); - g_value_set_object(&iconvalue, ui_icon_pixbuf(icon)); - gtk_list_store_set_value(store, &iter, c, &iconvalue); + if(icon) { + GValue iconvalue = G_VALUE_INIT; + g_value_init(&iconvalue, G_TYPE_OBJECT); + g_value_set_object(&iconvalue, ui_icon_pixbuf(icon)); + gtk_list_store_set_value(store, &iter, c, &iconvalue); + } #else GValue pixbufvalue = G_VALUE_INIT; - if(!icon->pixbuf && icon->info) { - GError *error = NULL; - GdkPixbuf *pixbuf = gtk_icon_info_load_icon(icon->info, &error); - icon->pixbuf = pixbuf; + if(icon) { + if(!icon->pixbuf && icon->info) { + GError *error = NULL; + GdkPixbuf *pixbuf = gtk_icon_info_load_icon(icon->info, &error); + icon->pixbuf = pixbuf; + } + g_value_init(&pixbufvalue, G_TYPE_OBJECT); + g_value_set_object(&pixbufvalue, icon->pixbuf); + gtk_list_store_set_value(store, &iter, c, &pixbufvalue); } - g_value_init(&pixbufvalue, G_TYPE_OBJECT); - g_value_set_object(&pixbufvalue, icon->pixbuf); - gtk_list_store_set_value(store, &iter, c, &pixbufvalue); #endif c++;