From 531f18d827dd515befa8a91f5ac80c6b3872498d Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Thu, 19 Dec 2024 08:51:52 +0100 Subject: GUI: add basic configuration It is simply not feasible to write the text file by hand on Windows. --- src/stardict.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/stardict.c') diff --git a/src/stardict.c b/src/stardict.c index 6775553..8fb2f68 100644 --- a/src/stardict.c +++ b/src/stardict.c @@ -357,6 +357,20 @@ error: return ret_val; } +/// Read an .ifo file. +/// @return StardictInfo *. Deallocate with stardict_info_free(); +StardictInfo * +stardict_info_new (const gchar *filename, GError **error) +{ + StardictInfo *ifo = g_new (StardictInfo, 1); + if (!load_ifo (ifo, filename, error)) + { + g_free (ifo); + return NULL; + } + return ifo; +} + /// List all dictionary files located in a path. /// @return GList. Deallocate the list with: /// @code @@ -377,12 +391,10 @@ stardict_list_dictionaries (const gchar *path) continue; gchar *filename = g_build_filename (path, name, NULL); - StardictInfo *ifo = g_new (StardictInfo, 1); - if (load_ifo (ifo, filename, NULL)) - dicts = g_list_append (dicts, ifo); - else - g_free (ifo); + StardictInfo *ifo = stardict_info_new (filename, NULL); g_free (filename); + if (ifo) + dicts = g_list_append (dicts, ifo); } g_dir_close (dir); g_pattern_spec_free (ps); -- cgit v1.2.3-70-g09d2