3 gchar
* checkpinyin(gchar
*pinyin
) {
5 g_ascii_strdown(pinyin
, -1);
6 g_strcanon(pinyin
, "01234abcdefghijklmnopqrstuvwxyz\n", '-');
7 result
= g_strsplit(pinyin
, "-", MAXTESTS
* 2);
9 pinyin
= g_strjoinv(NULL
, result
);
14 gtk_list_store_clear(GTK_LIST_STORE(liststore
));
15 treevalid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &mainIter
);
19 void fileOpen(gchar
*filename
) {
20 gchar
**testList
= NULL
;
27 if (g_file_get_contents(filename
, &contents
, &length
, &error
) != FALSE
) {
29 gchar
*processed
= checkpinyin(contents
);
31 testList
= g_strsplit(processed
, "\n", MAXTESTS
);
32 while ( testList
[i
] != NULL
) {
33 add_entry(testList
[i
]);
40 if (testList
== NULL
) {
41 testList
= g_strsplit("xu1\nci2", "\n", MAXTESTS
);
46 treevalid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &mainIter
);
52 void fileSave(gchar
*filename
) {
53 if (treevalid
== TRUE
&& filename
!= NULL
) {
57 /* Get first row in list store */
58 valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &iter
);
61 GString
*contents
= g_string_new("");
62 if (contents
!= NULL
) {
66 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &iter
, COL_TEXT
, &string
, -1);
67 contents
= g_string_append(contents
, string
);
68 contents
= g_string_append(contents
, "\r\n");
70 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(liststore
), &iter
);
75 if (g_file_set_contents(filename
, contents
->str
, -1, &error
) == FALSE
) {
78 g_string_free(contents
, true);