aboutsummaryrefslogtreecommitdiff
path: root/src/stardict.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-12-19 08:51:52 +0100
committerPřemysl Eric Janouch <p@janouch.name>2024-12-19 14:38:19 +0100
commit531f18d827dd515befa8a91f5ac80c6b3872498d (patch)
tree5cbfc9e79b0335d19141511b57df285f580ed51a /src/stardict.c
parent862cde36aeaf9b6fbaadc9ab32b95eaa3a8ba7f4 (diff)
downloadtdv-531f18d827dd515befa8a91f5ac80c6b3872498d.tar.gz
tdv-531f18d827dd515befa8a91f5ac80c6b3872498d.tar.xz
tdv-531f18d827dd515befa8a91f5ac80c6b3872498d.zip
GUI: add basic configuration
It is simply not feasible to write the text file by hand on Windows.
Diffstat (limited to 'src/stardict.c')
-rw-r--r--src/stardict.c22
1 files changed, 17 insertions, 5 deletions
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<StardictInfo *>. 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);