*/
/*******************************************************************************/
#include "livewp-common.h"
+#include "livewp-scene.h"
#include "livewp-settings.h"
+#include "livewp-home-widget.h"
/*******************************************************************************/
+void
+btn_setting_clicked(HildonButton *btn, gpointer data)
+{
+ Animation_WallpaperPrivate *priv = data;
+ // open settings dialog
+ fprintf(stderr, "btn setting clicked, %s\n", priv->theme);
+ lw_main_settings(priv, NULL);
+ fprintf(stderr, "btn setting clicked, %s\n", priv->theme);
+}
+/*******************************************************************************/
+void
+btn_power_clicked(HildonButton *btn, gpointer data)
+{
+ const gchar *value;
+ value = hildon_button_get_value(btn);
+ fprintf(stderr, "applet must be %s\n", value);
+ if (!strcmp(value, "stop"))
+ hildon_button_set_text(HILDON_BUTTON(btn), _("Start"), "start");
+ else
+ hildon_button_set_text(HILDON_BUTTON(btn), _("Stop"), "stop");
+}
+/*******************************************************************************/
+static void set_live_bg (Display *display, Window xwindow, int mode);
+static
+void set_live_bg (Display *display, Window xwindow, int mode)
+{
+ Atom atom;
+
+ atom = XInternAtom (display, "_HILDON_LIVE_DESKTOP_BACKGROUND", False);
+ fprintf (stderr, "XID: 0x%x\n", (unsigned)xwindow);
+
+ XChangeProperty (display,
+ xwindow,
+ atom,
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) &mode, 1);
+}
+/*******************************************************************************/
+void
+view_state_changed (Animation_WallpaperPrivate *priv)
+{
+ if (priv->visible){
+ if (priv->long_timer == 0 ){
+ priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, priv->desktop_plugin);
+ run_long_timeout(priv->desktop_plugin);
+ }
+ }else{
+ if (priv->long_timer != 0 ){
+ g_source_remove(priv->long_timer);
+ priv->long_timer = 0;
+ }
+ }
+}
+/*******************************************************************************/
+gboolean
+check_alive_event(Animation_WallpaperPrivate *priv)
+{
+ if ( time(NULL) - priv->last_alive_event > 10*60) /* If last event later 10 minute */
+ quit_from_program(priv);
+ return TRUE;
+}
+
+/*******************************************************************************/
+void
+view_changed (GConfClient *client, guint cnxn_id,
+ GConfEntry *entry, Animation_WallpaperPrivate *priv)
+{
+ if (entry->value->type == GCONF_VALUE_INT) {
+ if (priv->view == gconf_value_get_int(entry->value)){
+ if (priv->visible != TRUE){
+ priv->visible = TRUE;
+ view_state_changed(priv);
+ }
+ }else{
+ if (priv->visible != FALSE){
+ priv->visible = FALSE;
+ view_state_changed(priv);
+ }
+ }
+ }
+}
+/*******************************************************************************/
+void
+quit_from_program (Animation_WallpaperPrivate *priv)
+{
+ fprintf(stderr,"quit_from_program\n");
+ if (priv){
+ livewp_deinitialize_dbus(priv);
+ if (priv->view_notify != 0) {
+ gconf_client_notify_remove (gconf_client_get_default (), priv->view_notify);
+ priv->view_notify = 0;
+ }
+ if (priv->long_timer){
+ g_source_remove(priv->long_timer);
+ priv->long_timer = 0;
+ }
+ if (priv->short_timer){
+ g_source_remove(priv->short_timer);
+ priv->short_timer = 0;
+ }
+ destroy_scene(priv->desktop_plugin);
+ osso_deinitialize(priv->osso);
+ g_hash_table_destroy(priv->hash_scene_func);
+ g_free(priv->desktop_plugin);
+ priv->desktop_plugin = NULL;
+ g_free(priv);
+ priv = NULL;
+ }
+ gtk_main_quit();;
+}
+/*******************************************************************************/
int
main(int argc, char *argv[])
{
GtkWidget *main_widget = NULL;
- GtkWidget *window;
- GtkWidget *button;
- gint result;
HildonProgram *app;
- osso_context_t *osso_context=NULL;
+ int view = 1;
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
-#endif
+
+ if (argc == 2)
+ view = atoi(argv[1]);
+ if (view < 1 || view > 4)
+ view = 1;
+
+ AWallpaperPlugin *desktop_plugin = g_new0 (AWallpaperPlugin, 1);
+ Animation_WallpaperPrivate *priv = g_new0 (Animation_WallpaperPrivate, 1);
+ desktop_plugin->priv = priv;
+
+ gst_init (NULL, NULL);
+
+ /* Ininitializing */
hildon_gtk_init (&argc, &argv);
app = HILDON_PROGRAM (hildon_program_get_instance());
g_set_application_name (PACKAGE);
- osso_context = osso_initialize("org.maemo.livewp", VERSION, TRUE, NULL);
- if(!osso_context){
+ priv->osso = osso_initialize("org.maemo.livewp", VERSION, TRUE, NULL);
+ if(!priv->osso){
fprintf(stderr,"osso_initialize failed\n");
return 1;
}
-
-
- main_widget = hildon_stackable_window_new ();
+#ifdef ENABLE_NLS
+ setlocale(LC_ALL, "");
+ bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+#endif
+/* Create Main GUI */
+ main_widget = hildon_window_new ();
gtk_window_set_title(GTK_WINDOW(main_widget), PACKAGE);
+ gtk_window_fullscreen(GTK_WINDOW(main_widget));
+
+ gtk_widget_show_all(GTK_WIDGET(main_widget));
- button = hildon_button_new(HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
- HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
- hildon_button_set_text(HILDON_BUTTON(button), "кнопка", "");
- gtk_container_add(GTK_CONTAINER(main_widget), button);
+ priv->hash_scene_func = g_hash_table_new(g_str_hash, g_str_equal);
+ g_hash_table_insert(priv->hash_scene_func, g_strdup("Accel"), (gpointer)&init_scene_Accel);
+ g_hash_table_insert(priv->hash_scene_func, g_strdup("Berlin"), (gpointer)&init_scene_Berlin);
+ g_hash_table_insert(priv->hash_scene_func, g_strdup("Modern"), (gpointer)&init_scene_Modern);
+ g_hash_table_insert(priv->hash_scene_func, g_strdup("Matrix"), (gpointer)&init_scene_Matrix);
+ g_hash_table_insert(priv->hash_scene_func, g_strdup("Video"), (gpointer)&init_scene_Video);
+ priv->scene = NULL;
+ priv->window = main_widget;
+ fprintf(stderr,"XWINDOW %i\n",GDK_WINDOW_XID (main_widget->window));
+ priv->desktop_plugin = desktop_plugin;
- hildon_program_add_window(app, HILDON_WINDOW(main_widget));
+ priv->view = view;
+ /* Load config */
+ read_config(priv);
+ /* Initialize DBUS */
+ livewp_initialize_dbus(priv);
+ set_live_bg(GDK_WINDOW_XDISPLAY (main_widget->window), GDK_WINDOW_XID (main_widget->window), view);
+ if (current_active_view() == view)
+ priv->visible = TRUE;
+ else
+ priv->visible = FALSE;
+
+ priv->view_notify = 0;
+ fprintf(stderr,"VISIBLE %i %i\n",priv->visible, current_active_view());
+ gconf_client_add_dir(gconf_client_get_default (), "/apps/osso/hildon-desktop/views", GCONF_CLIENT_PRELOAD_NONE, NULL);
+ priv->view_notify = gconf_client_notify_add(gconf_client_get_default (),"/apps/osso/hildon-desktop/views/current",
+ (GConfClientNotifyFunc)view_changed, priv, NULL, NULL);
- gtk_widget_show_all(GTK_WIDGET(main_widget));
-#if 0
- window = create_settings();
- if (window){
- //gtk_widget_show_all(window);
+ init_scene_theme(desktop_plugin);
- result = gtk_dialog_run(GTK_DIALOG(window));
+ priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
- switch(result){
- case GTK_RESPONSE_YES:
- #if 0
- if (hildon_button_get_value(HILDON_BUTTON (theme_button))){
- if (priv->theme)
- g_free(priv->theme);
- if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Berlin")))
- priv->theme = g_strdup("Berlin");
- if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Modern")))
- priv->theme = g_strdup("Modern");
- if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Matrix")))
- priv->theme = g_strdup("Matrix");
- if (hildon_check_button_get_active (rich_animation_button))
- priv->rich_animation = TRUE;
- else
- priv->rich_animation = FALSE;
- }
- save_config(priv);
- reload_scene(priv->desktop_plugin);
- #endif
- //fprintf(stderr, "click save %s\n", hildon_button_get_value(HILDON_BUTTON(theme_button)));
- fprintf(stderr, "click save \n");
- break;
- default:
- case GTK_RESPONSE_OK:
- break;
- case GTK_RESPONSE_NO:
- fprintf(stderr, "click about\n");
- gtk_widget_destroy(window);
- window = NULL;
- //lw_about();
- break;
- }
- //if (window)
- // gtk_widget_destroy(window);
- //}
- }
-#endif
- fprintf(stderr,"start fdf\n");
- gtk_main();
+ priv->alive_timer = g_timeout_add(60000*10, (GtkFunction)check_alive_event, priv); /* One per 10 minute */
+ gtk_main();
return 0;
}