-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
82 lines (64 loc) · 1.93 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "support.h"
#include "model.h"
if(check_file_exist("dict_db"))
tree_word = btopn("dict_db", 0, FALSE);
else{
tree_word = btcrt("dict_db", 0, FALSE);
load_sample_2_tree(tree_word, "FOLDOC");
}
if(check_file_exist("soundex_db"))
tree_soundex = btopn("soundex_db", 0, FALSE);
else{
tree_soundex = btcrt("soundex_db", 0, FALSE);
load_soundex_db(tree_soundex, tree_word);
}
/* Init GTK+ */
gtk_init(&argc, &argv);
/* Create new GtkBuilder object */
builder = gtk_builder_new();
if (!gtk_builder_add_from_file(builder, UI_FILE, &error))
{
g_warning("%s", error->message);
g_free(error);
return 1;
}
/* Allocate data structure */
data = g_slice_new(ChData);
/* Get objects from UI */
#define GW(name) CH_GET_WIDGET(builder, name, data)
GW(main_window);
GW(dlg_add);
GW(dlg_help);
GW(dlg_delete);
GW(dlg_edit);
GW(entry_add);
GW(txt_meaning_add);
GW(treeview_result_main);
GW(entry_search_main);
GW(txt_meaning_main);
GW(word_label_edit);
GW(txt_meaning_edit);
GW(list_store1);
GW(list_store2);
data->tree_word = tree_word;
data->tree_soundex = tree_soundex;
data->stack = stack;
/* Get more objects to use */
#undef GW
CH_GET_OBJECT(builder, list_store1, GTK_LIST_STORE, data);
CH_GET_OBJECT(builder, list_store2, GTK_LIST_STORE, data);
/* Connect signals */
gtk_builder_connect_signals(builder, data);
/* Destroy builder, since we don't need it anymore */
g_object_unref(G_OBJECT(builder));
/* Show window */
gtk_widget_show(data -> main_window);
/* Start main loop */
gtk_main();
/* Free any allocated data */
g_slice_free(ChData, data);
btcls(tree_soundex);
btcls(tree_word);
freeStack(&stack);
return(0);
}