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 \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 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;
62 GtkListStore *list = NULL;
63 HildonTouchSelectorColumn *column = NULL;
65 result_table = g_hash_table_new(g_str_hash, g_str_equal);
67 if (!g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")))
68 g_hash_table_insert(result_table, g_hash_table_lookup(store->data, "category"), 1);
69 store = g_slist_next(store);
72 category_list = g_hash_table_get_keys (result_table);
73 selector = hildon_touch_selector_new_text();
75 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("LiveWallpaper") );
76 while (category_list){
77 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),category_list->data );
78 category_list = g_list_next(category_list);
84 /*******************************************************************************/
86 create_theme_selector (Animation_WallpaperPrivate *priv){
89 /*******************************************************************************/
91 theme_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){
93 lw_theme_settings(GTK_WIDGET(button), priv);
95 /********************************************************************************/
97 set_button_image(GtkWidget * button, Animation_WallpaperPrivate *priv, gboolean enable){
98 GtkWidget * image = NULL;
99 GdkPixbuf * pixbuf = NULL;
101 gchar *icon_on = NULL;
102 gchar *icon_off = NULL;
103 GSList *store = priv->extheme_list;
105 if (!strcmp(priv->theme, g_hash_table_lookup(store->data, "name"))){
106 icon_on = g_strdup(g_hash_table_lookup(store->data, "icon_on"));
107 icon_off = g_strdup(g_hash_table_lookup(store->data, "icon_off"));
110 store = g_list_next(store);
114 str = g_strdup_printf("%s", icon_on);
116 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
117 priv->theme, "icon.png");
120 str = g_strdup_printf("%s", icon_off);
122 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
123 priv->theme, "icond.png");
125 fprintf(stderr, "icon = %s\n", str);
126 pixbuf = gdk_pixbuf_new_from_file_at_size (str,
137 image = gtk_image_new_from_pixbuf (pixbuf);
138 g_object_unref(G_OBJECT(pixbuf));
141 hildon_button_set_image (HILDON_BUTTON (button), image);
143 /********************************************************************************/
145 create_image_button (gint view, DBusConnection *conn_sess){
148 Animation_WallpaperPrivate *priv = g_new0(Animation_WallpaperPrivate, 1);
149 /* Add external themes to priv */
150 priv->extheme_list = get_list_exthemes();
153 priv->theme_string_parametr1 = NULL;
154 priv->dbus_conn_session = conn_sess;
156 button = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
157 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
158 g_object_set_data(G_OBJECT(button), "view", GINT_TO_POINTER(view));
159 g_object_set_data(G_OBJECT(button), "priv", priv);
160 set_button_image(button, priv, check_applet_state(view));
161 g_signal_connect(button, "clicked", G_CALLBACK(theme_button_clicked), priv);
162 hildon_button_set_image_position (HILDON_BUTTON (button), GTK_POS_RIGHT);
166 /********************************************************************************/
168 changed_value_theme_cb (HildonPickerButton *picker, Animation_WallpaperPrivate *priv)
170 const gchar *choice = hildon_button_get_value(HILDON_BUTTON (picker));
171 GtkWidget *vbox = NULL;
173 vbox = g_object_get_data(G_OBJECT(priv->window), "custom_vbox");
175 gtk_widget_destroy(vbox);
176 vbox = gtk_vbox_new (FALSE, 5);
177 g_object_set_data(G_OBJECT(priv->window), "custom_vbox", vbox);
178 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(priv->window)->vbox),
179 vbox, TRUE, TRUE, 5);
181 if (!strcmp(choice, _("Berlin"))){
182 rich_animation_additional_parametr(vbox,priv);
184 if (!strcmp(choice, _("Modern"))){
185 rich_animation_additional_parametr(vbox,priv);
187 if (!strcmp(choice, _("Matrix"))){
188 rich_animation_additional_parametr(vbox,priv);
191 if (!strcmp(choice, _("Accel"))){
192 rich_animation_additional_parametr(vbox,priv);
194 if (!strcmp(choice, _("Video"))){
195 additional_parametr_for_theme_video(vbox, priv);
198 gtk_widget_show(vbox);
200 /********************************************************************************/
202 changed_value_category_cb (HildonPickerButton *picker, Animation_WallpaperPrivate *priv)
204 const gchar *choice = hildon_button_get_value(HILDON_BUTTON (picker));
205 GtkWidget *theme_button = NULL;
207 theme_button = g_object_get_data(G_OBJECT(priv->window), "theme_button");
210 HildonTouchSelector * selector = hildon_picker_button_get_selector((HildonPickerButton *) theme_button);
211 hildon_touch_selector_remove_column(selector, 0);
212 hildon_touch_selector_append_text_column(selector, gtk_list_store_new (1, G_TYPE_STRING), TRUE);
213 fill_theme_button(priv, theme_button, hildon_button_get_value(HILDON_BUTTON (picker)));
215 /********************************************************************************/
217 fill_theme_button (Animation_WallpaperPrivate *priv, GtkWidget *button, gchar *category){
219 gchar *theme = priv->theme;
223 GSList *store = priv->extheme_list;
224 HildonTouchSelector * selector = hildon_picker_button_get_selector((HildonPickerButton *) button);
226 selector = hildon_touch_selector_new_text ();
228 hildon_button_set_value(HILDON_BUTTON(button), NULL);
229 if (!strcmp(category, "LiveWallpaper")){
230 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Berlin"));
231 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Modern"));
232 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Matrix"));
233 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Accel"));
234 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Video"));
237 if (!strcmp(theme, "Berlin")){
238 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
239 hildon_button_set_value(HILDON_BUTTON(button), _("Berlin"));
241 if (!strcmp(theme, "Modern")){
242 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 1);
243 hildon_button_set_value(HILDON_BUTTON(button), _("Modern"));
245 if (!strcmp(theme, "Matrix")){
246 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 2);
247 hildon_button_set_value(HILDON_BUTTON(button), _("Matrix"));
249 if (!strcmp(theme, "Accel")){
250 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 3);
251 hildon_button_set_value(HILDON_BUTTON(button), _("Accel"));
253 if (!strcmp(theme, "Video")){
254 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 4);
255 hildon_button_set_value(HILDON_BUTTON(button), _("Video"));
260 if (!g_hash_table_lookup(store->data, "category"))
262 if (!strcmp(g_hash_table_lookup(store->data, "category"), category)){
263 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), g_hash_table_lookup(store->data, "name"));
264 if (!strcmp(theme, g_hash_table_lookup(store->data, "name"))){
265 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, num);
266 hildon_button_set_value(HILDON_BUTTON(button), _(g_hash_table_lookup(store->data, "name")));
270 store = g_slist_next(store);
273 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
274 HILDON_TOUCH_SELECTOR (selector));
277 /********************************************************************************/
279 create_themes_button (Animation_WallpaperPrivate *priv, gchar *category){
282 button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
283 hildon_button_set_title (HILDON_BUTTON (button), _("Theme"));
284 fill_theme_button(priv, button, category);
289 /********************************************************************************/
291 create_categories_button (Animation_WallpaperPrivate *priv){
295 gchar *theme = priv->theme;
298 selector = create_category_selector(priv);
299 button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
300 hildon_button_set_title (HILDON_BUTTON (button), _("Category"));
301 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
302 HILDON_TOUCH_SELECTOR (selector));
304 if (!strcmp(theme, "Berlin")){
305 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
306 hildon_button_set_value(HILDON_BUTTON(button), _("LiveWallpaper"));
308 if (!strcmp(theme, "Modern")){
309 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
310 hildon_button_set_value(HILDON_BUTTON(button), _("LiveWallpaper"));
312 if (!strcmp(theme, "Matrix")){
313 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
314 hildon_button_set_value(HILDON_BUTTON(button), _("LiveWallpaper"));
316 if (!strcmp(theme, "Accel")){
317 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
318 hildon_button_set_value(HILDON_BUTTON(button), _("LiveWallpaper"));
320 if (!strcmp(theme, "Video")){
321 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
322 hildon_button_set_value(HILDON_BUTTON(button), _("LiveWallpaper"));
324 GSList *store = priv->extheme_list;
326 if (!strcmp(theme, g_hash_table_lookup(store->data, "name"))){
327 if (g_hash_table_lookup(store->data, "category"))
328 hildon_button_set_value(HILDON_BUTTON(button), _(g_hash_table_lookup(store->data, "category")));
329 /* hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, num); */
332 store = g_slist_next(store);
338 /*******************************************************************************/
340 create_rich_animation_button (gboolean active, gchar *name)
343 button = hildon_check_button_new (HILDON_SIZE_AUTO);
344 gtk_button_set_label (GTK_BUTTON (button), name);
345 hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
348 /*******************************************************************************/
350 create_enable_button (gboolean active)
353 button = hildon_check_button_new (HILDON_SIZE_AUTO);
354 gtk_button_set_label (GTK_BUTTON (button), _("Enable"));
355 hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
359 /*******************************************************************************/
361 show_settings(GtkWidget *widget, Animation_WallpaperPrivate *priv){
362 lw_main_settings(priv, NULL);
364 /*******************************************************************************/
366 lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data){
368 GtkWidget *window = NULL;
369 GtkWidget *theme_button1;
370 GtkWidget *theme_button2;
371 GtkWidget *theme_button3;
372 GtkWidget *theme_button4;
374 Animation_WallpaperPrivate *priv_temp = NULL;
376 window = gtk_dialog_new();
378 gtk_window_set_title(GTK_WINDOW(window), _("Live Wallpaper Settings"));
379 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
380 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
381 /* Create Theme button */
382 hbox = gtk_hbox_new(FALSE, 5);
383 theme_button1 = create_image_button(1, priv->dbus_conn_session);
384 gtk_box_pack_start(GTK_BOX(hbox),
385 theme_button1, TRUE, TRUE, 5);
386 theme_button2 = create_image_button(2, priv->dbus_conn_session);
387 gtk_box_pack_start(GTK_BOX(hbox),
388 theme_button2, TRUE, TRUE, 5);
389 theme_button3 = create_image_button(3, priv->dbus_conn_session);
390 gtk_box_pack_start(GTK_BOX(hbox),
391 theme_button3, TRUE, TRUE, 5);
392 theme_button4 = create_image_button(4, priv->dbus_conn_session);
393 gtk_box_pack_start(GTK_BOX(hbox),
394 theme_button4, TRUE, TRUE, 5);
395 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
396 hbox, TRUE, TRUE, 5);
398 gtk_widget_show (theme_button1);
399 gtk_widget_show (theme_button2);
400 gtk_widget_show (theme_button3);
401 gtk_widget_show (theme_button4);
402 gtk_widget_show_all (hbox);
403 gtk_widget_show (window);
404 gtk_dialog_add_button(GTK_DIALOG(window), _("About"), GTK_RESPONSE_NO);
406 result = gtk_dialog_run(GTK_DIALOG(window));
408 priv_temp = g_object_get_data(G_OBJECT(theme_button1), "priv");
413 priv_temp = g_object_get_data(G_OBJECT(theme_button2), "priv");
418 priv_temp = g_object_get_data(G_OBJECT(theme_button3), "priv");
423 priv_temp = g_object_get_data(G_OBJECT(theme_button4), "priv");
431 case GTK_RESPONSE_NO:
432 gtk_widget_destroy(window);
440 gtk_widget_destroy(window);
442 /*******************************************************************************/
444 file_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){
446 GtkWidget *dialog = hildon_file_chooser_dialog_new(GTK_WINDOW (priv->window), GTK_FILE_CHOOSER_ACTION_OPEN);
448 if (priv->theme_string_parametr1)
449 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), priv->theme_string_parametr1);
451 gtk_widget_show_all (GTK_WIDGET (dialog));
453 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
455 hildon_button_set_value (HILDON_BUTTON(button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
457 gtk_widget_destroy (dialog);
460 /*******************************************************************************/
462 rich_animation_additional_parametr(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
463 GtkWidget *rich_animation_button;
464 /* Create rich animation button */
465 rich_animation_button = create_rich_animation_button(priv->rich_animation, _("Rich Animation"));
466 gtk_box_pack_start(GTK_BOX(vbox),
467 rich_animation_button, TRUE, TRUE, 5);
468 g_object_set_data(G_OBJECT(priv->window), "rich_animation_button", rich_animation_button);
469 gtk_widget_show (rich_animation_button);
471 /*******************************************************************************/
473 additional_parametr_for_theme_video(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
475 GtkWidget *file_button;
476 GtkWidget *rich_animation_button;
478 if (priv->theme_string_parametr1)
479 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL,
480 _("Play file"), priv->theme_string_parametr1);
482 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL,
485 g_signal_connect (file_button, "clicked", G_CALLBACK (file_button_clicked), priv);
487 gtk_box_pack_start(GTK_BOX(vbox),
488 file_button, TRUE, TRUE, 5);
489 g_object_set_data(G_OBJECT(priv->window), "filename_button", file_button); /* Create rich animation button */
490 rich_animation_button = create_rich_animation_button(priv->rich_animation, _("Loop"));
491 gtk_box_pack_start(GTK_BOX(vbox),
492 rich_animation_button, TRUE, TRUE, 5);
493 g_object_set_data(G_OBJECT(priv->window), "rich_animation_button", rich_animation_button);
495 gtk_widget_show (file_button);
496 gtk_widget_show (rich_animation_button);
499 /*******************************************************************************/
501 lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) {
503 GtkWidget *window = NULL;
504 GtkWidget *save_button;
505 GtkWidget *theme_button;
506 GtkWidget *category_button;
507 GtkWidget *enable_button;
509 GtkWidget *button1 = NULL;
510 GtkWidget *rich_animation_button = NULL;
511 gint view = priv->view;
513 window = gtk_dialog_new();
514 priv->window = window;
516 gtk_window_set_title(GTK_WINDOW(window), _("View Settings"));
517 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
518 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
519 /* Create Enable button */
520 enable_button = create_enable_button(check_applet_state(view));
521 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
522 enable_button, TRUE, TRUE, 5);
523 /* Create Category button */
524 category_button = create_categories_button(priv);
525 g_object_set_data(G_OBJECT(window), "category_button", category_button);
526 g_signal_connect (G_OBJECT (category_button), "value-changed", G_CALLBACK (changed_value_category_cb), priv);
527 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
528 category_button, TRUE, TRUE, 5);
530 /* Create Theme button */
531 theme_button = create_themes_button(priv,hildon_button_get_value(HILDON_BUTTON (category_button)));
532 g_object_set_data(G_OBJECT(window), "theme_button", theme_button);
533 g_signal_connect (G_OBJECT (theme_button), "value-changed", G_CALLBACK (changed_value_theme_cb), priv);
534 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
535 theme_button, TRUE, TRUE, 5);
537 /* Create custom vbox */
538 vbox = gtk_vbox_new (FALSE, 5);
539 g_object_set_data(G_OBJECT(window), "custom_vbox", vbox);
540 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
541 vbox, TRUE, TRUE, 5);
542 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Berlin"))||
543 !strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Matrix"))||
544 !strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Accel"))||
545 !strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Modern"))){
546 rich_animation_additional_parametr(vbox, priv);
549 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Video"))){
550 additional_parametr_for_theme_video(vbox, priv);
553 gtk_widget_show (enable_button);
554 gtk_widget_show (category_button);
555 gtk_widget_show (theme_button);
556 gtk_widget_show (vbox);
557 gtk_widget_show (window);
558 save_button = gtk_dialog_add_button(GTK_DIALOG(window), _("Save"), GTK_RESPONSE_YES);
560 result = gtk_dialog_run(GTK_DIALOG(window));
563 case GTK_RESPONSE_YES:
565 if (hildon_button_get_value(HILDON_BUTTON (theme_button)) &&
566 strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "")){
567 /* Check Xsnow program */
568 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Xsnow"))){
569 if (access("/usr/bin/xsnow", F_OK) != 0){
570 hildon_banner_show_information(GTK_WIDGET(button), NULL,
571 _("You haven't got the installed package Xsnow. Please install it via using Application Manager"));
572 /* if not scuccess exit from wthout saving */
579 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Berlin")))
580 priv->theme = g_strdup("Berlin");
581 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Modern")))
582 priv->theme = g_strdup("Modern");
583 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Matrix")))
584 priv->theme = g_strdup("Matrix");
585 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Accel")))
586 priv->theme = g_strdup("Accel");
587 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Video"))){
588 priv->theme = g_strdup("Video");
589 button1 = g_object_get_data(G_OBJECT(priv->window), "filename_button");
591 if (priv->theme_string_parametr1)
592 g_free(priv->theme_string_parametr1);
593 priv->theme_string_parametr1 = g_strdup((gchar*)hildon_button_get_value (HILDON_BUTTON(button1)));
596 /* Check external themes */
597 GSList *store = priv->extheme_list;
599 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _(g_hash_table_lookup(store->data, "name")))){
600 priv->theme = g_strdup(g_hash_table_lookup(store->data, "name"));
601 //priv->hash_theme = store->data;
604 store = g_slist_next(store);
609 rich_animation_button = g_object_get_data(G_OBJECT(priv->window), "rich_animation_button");
610 if (rich_animation_button){
611 /* Check rich animation */
612 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(rich_animation_button)))
613 priv->rich_animation = TRUE;
615 priv->rich_animation = FALSE;
619 /* action with applet */
620 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(enable_button))){
621 if (!check_applet_state(view)){
624 send_dbus_signal (priv,
625 LIVEWP_SIGNAL_INTERFACE,
627 LIVEWP_RELOAD_CONFIG);
630 if (check_applet_state(view))
633 set_button_image(button, priv, check_applet_state(view));
636 case GTK_RESPONSE_OK:
638 case GTK_RESPONSE_NO:
639 gtk_widget_destroy(window);
645 gtk_widget_destroy(window);
647 /*******************************************************************************/
649 check_applet_state(gint number){
651 HDConfigFile *config_file = NULL;
652 GKeyFile *gkey_file = NULL;
654 gboolean result = FALSE;
655 if (number > 4 || number < 1)
658 str = g_strdup_printf("livewp-home-widget.desktop-%i", (number - 1));
659 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
661 gkey_file = hd_config_file_load_file(config_file, FALSE);
662 if (gkey_file && str){
663 result = g_key_file_has_group(gkey_file, str);
668 /*******************************************************************************/
670 start_applet(gint number){
672 HDConfigFile *config_file = NULL;
673 GKeyFile *gkey_file = NULL;
676 if (number > 4 || number < 1)
678 str = g_strdup_printf("livewp-home-widget.desktop-%i",(number - 1));
679 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
681 gkey_file = hd_config_file_load_file(config_file, FALSE);
683 g_key_file_set_string (gkey_file, str, "X-Desktop-File", "/usr/share/applications/hildon-home/livewp-home-widget.desktop");
684 hd_config_file_save_file( config_file, gkey_file);
685 g_key_file_free(gkey_file);
687 fprintf(stderr, "Problem with config file");
690 g_object_unref(config_file);
692 /*******************************************************************************/
694 stop_applet(gint number){
695 HDConfigFile *config_file = NULL;
696 GKeyFile *gkey_file = NULL;
699 if (number > 4 || number < 1)
701 str = g_strdup_printf("livewp-home-widget.desktop-%i", (number - 1));
702 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
704 gkey_file = hd_config_file_load_file(config_file, FALSE);
706 g_key_file_remove_group(gkey_file, str, NULL);
707 hd_config_file_save_file( config_file, gkey_file);
708 g_key_file_free(gkey_file);
710 fprintf(stderr, "Problem with config file");
713 g_object_unref(config_file);