working with .bzip files - gui modifications
[mdictionary] / src / gui / src / ws_gui.c
1 /*******************************************************************************
2 This file is part of WhiteStork.
3
4 WhiteStork is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 WhiteStork is distributed in the hope that it will be useful, 
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License 
15 along with WhiteStork; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18 Copyright 2006 ComArch S.A.
19 *******************************************************************************/
20 #include <ws_gui.h>
21 #include <ws_gui_callbacks.h>
22 #include <ws_gui_layout.h>
23
24 #include <pc-instances.h>
25
26 //int ws_gui_init(int argc, char *argv[])
27 int main(int argc, char *argv[])
28 {
29         if (is_already_running_this_application() > 1)
30         {
31         //       if YES - do not start another one - terminate
32                 g_debug("Another instance of application curently is running\n");
33                 //return 1;
34         }
35         else
36         {
37                 g_debug("OK\n");
38         }
39         
40         
41         gtk_init(&argc, &argv);
42
43         //localization
44         setlocale(LC_ALL, "");
45         bindtextdomain("whitestork", "/usr/share/locale");
46         bind_textdomain_codeset("whitestork", "UTF-8");
47         textdomain("whitestork");
48
49         if (strcmp(_("ws_check"), "ws_check") == 0)
50         {
51                 setlocale(LC_ALL, "en_GB");
52                 bindtextdomain("whitestork", "/usr/share/locale");
53                 bind_textdomain_codeset("whitestork", "UTF-8");
54                 textdomain("whitestork");
55         }
56
57
58         WSGuiApp *ws_gui_app;
59         ws_gui_app = (WSGuiApp*)g_malloc(sizeof(WSGuiApp)); 
60
61         //memory allocation
62         ws_gui_app->ws_gui_w_list = 
63                 (struct WSGuiList*)g_malloc(sizeof(struct WSGuiList));
64         ws_gui_app->ws_gui_menu = 
65                 (struct WSGuiMenu*)g_malloc(sizeof(struct WSGuiMenu));
66
67         //gonf
68         ws_gui_app->client = gconf_client_get_default();
69
70         ws_gui_create_window(ws_gui_app);
71         ws_gui_read_adjustment(ws_gui_app);
72
73
74         //dbus wrapper
75         ws_gui_app->dbus_data = ws_dbus_create ("WhiteStorkGui", "v1.0");
76
77         ws_dbus_config (ws_gui_app->dbus_data, 
78                         WS_DBUS_CONFIG_SERVICE,
79                         "org.maemo.WhiteStorkGui");
80         ws_dbus_config (ws_gui_app->dbus_data,
81                         WS_DBUS_CONFIG_OBJECT,
82                         "/org/maemo/WhiteStorkGui");
83         ws_dbus_config (ws_gui_app->dbus_data,
84                         WS_DBUS_CONFIG_IFACE,
85                         "org.maemo.WhiteStorkGui");
86         ws_dbus_config (ws_gui_app->dbus_data,
87                         WS_DBUS_CONFIG_REMOTE_SERVICE,
88                         "org.maemo.WhiteStorkManager");
89         ws_dbus_config (ws_gui_app->dbus_data,
90                         WS_DBUS_CONFIG_REMOTE_OBJECT,
91                         "/org/maemo/WhiteStorkManager");
92         ws_dbus_config (ws_gui_app->dbus_data,
93                         WS_DBUS_CONFIG_REMOTE_IFACE,
94                         "org.maemo.WhiteStorkManager");
95
96         ws_dbus_connect (ws_gui_app->dbus_data);
97
98         ws_dbus_set_cb (ws_gui_app->dbus_data,
99                         "return_words",
100                         ws_gui_dbus_return_words,
101                         ws_gui_app);
102
103         ws_dbus_set_cb (ws_gui_app->dbus_data,
104                         "return_translations",
105                         ws_gui_dbus_return_translation,
106                         ws_gui_app);
107          ws_dbus_set_cb (ws_gui_app->dbus_data,
108                         "return_extracted_dict",
109                         ws_dbus_server_return_extracted_dict2,
110                         ws_gui_app);
111         ws_dbus_set_cb (ws_gui_app->dbus_data,
112                         "update_progressbar",
113                         ws_dbus_progress_bar,
114                         ws_gui_app);
115         ws_dbus_set_cb (ws_gui_app->dbus_data,
116                         "signal",
117                         ws_gui_signal_hander,
118                         ws_gui_app);
119
120         //setting the clipboard
121         ws_gui_app->ws_gui_clipboard = 
122                 gtk_widget_get_clipboard (GTK_WIDGET(ws_gui_app->ws_gui_html),
123                                           GDK_SELECTION_CLIPBOARD);
124
125         //connecting the signals
126         g_signal_connect(G_OBJECT (ws_gui_app->ws_gui_w_list->ws_gui_selection),
127                          "changed",
128                          G_CALLBACK (ws_gui_tree_selection_changed), 
129                          ws_gui_app);
130         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_hildon_window),
131                         "key-press-event",
132                          G_CALLBACK(hildon_key_press_listener),
133                          ws_gui_app);
134         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_html),
135                          "button-press-event",
136                          G_CALLBACK(ws_gui_button_press),
137                          ws_gui_app);
138         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_html),
139                          "button-release-event",
140                          G_CALLBACK(ws_gui_button_release),
141                          ws_gui_app);
142         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_hildon_window),
143                          "delete-event",
144                          G_CALLBACK(ws_gui_on_exit),
145                          ws_gui_app);
146
147         ws_dbus_notify(ws_gui_app->dbus_data,
148                        WS_DBUS_ERROR_UNKNOWN);
149
150         gtk_main();
151         
152         return 0;
153 }
154