added possibilty to configure in Control Panel
[livewp] / applet / src / livewp-main.c
1 /* vim: set sw=4 ts=4 et: */
2 /*
3  * This file is part of Live Wallpaper (livewp)
4  * 
5  * Copyright (C) 2010 Vlad Vasiliev
6  * Copyright (C) 2010 Tanya Makova
7  *       for the code
8  * 
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.
13  * 
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.
18  * 
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
22  * 02110-1301 USA
23 */
24 /*******************************************************************************/
25 #include "livewp-common.h"
26 #include "livewp-settings.h"
27 /*******************************************************************************/
28
29 void 
30 btn_setting_clicked(HildonButton *btn, gpointer data)
31 {
32     Animation_WallpaperPrivate *priv = data;
33     // open settings dialog
34     fprintf(stderr, "btn setting clicked, %s\n", priv->theme);
35     lw_settings(priv, NULL);
36     fprintf(stderr, "btn setting clicked, %s\n", priv->theme);
37 }
38 void
39 btn_power_clicked(HildonButton *btn, gpointer data)
40 {
41     const gchar *value; 
42     value = hildon_button_get_value(btn);
43     fprintf(stderr, "applet must be %s\n", value);
44     if (!strcmp(value, "stop"))
45         hildon_button_set_text(HILDON_BUTTON(btn), _("Start"), "start");
46     else 
47         hildon_button_set_text(HILDON_BUTTON(btn), _("Stop"), "stop");
48 }
49 int
50 main(int argc, char *argv[])
51 {
52     GtkWidget *main_widget = NULL;
53     GtkWidget *window;
54     GtkWidget *btn_setting, *vbox, *btn_power;
55     gint result;
56     HildonProgram       *app;
57
58     Animation_WallpaperPrivate *priv = g_new0 (Animation_WallpaperPrivate, 1);
59
60 #ifdef ENABLE_NLS
61     setlocale(LC_ALL, "");
62     bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
63     bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
64     textdomain(GETTEXT_PACKAGE);
65 #endif
66     /* Ininitializing */
67     hildon_gtk_init (&argc, &argv);
68     app = HILDON_PROGRAM (hildon_program_get_instance());
69     g_set_application_name (PACKAGE);
70  
71     priv->osso = osso_initialize("org.maemo.livewp", VERSION, TRUE, NULL);
72     if(!priv->osso){
73         fprintf(stderr,"osso_initialize failed\n");
74         return 1;
75     }
76
77     /* Load config */
78     read_config(priv);
79
80     /* Initialize DBUS */
81     livewp_initialize_dbus(priv);
82
83     /* Create Main GUI */
84     main_widget = hildon_stackable_window_new ();
85     gtk_window_set_title(GTK_WINDOW(main_widget), PACKAGE);
86
87     vbox = gtk_vbox_new(FALSE, 5);
88     btn_setting = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
89                                HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
90     hildon_button_set_text(HILDON_BUTTON(btn_setting), _("Settings"), "");
91     g_signal_connect(btn_setting, "clicked", G_CALLBACK(btn_setting_clicked), priv);
92     //gtk_container_add(GTK_CONTAINER(main_widget), button);
93     gtk_box_pack_start(vbox, btn_setting, FALSE, FALSE, 0);
94     
95     btn_power = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
96                                HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
97     if (1)/* if applet started*/{
98         hildon_button_set_text(HILDON_BUTTON(btn_power), _("Stop"), "stop");
99     }
100     else{ 
101         hildon_button_set_text(HILDON_BUTTON(btn_power), _("Start"), "start");
102     }
103     g_signal_connect(btn_power, "clicked", G_CALLBACK(btn_power_clicked), priv);
104     //gtk_container_add(GTK_CONTAINER(main_widget), button);
105     gtk_box_pack_start(vbox, btn_power, FALSE, FALSE, 0);
106
107     gtk_container_add(GTK_CONTAINER(main_widget), vbox);
108
109     g_signal_connect(main_widget, "destroy", G_CALLBACK(gtk_main_quit), NULL);
110     hildon_program_add_window(app, HILDON_WINDOW(main_widget));
111
112     gtk_widget_show_all(GTK_WIDGET(main_widget));
113     gtk_main();
114     return 0;
115 }