d66e61e905fd5ae889f5b0a643d65406835226af
[mdictionary] / gui / src / ws_gui_layout.c
1 /********************************************************************************
2 Copyright 2006, ComArch S.A
3 All rights reserved
4
5 Terms of use
6
7
8 READ THE TERMS OF USE CAREFULLY BEFORE INSTALALTION OF THIS SOFTWARE. BY
9 INSTALALTION OF THIS SOFTWARE, YOU AGREE TO THE FOLLOWING TERMS OF USE.
10
11 1. LICENSE TO USE. ComArch grants you a non-exclusive and non-transferable
12 license for the internal use only of the accompanying software and
13 documentation and any error corrections provided by ComArch (collectively
14 "Software"), by the one user.
15
16 2. RESTRICTIONS. Software is confidential and copyrighted. Title to Software
17 and all associated intellectual property rights is retained by ComArch
18 and/or its licensors. Unless enforcement is prohibited by applicable law,
19 you may not modify, decompile, or reverse engineer Software. You acknowledge
20 that Software is not designed, licensed or intended for use in the design,
21 construction, operation or maintenance of any nuclear facility. Sun ComArch
22 disclaims any express or implied warranty of fitness for such uses. No
23 right, title or interest in or to any trademark, service mark, logo or trade
24 name of ComArch or its licensors is granted under this terms of use.
25
26
27 3. DISCLAIMER OF WARRANTY. UNLESS SPECIFIED IN THIS AGREEMENT TERMS OF USE,
28 ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
29 ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
30 NON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS
31 ARE HELD TO BE LEGALLY INVALID.
32
33 4. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT
34 WILL COMARCH OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR
35 DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
36 DAMAGES, HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT
37 OF OR RELATED TO THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF COMARCH
38 HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. In no event will
39 ComArch's liability to you, whether in contract, tort (including
40 negligence), or otherwise, exceed []. The foregoing limitations will apply
41 even if the above stated warranty fails of its essential purpose.
42
43 5. Termination. This license is effective until terminated. You may
44 terminate this license at any time by destroying all copies of Software.
45 This license will terminate immediately without notice from ComArch if you
46 fail to comply with any provision of this license. Upon Termination, you
47 must destroy all copies of Software.
48
49 6. Export Regulations. All Software and technical data delivered under this
50 terms of use are subject to Polish export control laws and may be subject to
51 export or import regulations in other countries. You agree to comply
52 strictly with all such laws and regulations and acknowledge that you have
53 the responsibility to obtain such licenses to export, re-export, or import
54 as may be required after delivery to you.
55
56 7. Governing Law. Any action related to this license will be governed by
57 Polish Law.
58
59 8. Severability. If any provision of this terms of use is held to be
60 unenforceable, this terms of use will remain in effect with the provision
61 omitted, unless omission would frustrate the intent of the parties, in which
62 case this terms of use will immediately terminate.
63
64 9. Integration. This document is the entire  agreement between you and
65 ComArch relating to its subject matter. It supersedes all prior or
66 contemporaneous oral or written communications, proposals, representations
67 and warranties and prevails over any conflicting or additional terms of any
68 quote, order, acknowledgment, or other communication between the parties
69 relating to its subject matter during the term of these terms of use. No
70 modification of this Agreement will be binding, unless in writing and signed
71 by an authorized representative of each party.
72
73 *********************************************************************************/
74
75 #include "../../include/ws_gui_layout.h"
76 #include "../../include/ws_gui.h"
77 #include "../../include/ws_gui_callbacks.h"
78 #include "../../include/ws_dbus.h"
79
80
81 /** this function creates main window and it components; moreover there are signal connections;
82  *
83  * @param user_data - data set when the signal handler was connected 
84  */
85 void ws_gui_create_window(gpointer user_data) 
86 {
87         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
88         
89         ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string = "<font size=+2><center><br>Welcome to<br><b>WhiteStork</b><br>Dictionary.</font><br><IMG SRC=file:/usr/share/pixmaps/whitestork.png></center>";
90
91         GArray *array_tmp = g_array_new (TRUE, TRUE, sizeof(gchar*));
92
93         ws_gui_app->ws_gui_banner_flag = FALSE;
94         ws_gui_app->ws_gui_full_screen_flag = FALSE;    
95         ws_gui_app->caching_flag = FALSE;
96         
97         ws_gui_app->ws_gui_history = g_array_new(TRUE, TRUE, sizeof(gchar*));
98         ws_gui_app->ws_gui_history_cur_pos = -1;
99         ws_gui_app->ws_gui_hildon_program = HILDON_PROGRAM(hildon_program_get_instance());
100         g_set_application_name("WhiteStork");
101         
102         ws_gui_app->ws_gui_hildon_window = HILDON_WINDOW(hildon_window_new());
103         hildon_program_add_window(ws_gui_app->ws_gui_hildon_program, ws_gui_app->ws_gui_hildon_window);
104         
105         ws_gui_create_main_menu(ws_gui_app);
106         ws_gui_create_find_toolbar(ws_gui_app);
107  
108         ws_gui_app->ws_gui_hpane = gtk_hpaned_new();
109  
110         ws_gui_app->ws_gui_scrolledwindow_left = gtk_scrolled_window_new (NULL, NULL);
111         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ws_gui_app->ws_gui_scrolledwindow_left), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
112         
113         gtk_paned_set_position(GTK_PANED(ws_gui_app->ws_gui_hpane), 100);
114         //gtk_widget_set_size_request (ws_gui_app->ws_gui_scrolledwindow_left, 50, 100);
115         
116         gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(ws_gui_app->ws_gui_scrolledwindow_left), GTK_CORNER_TOP_LEFT);
117  
118         ws_gui_app->ws_gui_scrolledwindow_right = gtk_scrolled_window_new (NULL, NULL);
119         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ws_gui_app->ws_gui_scrolledwindow_right), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
120         
121         ws_gui_app->ws_gui_w_list->ws_gui_store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_UINT);
122         ws_gui_app->ws_gui_w_list->ws_gui_view = create_view_and_model(array_tmp, ws_gui_app);  
123         gtk_widget_show_all(GTK_WIDGET(ws_gui_app->ws_gui_w_list->ws_gui_view));
124         
125         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(ws_gui_app->ws_gui_scrolledwindow_left), ws_gui_app->ws_gui_w_list->ws_gui_view);
126
127         ws_gui_app->ws_gui_html = gtk_html_new();
128         
129         ws_gui_app->p = pango_font_description_from_string("Tahoma 12");
130         gtk_widget_modify_font(GTK_WIDGET(ws_gui_app->ws_gui_html), ws_gui_app->p);
131         //ws_gui_app->ws_gui_html = gtk_html_new_from_string(ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string, strlen(ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string));
132         
133         g_signal_connect(GTK_OBJECT (ws_gui_app->ws_gui_html), "url_requested", G_CALLBACK(ws_gui_url_requested), ws_gui_app);
134         
135         gtk_html_load_from_string(GTK_HTML(ws_gui_app->ws_gui_html), ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string, -1);
136         
137
138         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(ws_gui_app->ws_gui_scrolledwindow_right), ws_gui_app->ws_gui_html);
139         //gtk_paned_add1(GTK_PANED(ws_gui_app->ws_gui_hpane), ws_gui_app->ws_gui_scrolledwindow_left);
140         //gtk_paned_add2(GTK_PANED(ws_gui_app->ws_gui_hpane), ws_gui_app->ws_gui_scrolledwindow_right);
141         gtk_paned_pack1(GTK_PANED(ws_gui_app->ws_gui_hpane), ws_gui_app->ws_gui_scrolledwindow_left,TRUE, TRUE);
142         gtk_paned_pack2(GTK_PANED(ws_gui_app->ws_gui_hpane), ws_gui_app->ws_gui_scrolledwindow_right,TRUE, TRUE);
143
144         gtk_html_set_editable(GTK_HTML(ws_gui_app->ws_gui_html), FALSE); /* editable */
145         //gtk_html_set_allow_frameset (GTK_HTML(ws_gui_app->ws_gui_html), TRUE);
146         gtk_html_allow_selection(GTK_HTML(ws_gui_app->ws_gui_html), TRUE);
147         //gtk_html_set_blocking(GTK_HTML(ws_gui_app->ws_gui_html), TRUE);
148         
149         gtk_container_add(GTK_CONTAINER(ws_gui_app->ws_gui_hildon_window), ws_gui_app->ws_gui_hpane);
150         gtk_widget_show_all(GTK_WIDGET(ws_gui_app->ws_gui_hildon_window));
151         
152         ws_gui_app->ws_gui_w_list->ws_gui_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ws_gui_app->ws_gui_w_list->ws_gui_view));
153         
154         gtk_tree_selection_set_mode (ws_gui_app->ws_gui_w_list->ws_gui_selection, GTK_SELECTION_BROWSE);
155         
156 }
157
158 /** this function creates a find toolbar and connects signals to the tollbars components
159  *
160  * @param user_data - set when the signal handler was connected
161  */
162 void ws_gui_create_find_toolbar(gpointer user_data)
163 {
164         WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;    
165
166         GtkToolItem *space;
167         ws_gui_app->ws_gui_hildon_find_toolbar = HILDON_FIND_TOOLBAR(hildon_find_toolbar_new("Find: "));
168
169         ws_gui_app->ws_gui_toobar_button_hide = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_GOTO_FIRST);
170         ws_gui_app->ws_gui_toobar_button_back = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
171         ws_gui_app->ws_gui_toobar_button_forward = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
172         ws_gui_app->ws_gui_toobar_button_stop = gtk_tool_button_new_from_stock(GTK_STOCK_STOP);
173         space = gtk_separator_tool_item_new(); 
174
175         ws_gui_app->ws_gui_toobar_button_close = gtk_toolbar_get_nth_item(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar), 4);
176         gtk_tool_item_set_visible_horizontal(ws_gui_app->ws_gui_toobar_button_close, FALSE);
177         
178         gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar), ws_gui_app->ws_gui_toobar_button_hide, 0);
179         gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar), ws_gui_app->ws_gui_toobar_button_back, -1);
180         gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar), ws_gui_app->ws_gui_toobar_button_forward, -1);
181         gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar), space, -1);
182         gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar), ws_gui_app->ws_gui_toobar_button_stop, -1);
183     
184         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar), "search", G_CALLBACK(ws_gui_search), ws_gui_app);
185         
186         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_toobar_button_hide), "toggled", G_CALLBACK(ws_gui_words_list_hide), ws_gui_app);
187         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_toobar_button_back), "clicked", G_CALLBACK(ws_gui_history_back), ws_gui_app);
188         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_toobar_button_forward), "clicked", G_CALLBACK(ws_gui_history_next), ws_gui_app);
189         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_toobar_button_stop), "clicked", G_CALLBACK(ws_gui_search_stop), ws_gui_app);
190
191         gtk_widget_set_sensitive (GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_back), FALSE);
192         gtk_widget_set_sensitive (GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_forward), FALSE);
193         gtk_widget_set_sensitive (GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_stop), FALSE);
194         
195
196         hildon_window_add_toolbar(ws_gui_app->ws_gui_hildon_window, GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar));
197 }
198
199 /** this function creates application menu and its items and connect signals to them
200  *
201  * @param user_data - set when the signal handler was connected
202  */
203 void ws_gui_create_main_menu (gpointer user_data) 
204 {
205         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
206
207         ws_gui_app->ws_gui_menu->ws_gui_submenu_0 = gtk_menu_new();
208         ws_gui_app->ws_gui_menu->ws_gui_submenu_1 = gtk_menu_new();
209         ws_gui_app->ws_gui_menu->ws_gui_submenu_2 = gtk_menu_new();
210         ws_gui_app->ws_gui_menu->ws_gui_submenu_3 = gtk_menu_new();
211         ws_gui_app->ws_gui_menu->ws_gui_main_menu = gtk_menu_new();
212  
213         ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries = gtk_menu_item_new_with_label("Dictionaries");
214         ws_gui_app->ws_gui_menu->ws_gui_menu_edit = gtk_menu_item_new_with_label("Edit");
215         ws_gui_app->ws_gui_menu->ws_gui_menu_view = gtk_menu_item_new_with_label("View");
216         ws_gui_app->ws_gui_menu->ws_gui_menu_search = gtk_menu_item_new_with_label("Search");
217         ws_gui_app->ws_gui_menu->ws_gui_menu_about = gtk_menu_item_new_with_label("About...");
218         ws_gui_app->ws_gui_menu->ws_gui_menu_close = gtk_menu_item_new_with_label("Close");
219         ws_gui_app->ws_gui_menu->ws_gui_separator = gtk_separator_menu_item_new();
220         ws_gui_app->ws_gui_menu->ws_gui_separator1 = gtk_separator_menu_item_new();
221
222         ws_gui_app->ws_gui_menu->ws_gui_menu_load_dict = gtk_menu_item_new_with_label("Load dictionary");
223         ws_gui_app->ws_gui_menu->ws_gui_menu_select_dict = gtk_menu_item_new_with_label("Select dictionaries ...");
224         ws_gui_app->ws_gui_menu->ws_gui_menu_remove_dict = gtk_menu_item_new_with_label("Remove dictionaries ...");
225         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_0, ws_gui_app->ws_gui_menu->ws_gui_menu_load_dict);
226         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_0, ws_gui_app->ws_gui_menu->ws_gui_menu_select_dict);
227         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_0, ws_gui_app->ws_gui_menu->ws_gui_menu_remove_dict);
228         gtk_widget_set_sensitive(GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries), TRUE);
229
230
231         ws_gui_app->ws_gui_menu->ws_gui_menu_copy = gtk_menu_item_new_with_label("Copy");
232         ws_gui_app->ws_gui_menu->ws_gui_menu_paste = gtk_menu_item_new_with_label("Paste");
233         ws_gui_app->ws_gui_menu->ws_gui_menu_select_all = gtk_menu_item_new_with_label("Select All");
234         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_1, ws_gui_app->ws_gui_menu->ws_gui_menu_copy);
235         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_1, ws_gui_app->ws_gui_menu->ws_gui_menu_paste);
236         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_1, ws_gui_app->ws_gui_menu->ws_gui_menu_select_all);
237         
238         ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list = gtk_check_menu_item_new_with_label("Hide words list");
239         ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_in = gtk_menu_item_new_with_label("Zoom in");
240         ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_out = gtk_menu_item_new_with_label("Zoom out");
241         ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen = gtk_check_menu_item_new_with_label("Full screen");
242         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_2, ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list);
243         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_2, ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_in);
244         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_2, ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_out);
245         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_2, ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen);
246
247         ws_gui_app->ws_gui_menu->ws_gui_menu_find_word = gtk_menu_item_new_with_label("Find");
248         ws_gui_app->ws_gui_menu->ws_gui_menu_find_next = gtk_menu_item_new_with_label("Find next");
249         ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev = gtk_menu_item_new_with_label("Find previous");
250         ws_gui_app->ws_gui_menu->ws_gui_menu_stop = gtk_menu_item_new_with_label("Stop");
251         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_3, ws_gui_app->ws_gui_menu->ws_gui_menu_find_word);
252         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_3, ws_gui_app->ws_gui_menu->ws_gui_menu_find_next);
253         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_3, ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev);
254         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_3, ws_gui_app->ws_gui_menu->ws_gui_menu_stop);
255  
256         
257         
258         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu, ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries);
259         gtk_menu_item_set_submenu(GTK_MENU_ITEM(ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries), ws_gui_app->ws_gui_menu->ws_gui_submenu_0);
260         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu, ws_gui_app->ws_gui_menu->ws_gui_separator1);
261
262         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu, ws_gui_app->ws_gui_menu->ws_gui_menu_edit);
263         gtk_menu_item_set_submenu(GTK_MENU_ITEM(ws_gui_app->ws_gui_menu->ws_gui_menu_edit), ws_gui_app->ws_gui_menu->ws_gui_submenu_1);
264         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu, ws_gui_app->ws_gui_menu->ws_gui_menu_view);
265         gtk_menu_item_set_submenu(GTK_MENU_ITEM(ws_gui_app->ws_gui_menu->ws_gui_menu_view), ws_gui_app->ws_gui_menu->ws_gui_submenu_2);
266         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu, ws_gui_app->ws_gui_menu->ws_gui_menu_search);
267         gtk_menu_item_set_submenu(GTK_MENU_ITEM(ws_gui_app->ws_gui_menu->ws_gui_menu_search), ws_gui_app->ws_gui_menu->ws_gui_submenu_3);
268         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu, ws_gui_app->ws_gui_menu->ws_gui_separator);
269         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu, ws_gui_app->ws_gui_menu->ws_gui_menu_about);
270         gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu, ws_gui_app->ws_gui_menu->ws_gui_menu_close);
271
272         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_load_dict), "activate", G_CALLBACK(ws_gui_dictionary_loader), ws_gui_app);
273         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_select_dict), "activate", G_CALLBACK(ws_gui_dictionary_chooser), ws_gui_app);
274         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_remove_dict), "activate", G_CALLBACK(ws_gui_dictionary_remover), ws_gui_app);
275         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_copy), "activate", GTK_SIGNAL_FUNC(ws_gui_html_copy), ws_gui_app);
276         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_paste), "activate", GTK_SIGNAL_FUNC(ws_gui_html_paste), ws_gui_app);
277         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_select_all), "activate", GTK_SIGNAL_FUNC(ws_gui_html_select_all), ws_gui_app);
278         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list), "activate", GTK_SIGNAL_FUNC(ws_gui_words_list_hide_from_menu), ws_gui_app);
279         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_in), "activate", G_CALLBACK(ws_gui_html_zoom_in), ws_gui_app);
280         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_out), "activate", G_CALLBACK(ws_gui_html_zoom_out), ws_gui_app);
281         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen), "activate", GTK_SIGNAL_FUNC(ws_gui_full_screen), ws_gui_app);
282         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_find_word), "activate", GTK_SIGNAL_FUNC(ws_gui_search), ws_gui_app);
283         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_find_next), "activate", GTK_SIGNAL_FUNC(ws_gui_history_next), ws_gui_app);
284         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev), "activate", GTK_SIGNAL_FUNC(ws_gui_history_back), ws_gui_app);
285         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_stop), "activate", GTK_SIGNAL_FUNC(ws_gui_search_stop), ws_gui_app);
286         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_about), "activate", G_CALLBACK(ws_gui_about_application), ws_gui_app);
287         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_menu_close), "activate", G_CALLBACK(ws_gui_menu_quit), ws_gui_app);
288  
289         hildon_window_set_menu(HILDON_WINDOW(ws_gui_app->ws_gui_hildon_window), GTK_MENU(ws_gui_app->ws_gui_menu->ws_gui_main_menu));
290
291         
292         gtk_widget_set_sensitive(GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_stop), FALSE);
293         gtk_widget_set_sensitive(GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_next), FALSE);
294         gtk_widget_set_sensitive(GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev), FALSE);
295
296
297         gtk_widget_show_all(ws_gui_app->ws_gui_menu->ws_gui_main_menu);
298 }
299
300
301 /** this function creates contex popup menu and its items and connect signals to them
302  *
303  * @param user_data - set when the signal handler was connected
304  */
305 GtkWidget * ws_gui_create_popup_menu (gpointer user_data)
306 {
307         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
308
309         ws_gui_app->ws_gui_menu->ws_gui_popup_menu = gtk_menu_new();
310         ws_gui_app->ws_gui_menu->ws_gui_popup_submenu = gtk_menu_new();
311         ws_gui_app->ws_gui_menu->ws_gui_separator = gtk_separator_menu_item_new();
312         
313         ws_gui_app->ws_gui_menu->ws_gui_popup_copy = gtk_menu_item_new_with_label("Copy");
314         gtk_menu_append((ws_gui_app->ws_gui_menu->ws_gui_popup_submenu), ws_gui_app->ws_gui_menu->ws_gui_popup_copy);
315         
316         ws_gui_app->ws_gui_menu->ws_gui_popup_paste = gtk_menu_item_new_with_label("Paste");
317         gtk_menu_append((ws_gui_app->ws_gui_menu->ws_gui_popup_submenu), ws_gui_app->ws_gui_menu->ws_gui_popup_paste);
318
319         ws_gui_app->ws_gui_menu->ws_gui_popup_select_all = gtk_menu_item_new_with_label("Select All");
320         gtk_menu_append((ws_gui_app->ws_gui_menu->ws_gui_popup_submenu), ws_gui_app->ws_gui_menu->ws_gui_popup_select_all);
321         gtk_widget_show_all(ws_gui_app->ws_gui_menu->ws_gui_popup_submenu);
322         
323         ws_gui_app->ws_gui_menu->ws_gui_popup_edit = gtk_menu_item_new_with_label ("Edit");
324         gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu), ws_gui_app->ws_gui_menu->ws_gui_popup_edit);
325
326         gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu), ws_gui_app->ws_gui_menu->ws_gui_separator);
327
328         ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_in = gtk_menu_item_new_with_label ("Zoom in");
329         gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu), ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_in);
330
331         ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_out = gtk_menu_item_new_with_label ("Zoom out");
332         gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu), ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_out);
333
334         gtk_widget_show_all(ws_gui_app->ws_gui_menu->ws_gui_popup_menu);
335         gtk_menu_item_set_submenu(GTK_MENU_ITEM(ws_gui_app->ws_gui_menu->ws_gui_popup_edit), ws_gui_app->ws_gui_menu->ws_gui_popup_submenu);
336
337         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_popup_copy), "activate", G_CALLBACK(ws_gui_html_copy_popup), ws_gui_app);
338         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_popup_paste), "activate", G_CALLBACK(ws_gui_html_paste), ws_gui_app);
339         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_popup_select_all), "activate", G_CALLBACK(ws_gui_html_select_all), ws_gui_app);
340         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_in), "activate", G_CALLBACK(ws_gui_html_zoom_in), ws_gui_app);
341         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_out), "activate", G_CALLBACK(ws_gui_html_zoom_out), ws_gui_app);
342         
343         return (GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_popup_menu));
344 }
345
346 void ws_gui_dictionary_chooser(GtkMenuItem *menuitem, gpointer user_data)
347 {
348         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
349
350         GtkWidget *dialog1;
351         GtkWidget *dialog_vbox1;
352         GtkWidget *scrolledwindow1;
353         GtkWidget *viewport1;
354         GtkWidget *vbox1;
355
356         GtkWidget *checkbutton;
357         GtkWidget *cancel_button;
358         GtkWidget *ok_button;
359         guint i =0;
360         gchar* string;
361         gchar* path;
362         gchar* name;
363         GArray *checkboxes;
364         
365         checkboxes = g_array_new (TRUE, TRUE, sizeof(GtkWidget*));
366
367         if (gconf_client_dir_exists(ws_gui_app->client, GCONF_PATH, NULL) == TRUE)
368         {
369         ws_gui_app->directories = gconf_client_all_dirs(ws_gui_app->client, GCONF_PATH, NULL);
370         }
371         else 
372         {
373                 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n.::GUI::. /apps/WhiteStork/Dictionaries does not exist!!");
374         }
375
376         dialog1 = gtk_dialog_new ();
377         gtk_window_set_title (GTK_WINDOW (dialog1), ("Choose dictionaries"));
378         gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);
379         gtk_window_set_default_size(GTK_WINDOW (dialog1), 300, 200);
380         
381         dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
382         gtk_widget_show (dialog_vbox1);
383         
384         scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
385         gtk_widget_show (scrolledwindow1);
386         gtk_box_pack_start (GTK_BOX (dialog_vbox1), scrolledwindow1, TRUE, TRUE, 0);
387         
388         viewport1 = gtk_viewport_new (NULL, NULL);
389         gtk_widget_show (viewport1);
390         gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport1);
391         
392         vbox1 = gtk_vbox_new (FALSE, 0);
393         gtk_widget_show (vbox1);
394         gtk_container_add (GTK_CONTAINER (viewport1), vbox1);
395         
396         for (i=0; i< g_slist_length(ws_gui_app->directories);i++)
397         {
398         string = (gchar*)g_slist_nth_data(ws_gui_app->directories, i); 
399         //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n.::GUI::. list item: %s", string);
400         name = g_path_get_basename(string);
401         checkbutton = gtk_check_button_new_with_label(name);
402         path = g_strconcat(string, "/active", NULL);
403         if (gconf_client_get_bool (ws_gui_app->client, path, NULL) == TRUE)
404         {
405                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), TRUE);
406         }
407         else 
408         {
409                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), FALSE);
410         }
411         
412         g_array_append_val(checkboxes, checkbutton);
413         gtk_box_pack_start (GTK_BOX (vbox1), checkbutton, FALSE, FALSE, 0);
414         gtk_widget_show (checkbutton);
415         }
416         
417         cancel_button = gtk_button_new_from_stock ("cancel");
418         gtk_widget_show (cancel_button);
419         gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancel_button, GTK_RESPONSE_CANCEL);
420         
421         ok_button = gtk_button_new_from_stock ("ok");
422         gtk_widget_show (ok_button);
423         gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), ok_button, GTK_RESPONSE_OK);
424         
425         i = gtk_dialog_run(GTK_DIALOG(dialog1));
426
427         if (i == GTK_RESPONSE_OK) 
428         {
429                 for(i=0;i<(checkboxes->len);i++)
430                 {
431                         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_array_index(checkboxes, GtkWidget *, i))) == TRUE)
432                         {
433                                 name = gtk_button_get_label(GTK_BUTTON(g_array_index(checkboxes, GtkWidget *, i)));
434                                 path=g_strconcat(GCONF_PATH, "/", name, "/active", NULL);
435                                 gconf_client_set_bool (ws_gui_app->client, path, TRUE, NULL);
436                         }
437
438                         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_array_index(checkboxes, GtkWidget *, i))) == FALSE)
439                         {
440                                 name = gtk_button_get_label(GTK_BUTTON(g_array_index(checkboxes, GtkWidget *, i)));
441                                 path=g_strconcat(GCONF_PATH, "/", name, "/active", NULL);
442                                 gconf_client_set_bool(ws_gui_app->client, path, FALSE, NULL);
443                         }
444                 }
445         ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_CONFIG_CHANGED);
446         gtk_widget_destroy (dialog1);
447         }
448         else if (i == GTK_RESPONSE_CANCEL) 
449         {
450         //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. Dictionary selection dialog - CANCEL");
451         gtk_widget_destroy (dialog1);
452         }
453         
454         g_slist_free(ws_gui_app->directories);
455 }
456
457 void ws_gui_dictionary_loader(GtkMenuItem *menuitem, gpointer user_data)
458 {
459         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
460                 
461         GtkWidget *dialog;
462         GtkWidget *dialog2;
463
464         dialog = gtk_file_chooser_dialog_new("Load dictionary", GTK_WINDOW(ws_gui_app->ws_gui_hildon_window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
465         gtk_window_set_default_size(GTK_WINDOW (dialog), 300, 300);
466         gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER(dialog), TRUE);
467         
468         gtk_widget_show_all(GTK_WIDGET(dialog));
469         
470         
471         if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
472         { 
473                 char *filename;
474                 char *name;
475                 char *path;
476                 int len;
477                 char *filepath;
478
479                 gchar* tmp;
480         
481                 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
482                 //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. File name: %s\n", filename);
483                 name = g_path_get_basename(filename);
484                 //tmp2 = g_strsplit(filename, "/", 1);
485                 len = strlen(filename) - strlen(name) -1;
486                 tmp = g_strndup (filename, len);
487                 tmp = g_path_get_basename(tmp);
488                 //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. Nazwa folderu: %s", tmp);
489                 
490                 //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n.::GUI::. extension: %s", tmp[0]);
491                 
492                 if (g_str_has_suffix(name, ".xdxf"))
493                 {
494                 len = strlen(filename) - strlen(name) -1;
495                 filepath = g_strndup (filename, len);
496                 path = g_strconcat(GCONF_PATH, "/", tmp, "/path", NULL);
497                 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. filename: %s", filename);
498                 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. name: %s", name);
499                 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. path: %s", path);
500                 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. filepath: %s", filepath);
501                 gconf_client_set_string(ws_gui_app->client, path, filepath , NULL);
502                 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. OK");
503                 path = g_strconcat(GCONF_PATH, "/", tmp, "/active", NULL);
504                 //gconf_client_set_bool(ws_gui_app->client, path, FALSE , NULL);
505                 gtk_widget_destroy (dialog);
506                 
507                 dialog2 = gtk_message_dialog_new (GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
508                                   GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
509                                   GTK_BUTTONS_YES_NO,
510                                   "Do you want to optimize this dictionary now?");
511                 gtk_widget_show_all(GTK_WIDGET(dialog2));
512
513                 if (gtk_dialog_run (GTK_DIALOG (dialog2)) == GTK_RESPONSE_YES)
514                 {
515                 gconf_client_set_bool(ws_gui_app->client, path, TRUE , NULL);
516                 gtk_widget_destroy (dialog2);
517                 }
518                 else 
519                 {
520                 gconf_client_set_bool(ws_gui_app->client, path, FALSE , NULL);
521                 gtk_widget_destroy (dialog2);
522                 }
523                 ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_CONFIG_CHANGED);
524                 gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window), "New dictionary has been added");
525                 }
526                 else
527                 {
528                 //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n.::GUI::. Bad dictionary file extension.");
529                 gtk_widget_destroy (dialog);
530                 gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window), "Wrong dictionary file");
531                 }
532                 
533                 
534         }
535         else 
536         {
537         gtk_widget_destroy (dialog);
538         }
539
540 }
541
542 void ws_gui_dictionary_remover(GtkMenuItem *menuitem, gpointer user_data)
543 {
544 WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
545
546         GtkWidget *dialog1;
547         GtkWidget *dialog_vbox1;
548         GtkWidget *scrolledwindow1;
549         GtkWidget *viewport1;
550         GtkWidget *vbox1;
551
552         GtkWidget *checkbutton;
553         GtkWidget *cancel_button;
554         GtkWidget *ok_button;
555         guint i =0;
556         gchar* string;
557         gchar* path;
558         gchar* name;
559         GArray *checkboxes;
560         
561         checkboxes = g_array_new (TRUE, TRUE, sizeof(GtkWidget*));
562
563         if (gconf_client_dir_exists(ws_gui_app->client, GCONF_PATH, NULL) == TRUE)
564         {
565         ws_gui_app->directories = gconf_client_all_dirs(ws_gui_app->client, GCONF_PATH, NULL);
566         }
567         else 
568         {
569                 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n.::GUI::. /apps/WhiteStork/Dictionaries does not exist!!");
570         }
571
572         dialog1 = gtk_dialog_new ();
573         gtk_window_set_title (GTK_WINDOW (dialog1), ("Remove dictionaries"));
574         gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);
575         gtk_window_set_default_size(GTK_WINDOW (dialog1), 300, 200);
576         
577         dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
578         gtk_widget_show (dialog_vbox1);
579         
580         scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
581         gtk_widget_show (scrolledwindow1);
582         gtk_box_pack_start (GTK_BOX (dialog_vbox1), scrolledwindow1, TRUE, TRUE, 0);
583         
584         viewport1 = gtk_viewport_new (NULL, NULL);
585         gtk_widget_show (viewport1);
586         gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport1);
587         
588         vbox1 = gtk_vbox_new (FALSE, 0);
589         gtk_widget_show (vbox1);
590         gtk_container_add (GTK_CONTAINER (viewport1), vbox1);
591         
592         for (i=0; i< g_slist_length(ws_gui_app->directories);i++)
593         {
594         string = (gchar*)g_slist_nth_data(ws_gui_app->directories, i); 
595         //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n.::GUI::. list item: %s", string);
596         name = g_path_get_basename(string);
597         checkbutton = gtk_check_button_new_with_label(name);
598         
599         g_array_append_val(checkboxes, checkbutton);
600         gtk_box_pack_start (GTK_BOX (vbox1), checkbutton, FALSE, FALSE, 0);
601         gtk_widget_show (checkbutton);
602         }
603         
604         cancel_button = gtk_button_new_from_stock ("cancel");
605         gtk_widget_show (cancel_button);
606         gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancel_button, GTK_RESPONSE_CANCEL);
607         
608         ok_button = gtk_button_new_from_stock ("remove selected");
609         gtk_widget_show (ok_button);
610         gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), ok_button, GTK_RESPONSE_OK);
611         
612         i = gtk_dialog_run(GTK_DIALOG(dialog1));
613
614         if (i == GTK_RESPONSE_OK) 
615         {
616                 for(i=0;i<(checkboxes->len);i++)
617                 {
618                         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_array_index(checkboxes, GtkWidget *, i))) == TRUE)
619                         {
620                                 name = gtk_button_get_label(GTK_BUTTON(g_array_index(checkboxes, GtkWidget *, i)));
621                                 path=g_strconcat(GCONF_PATH, "/", name, NULL);
622                                 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "do usuniecia: %s", path);
623                                 gconf_client_recursive_unset(ws_gui_app->client, path, GCONF_UNSET_INCLUDING_SCHEMA_NAMES, NULL);
624                                 //gconf_client_remove_dir (ws_gui_app->client, path, NULL);
625                         }
626                 }
627         ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_CONFIG_CHANGED);
628         gtk_widget_destroy (dialog1);
629         }
630         else if (i == GTK_RESPONSE_CANCEL) 
631         {
632         //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. Dictionary selection dialog - CANCEL");
633         gtk_widget_destroy (dialog1);
634         }
635         
636         g_slist_free(ws_gui_app->directories);
637 }
638
639 void ws_gui_about_application(GtkMenuItem *menuitem, gpointer user_data)
640 {
641         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
642         
643         //gchar *license = "User Interface\nCopyright 2006, ComArch S.A\nAll rights reserved\n\n\nDBUS wrapper\nCopyright (C) 1991,\n1999 Free Software Foundation, Inc. \n51 Franklin Street, Fifth Floor,\nBoston, MA  02110-1301 USA\nEveryone is permitted to copy \nand distribute verbatim copies \nof this license document,\nbut changing it is not allowed.\n\nhttp://www.gnu.org/licenses/lgpl.html \n\n\nEngine\nCopyright (C) 1989,\n1991 Free Software Foundation, Inc., \n51 Franklin Street, Fifth Floor, \nBoston, MA 02110-1301 USA \nEveryone is permitted to copy \nand distribute verbatim copies \nof this license document,\nbut changing it is not allowed.\n\nhttp://www.gnu.org/licenses/gpl.txt\n";
644
645         GtkWidget *about_dialog;
646         gtk_widget_set_sensitive (GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar), FALSE);
647         GtkWidget *dialog_vbox1;
648         GtkWidget *vbox1;
649         GtkWidget *image;
650         GtkWidget *label2;
651         GtkWidget *label3;
652         GtkWidget *label4;
653         GtkWidget *scrolledwindow;
654         GtkWidget *textview;
655         GtkWidget *button1;
656         //GtkWidget *button2;
657
658         about_dialog = gtk_dialog_new ();
659         gtk_window_set_title (GTK_WINDOW (about_dialog), "About");
660         gtk_window_set_default_size(GTK_WINDOW (about_dialog), 350, 200);
661         
662         dialog_vbox1 = GTK_DIALOG (about_dialog)->vbox;
663         gtk_widget_show (dialog_vbox1);
664         
665         vbox1 = gtk_vbox_new (FALSE, 0);
666         gtk_widget_show (vbox1);
667         gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);
668         
669         image = gtk_image_new_from_file ("/usr/share/pixmaps/whitestork.png");
670         gtk_box_pack_start (GTK_BOX (vbox1), image, TRUE, TRUE, 0);
671         
672         label2 = gtk_label_new ("WhiteStork");
673         ws_gui_app->p = pango_font_description_from_string("Tahoma 16");
674         gtk_widget_modify_font(GTK_WIDGET(label2), ws_gui_app->p);
675         gtk_label_set_pattern (GTK_LABEL(label2), "__________");
676         gtk_box_pack_start (GTK_BOX (vbox1), label2, FALSE, FALSE, 5);
677         
678         label3 = gtk_label_new ("Maemo Multilingual Dictionary");
679         ws_gui_app->p = pango_font_description_from_string("Tahoma 12");
680         gtk_widget_modify_font(GTK_WIDGET(label3), ws_gui_app->p);
681         gtk_box_pack_start (GTK_BOX (vbox1), label3, FALSE, FALSE, 5);
682         
683         label4 = gtk_label_new ("Copyright 2006, ComArch S.A\nAll rights reserved");
684         ws_gui_app->p = pango_font_description_from_string("Tahoma 12");
685         gtk_widget_modify_font(GTK_WIDGET(label4), ws_gui_app->p);
686         gtk_box_pack_start (GTK_BOX (vbox1), label4, FALSE, FALSE, 5);
687         gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_CENTER);
688
689         scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
690         gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_SHADOW_ETCHED_OUT);
691         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
692         gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow, TRUE, TRUE, 0);
693
694         textview = gtk_text_view_new ();
695         ws_gui_app->p = pango_font_description_from_string("Tahoma 10");
696         gtk_widget_modify_font(GTK_WIDGET(textview), ws_gui_app->p);
697         gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
698         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textview), 10);
699         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(textview), 10);
700         gtk_container_add (GTK_CONTAINER (scrolledwindow), textview);
701         gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)), "The following third party\ncomponents may be\nincluded depending \non your system configuration:\n\nD-BUS - License information:\nhttp://opensource.org/licenses/academic.php", -1);
702
703         button1 = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
704         gtk_dialog_add_action_widget (GTK_DIALOG(about_dialog), button1, GTK_RESPONSE_CLOSE);
705         
706         //button2 = gtk_button_new_with_label("License");
707         //gtk_dialog_add_action_widget (GTK_DIALOG (about_dialog), button2, GTK_RESPONSE_OK);
708         gtk_widget_show_all (GTK_WIDGET(about_dialog));
709
710         if (gtk_dialog_run(GTK_DIALOG(about_dialog)) == GTK_RESPONSE_CLOSE)
711         {
712         //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "About...");
713         gtk_widget_destroy(GTK_WIDGET(about_dialog));
714         }
715         else if (gtk_dialog_run(GTK_DIALOG(about_dialog)) == GTK_RESPONSE_OK)
716         {
717
718         }
719         
720         gtk_widget_set_sensitive (GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar), TRUE);
721         
722
723         /*GtkWidget *about_dialog;
724         gtk_widget_set_sensitive (GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar), FALSE);
725
726         if (gtk_window_set_default_icon_from_file("/usr/share/pixmaps/icon.png", NULL))
727         {
728         g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Default icon set");
729         }
730         about_dialog = gtk_about_dialog_new();
731         gtk_about_dialog_set_name (GTK_ABOUT_DIALOG(about_dialog), "WhiteStork");
732         gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about_dialog), "Copyright 2006, ComArch S.A\nAll rights reserved");
733         //gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(about_dialog),"whitestork.png");
734         gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about_dialog), "Maemo Multilingual Dictionary");
735         
736         gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(about_dialog), license);
737         //LGPL: http://www.gnu.org/licenses/lgpl.html 
738         //GPL: http://www.gnu.org/licenses/gpl.txt
739         //gtk_show_about_dialog(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window), NULL);
740         */
741
742 }
743
744 GtkWidget* licence_dialog(gpointer user_data)
745 {
746         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
747         GtkWidget *license_dialog;
748         
749         GtkWidget *license_vbox1;
750         GtkWidget *scrolledwindow1;
751         GtkWidget *textview1;
752         GtkWidget *button1;
753         GtkWidget *button2;
754
755         license_dialog = gtk_dialog_new ();
756         gtk_window_set_title (GTK_WINDOW (license_dialog), "Licence");
757         gtk_window_set_default_size(GTK_WINDOW (license_dialog), 500, 300);
758         
759         license_vbox1 = GTK_DIALOG (license_dialog)->vbox;
760         gtk_widget_show(license_vbox1);
761         
762         scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
763         gtk_box_pack_start (GTK_BOX (license_vbox1), scrolledwindow1, TRUE, TRUE, 0);
764         gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);
765         
766         textview1 = gtk_text_view_new ();
767         ws_gui_app->p = pango_font_description_from_string("Tahoma 10");
768         gtk_widget_modify_font(GTK_WIDGET(textview1), ws_gui_app->p);
769         gtk_container_add (GTK_CONTAINER (scrolledwindow1), textview1);
770         gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1)), "Terms of use\n\nREAD THE TERMS OF USE CAREFULLY BEFORE INSTALALTION OF THIS SOFTWARE. BY\nINSTALALTION OF THIS SOFTWARE, YOU AGREE TO THE FOLLOWING TERMS OF USE.\n\n1. LICENSE TO USE. ComArch grants you a non-exclusive and non-transferable\nlicense for the internal use only of the accompanying software and\ndocumentation and any error corrections provided by ComArch (collectively \"Software\"), by the one user.\n\n2. RESTRICTIONS. Software is confidential and copyrighted. Title to Software\nand all associated intellectual property rights is retained by ComArch\nand/or its licensors. Unless enforcement is prohibited by applicable law,\nyou may not modify, decompile, or reverse engineer Software. You acknowledge\nthat Software is not designed, licensed or intended for use in the design,\nconstruction, operation or maintenance of any nuclear facility. Sun ComArch\ndisclaims any express or implied warranty of fitness for such uses. No\nright, title or interest in or to any trademark, service mark, logo or trade\nname of ComArch or its licensors is granted under this terms of use.\n\n3. DISCLAIMER OF WARRANTY. UNLESS SPECIFIED IN THIS AGREEMENT TERMS OF USE,\nALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING\nANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR\nNON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS\nARE HELD TO BE LEGALLY INVALID.\n\n4. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT\nWILL COMARCH OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR\nDATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE\nDAMAGES, HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT\nOF OR RELATED TO THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF COMARCH\nHAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. In no event will\nComArch's liability to you, whether in contract, tort (including\nnegligence), or otherwise, exceed []. The foregoing limitations will apply\neven if the above stated warranty fails of its essential purpose.\n\n5. Termination. This license is effective until terminated. You may\nterminate this license at any time by destroying all\ncopies of Software.\nThis license will terminate immediately without notice from ComArch if you\nfail to comply with any provision of this license. Upon Termination, you\nmust destroy all copies of Software.\n\n6. Export Regulations. All Software and technical data delivered under this\nterms of use are subject to Polish export control laws and may be subject to\nexport or import regulations in other countries. You agree to comply\nstrictly with all such laws and regulations and acknowledge that you have\nthe responsibility to obtain such licenses to export, re-export, or import\nas may be required after delivery to you.\n\n7. Governing Law. Any action related to this license will be governed by\nPolish Law.\n\n8. Severability. If any provision of this terms of use is held to be\nunenforceable, this terms of use will remain in effect with the provision\nomitted, unless omission would frustrate the intent of the parties, in which\ncase this terms of use will immediately terminate.\n\n9. Integration. This document is the entire  agreement between you and\nComArch relating to its subject matter. It supersedes all prior or\ncontemporaneous oral or written communications, proposals, representations\nand warranties and prevails over any conflicting or additional\nterms of any\nquote, order, acknowledgment, or other communication between the parties\nrelating to its subject matter during the term of these terms of use. No\nmodification of this Agreement will be binding, unless in writing and signed\nby an authorized representative of each party.", -1);
771         
772         button1 = gtk_button_new_with_label("Agree");
773         gtk_dialog_add_action_widget (GTK_DIALOG (license_dialog), button1, GTK_RESPONSE_OK);
774         
775         
776         button2 = gtk_button_new_with_label("Disagree");
777         gtk_dialog_add_action_widget (GTK_DIALOG (license_dialog), button2, GTK_RESPONSE_CLOSE);
778
779         gtk_widget_show_all(license_dialog);
780         return license_dialog;
781
782 }