1 /* vim: set sw=4 ts=4 et: */
3 * This file is part of Live Wallpaper (livewp)
5 * Copyright (C) 2010 Vlad Vasiliev
6 * Copyright (C) 2010 Tanya Makova
9 * This software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
14 * This software is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this software; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 /*******************************************************************************/
25 #include "livewp-settings.h"
26 /*******************************************************************************/
29 GtkWidget *window = NULL,
32 window = gtk_dialog_new();
33 gtk_window_set_title(GTK_WINDOW(window), _("About"));
34 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
35 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
36 vbox = gtk_vbox_new (FALSE, 5);
37 label_about = gtk_label_new (_("Live Wallpaper Version 0.8.1 \n Copyright(c) 2010\n \
38 Tanya Makova\n Vlad Vasiliev\n \
39 Copyright(c) 2010 for design themes Berlin, Modern and Accel Vasya Bobrikov\n \
40 Copyright(c) 2010 for design theme Matrix and icons Andrew Zhilin\n \
42 Finnish - Marko Vertainen\n \
43 Spain - Alejandro López\n \
44 Russian - Tanya Makova \n \
46 gtk_box_pack_start (GTK_BOX (vbox), label_about, FALSE, FALSE, 0);
47 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
49 gtk_widget_show (label_about);
50 gtk_widget_show (vbox);
51 gtk_widget_show (window);
52 gtk_dialog_run(GTK_DIALOG(window));
55 /*******************************************************************************/
57 create_category_selector (Animation_WallpaperPrivate *priv){
59 GSList *store = priv->extheme_list;
61 GHashTable *result_table = NULL;
63 result_table = g_hash_table_new(g_str_hash, g_str_equal);
65 if (!g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")))
66 g_hash_table_insert(result_table, g_hash_table_lookup(store->data, "category"), (gint *)1);
67 store = g_slist_next(store);
70 category_list = g_hash_table_get_keys (result_table);
71 selector = hildon_touch_selector_new_text();
73 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "LiveWallpaper" );
74 while (category_list){
75 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),category_list->data );
76 category_list = g_list_next(category_list);
82 /*******************************************************************************/
84 theme_button_clicked(GtkWidget *button, GdkEventButton *event, Animation_WallpaperPrivate *priv){
86 lw_theme_settings(GTK_WIDGET(button), priv);
89 /********************************************************************************/
91 set_button_image(GtkWidget * button, Animation_WallpaperPrivate *priv, gboolean enable){
92 GtkWidget * image = NULL;
93 GdkPixbuf * pixbuf = NULL;
95 gchar *icon_on = NULL;
96 gchar *icon_off = NULL;
97 GSList *store = priv->extheme_list;
100 if (!strcmp(priv->theme, g_hash_table_lookup(store->data, "name"))){
101 icon_on = g_strdup(g_hash_table_lookup(store->data, "icon_on"));
102 icon_off = g_strdup(g_hash_table_lookup(store->data, "icon_off"));
105 store = (GSList *)g_list_next(store);
109 str = g_strdup_printf("%s", icon_on);
111 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
112 priv->theme, "icon.png");
115 str = g_strdup_printf("%s", icon_off);
117 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
118 priv->theme, "icond.png");
120 pixbuf = gdk_pixbuf_new_from_file_at_size (str,
131 image = gtk_image_new_from_pixbuf (pixbuf);
132 g_object_unref(G_OBJECT(pixbuf));
135 //hildon_button_set_image (HILDON_BUTTON (button), image);
136 GList *list = gtk_container_get_children(GTK_CONTAINER (button));
138 gtk_container_remove(GTK_CONTAINER (button), list->data);
140 gtk_container_add(GTK_CONTAINER (button), image);
141 gtk_widget_show(image);
142 gtk_widget_show(button);
145 /********************************************************************************/
147 create_image_button (gint view, DBusConnection *conn_sess){
149 GtkWidget *event_box;
151 Animation_WallpaperPrivate *priv = g_new0(Animation_WallpaperPrivate, 1);
152 /* Add external themes to priv */
153 priv->extheme_list = get_list_exthemes();
156 priv->theme_string_parametr1 = NULL;
157 priv->dbus_conn_session = conn_sess;
160 event_box = gtk_event_box_new();
161 g_object_set_data(G_OBJECT(event_box), "view", GINT_TO_POINTER(view));
162 g_object_set_data(G_OBJECT(event_box), "priv", priv);
163 set_button_image(event_box, priv, check_applet_state(view));
164 g_signal_connect(G_OBJECT (event_box), "button_press_event", G_CALLBACK(theme_button_clicked), priv);
167 button = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
168 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
169 g_object_set_data(G_OBJECT(button), "view", GINT_TO_POINTER(view));
170 g_object_set_data(G_OBJECT(button), "priv", priv);
171 set_button_image(button, priv, check_applet_state(view));
172 g_signal_connect(button, "clicked", G_CALLBACK(theme_button_clicked), priv);
173 hildon_button_set_image_position (HILDON_BUTTON (button), GTK_POS_RIGHT);
177 /********************************************************************************/
179 changed_value_theme_cb (HildonPickerButton *picker, Animation_WallpaperPrivate *priv)
181 const gchar *choice = hildon_button_get_value(HILDON_BUTTON (picker));
182 GtkWidget *vbox = NULL;
183 GtkWidget *area_vbox = NULL;
185 area_vbox = g_object_get_data(G_OBJECT(priv->window), "area_vbox");
188 vbox = g_object_get_data(G_OBJECT(priv->window), "custom_vbox");
190 gtk_widget_destroy(vbox);
192 vbox = gtk_vbox_new (TRUE, 5);
193 g_object_set_data(G_OBJECT(priv->window), "custom_vbox", vbox);
194 gtk_box_pack_start(GTK_BOX(area_vbox),
195 vbox, FALSE, FALSE, 5);
197 if (!strcmp(choice, _("Berlin"))){
198 rich_animation_additional_parametr(vbox,priv);
200 if (!strcmp(choice, _("Modern"))){
201 rich_animation_additional_parametr(vbox,priv);
203 if (!strcmp(choice, _("Matrix"))){
204 rich_animation_additional_parametr(vbox,priv);
207 if (!strcmp(choice, _("Accel"))){
208 rich_animation_additional_parametr(vbox,priv);
210 if (!strcmp(choice, _("Video"))){
211 additional_parametr_for_theme_video(vbox, priv);
214 gtk_widget_show(vbox);
216 /********************************************************************************/
218 changed_value_category_cb (HildonPickerButton *picker, Animation_WallpaperPrivate *priv)
220 GtkWidget *theme_button = NULL;
222 theme_button = g_object_get_data(G_OBJECT(priv->window), "theme_button");
225 HildonTouchSelector * selector = hildon_picker_button_get_selector((HildonPickerButton *) theme_button);
226 hildon_touch_selector_remove_column(selector, 0);
227 hildon_touch_selector_append_text_column(selector, (GtkTreeModel*)gtk_list_store_new (1, G_TYPE_STRING), TRUE);
228 fill_theme_button(priv, theme_button, (gchar *)hildon_button_get_value(HILDON_BUTTON (picker)));
230 /********************************************************************************/
232 fill_theme_button (Animation_WallpaperPrivate *priv, GtkWidget *button, gchar *category){
234 gchar *theme = priv->theme;
236 hildon_button_set_value(HILDON_BUTTON (button), NULL);
238 changed_value_theme_cb(HILDON_PICKER_BUTTON (button), priv);
241 GSList *store = priv->extheme_list;
242 HildonTouchSelector * selector = hildon_picker_button_get_selector((HildonPickerButton *) button);
244 selector = (HildonTouchSelector *)hildon_touch_selector_new_text ();
246 hildon_button_set_value(HILDON_BUTTON(button), NULL);
247 if (!strcmp(category, "LiveWallpaper")){
248 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Berlin"));
249 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Modern"));
250 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Matrix"));
251 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Accel"));
252 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Video"));
255 if (!strcmp(theme, "Berlin")){
256 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
257 hildon_button_set_value(HILDON_BUTTON(button), _("Berlin"));
259 if (!strcmp(theme, "Modern")){
260 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 1);
261 hildon_button_set_value(HILDON_BUTTON(button), _("Modern"));
263 if (!strcmp(theme, "Matrix")){
264 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 2);
265 hildon_button_set_value(HILDON_BUTTON(button), _("Matrix"));
267 if (!strcmp(theme, "Accel")){
268 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 3);
269 hildon_button_set_value(HILDON_BUTTON(button), _("Accel"));
271 if (!strcmp(theme, "Video")){
272 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 4);
273 hildon_button_set_value(HILDON_BUTTON(button), _("Video"));
278 if (!g_hash_table_lookup(store->data, "category"))
280 if (!strcmp(g_hash_table_lookup(store->data, "category"), category)){
281 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), g_hash_table_lookup(store->data, "name"));
282 if (!strcmp(theme, g_hash_table_lookup(store->data, "name"))){
283 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, num);
284 hildon_button_set_value(HILDON_BUTTON(button), _(g_hash_table_lookup(store->data, "name")));
288 store = g_slist_next(store);
291 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
292 HILDON_TOUCH_SELECTOR (selector));
294 changed_value_theme_cb(HILDON_PICKER_BUTTON (button), priv);
296 /********************************************************************************/
298 create_themes_button (Animation_WallpaperPrivate *priv, gchar *category){
301 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
302 hildon_button_set_title (HILDON_BUTTON (button), _("Theme"));
307 /********************************************************************************/
309 create_categories_button (Animation_WallpaperPrivate *priv){
313 gchar *theme = priv->theme;
315 GHashTable *result_table = NULL;
317 result_table = g_hash_table_new(g_str_hash, g_str_equal);
318 selector = create_category_selector(priv);
319 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
320 hildon_button_set_title (HILDON_BUTTON (button), _("Category"));
321 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
322 HILDON_TOUCH_SELECTOR (selector));
324 if (!strcmp(theme, "Berlin")){
325 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
326 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
328 if (!strcmp(theme, "Modern")){
329 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
330 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
332 if (!strcmp(theme, "Matrix")){
333 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
334 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
336 if (!strcmp(theme, "Accel")){
337 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
338 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
340 if (!strcmp(theme, "Video")){
341 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
342 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
344 GSList *store = priv->extheme_list;
347 if (g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")) == NULL){
348 g_hash_table_insert(result_table, g_hash_table_lookup(store->data, "category"), (gint *)num);
351 if (!strcmp(theme, g_hash_table_lookup(store->data, "name"))){
352 if (g_hash_table_lookup(store->data, "category"))
353 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0,
354 (gint)g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")));
355 hildon_button_set_value(HILDON_BUTTON(button), g_hash_table_lookup(store->data, "category"));
359 store = g_slist_next(store);
365 /*******************************************************************************/
367 create_bool_button (gboolean active, gchar *name)
370 button = hildon_check_button_new (HILDON_SIZE_AUTO);
371 gtk_button_set_label (GTK_BUTTON (button), name);
372 hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
375 /*******************************************************************************/
377 create_enable_button (gboolean active)
380 button = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
381 gtk_button_set_label (GTK_BUTTON (button), _("Enable"));
382 hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
386 /*******************************************************************************/
388 show_settings(GtkWidget *widget, Animation_WallpaperPrivate *priv){
389 lw_main_settings(priv, NULL);
391 /*******************************************************************************/
393 lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data){
395 GtkWidget *window = NULL;
396 GtkWidget *theme_button1;
397 GtkWidget *theme_button2;
398 GtkWidget *theme_button3;
399 GtkWidget *theme_button4;
401 Animation_WallpaperPrivate *priv_temp = NULL;
403 window = gtk_dialog_new();
405 gtk_window_set_title(GTK_WINDOW(window), _("Live Wallpaper Settings"));
406 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
407 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
408 /* Create Theme button */
409 hbox = gtk_hbox_new(FALSE, 0);
410 theme_button1 = create_image_button(1, priv->dbus_conn_session);
411 gtk_box_pack_start(GTK_BOX(hbox),
412 theme_button1, TRUE, TRUE, 0);
413 theme_button2 = create_image_button(2, priv->dbus_conn_session);
414 gtk_box_pack_start(GTK_BOX(hbox),
415 theme_button2, TRUE, TRUE, 0);
416 theme_button3 = create_image_button(3, priv->dbus_conn_session);
417 gtk_box_pack_start(GTK_BOX(hbox),
418 theme_button3, TRUE, TRUE, 0);
419 theme_button4 = create_image_button(4, priv->dbus_conn_session);
420 gtk_box_pack_start(GTK_BOX(hbox),
421 theme_button4, TRUE, TRUE, 0);
422 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
423 hbox, TRUE, TRUE, 5);
425 gtk_widget_show (theme_button1);
426 gtk_widget_show (theme_button2);
427 gtk_widget_show (theme_button3);
428 gtk_widget_show (theme_button4);
429 gtk_widget_show_all (hbox);
430 gtk_widget_show (window);
431 gtk_dialog_add_button(GTK_DIALOG(window), _("About"), GTK_RESPONSE_NO);
433 result = gtk_dialog_run(GTK_DIALOG(window));
435 priv_temp = g_object_get_data(G_OBJECT(theme_button1), "priv");
440 priv_temp = g_object_get_data(G_OBJECT(theme_button2), "priv");
445 priv_temp = g_object_get_data(G_OBJECT(theme_button3), "priv");
450 priv_temp = g_object_get_data(G_OBJECT(theme_button4), "priv");
458 case GTK_RESPONSE_NO:
459 gtk_widget_destroy(window);
467 gtk_widget_destroy(window);
469 /*******************************************************************************/
471 file_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){
473 GtkWidget *dialog = hildon_file_chooser_dialog_new(GTK_WINDOW (priv->window), GTK_FILE_CHOOSER_ACTION_OPEN);
475 if (priv->theme_string_parametr1)
476 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), priv->theme_string_parametr1);
478 gtk_widget_show_all (GTK_WIDGET (dialog));
480 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
482 hildon_button_set_value (HILDON_BUTTON(button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
484 gtk_widget_destroy (dialog);
487 /*******************************************************************************/
489 rich_animation_additional_parametr(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
490 GtkWidget *rich_animation_button;
492 /* Create rich animation button */
493 rich_animation_button = create_bool_button(priv->rich_animation, _("Rich Animation"));
494 gtk_box_pack_start(GTK_BOX(vbox),
495 rich_animation_button, TRUE, TRUE, 5);
496 g_object_set_data(G_OBJECT(priv->window), "rich_animation_button", rich_animation_button);
497 gtk_widget_show (rich_animation_button);
499 /*******************************************************************************/
501 additional_parametr_for_theme_video(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
503 GtkWidget *file_button;
504 GtkWidget *sound_button;
505 GtkWidget *rich_animation_button;
507 if (priv->theme_string_parametr1)
508 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL,
509 _("Play file"), priv->theme_string_parametr1);
511 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL,
514 g_signal_connect (file_button, "clicked", G_CALLBACK (file_button_clicked), priv);
516 gtk_box_pack_start(GTK_BOX(vbox),
517 file_button, TRUE, TRUE, 5);
518 g_object_set_data(G_OBJECT(priv->window), "filename_button", file_button);
519 /* Create rich animation button */
520 rich_animation_button = create_bool_button(priv->rich_animation, _("Loop"));
521 gtk_box_pack_start(GTK_BOX(vbox),
522 rich_animation_button, TRUE, TRUE, 5);
523 g_object_set_data(G_OBJECT(priv->window), "rich_animation_button", rich_animation_button);
524 /* Create sound button */
525 sound_button = create_bool_button(priv->theme_bool_parametr1, _("Sound"));
526 gtk_box_pack_start(GTK_BOX(vbox),
527 sound_button, TRUE, TRUE, 5);
528 g_object_set_data(G_OBJECT(priv->window), "sound_button", sound_button);
530 gtk_widget_show (file_button);
531 gtk_widget_show (sound_button);
532 gtk_widget_show (rich_animation_button);
535 /*******************************************************************************/
537 lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) {
539 GtkWidget *window = NULL;
540 GtkWidget *scrolled_window = NULL;
541 GtkWidget *save_button;
542 GtkWidget *theme_button;
543 GtkWidget *category_button;
544 GtkWidget *enable_button;
546 GtkWidget *temp_button;
547 GtkWidget *area_vbox;
548 GtkWidget *button1 = NULL;
549 GtkWidget *rich_animation_button = NULL;
550 gint view = priv->view;
552 window = gtk_dialog_new();
553 priv->window = window;
555 gtk_window_set_title(GTK_WINDOW(window), _("View Settings"));
556 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
557 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
560 area_vbox = gtk_vbox_new(FALSE, 2);
561 g_object_set_data(G_OBJECT(window), "area_vbox", area_vbox);
562 scrolled_window = hildon_pannable_area_new ();
563 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA (scrolled_window), GTK_WIDGET (area_vbox));
564 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
565 scrolled_window, FALSE, FALSE, 0);
567 gtk_widget_set_size_request(scrolled_window, -1, 370);
569 /* Create Enable button */
570 enable_button = create_enable_button(check_applet_state(view));
571 gtk_box_pack_start(GTK_BOX(area_vbox),
572 enable_button, FALSE, FALSE, 5);
573 /* Create Category button */
574 category_button = create_categories_button(priv);
575 g_object_set_data(G_OBJECT(window), "category_button", category_button);
576 g_signal_connect (G_OBJECT (category_button), "value-changed", G_CALLBACK (changed_value_category_cb), priv);
577 gtk_box_pack_start(GTK_BOX(area_vbox),
578 category_button, FALSE, FALSE, 5);
579 /* Create Custom vbox */
580 vbox = gtk_vbox_new (FALSE, 5);
581 g_object_set_data(G_OBJECT(window), "custom_vbox", vbox);
583 /* Create Theme button */
584 theme_button = create_themes_button(priv, (gchar *)hildon_button_get_value(HILDON_BUTTON (category_button)));
585 g_object_set_data(G_OBJECT(window), "theme_button", theme_button);
586 g_signal_connect (G_OBJECT (theme_button), "value-changed", G_CALLBACK (changed_value_theme_cb), priv);
587 gtk_box_pack_start(GTK_BOX(area_vbox),
588 theme_button, FALSE, FALSE, 5);
589 fill_theme_button(priv, theme_button, (gchar *)hildon_button_get_value(HILDON_BUTTON (category_button)));
591 /* Pack custom vbox. It must be last widget */
592 gtk_box_pack_start(GTK_BOX(area_vbox),
593 vbox, FALSE, FALSE, 5);
595 gtk_widget_show (enable_button);
596 gtk_widget_show (category_button);
597 gtk_widget_show (theme_button);
598 gtk_widget_show (vbox);
599 gtk_widget_show (area_vbox);
600 gtk_widget_show (scrolled_window);
601 gtk_widget_show (window);
603 save_button = gtk_dialog_add_button(GTK_DIALOG(window), _("Save"), GTK_RESPONSE_YES);
605 result = gtk_dialog_run(GTK_DIALOG(window));
608 case GTK_RESPONSE_YES:
610 if (hildon_button_get_value(HILDON_BUTTON (theme_button)) &&
611 strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "")){
612 /* Check Xsnow program */
613 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Xsnow"))){
614 if (access("/usr/bin/xsnow", F_OK) != 0){
615 hildon_banner_show_information(GTK_WIDGET(button), NULL,
616 _("You haven't got the installed package Xsnow. Please install it via using Application Manager"));
617 /* if not scuccess exit from wthout saving */
624 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Berlin")))
625 priv->theme = g_strdup("Berlin");
626 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Modern")))
627 priv->theme = g_strdup("Modern");
628 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Matrix")))
629 priv->theme = g_strdup("Matrix");
630 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Accel")))
631 priv->theme = g_strdup("Accel");
632 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Video"))){
633 priv->theme = g_strdup("Video");
634 button1 = g_object_get_data(G_OBJECT(priv->window), "filename_button");
636 if (priv->theme_string_parametr1)
637 g_free(priv->theme_string_parametr1);
638 priv->theme_string_parametr1 = g_strdup((gchar*)hildon_button_get_value (HILDON_BUTTON(button1)));
640 temp_button = g_object_get_data(G_OBJECT(priv->window), "sound_button");
642 /* Check rich animation */
643 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(temp_button)))
644 priv->theme_bool_parametr1 = TRUE;
646 priv->theme_bool_parametr1 = FALSE;
649 /* Check external themes */
650 GSList *store = priv->extheme_list;
652 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _(g_hash_table_lookup(store->data, "name")))){
653 priv->theme = g_strdup(g_hash_table_lookup(store->data, "name"));
654 //priv->hash_theme = store->data;
657 store = g_slist_next(store);
662 rich_animation_button = g_object_get_data(G_OBJECT(priv->window), "rich_animation_button");
663 if (rich_animation_button){
664 /* Check rich animation */
665 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(rich_animation_button)))
666 priv->rich_animation = TRUE;
668 priv->rich_animation = FALSE;
672 /* action with applet */
673 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(enable_button))){
674 if (!check_applet_state(view)){
677 send_dbus_signal (priv,
678 LIVEWP_SIGNAL_INTERFACE,
680 LIVEWP_RELOAD_CONFIG);
683 if (check_applet_state(view))
686 set_button_image(button, priv, check_applet_state(view));
689 case GTK_RESPONSE_OK:
691 case GTK_RESPONSE_NO:
692 gtk_widget_destroy(window);
698 gtk_widget_destroy(window);
700 /*******************************************************************************/
702 check_applet_state(gint number){
704 HDConfigFile *config_file = NULL;
705 GKeyFile *gkey_file = NULL;
707 gboolean result = FALSE;
708 if (number > 4 || number < 1)
711 str = g_strdup_printf("livewp-home-widget.desktop-%i", (number - 1));
712 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
714 gkey_file = hd_config_file_load_file(config_file, FALSE);
715 if (gkey_file && str){
716 result = g_key_file_has_group(gkey_file, str);
721 /*******************************************************************************/
723 start_applet(gint number){
725 HDConfigFile *config_file = NULL;
726 GKeyFile *gkey_file = NULL;
729 if (number > 4 || number < 1)
731 str = g_strdup_printf("livewp-home-widget.desktop-%i",(number - 1));
732 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
734 gkey_file = hd_config_file_load_file(config_file, FALSE);
736 g_key_file_set_string (gkey_file, str, "X-Desktop-File", "/usr/share/applications/hildon-home/livewp-home-widget.desktop");
737 hd_config_file_save_file( config_file, gkey_file);
738 g_key_file_free(gkey_file);
740 fprintf(stderr, "Problem with config file");
743 g_object_unref(config_file);
745 /*******************************************************************************/
747 stop_applet(gint number){
748 HDConfigFile *config_file = NULL;
749 GKeyFile *gkey_file = NULL;
752 if (number > 4 || number < 1)
754 str = g_strdup_printf("livewp-home-widget.desktop-%i", (number - 1));
755 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
757 gkey_file = hd_config_file_load_file(config_file, FALSE);
759 g_key_file_remove_group(gkey_file, str, NULL);
760 hd_config_file_save_file( config_file, gkey_file);
761 g_key_file_free(gkey_file);
763 fprintf(stderr, "Problem with config file");
766 g_object_unref(config_file);