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 /*******************************************************************************/
30 GtkWidget *window = NULL,
33 window = gtk_dialog_new();
34 gtk_window_set_title(GTK_WINDOW(window), _("About"));
35 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
36 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
37 vbox = gtk_vbox_new (FALSE, 5);
38 about_string = g_strdup_printf(_("Live Wallpaper Version %s \n Copyright(c) 2010\n \
39 Tanya Makova\n Vlad Vasiliev\n \
40 Copyright(c) 2010 for design themes Berlin, Modern and Accel Vasya Bobrikov\n \
41 Copyright(c) 2010 for design themes Matrix Fifteen and for icons Andrew Zhilin\n \
43 Finnish - Marko Vertainen\n \
44 Spain - Alejandro López\n \
45 Italian - Emanuele Cassioli\n \
46 Russian - Tanya Makova \n \
47 Vlad Vasiliev\n"), VERSION);
49 label_about = gtk_label_new (about_string);
50 gtk_box_pack_start (GTK_BOX (vbox), label_about, FALSE, FALSE, 0);
51 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
53 gtk_widget_show (label_about);
54 gtk_widget_show (vbox);
55 gtk_widget_show (window);
56 gtk_dialog_run(GTK_DIALOG(window));
59 /*******************************************************************************/
61 create_category_selector (Animation_WallpaperPrivate *priv){
63 GSList *store = priv->extheme_list;
65 GHashTable *result_table = NULL;
67 result_table = g_hash_table_new(g_str_hash, g_str_equal);
69 if (!g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")))
70 g_hash_table_insert(result_table, g_hash_table_lookup(store->data, "category"), (gint *)1);
71 store = g_slist_next(store);
74 /* Add Xscreensaver for install message */
75 if (!g_hash_table_lookup(result_table,"Xscreensaver"))
76 g_hash_table_insert(result_table, "Xscreensaver", (gint *)1);
79 category_list = g_hash_table_get_keys (result_table);
80 selector = hildon_touch_selector_new_text();
82 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "LiveWallpaper" );
83 while (category_list){
84 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),category_list->data );
85 category_list = g_list_next(category_list);
91 /*******************************************************************************/
93 theme_button_clicked(GtkWidget *button, GdkEventButton *event, Animation_WallpaperPrivate *priv){
94 lw_theme_settings(GTK_WIDGET(button), priv);
96 /********************************************************************************/
98 set_button_image(GtkWidget * button, Animation_WallpaperPrivate *priv, gboolean enable){
99 GtkWidget * image = NULL;
100 GdkPixbuf * pixbuf = NULL;
102 gchar *icon_on = NULL;
103 gchar *icon_off = NULL;
104 GSList *store = priv->extheme_list;
107 if (!strcmp(priv->theme, g_hash_table_lookup(store->data, "name"))){
108 icon_on = g_strdup(g_hash_table_lookup(store->data, "icon_on"));
109 icon_off = g_strdup(g_hash_table_lookup(store->data, "icon_off"));
112 store = (GSList *)g_list_next(store);
116 str = g_strdup_printf("%s", icon_on);
118 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
119 priv->theme, "icon.png");
120 if (access(str, F_OK) != 0){
122 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
123 "Video", "icon.png");
128 str = g_strdup_printf("%s", icon_off);
130 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
131 priv->theme, "icond.png");
132 if (access(str, F_OK) != 0){
134 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
135 "Video", "icond.png");
138 pixbuf = gdk_pixbuf_new_from_file_at_size (str,
149 image = gtk_image_new_from_pixbuf (pixbuf);
150 g_object_unref(G_OBJECT(pixbuf));
153 //hildon_button_set_image (HILDON_BUTTON (button), image);
154 GList *list = gtk_container_get_children(GTK_CONTAINER (button));
156 gtk_container_remove(GTK_CONTAINER (button), list->data);
158 gtk_container_add(GTK_CONTAINER (button), image);
159 gtk_widget_show(image);
160 gtk_widget_show(button);
163 /********************************************************************************/
165 create_image_button (gint view, DBusConnection *conn_sess){
166 GtkWidget *event_box;
168 Animation_WallpaperPrivate *priv = g_new0(Animation_WallpaperPrivate, 1);
169 /* Add external themes to priv */
170 priv->extheme_list = get_list_exthemes();
173 priv->theme_string_parametr1 = NULL;
174 priv->dbus_conn_session = conn_sess;
177 event_box = gtk_event_box_new();
178 g_object_set_data(G_OBJECT(event_box), "view", GINT_TO_POINTER(view));
179 g_object_set_data(G_OBJECT(event_box), "priv", priv);
180 set_button_image(event_box, priv, check_applet_state(view));
181 g_signal_connect(G_OBJECT (event_box), "button_press_event", G_CALLBACK(theme_button_clicked), priv);
184 button = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
185 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
186 g_object_set_data(G_OBJECT(button), "view", GINT_TO_POINTER(view));
187 g_object_set_data(G_OBJECT(button), "priv", priv);
188 set_button_image(button, priv, check_applet_state(view));
189 g_signal_connect(button, "clicked", G_CALLBACK(theme_button_clicked), priv);
190 hildon_button_set_image_position (HILDON_BUTTON (button), GTK_POS_RIGHT);
194 /********************************************************************************/
196 changed_value_one_in_all_cb (GtkWidget *toggle, Animation_WallpaperPrivate *priv)
198 priv->one_in_all_view = hildon_check_button_get_active((HildonCheckButton *)toggle);
199 create_themes_buttons_hbox(priv);
200 fprintf(stderr, "changed_value_one_in_all_cb\n");
202 /********************************************************************************/
204 changed_value_theme_cb (HildonPickerButton *picker, Animation_WallpaperPrivate *priv)
206 const gchar *choice = hildon_button_get_value(HILDON_BUTTON (picker));
207 GtkWidget *vbox = NULL;
208 GtkWidget *area_vbox = NULL;
210 area_vbox = g_object_get_data(G_OBJECT(priv->window), "area_vbox");
213 vbox = g_object_get_data(G_OBJECT(priv->window), "custom_vbox");
215 gtk_widget_destroy(vbox);
217 vbox = gtk_vbox_new (TRUE, 5);
218 g_object_set_data(G_OBJECT(priv->window), "custom_vbox", vbox);
219 gtk_box_pack_start(GTK_BOX(area_vbox),
220 vbox, FALSE, FALSE, 5);
222 if (!strcmp(choice, _("Berlin"))){
223 rich_animation_additional_parametr(vbox,priv);
225 if (!strcmp(choice, _("Modern"))){
226 rich_animation_additional_parametr(vbox,priv);
228 if (!strcmp(choice, _("Matrix"))){
229 rich_animation_additional_parametr(vbox,priv);
232 if (!strcmp(choice, _("Accel"))){
233 rich_animation_additional_parametr(vbox,priv);
235 if (!strcmp(choice, _("Video"))){
236 additional_parametr_for_theme_video(vbox, priv);
239 gtk_widget_show(vbox);
241 /********************************************************************************/
243 changed_value_category_cb (HildonPickerButton *picker, Animation_WallpaperPrivate *priv)
245 GtkWidget *theme_button = NULL;
246 const gchar *choice = hildon_button_get_value(HILDON_BUTTON (picker));
248 theme_button = g_object_get_data(G_OBJECT(priv->window), "theme_button");
251 HildonTouchSelector * selector = hildon_picker_button_get_selector((HildonPickerButton *) theme_button);
252 hildon_touch_selector_remove_column(selector, 0);
253 hildon_touch_selector_append_text_column(selector, (GtkTreeModel*)gtk_list_store_new (1, G_TYPE_STRING), TRUE);
254 fill_theme_button(priv, theme_button, (gchar *)hildon_button_get_value(HILDON_BUTTON (picker)));
255 /* check xscreensaver category */
257 if (!strcmp(choice,"Xscreensaver"))
258 if (access("/usr/bin/xscreensaver", F_OK) != 0){
259 show_problem_package((GtkWidget *)picker, "Xscreensaver");
264 /********************************************************************************/
266 fill_theme_button (Animation_WallpaperPrivate *priv, GtkWidget *button, gchar *category){
268 gchar *theme = priv->theme;
269 gboolean flag = False;
271 hildon_button_set_value(HILDON_BUTTON (button), NULL);
273 changed_value_theme_cb(HILDON_PICKER_BUTTON (button), priv);
276 GSList *store = priv->extheme_list;
277 HildonTouchSelector * selector = hildon_picker_button_get_selector((HildonPickerButton *) button);
279 selector = (HildonTouchSelector *)hildon_touch_selector_new_text ();
281 hildon_button_set_value(HILDON_BUTTON(button), NULL);
282 if (!strcmp(category, "LiveWallpaper")){
283 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Berlin"));
284 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Modern"));
285 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Matrix"));
286 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Accel"));
287 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Video"));
290 if (!strcmp(theme, "Berlin")){
291 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
292 hildon_button_set_value(HILDON_BUTTON(button), _("Berlin"));
294 if (!strcmp(theme, "Modern")){
295 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 1);
296 hildon_button_set_value(HILDON_BUTTON(button), _("Modern"));
298 if (!strcmp(theme, "Matrix")){
299 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 2);
300 hildon_button_set_value(HILDON_BUTTON(button), _("Matrix"));
302 if (!strcmp(theme, "Accel")){
303 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 3);
304 hildon_button_set_value(HILDON_BUTTON(button), _("Accel"));
306 if (!strcmp(theme, "Video")){
307 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 4);
308 hildon_button_set_value(HILDON_BUTTON(button), _("Video"));
313 if (!g_hash_table_lookup(store->data, "category"))
315 if (!strcmp(g_hash_table_lookup(store->data, "category"), category)){
316 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), g_hash_table_lookup(store->data, "name"));
317 if (!strcmp(theme, g_hash_table_lookup(store->data, "name"))){
318 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, num);
319 hildon_button_set_value(HILDON_BUTTON(button), _(g_hash_table_lookup(store->data, "name")));
323 store = g_slist_next(store);
325 /* Added Shreman's Aquarium for message */
326 if (!strcmp(category, "Unknown")){
327 store = priv->extheme_list;
329 if (!strcmp("Shermans Aquarium" , g_hash_table_lookup(store->data, "name"))){
333 store = g_slist_next(store);
336 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "Shermans Aquarium");
339 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
340 HILDON_TOUCH_SELECTOR (selector));
342 changed_value_theme_cb(HILDON_PICKER_BUTTON (button), priv);
344 /********************************************************************************/
346 create_themes_button (Animation_WallpaperPrivate *priv, gchar *category){
349 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
350 hildon_button_set_title (HILDON_BUTTON (button), _("Theme"));
355 /********************************************************************************/
357 create_categories_button (Animation_WallpaperPrivate *priv){
361 gchar *theme = priv->theme;
363 GHashTable *result_table = NULL;
365 result_table = g_hash_table_new(g_str_hash, g_str_equal);
366 selector = create_category_selector(priv);
367 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
368 hildon_button_set_title (HILDON_BUTTON (button), _("Category"));
369 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
370 HILDON_TOUCH_SELECTOR (selector));
372 if (!strcmp(theme, "Berlin")){
373 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
374 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
376 if (!strcmp(theme, "Modern")){
377 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
378 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
380 if (!strcmp(theme, "Matrix")){
381 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
382 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
384 if (!strcmp(theme, "Accel")){
385 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
386 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
388 if (!strcmp(theme, "Video")){
389 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
390 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
392 GSList *store = priv->extheme_list;
395 if (g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")) == NULL){
396 g_hash_table_insert(result_table, g_hash_table_lookup(store->data, "category"), (gint *)num);
399 if (!strcmp(theme, g_hash_table_lookup(store->data, "name"))){
400 if (g_hash_table_lookup(store->data, "category"))
401 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0,
402 (gint)g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")));
403 hildon_button_set_value(HILDON_BUTTON(button), g_hash_table_lookup(store->data, "category"));
407 store = g_slist_next(store);
413 /*******************************************************************************/
415 create_bool_button (gboolean active, gchar *name)
418 button = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
419 gtk_button_set_label (GTK_BUTTON (button), name);
420 hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
423 /*******************************************************************************/
425 create_enable_button (gboolean active)
428 button = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
429 gtk_button_set_label (GTK_BUTTON (button), _("Enable"));
430 hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
434 /*******************************************************************************/
436 show_settings(GtkWidget *widget, Animation_WallpaperPrivate *priv){
437 lw_main_settings(priv, NULL);
439 /*******************************************************************************/
441 create_themes_buttons_hbox(Animation_WallpaperPrivate *priv){
442 GtkWidget *hbox = NULL;
443 GtkWidget *area_hbox = NULL;
444 GtkWidget *theme_button1;
445 GtkWidget *theme_button2;
446 GtkWidget *theme_button3;
447 GtkWidget *theme_button4;
450 area_hbox = g_object_get_data(G_OBJECT(priv->window), "area_hbox");
453 hbox = g_object_get_data(G_OBJECT(priv->window), "custom_hbox");
455 gtk_widget_destroy(hbox);
457 hbox = gtk_hbox_new(FALSE, 0);
458 g_object_set_data(G_OBJECT(priv->window), "custom_hbox", hbox);
459 gtk_box_pack_start(GTK_BOX(area_hbox),
460 hbox, FALSE, FALSE, 5);
461 /* Create Theme buttons */
462 theme_button1 = create_image_button(1, priv->dbus_conn_session);
463 gtk_box_pack_start(GTK_BOX(hbox),
464 theme_button1, TRUE, TRUE, 0);
465 gtk_widget_show (theme_button1);
466 gtk_widget_show (hbox);
467 if (priv->one_in_all_view)
469 theme_button2 = create_image_button(2, priv->dbus_conn_session);
470 gtk_box_pack_start(GTK_BOX(hbox),
471 theme_button2, TRUE, TRUE, 0);
472 gtk_widget_show (theme_button2);
473 theme_button3 = create_image_button(3, priv->dbus_conn_session);
474 gtk_box_pack_start(GTK_BOX(hbox),
475 theme_button3, TRUE, TRUE, 0);
476 gtk_widget_show (theme_button3);
477 theme_button4 = create_image_button(4, priv->dbus_conn_session);
478 gtk_box_pack_start(GTK_BOX(hbox),
479 theme_button4, TRUE, TRUE, 0);
480 gtk_widget_show (theme_button4);
483 /*******************************************************************************/
485 lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data){
487 GtkWidget *window = NULL;
488 GtkWidget *area_hbox;
489 GtkWidget *one_in_all_view_button;
490 gboolean one_in_all_view;
491 Animation_WallpaperPrivate *priv_temp = NULL;
493 window = gtk_dialog_new();
494 priv->window = window;
496 one_in_all_view = priv->one_in_all_view;
497 gtk_window_set_title(GTK_WINDOW(window), _("Live Wallpaper Settings"));
498 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
499 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
500 one_in_all_view_button = create_bool_button(priv->one_in_all_view, _("One theme in all views"));
501 g_signal_connect (G_OBJECT (one_in_all_view_button), "toggled", G_CALLBACK (changed_value_one_in_all_cb), priv);
502 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), one_in_all_view_button, TRUE, TRUE, 5);
503 area_hbox = gtk_vbox_new(FALSE, 2);
504 g_object_set_data(G_OBJECT(window), "area_hbox", area_hbox);
505 create_themes_buttons_hbox(priv);
506 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
507 area_hbox, TRUE, TRUE, 0);
509 gtk_widget_show (one_in_all_view_button);
510 gtk_widget_show_all (area_hbox);
511 gtk_widget_show (window);
512 gtk_dialog_add_button(GTK_DIALOG(window), _("About"), GTK_RESPONSE_NO);
514 result = gtk_dialog_run(GTK_DIALOG(window));
516 priv_temp = g_object_get_data(G_OBJECT(theme_button1), "priv");
521 priv_temp = g_object_get_data(G_OBJECT(theme_button2), "priv");
526 priv_temp = g_object_get_data(G_OBJECT(theme_button3), "priv");
531 priv_temp = g_object_get_data(G_OBJECT(theme_button4), "priv");
539 case GTK_RESPONSE_NO:
540 gtk_widget_destroy(window);
546 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(one_in_all_view_button)) != one_in_all_view){
547 save_one_in_all_views_to_config(hildon_check_button_get_active (HILDON_CHECK_BUTTON(one_in_all_view_button)));
548 fprintf(stderr,"CHECK!!!!!!!!!!!!!!\n");
561 gtk_widget_destroy(window);
563 /*******************************************************************************/
565 file_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){
567 GtkWidget *dialog = hildon_file_chooser_dialog_new(GTK_WINDOW (priv->window), GTK_FILE_CHOOSER_ACTION_OPEN);
569 if (priv->theme_string_parametr1)
570 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), priv->theme_string_parametr1);
572 gtk_widget_show_all (GTK_WIDGET (dialog));
574 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
576 hildon_button_set_value (HILDON_BUTTON(button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
578 gtk_widget_destroy (dialog);
581 /*******************************************************************************/
583 rich_animation_additional_parametr(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
584 GtkWidget *rich_animation_button;
586 /* Create rich animation button */
587 rich_animation_button = create_bool_button(priv->rich_animation, _("Rich Animation"));
588 gtk_box_pack_start(GTK_BOX(vbox),
589 rich_animation_button, TRUE, TRUE, 5);
590 g_object_set_data(G_OBJECT(priv->window), "rich_animation_button", rich_animation_button);
591 gtk_widget_show (rich_animation_button);
593 /*******************************************************************************/
595 additional_parametr_for_theme_video(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
597 GtkWidget *file_button;
598 GtkWidget *rich_animation_button;
600 if (priv->theme_string_parametr1)
601 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL,
602 _("Play file"), priv->theme_string_parametr1);
604 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL,
607 g_signal_connect (file_button, "clicked", G_CALLBACK (file_button_clicked), priv);
609 gtk_box_pack_start(GTK_BOX(vbox),
610 file_button, TRUE, TRUE, 5);
611 g_object_set_data(G_OBJECT(priv->window), "filename_button", file_button);
612 /* Create rich animation button */
613 rich_animation_button = create_bool_button(priv->rich_animation, _("Loop"));
614 gtk_box_pack_start(GTK_BOX(vbox),
615 rich_animation_button, TRUE, TRUE, 5);
616 g_object_set_data(G_OBJECT(priv->window), "rich_animation_button", rich_animation_button);
617 /* Create sound button */
620 /* Doesn't work in real device. Hardware volume buttons can to change volume for mutted track */
621 sound_button = create_bool_button(priv->theme_bool_parametr1, _("Sound"));
622 gtk_box_pack_start(GTK_BOX(vbox),
623 sound_button, TRUE, TRUE, 5);
624 g_object_set_data(G_OBJECT(priv->window), "sound_button", sound_button);
625 gtk_widget_show (sound_button);
627 gtk_widget_show (file_button);
628 gtk_widget_show (rich_animation_button);
631 /*******************************************************************************/
633 show_problem_package (GtkWidget *widget, gchar *package_name){
635 text = g_strdup_printf(_("You haven't got the installed package %s. Please install it via using Application Manager"), package_name);
636 hildon_banner_show_information(GTK_WIDGET(widget), NULL, text);
639 /*******************************************************************************/
641 lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) {
643 GtkWidget *window = NULL;
644 GtkWidget *scrolled_window = NULL;
645 GtkWidget *save_button;
646 GtkWidget *theme_button;
647 GtkWidget *category_button;
648 GtkWidget *enable_button;
650 GtkWidget *area_vbox;
651 GtkWidget *button1 = NULL;
652 GtkWidget *rich_animation_button = NULL;
653 gint view = priv->view;
655 window = gtk_dialog_new();
656 priv->window = window;
658 gtk_window_set_title(GTK_WINDOW(window), _("View Settings"));
659 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
660 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
663 area_vbox = gtk_vbox_new(FALSE, 2);
664 g_object_set_data(G_OBJECT(window), "area_vbox", area_vbox);
665 scrolled_window = hildon_pannable_area_new ();
666 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA (scrolled_window), GTK_WIDGET (area_vbox));
667 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
668 scrolled_window, FALSE, FALSE, 0);
670 gtk_widget_set_size_request(scrolled_window, -1, 370);
672 /* Create Enable button */
673 enable_button = create_enable_button(check_applet_state(view));
674 gtk_box_pack_start(GTK_BOX(area_vbox),
675 enable_button, FALSE, FALSE, 5);
676 /* Create Category button */
677 category_button = create_categories_button(priv);
678 g_object_set_data(G_OBJECT(window), "category_button", category_button);
679 g_signal_connect (G_OBJECT (category_button), "value-changed", G_CALLBACK (changed_value_category_cb), priv);
680 gtk_box_pack_start(GTK_BOX(area_vbox),
681 category_button, FALSE, FALSE, 5);
682 /* Create Custom vbox */
683 vbox = gtk_vbox_new (FALSE, 5);
684 g_object_set_data(G_OBJECT(window), "custom_vbox", vbox);
686 /* Create Theme button */
687 theme_button = create_themes_button(priv, (gchar *)hildon_button_get_value(HILDON_BUTTON (category_button)));
688 g_object_set_data(G_OBJECT(window), "theme_button", theme_button);
689 g_signal_connect (G_OBJECT (theme_button), "value-changed", G_CALLBACK (changed_value_theme_cb), priv);
690 gtk_box_pack_start(GTK_BOX(area_vbox),
691 theme_button, FALSE, FALSE, 5);
692 fill_theme_button(priv, theme_button, (gchar *)hildon_button_get_value(HILDON_BUTTON (category_button)));
694 /* Pack custom vbox. It must be last widget */
695 gtk_box_pack_start(GTK_BOX(area_vbox),
696 vbox, FALSE, FALSE, 5);
698 gtk_widget_show (enable_button);
699 gtk_widget_show (category_button);
700 gtk_widget_show (theme_button);
701 gtk_widget_show (vbox);
702 gtk_widget_show (area_vbox);
703 gtk_widget_show (scrolled_window);
704 gtk_widget_show (window);
706 save_button = gtk_dialog_add_button(GTK_DIALOG(window), _("Save"), GTK_RESPONSE_YES);
708 result = gtk_dialog_run(GTK_DIALOG(window));
711 case GTK_RESPONSE_YES:
713 if (hildon_button_get_value(HILDON_BUTTON (theme_button)) &&
714 strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "")){
715 /* Check Xsnow program */
716 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Xsnow"))){
717 if (access("/usr/bin/xsnow", F_OK) != 0){
718 show_problem_package(button, "Xsnow");
719 /* if not scuccess exit from wthout saving */
723 /* Check Shermans program */
724 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "Shermans Aquarium")){
725 if (access("/usr/bin/shermans", F_OK) != 0){
726 show_problem_package(button,"'Sherman's Aquarium'");
727 /* if not scuccess exit from wthout saving */
731 /* Check Conky program */
732 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "Conky")){
733 if (access("/usr/bin/conky", F_OK) != 0){
734 show_problem_package(button,"'Conky'");
735 /* if not scuccess exit from wthout saving */
739 /* Check Orrery program */
740 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "Orrery")){
741 if (access("/opt/maemo/usr/bin/orrery", F_OK) != 0){
742 show_problem_package(button,"'Orrery'");
743 /* if not scuccess exit from wthout saving */
747 /* Check Colorflood program */
748 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "Colorflood")){
749 if (access("/usr/bin/colorflood", F_OK) != 0){
750 show_problem_package(button,"'Colorflood'");
751 /* if not scuccess exit from wthout saving */
758 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Berlin")))
759 priv->theme = g_strdup("Berlin");
760 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Modern")))
761 priv->theme = g_strdup("Modern");
762 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Matrix")))
763 priv->theme = g_strdup("Matrix");
764 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Accel")))
765 priv->theme = g_strdup("Accel");
766 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Video"))){
767 priv->theme = g_strdup("Video");
768 button1 = g_object_get_data(G_OBJECT(priv->window), "filename_button");
770 if (priv->theme_string_parametr1)
771 g_free(priv->theme_string_parametr1);
772 priv->theme_string_parametr1 = g_strdup((gchar*)hildon_button_get_value (HILDON_BUTTON(button1)));
775 temp_button = g_object_get_data(G_OBJECT(priv->window), "sound_button");
777 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(temp_button)))
778 priv->theme_bool_parametr1 = TRUE;
780 priv->theme_bool_parametr1 = FALSE;
784 /* Check external themes */
785 GSList *store = priv->extheme_list;
787 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _(g_hash_table_lookup(store->data, "name")))){
788 priv->theme = g_strdup(g_hash_table_lookup(store->data, "name"));
789 //priv->hash_theme = store->data;
792 store = g_slist_next(store);
797 rich_animation_button = g_object_get_data(G_OBJECT(priv->window), "rich_animation_button");
798 if (rich_animation_button){
799 /* Check rich animation */
800 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(rich_animation_button)))
801 priv->rich_animation = TRUE;
803 priv->rich_animation = FALSE;
807 /* action with applet */
808 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(enable_button))){
809 if (!check_applet_state(view)){
812 send_dbus_signal (priv,
813 LIVEWP_SIGNAL_INTERFACE,
815 LIVEWP_RELOAD_CONFIG);
818 if (check_applet_state(view))
821 set_button_image(button, priv, check_applet_state(view));
824 case GTK_RESPONSE_OK:
826 case GTK_RESPONSE_NO:
827 gtk_widget_destroy(window);
833 gtk_widget_destroy(window);
835 /*******************************************************************************/
837 check_applet_state(gint number){
839 HDConfigFile *config_file = NULL;
840 GKeyFile *gkey_file = NULL;
842 gboolean result = FALSE;
843 if (number > 4 || number < 1)
846 str = g_strdup_printf("livewp-home-widget.desktop-%i", (number - 1));
847 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
849 gkey_file = hd_config_file_load_file(config_file, FALSE);
850 if (gkey_file && str){
851 result = g_key_file_has_group(gkey_file, str);
856 /*******************************************************************************/
858 start_applet(gint number){
860 HDConfigFile *config_file = NULL;
861 GKeyFile *gkey_file = NULL;
864 if (number > 4 || number < 1)
866 str = g_strdup_printf("livewp-home-widget.desktop-%i",(number - 1));
867 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
869 gkey_file = hd_config_file_load_file(config_file, FALSE);
871 g_key_file_set_string (gkey_file, str, "X-Desktop-File", "/usr/share/applications/hildon-home/livewp-home-widget.desktop");
872 hd_config_file_save_file( config_file, gkey_file);
873 g_key_file_free(gkey_file);
875 fprintf(stderr, "Problem with config file");
878 g_object_unref(config_file);
880 /*******************************************************************************/
882 stop_applet(gint number){
883 HDConfigFile *config_file = NULL;
884 GKeyFile *gkey_file = NULL;
887 if (number > 4 || number < 1)
889 str = g_strdup_printf("livewp-home-widget.desktop-%i", (number - 1));
890 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
892 gkey_file = hd_config_file_load_file(config_file, FALSE);
894 g_key_file_remove_group(gkey_file, str, NULL);
895 hd_config_file_save_file( config_file, gkey_file);
896 g_key_file_free(gkey_file);
898 fprintf(stderr, "Problem with config file");
901 g_object_unref(config_file);