3 #include "signals-editor.h"
9 gtk_list_store_clear(GTK_LIST_STORE(liststore
));
10 treevalid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &mainIter
);
14 void setBase(gchar
*newbase
) {
20 void setFile(gchar
*newfile
) {
27 void fileOpen(gchar
*filename
) {
28 gchar
**testList
= NULL
;
34 if (g_file_get_contents(filename
, &contents
, &length
, NULL
) != FALSE
) {
38 processed
= checkPinyin(contents
);
39 testList
= g_strsplit(processed
, "\n", MAXTESTS
);
42 while ( testList
[i
] != NULL
) {
43 if (g_str_has_prefix (testList
[i
], "#")) {
44 /* Voeg commentaar toe ofzo */
46 add_entry(testList
[i
]);
52 if (testList
== NULL
) {
53 testList
= g_strsplit("xu1\nci2", "\n", MAXTESTS
);
59 gtk_window_set_title(GTK_WINDOW(glade_xml_get_widget(xml
, "windowWordlist")), filename
);
61 setBase(g_path_get_dirname(filename
));
62 setFile(g_strdup(filename
));
64 treevalid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &mainIter
);
69 void fileSave(gchar
*filename
) {
70 if (treevalid
== TRUE
&& filename
!= NULL
) {
74 /* Get first row in list store */
75 valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &iter
);
78 GString
*contents
= g_string_new("");
79 if (contents
!= NULL
) {
83 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &iter
, COL_TEXT
, &string
, -1);
84 contents
= g_string_append(contents
, string
);
85 contents
= g_string_append(contents
, "\r\n");
87 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(liststore
), &iter
);
91 g_file_set_contents(filename
, contents
->str
, -1, NULL
);
93 g_string_free(contents
, true);