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 General Public License
11 * as published by the Free Software Foundation; either version 2 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 \nand for icons Andrew Zhilin\n \
43 Finnish - Marko Vertainen\n \
44 Spain - Alejandro López\n \
45 Italian - Emanuele Cassioli\n \
46 Dutch - Roland van Tilburg (aka ROLAN900D) \n \
47 Russian - Tanya Makova \n \
48 Vlad Vasiliev\n"), VERSION);
50 label_about = gtk_label_new (about_string);
51 gtk_box_pack_start (GTK_BOX (vbox), label_about, FALSE, FALSE, 0);
52 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
54 gtk_widget_show (label_about);
55 gtk_widget_show (vbox);
56 gtk_widget_show (window);
57 gtk_dialog_run(GTK_DIALOG(window));
60 /*******************************************************************************/
62 create_category_selector (Animation_WallpaperPrivate *priv){
64 GSList *store = priv->extheme_list;
65 GHashTable *result_table = NULL;
67 selector = hildon_touch_selector_new_text();
70 result_table = g_hash_table_new(g_str_hash, g_str_equal);
72 if (!g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category"))){
73 g_hash_table_insert(result_table, g_hash_table_lookup(store->data, "category"), (gint *)1);
74 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), g_hash_table_lookup(store->data, "category"));
76 store = g_slist_next(store);
79 /* Add Xscreensaver for install message */
80 if (!g_hash_table_lookup(result_table,"Xscreensaver")){
81 g_hash_table_insert(result_table, "Xscreensaver", (gint *)1);
82 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "Xscreensaver");
84 /* Add LiveWallpaper to selector */
85 if (!g_hash_table_lookup(result_table,"LiveWallpaper")){
86 hildon_touch_selector_prepend_text (HILDON_TOUCH_SELECTOR (selector), "LiveWallpaper" );
92 /*******************************************************************************/
94 theme_button_clicked(GtkWidget *button, GdkEventButton *event, Animation_WallpaperPrivate *priv){
95 lw_theme_settings(GTK_WIDGET(button), priv);
97 /********************************************************************************/
99 set_button_image(GtkWidget * button, Animation_WallpaperPrivate *priv, gboolean enable){
100 GtkWidget * image = NULL;
101 GdkPixbuf * pixbuf = NULL;
103 gchar *icon_on = NULL;
104 gchar *icon_off = NULL;
105 GSList *store = priv->extheme_list;
108 if (!strcmp(priv->theme, g_hash_table_lookup(store->data, "name"))){
109 icon_on = g_strdup(g_hash_table_lookup(store->data, "icon_on"));
110 icon_off = g_strdup(g_hash_table_lookup(store->data, "icon_off"));
113 store = (GSList *)g_list_next(store);
117 str = g_strdup_printf("%s", icon_on);
119 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
120 priv->theme, "icon.png");
121 if (access(str, F_OK) != 0){
123 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
124 "Video", "icon.png");
129 str = g_strdup_printf("%s", icon_off);
131 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
132 priv->theme, "icond.png");
133 if (access(str, F_OK) != 0){
135 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
136 "Video", "icond.png");
139 pixbuf = gdk_pixbuf_new_from_file_at_size (str,
150 image = gtk_image_new_from_pixbuf (pixbuf);
151 g_object_unref(G_OBJECT(pixbuf));
154 //hildon_button_set_image (HILDON_BUTTON (button), image);
155 GList *list = gtk_container_get_children(GTK_CONTAINER (button));
157 gtk_container_remove(GTK_CONTAINER (button), list->data);
159 gtk_container_add(GTK_CONTAINER (button), image);
160 gtk_widget_show(image);
161 gtk_widget_show(button);
164 /********************************************************************************/
166 create_image_button (gint view, DBusConnection *conn_sess){
167 GtkWidget *event_box;
169 Animation_WallpaperPrivate *priv = g_new0(Animation_WallpaperPrivate, 1);
170 /* Add external themes to priv */
171 priv->extheme_list = get_list_exthemes();
174 priv->theme_string_parametr1 = NULL;
175 priv->dbus_conn_session = conn_sess;
178 event_box = gtk_event_box_new();
179 g_object_set_data(G_OBJECT(event_box), "view", GINT_TO_POINTER(view));
180 g_object_set_data(G_OBJECT(event_box), "priv", priv);
181 set_button_image(event_box, priv, check_applet_state(view));
182 g_signal_connect(G_OBJECT (event_box), "button_release_event", G_CALLBACK(theme_button_clicked), priv);
185 button = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
186 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
187 g_object_set_data(G_OBJECT(button), "view", GINT_TO_POINTER(view));
188 g_object_set_data(G_OBJECT(button), "priv", priv);
189 set_button_image(button, priv, check_applet_state(view));
190 g_signal_connect(button, "clicked", G_CALLBACK(theme_button_clicked), priv);
191 hildon_button_set_image_position (HILDON_BUTTON (button), GTK_POS_RIGHT);
195 /********************************************************************************/
197 changed_value_one_in_all_cb (GtkWidget *toggle, Animation_WallpaperPrivate *priv)
199 priv->one_in_all_view = hildon_check_button_get_active((HildonCheckButton *)toggle);
200 create_themes_buttons_hbox(priv);
201 fprintf(stderr, "changed_value_one_in_all_cb\n");
203 /********************************************************************************/
205 changed_value_theme_cb (HildonPickerButton *picker, Animation_WallpaperPrivate *priv)
207 const gchar *choice = hildon_button_get_value(HILDON_BUTTON (picker));
208 GtkWidget *vbox = NULL;
209 GtkWidget *area_vbox = NULL;
211 area_vbox = g_object_get_data(G_OBJECT(priv->window), "area_vbox");
214 vbox = g_object_get_data(G_OBJECT(priv->window), "custom_vbox");
216 gtk_widget_destroy(vbox);
218 vbox = gtk_vbox_new (TRUE, 5);
219 g_object_set_data(G_OBJECT(priv->window), "custom_vbox", vbox);
220 gtk_box_pack_start(GTK_BOX(area_vbox),
221 vbox, FALSE, FALSE, 5);
223 if (!strcmp(choice, _("Berlin"))){
224 rich_animation_additional_parametr(vbox,priv);
226 if (!strcmp(choice, _("Modern"))){
227 rich_animation_additional_parametr(vbox,priv);
229 if (!strcmp(choice, _("Matrix"))){
230 rich_animation_additional_parametr(vbox,priv);
233 if (!strcmp(choice, _("Accel"))){
234 rich_animation_additional_parametr(vbox,priv);
236 if (!strcmp(choice, _("Video"))){
237 additional_parametr_for_theme_video(vbox, priv);
239 if (!strcmp(choice, _("Flash"))){
240 additional_parametr_for_theme_flash(vbox, priv);
242 if (!strcmp(choice, _("Slideshow"))){
243 additional_parametr_for_theme_slideshow(vbox, priv);
247 gtk_widget_show(vbox);
249 /********************************************************************************/
251 changed_value_category_cb (HildonPickerButton *picker, Animation_WallpaperPrivate *priv)
253 GtkWidget *theme_button = NULL;
258 const gchar *choice = hildon_button_get_value(HILDON_BUTTON (picker));
260 theme_button = g_object_get_data(G_OBJECT(priv->window), "theme_button");
263 HildonTouchSelector * selector = hildon_picker_button_get_selector((HildonPickerButton *) theme_button);
264 hildon_touch_selector_remove_column(selector, 0);
265 hildon_touch_selector_append_text_column(selector, (GtkTreeModel*)gtk_list_store_new (1, G_TYPE_STRING), TRUE);
266 fill_theme_button(priv, theme_button, (gchar *)hildon_button_get_value(HILDON_BUTTON (picker)));
267 /* check xscreensaver category */
269 if (!strcmp(choice,"Xscreensaver"))
270 if (access("/usr/bin/xscreensaver", F_OK) != 0){
271 text = g_strdup_printf(_("You haven't got the installed package %s. Do you want to install it via using Application Manager?"), "Xscreensaver");
272 confirm = hildon_note_new_confirmation(GTK_WINDOW(priv->window), text);
273 if(GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))){
274 gchar * cmd = g_strdup_printf("dbus-send --print-reply --dest=com.nokia.osso_browser /com/nokia/osso_browser/service com.nokia.osso_browser.open_new_window string:%s", "http://maemo.org/downloads/product/raw/Maemo5/xscreensaver/?get_installfile");
275 fprintf(stderr, "system %s\n", cmd);
280 gtk_widget_destroy(confirm);
284 /********************************************************************************/
286 fill_theme_button (Animation_WallpaperPrivate *priv, GtkWidget *button, gchar *category){
288 gchar *theme = priv->theme;
289 gboolean flag = False;
291 hildon_button_set_value(HILDON_BUTTON (button), NULL);
293 changed_value_theme_cb(HILDON_PICKER_BUTTON (button), priv);
296 GSList *store = priv->extheme_list;
297 HildonTouchSelector * selector = hildon_picker_button_get_selector((HildonPickerButton *) button);
299 selector = (HildonTouchSelector *)hildon_touch_selector_new_text ();
301 hildon_button_set_value(HILDON_BUTTON(button), NULL);
302 if (!strcmp(category, "LiveWallpaper")){
303 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Berlin"));
304 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Modern"));
305 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Matrix"));
306 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Accel"));
307 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Video"));
308 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Slideshow"));
311 if (!strcmp(theme, "Berlin")){
312 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
313 hildon_button_set_value(HILDON_BUTTON(button), _("Berlin"));
315 if (!strcmp(theme, "Modern")){
316 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 1);
317 hildon_button_set_value(HILDON_BUTTON(button), _("Modern"));
319 if (!strcmp(theme, "Matrix")){
320 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 2);
321 hildon_button_set_value(HILDON_BUTTON(button), _("Matrix"));
323 if (!strcmp(theme, "Accel")){
324 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 3);
325 hildon_button_set_value(HILDON_BUTTON(button), _("Accel"));
327 if (!strcmp(theme, "Video")){
328 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 4);
329 hildon_button_set_value(HILDON_BUTTON(button), _("Video"));
331 if (!strcmp(theme, "Slideshow")){
332 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 4);
333 hildon_button_set_value(HILDON_BUTTON(button), _("Slideshow"));
338 if (!g_hash_table_lookup(store->data, "category"))
340 if (!strcmp(g_hash_table_lookup(store->data, "category"), category)){
341 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), g_hash_table_lookup(store->data, "name"));
342 if (!strcmp(theme, g_hash_table_lookup(store->data, "name"))){
343 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, num);
344 hildon_button_set_value(HILDON_BUTTON(button), _(g_hash_table_lookup(store->data, "name")));
348 store = g_slist_next(store);
350 /* Added Shreman's Aquarium for message */
351 if (!strcmp(category, "Unknown")){
352 store = priv->extheme_list;
354 if (!strcmp("Shermans Aquarium" , g_hash_table_lookup(store->data, "name"))){
358 store = g_slist_next(store);
361 hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), "Shermans Aquarium");
364 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
365 HILDON_TOUCH_SELECTOR (selector));
367 changed_value_theme_cb(HILDON_PICKER_BUTTON (button), priv);
369 /********************************************************************************/
371 create_themes_button (Animation_WallpaperPrivate *priv, gchar *category){
374 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
375 hildon_button_set_title (HILDON_BUTTON (button), _("Theme"));
380 /********************************************************************************/
382 create_categories_button (Animation_WallpaperPrivate *priv){
386 gchar *theme = priv->theme;
388 GHashTable *result_table = NULL;
390 result_table = g_hash_table_new(g_str_hash, g_str_equal);
391 selector = create_category_selector(priv);
392 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
393 hildon_button_set_title (HILDON_BUTTON (button), _("Category"));
394 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
395 HILDON_TOUCH_SELECTOR (selector));
397 if (!strcmp(theme, "Berlin")){
398 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
399 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
401 if (!strcmp(theme, "Modern")){
402 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
403 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
405 if (!strcmp(theme, "Matrix")){
406 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
407 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
409 if (!strcmp(theme, "Accel")){
410 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
411 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
413 if (!strcmp(theme, "Video")){
414 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
415 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
417 if (!strcmp(theme, "Slideshow")){
418 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0);
419 hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper");
421 GSList *store = priv->extheme_list;
424 if (g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")) == NULL){
425 g_hash_table_insert(result_table, g_hash_table_lookup(store->data, "category"), (gint *)num);
428 if (!strcmp(theme, g_hash_table_lookup(store->data, "name"))){
429 if (g_hash_table_lookup(store->data, "category")){
430 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0,
431 (gint)g_hash_table_lookup(result_table, g_hash_table_lookup(store->data, "category")));
432 hildon_button_set_value(HILDON_BUTTON(button), g_hash_table_lookup(store->data, "category"));
437 store = g_slist_next(store);
443 /*******************************************************************************/
445 create_bool_button (gboolean active, gchar *name)
448 button = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
449 gtk_button_set_label (GTK_BUTTON (button), name);
450 hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
453 /*******************************************************************************/
455 create_enable_button (gboolean active)
458 button = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
459 gtk_button_set_label (GTK_BUTTON (button), _("Enable"));
460 hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
464 /*******************************************************************************/
466 show_settings(GtkWidget *widget, Animation_WallpaperPrivate *priv){
467 lw_main_settings(priv, NULL);
469 /*******************************************************************************/
471 create_themes_buttons_hbox(Animation_WallpaperPrivate *priv){
472 GtkWidget *hbox = NULL;
473 GtkWidget *area_hbox = NULL;
474 GtkWidget *theme_button;
475 GSList *stlist = NULL;
476 GConfClient *gconf_client = NULL;
477 GConfValue *value = NULL;
478 guint count_of_view = 1;
482 area_hbox = g_object_get_data(G_OBJECT(priv->window), "area_hbox");
485 hbox = g_object_get_data(G_OBJECT(priv->window), "custom_hbox");
487 gtk_widget_destroy(hbox);
490 hbox = gtk_hbox_new(FALSE, 0);
491 g_object_set_data(G_OBJECT(priv->window), "custom_hbox", hbox);
492 gtk_box_pack_start(GTK_BOX(area_hbox),
493 hbox, FALSE, FALSE, 5);
494 /* Create Theme buttons */
495 theme_button = create_image_button(1, priv->dbus_conn_session);
496 gtk_box_pack_start(GTK_BOX(hbox),
497 theme_button, TRUE, TRUE, 10);
498 gtk_widget_show (theme_button);
499 gtk_widget_show (hbox);
500 if (priv->one_in_all_view)
503 gconf_client = gconf_client_get_default();
507 stlist = gconf_client_get_list(gconf_client,
508 "/apps/osso/hildon-desktop/views/active",
509 GCONF_VALUE_INT, NULL);
511 count_of_view = g_slist_length(stlist);
512 g_slist_free(stlist);
515 g_object_unref(gconf_client);
516 for (i = 2; i < count_of_view + 1; i++){
517 theme_button = create_image_button(i, priv->dbus_conn_session);
518 gtk_box_pack_start(GTK_BOX(hbox),
519 theme_button, TRUE, TRUE, 10);
520 gtk_widget_show (theme_button);
523 /*******************************************************************************/
525 lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data){
527 GtkWidget *window = NULL;
528 GtkWidget *banner = NULL;
529 GtkWidget *area_hbox;
530 GtkWidget *scrolled_window;
531 GtkWidget *one_in_all_view_button;
532 gboolean one_in_all_view;
535 window = gtk_dialog_new();
536 priv->window = window;
538 one_in_all_view = priv->one_in_all_view;
539 gtk_window_set_title(GTK_WINDOW(window), _("Live Wallpaper Settings"));
540 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
541 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
542 one_in_all_view_button = create_bool_button(priv->one_in_all_view, _("One theme in all views"));
543 g_signal_connect (G_OBJECT (one_in_all_view_button), "toggled", G_CALLBACK (changed_value_one_in_all_cb), priv);
544 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), one_in_all_view_button, TRUE, TRUE, 5);
545 area_hbox = gtk_vbox_new(FALSE, 2);
546 g_object_set_data(G_OBJECT(window), "area_hbox", area_hbox);
548 create_themes_buttons_hbox(priv);
549 scrolled_window = hildon_pannable_area_new ();
550 g_object_set (G_OBJECT (scrolled_window), "mov-mode", HILDON_MOVEMENT_MODE_HORIZ, NULL);
551 g_object_set (G_OBJECT (scrolled_window), "hscrollbar-policy", GTK_POLICY_ALWAYS, NULL);
552 g_object_set (G_OBJECT (scrolled_window), "scrollbar-fade-delay", 27000, NULL);
553 g_object_set (G_OBJECT (scrolled_window), "indicator-width", 28, NULL);
554 gtk_widget_set_size_request(scrolled_window, -1, 120);
555 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA (scrolled_window), GTK_WIDGET (area_hbox));
557 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
558 scrolled_window, TRUE, TRUE, 0);
560 gtk_widget_show(scrolled_window);
561 gtk_widget_show(one_in_all_view_button);
562 gtk_widget_show_all(area_hbox);
563 gtk_widget_show(window);
564 gtk_dialog_add_button(GTK_DIALOG(window), _("About"), GTK_RESPONSE_NO);
566 result = gtk_dialog_run(GTK_DIALOG(window));
569 case GTK_RESPONSE_NO:
570 gtk_widget_destroy(window);
576 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(one_in_all_view_button)) != one_in_all_view){
577 save_one_in_all_views_to_config(hildon_check_button_get_active (HILDON_CHECK_BUTTON(one_in_all_view_button)));
578 //fprintf(stderr,"CHECK!!!!!!!!!!!!!!\n");
579 banner = hildon_banner_show_information (window, NULL, _("Livewallpaper is reloading..."));
580 hildon_banner_set_timeout(HILDON_BANNER(banner), 3000);
583 g_timeout_add(3000, (GSourceFunc)cb_timeout_settings, window);
586 gtk_widget_destroy(window);
589 /*******************************************************************************/
591 cb_timeout_settings(GtkWidget *window){
598 gtk_widget_destroy(window);
601 /*******************************************************************************/
603 file_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){
605 GtkWidget *dialog = hildon_file_chooser_dialog_new(GTK_WINDOW (priv->window), GTK_FILE_CHOOSER_ACTION_OPEN);
607 if (priv->theme_string_parametr1)
608 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), priv->theme_string_parametr1);
610 gtk_widget_show_all (GTK_WIDGET (dialog));
612 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
614 hildon_button_set_value (HILDON_BUTTON(button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
616 gtk_widget_destroy (dialog);
619 /*******************************************************************************/
621 folder_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){
623 GtkWidget *dialog = hildon_file_chooser_dialog_new(GTK_WINDOW (priv->window), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
625 if (priv->theme_string_parametr1)
626 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), priv->theme_string_parametr1);
628 gtk_widget_show_all (GTK_WIDGET (dialog));
630 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
632 hildon_button_set_value (HILDON_BUTTON(button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
634 gtk_widget_destroy (dialog);
637 /*******************************************************************************/
639 rich_animation_additional_parametr(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
640 GtkWidget *rich_animation_button;
642 /* Create rich animation button */
643 rich_animation_button = create_bool_button(priv->rich_animation, _("Rich Animation"));
644 gtk_box_pack_start(GTK_BOX(vbox),
645 rich_animation_button, TRUE, TRUE, 5);
646 g_object_set_data(G_OBJECT(priv->window), "rich_animation_button", rich_animation_button);
647 gtk_widget_show (rich_animation_button);
649 /*******************************************************************************/
651 link_button_clicked(GtkButton *button, gchar *url){
653 gchar * cmd = g_strdup_printf("dbus-send --print-reply --dest=com.nokia.osso_browser \
654 /com/nokia/osso_browser/service com.nokia.osso_browser.open_new_window string:%s", url);
655 fprintf(stderr, "system %s\n", cmd);
659 /*******************************************************************************/
661 additional_parametr_for_theme_video(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
663 GtkWidget *file_button;
664 GtkWidget *link_button;
665 GtkWidget *smoothing_button;
666 GtkWidget *rich_animation_button;
668 if (priv->theme_string_parametr1)
669 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL,
670 _("Play file"), priv->theme_string_parametr1);
672 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL,
675 g_signal_connect (file_button, "clicked", G_CALLBACK (file_button_clicked), priv);
677 gtk_box_pack_start(GTK_BOX(vbox),
678 file_button, TRUE, TRUE, 5);
679 g_object_set_data(G_OBJECT(priv->window), "filename_button", file_button);
680 /* Create rich animation button */
681 rich_animation_button = create_bool_button(priv->rich_animation, _("Loop"));
682 gtk_box_pack_start(GTK_BOX(vbox),
683 rich_animation_button, TRUE, TRUE, 5);
684 g_object_set_data(G_OBJECT(priv->window), "rich_animation_button", rich_animation_button);
685 /* Create Smoothing button */
687 smoothing_button = create_bool_button(priv->theme_bool_parametr1, _("Smoothing (Need more memory)"));
688 gtk_box_pack_start(GTK_BOX(vbox),
689 smoothing_button, TRUE, TRUE, 5);
690 g_object_set_data(G_OBJECT(priv->window), "smoothing_button", smoothing_button);
692 link_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL,
693 _("Press me for"), _("download more videos"));
695 g_signal_connect (link_button, "clicked", G_CALLBACK (link_button_clicked), "http://talk.maemo.org/showthread.php?t=60185");
696 gtk_box_pack_start(GTK_BOX(vbox),
697 link_button, TRUE, TRUE, 5);
699 gtk_widget_show (smoothing_button);
700 gtk_widget_show (file_button);
701 gtk_widget_show (rich_animation_button);
702 gtk_widget_show (link_button);
705 /*******************************************************************************/
707 additional_parametr_for_theme_flash(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
709 GtkWidget *file_button;
710 GtkWidget *link_button;
711 GtkWidget *smoothing_button;
712 GtkWidget *rich_animation_button;
714 if (priv->theme_string_parametr1)
715 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL,
716 _("Play file"), priv->theme_string_parametr1);
718 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL,
721 g_signal_connect (file_button, "clicked", G_CALLBACK (file_button_clicked), priv);
723 gtk_box_pack_start(GTK_BOX(vbox),
724 file_button, TRUE, TRUE, 5);
725 g_object_set_data(G_OBJECT(priv->window), "filename_button", file_button);
726 gtk_widget_show (file_button);
728 /*******************************************************************************/
730 additional_parametr_for_theme_slideshow(GtkWidget *vbox, Animation_WallpaperPrivate *priv){
732 GtkWidget *file_button;
733 GtkWidget *link_button;
734 GtkWidget *smoothing_button;
735 GtkWidget *rich_animation_button;
737 if (priv->theme_string_parametr1)
738 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL,
739 _("Folder with images"), priv->theme_string_parametr1);
741 file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL,
742 _("Folder with images")," ");
744 g_signal_connect (file_button, "clicked", G_CALLBACK (folder_button_clicked), priv);
746 gtk_box_pack_start(GTK_BOX(vbox),
747 file_button, TRUE, TRUE, 5);
748 g_object_set_data(G_OBJECT(priv->window), "filename_button", file_button);
749 gtk_widget_show (file_button);
751 /*******************************************************************************/
754 show_problem_package (GtkWidget *widget, gchar *package_name){
756 text = g_strdup_printf(_("You haven't got the installed package %s. Please install it via using Application Manager"), package_name);
757 hildon_banner_show_information(GTK_WIDGET(widget), NULL, text);
760 /*******************************************************************************/
762 show_duplicate_theme (GtkWidget *widget, gchar *theme_name){
764 text = g_strdup_printf(_("Theme %s has already been selected"), theme_name);
765 hildon_banner_show_information(GTK_WIDGET(widget), NULL, text);
769 /*******************************************************************************/
771 lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) {
773 GtkWidget *window = NULL;
774 GtkWidget *scrolled_window = NULL;
775 GtkWidget *save_button;
776 GtkWidget *theme_button;
777 GtkWidget *category_button;
778 GtkWidget *enable_button;
780 GtkWidget *area_vbox;
781 GtkWidget *temp_button;
782 GtkWidget *button1 = NULL;
783 GtkWidget *rich_animation_button = NULL;
785 gint view = priv->view;
789 window = gtk_dialog_new();
790 priv->window = window;
792 gtk_window_set_title(GTK_WINDOW(window), _("View Settings"));
793 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
794 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
797 area_vbox = gtk_vbox_new(FALSE, 2);
798 g_object_set_data(G_OBJECT(window), "area_vbox", area_vbox);
799 scrolled_window = hildon_pannable_area_new ();
800 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA (scrolled_window), GTK_WIDGET (area_vbox));
801 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),
802 scrolled_window, FALSE, FALSE, 0);
804 gtk_widget_set_size_request(scrolled_window, -1, 370);
806 /* Create Enable button */
807 enable_button = create_enable_button(check_applet_state(view));
808 gtk_box_pack_start(GTK_BOX(area_vbox),
809 enable_button, FALSE, FALSE, 5);
810 /* Create Category button */
811 category_button = create_categories_button(priv);
812 g_object_set_data(G_OBJECT(window), "category_button", category_button);
813 g_signal_connect (G_OBJECT (category_button), "value-changed", G_CALLBACK (changed_value_category_cb), priv);
814 gtk_box_pack_start(GTK_BOX(area_vbox),
815 category_button, FALSE, FALSE, 5);
816 /* Create Custom vbox */
817 vbox = gtk_vbox_new (FALSE, 5);
818 g_object_set_data(G_OBJECT(window), "custom_vbox", vbox);
820 /* Create Theme button */
821 theme_button = create_themes_button(priv, (gchar *)hildon_button_get_value(HILDON_BUTTON (category_button)));
822 g_object_set_data(G_OBJECT(window), "theme_button", theme_button);
823 g_signal_connect (G_OBJECT (theme_button), "value-changed", G_CALLBACK (changed_value_theme_cb), priv);
824 gtk_box_pack_start(GTK_BOX(area_vbox),
825 theme_button, FALSE, FALSE, 5);
826 fill_theme_button(priv, theme_button, (gchar *)hildon_button_get_value(HILDON_BUTTON (category_button)));
828 /* Pack custom vbox. It must be last widget */
829 gtk_box_pack_start(GTK_BOX(area_vbox),
830 vbox, FALSE, FALSE, 5);
832 gtk_widget_show (enable_button);
833 gtk_widget_show (category_button);
834 gtk_widget_show (theme_button);
835 gtk_widget_show (vbox);
836 gtk_widget_show (area_vbox);
837 gtk_widget_show (scrolled_window);
838 gtk_widget_show (window);
840 save_button = gtk_dialog_add_button(GTK_DIALOG(window), _("Save"), GTK_RESPONSE_YES);
842 result = gtk_dialog_run(GTK_DIALOG(window));
845 case GTK_RESPONSE_YES:
847 if (hildon_button_get_value(HILDON_BUTTON (theme_button)) &&
848 strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "")){
850 if (priv->theme_string_parametr1){
851 g_free(priv->theme_string_parametr1);
852 priv->theme_string_parametr1 = NULL;
857 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Berlin")))
858 priv->theme = g_strdup("Berlin");
859 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Modern")))
860 priv->theme = g_strdup("Modern");
861 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Matrix")))
862 priv->theme = g_strdup("Matrix");
863 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Accel")))
864 priv->theme = g_strdup("Accel");
865 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Video"))){
866 priv->theme = g_strdup("Video");
867 button1 = g_object_get_data(G_OBJECT(priv->window), "filename_button");
869 priv->theme_string_parametr1 = g_strdup((gchar*)hildon_button_get_value (HILDON_BUTTON(button1)));
871 temp_button = g_object_get_data(G_OBJECT(priv->window), "smoothing_button");
873 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(temp_button)))
874 priv->theme_bool_parametr1 = TRUE;
876 priv->theme_bool_parametr1 = FALSE;
879 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Flash"))){
880 button1 = g_object_get_data(G_OBJECT(priv->window), "filename_button");
882 if (priv->theme_string_parametr1)
883 g_free(priv->theme_string_parametr1);
884 priv->theme_string_parametr1 = g_strdup((gchar*)hildon_button_get_value (HILDON_BUTTON(button1)));
887 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Slideshow"))){
888 priv->theme = g_strdup("Slideshow");
889 button1 = g_object_get_data(G_OBJECT(priv->window), "filename_button");
891 if (priv->theme_string_parametr1)
892 g_free(priv->theme_string_parametr1);
893 priv->theme_string_parametr1 = g_strdup((gchar*)hildon_button_get_value (HILDON_BUTTON(button1)));
896 /* Check external themes */
897 GSList *store = priv->extheme_list;
899 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _(g_hash_table_lookup(store->data, "name")))){
900 //check if theme installed
901 gchar *check_path = g_hash_table_lookup(store->data, "check_path");
903 if (access(check_path, F_OK) != 0){
904 gchar * install_file = g_hash_table_lookup(store->data, "install_file");
906 if (g_hash_table_lookup(store->data, "associated_package"))
907 text = g_strdup_printf(_("You haven't got the installed package %s. Do you want to install it via using Application Manager?"),
908 (gchar *) g_hash_table_lookup(store->data, "associated_package"));
910 text = g_strdup_printf(_("You haven't got the installed package %s. Do you want to install it via using Application Manager?"),
911 (gchar *)g_hash_table_lookup(store->data, "name"));
912 confirm = hildon_note_new_confirmation(GTK_WINDOW(window), text);
913 if(GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))){
914 gchar * cmd = g_strdup_printf("dbus-send --print-reply --dest=com.nokia.osso_browser /com/nokia/osso_browser/service com.nokia.osso_browser.open_new_window string:%s", install_file);
915 fprintf(stderr, "system %s\n", cmd);
920 gtk_widget_destroy(confirm);
922 if (g_hash_table_lookup(store->data, "associated_package"))
923 show_problem_package(button, g_hash_table_lookup(store->data, "associated_package"));
925 show_problem_package(button, g_hash_table_lookup(store->data, "name"));
926 /* if not success exit from without saving */
932 //check if theme already selected
933 gchar *copies = g_hash_table_lookup(store->data, "copies");
934 //fprintf(stderr, "copies = %s\n", copies);
936 count = atoi(copies);
938 if (count > get_count_themes_from_config(g_hash_table_lookup(store->data, "name")))
939 priv->theme = g_strdup(g_hash_table_lookup(store->data, "name"));
941 show_duplicate_theme(button, g_hash_table_lookup(store->data, "name"));
942 //priv->hash_theme = store->data;
945 store = g_slist_next(store);
947 fprintf(stderr, "theme = %s\n", priv->theme);
950 rich_animation_button = g_object_get_data(G_OBJECT(priv->window), "rich_animation_button");
951 if (rich_animation_button){
952 /* Check rich animation */
953 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(rich_animation_button)))
954 priv->rich_animation = TRUE;
956 priv->rich_animation = FALSE;
960 /* action with applet */
961 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(enable_button))){
962 if (!check_applet_state(view)){
965 send_dbus_signal (priv,
966 LIVEWP_SIGNAL_INTERFACE,
968 LIVEWP_RELOAD_CONFIG);
971 if (check_applet_state(view))
974 set_button_image(button, priv, check_applet_state(view));
977 case GTK_RESPONSE_OK:
979 case GTK_RESPONSE_NO:
980 gtk_widget_destroy(window);
986 gtk_widget_destroy(window);
988 /*******************************************************************************/
990 check_applet_state(gint number){
992 HDConfigFile *config_file = NULL;
993 GKeyFile *gkey_file = NULL;
995 gboolean result = FALSE;
996 if (number > 9 || number < 1)
999 str = g_strdup_printf("livewp-home-widget.desktop-%i", (number - 1));
1000 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
1002 gkey_file = hd_config_file_load_file(config_file, FALSE);
1003 if (gkey_file && str){
1004 result = g_key_file_has_group(gkey_file, str);
1009 /*******************************************************************************/
1011 start_applet(gint number){
1013 HDConfigFile *config_file = NULL;
1014 GKeyFile *gkey_file = NULL;
1017 if (number > 9 || number < 1)
1019 str = g_strdup_printf("livewp-home-widget.desktop-%i",(number - 1));
1020 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
1022 gkey_file = hd_config_file_load_file(config_file, FALSE);
1024 g_key_file_set_string (gkey_file, str, "X-Desktop-File", "/usr/share/applications/hildon-home/livewp-home-widget.desktop");
1025 hd_config_file_save_file( config_file, gkey_file);
1026 g_key_file_free(gkey_file);
1028 fprintf(stderr, "Problem with config file");
1031 g_object_unref(config_file);
1033 /*******************************************************************************/
1035 stop_applet(gint number){
1036 HDConfigFile *config_file = NULL;
1037 GKeyFile *gkey_file = NULL;
1040 if (number > 9 || number < 1)
1042 str = g_strdup_printf("livewp-home-widget.desktop-%i", (number - 1));
1043 config_file = hd_config_file_new(NULL, "/home/user/.config/hildon-desktop/", "home.plugins");
1045 gkey_file = hd_config_file_load_file(config_file, FALSE);
1047 g_key_file_remove_group(gkey_file, str, NULL);
1048 hd_config_file_save_file( config_file, gkey_file);
1049 g_key_file_free(gkey_file);
1051 fprintf(stderr, "Problem with config file");
1054 g_object_unref(config_file);