2 #include "signals-editor.h"
4 gchar
* checkPinyin(gchar
*pinyin
) {
6 g_ascii_strdown(pinyin
, -1);
7 g_strcanon(pinyin
, "#012345abcdefghijklmnopqrstuvwxyz\n", '-');
8 result
= g_strsplit(pinyin
, "-", MAXTESTS
* 2);
10 pinyin
= g_strjoinv(NULL
, result
);
14 void on_buttonAddAdd_clicked (GtkWidget
*entry
, gpointer data
)
16 gchar
*processed
= checkPinyin(g_strdup(gtk_entry_get_text(GTK_ENTRY(entry
))));
20 void add_entry(gchar
*txt
) {
21 /* ignore if entry is empty */
26 gtk_list_store_append(GTK_LIST_STORE(liststore
), &newrow
);
28 gtk_list_store_set(GTK_LIST_STORE(liststore
), &newrow
, COL_TEXT
, txt
, -1);
31 if (treevalid
== FALSE
) {
32 treevalid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &mainIter
);
38 void remove_entry (GtkWidget
*treeview
, gpointer data
)
40 GtkTreeSelection
*sel
;
41 GtkTreeIter selected_row
;
43 sel
= gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview
));
45 if (gtk_tree_selection_get_selected(sel
, &liststore
, &selected_row
))
47 gtk_list_store_remove(GTK_LIST_STORE(liststore
), &selected_row
);
48 treevalid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &mainIter
);
53 void on_treeview_edited (GtkCellRendererText
*celltext
,
54 const gchar
*string_path
, const gchar
*new_text
, gpointer data
) {
56 GtkTreeModel
*model
= GTK_TREE_MODEL(data
);
58 gtk_tree_model_get_iter_from_string(model
, &iter
, string_path
);
59 gtk_list_store_set(GTK_LIST_STORE(model
), &iter
, COL_TEXT
, new_text
, -1);
60 treevalid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &mainIter
);
64 gboolean
on_treeother() {
65 treevalid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore
), &mainIter
);
70 void on_buttonOpen2_clicked(GtkWidget
*filechooser
, gpointer data
) {
71 gchar
*filename
= gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser
));
77 void on_buttonOpen_clicked(GtkWidget
*filechooser
, gpointer data
) {
78 /* Eerst vragen oude op te slaan ? */
80 gchar
*filename
= gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser
));
82 if (g_str_has_suffix(filename
, ".sgc") || g_str_has_suffix(filename
, ".SGC")) {
83 if (openSGC(filename
)) {
84 gchar
*basename
= g_path_get_basename(filename
);
85 int end
= strlen(basename
)-3;
86 gchar
*basenamenoext
= g_malloc(end
* sizeof(gchar
));
87 gchar
*currentDir
= g_get_current_dir();
88 g_strlcpy(basenamenoext
, basename
, end
);
90 filename
= g_strjoin(NULL
, currentDir
, G_DIR_SEPARATOR_S
, WORDLISTS
, G_DIR_SEPARATOR_S
, basenamenoext
, G_DIR_SEPARATOR_S
, "wordlist.txt", NULL
);
93 g_free(basenamenoext
);
94 gtk_widget_unrealize(glade_xml_get_widget(xml
, "menuWordlists"));
101 void on_buttonSaveDistribution_clicked(GtkWidget
*entry
, gpointer data
) {
102 if (GTK_ENTRY(entry
)) {
103 saveSGC(gtk_entry_get_text(GTK_ENTRY(entry
)), base
);
106 void on_buttonSaveNew_clicked(GtkWidget
*entry
, gpointer data
) {
107 if (GTK_ENTRY(entry
)) {
108 gchar
*currentDir
= g_get_current_dir();
109 gchar
*filename
= g_strjoin(NULL
, currentDir
, G_DIR_SEPARATOR_S
, WORDLISTS
, G_DIR_SEPARATOR_S
, gtk_entry_get_text(GTK_ENTRY(entry
)), G_DIR_SEPARATOR_S
, "wordlist.txt", NULL
);
111 setBase(g_path_get_dirname(filename
));
113 if (g_access(base
, F_OK
) != 0) {
114 g_mkdir_with_parents(base
, 0755);
117 if (g_access(file
, F_OK
) == 0) {
120 gtk_window_set_title(GTK_WINDOW(glade_xml_get_widget(xml
, "windowWordlist")), file
);
121 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(glade_xml_get_widget(xml
, "filechooserdialogWordlist")), file
);
122 fclose(g_fopen(file
, "w"));
123 gtk_widget_unrealize(glade_xml_get_widget(xml
, "menuWordlists"));