3 /* This file contains all code that is required to initiate the widgets.
4 * And should be linked to from Glade
7 void on_filechooserdialog_realize(GtkWidget
*widget
, gpointer user_data
){
10 filter
= gtk_file_filter_new ();
11 gtk_file_filter_add_pattern (filter
, "*.sgc");
12 gtk_file_filter_add_pattern (filter
, "*.txt");
13 gtk_file_filter_add_pattern (filter
, "*.zip");
14 gtk_file_filter_set_name (filter
, _("All Loadable Files"));
15 gtk_file_chooser_add_filter (GTK_WIDGET(widget
), filter
);
17 filter
= gtk_file_filter_new ();
18 gtk_file_filter_add_pattern (filter
, "*.sgc");
19 gtk_file_filter_set_name (filter
, _("SGC Distribution (*.sgc)"));
20 gtk_file_chooser_add_filter (GTK_WIDGET(widget
), filter
);
22 filter
= gtk_file_filter_new ();
23 gtk_file_filter_add_pattern (filter
, "*.txt");
24 gtk_file_filter_set_name (filter
, _("Plain Text (*.txt)"));
25 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(widget
), filter
);
27 filter
= gtk_file_filter_new ();
28 gtk_file_filter_add_pattern (filter
, "*.zip");
29 gtk_file_filter_set_name (filter
, _("Zip File (*.zip)"));
30 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(widget
), filter
);
34 void adder(gchar
*dir
, GtkWidget
*menu
) {
35 GDir
*dirExamples
= g_dir_open(dir
, 0, NULL
);
36 if (dirExamples
!= NULL
) {
38 while ((current
= g_dir_read_name (dirExamples
)) != NULL
) {
39 gchar
*path
= g_build_path(G_DIR_SEPARATOR_S
, dir
, current
, "wordlist.txt", NULL
);
41 if (g_file_test(path
, G_FILE_TEST_EXISTS
) == TRUE
) {
42 GtkWidget
*item
= gtk_image_menu_item_new_with_label(g_strdup(current
));
43 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item
), gtk_image_new_from_stock(GTK_STOCK_OPEN
, GTK_ICON_SIZE_MENU
));
44 g_signal_connect_data(item
, "activate", G_CALLBACK(fileOpen
), path
, g_free
, G_CONNECT_SWAPPED
);
45 gtk_menu_shell_prepend (GTK_MENU_SHELL(menu
), item
);
48 gtk_widget_show_all(GTK_WIDGET(menu
));
52 void on_menuWordlists_realize(GtkWidget
*menu
, gpointer user_data
) {
54 dir
= g_build_path(G_DIR_SEPARATOR_S
, g_getenv(STORAGE
), STOREAS
, WORDLISTS
, NULL
);
57 cwd
= g_get_current_dir();
58 dir
= g_build_path(G_DIR_SEPARATOR_S
, cwd
, WORDLISTS
, NULL
);
64 void on_windowMain_realize(GtkWidget
*widget
, gpointer user_data
) {
65 GtkCellRenderer
*renderer
;
66 GtkTreeViewColumn
*col
;
67 GtkTreeSelection
*sel
;
68 GtkWidget
*view
= glade_xml_get_widget(xml
, "treeviewWords");
70 liststore
= gtk_list_store_new(NUM_COLS
, G_TYPE_STRING
); /* NUM_COLS = 1 */
72 gtk_tree_view_set_model(GTK_TREE_VIEW(view
), GTK_TREE_MODEL(liststore
));
74 renderer
= gtk_cell_renderer_text_new();
76 g_object_set(renderer
, "editable", TRUE
, NULL
);
77 g_signal_connect(renderer
, "edited", G_CALLBACK(on_treeview_edited
), GTK_TREE_MODEL(liststore
));
79 col
= gtk_tree_view_column_new();
81 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
82 gtk_tree_view_column_add_attribute(col
, renderer
, "text", COL_TEXT
);
83 gtk_tree_view_column_set_title(col
, _(" Mandarin "));
85 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
87 sel
= gtk_tree_view_get_selection(GTK_TREE_VIEW(view
));
88 gtk_tree_selection_set_mode(sel
, GTK_SELECTION_SINGLE
);
93 void removeRecordings() {
95 gchar
*file
= g_build_filename(SCRIPTPATH
, "lastExample.wav", NULL
);
98 if ((record
= g_dir_open(RECORDPATH
, 0, NULL
)) != NULL
) {
100 while ((name
= g_dir_read_name(record
)) != NULL
) {
101 if (g_str_has_suffix(name
, ".wav") || g_str_has_suffix(name
, ".Pitch") || g_str_has_suffix(name
, ".PitchTier")) {
102 file
= g_build_filename(RECORDPATH
, name
, NULL
);