0b2332b204a631f241ef4c8aa443a37e0bd05fae
[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->desktop_plugin, priv);
36     fprintf(stderr, "btn setting clicked, %s\n", priv->theme);
37 }
38
39 int
40 main(int argc, char *argv[])
41 {
42     GtkWidget *main_widget = NULL;
43     GtkWidget *window;
44     GtkWidget *btn_setting, *vbox;
45     gint result;
46     HildonProgram       *app;
47     osso_context_t  *osso_context=NULL;
48     Animation_WallpaperPrivate *priv = g_new0 (Animation_WallpaperPrivate, 1);
49
50 #ifdef ENABLE_NLS
51     setlocale(LC_ALL, "");
52     bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
53     bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
54     textdomain(GETTEXT_PACKAGE);
55 #endif
56     /* Ininitializing */
57     hildon_gtk_init (&argc, &argv);
58     app = HILDON_PROGRAM (hildon_program_get_instance());
59     g_set_application_name (PACKAGE);
60  
61     osso_context = osso_initialize("org.maemo.livewp", VERSION, TRUE, NULL);
62     if(!osso_context){
63         fprintf(stderr,"osso_initialize failed\n");
64         return 1;
65     }
66
67     /* Load config */
68     read_config(priv);
69
70     /* Create Main GUI */
71     main_widget = hildon_stackable_window_new ();
72     gtk_window_set_title(GTK_WINDOW(main_widget), PACKAGE);
73
74     vbox = gtk_vbox_new(FALSE, 5);
75     btn_setting = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
76                                HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
77     hildon_button_set_text(HILDON_BUTTON(btn_setting), _("Settings"), "");
78     g_signal_connect(btn_setting, "clicked", G_CALLBACK(btn_setting_clicked), priv);
79     //gtk_container_add(GTK_CONTAINER(main_widget), button);
80     gtk_box_pack_start(vbox, btn_setting, FALSE, FALSE, 0);
81     gtk_container_add(GTK_CONTAINER(main_widget), vbox);
82
83     g_signal_connect(main_widget, "destroy", G_CALLBACK(gtk_main_quit), NULL);
84     hildon_program_add_window(app, HILDON_WINDOW(main_widget));
85
86     gtk_widget_show_all(GTK_WIDGET(main_widget));
87     gtk_main();
88     return 0;
89 }