added dbus signal for stoping of livebg
authorvlad <vlad@vlanout.(none)>
Fri, 23 Jul 2010 19:54:57 +0000 (22:54 +0300)
committervlad <vlad@vlanout.(none)>
Fri, 23 Jul 2010 19:54:57 +0000 (22:54 +0300)
applet/src/livewp-common.h
applet/src/livewp-dbus.c
applet/src/livewp-main.c

index 1b61bae..afd161c 100644 (file)
@@ -109,6 +109,10 @@ struct _AWallpaperPluginClass
 #define LIVEWP_SIGNAL_RELOAD_CONFIG_PATH "/org/maemo/livewp/reload_config"
 #define LIVEWP_RELOAD_CONFIG "reload_config"
 #define LIVEWP_RELOAD_PLUGIN "reload_plugin"
+#define LIVEWP_STOP_LIVEBG_ON_VIEW0 "stop_livebg_on_view0"
+#define LIVEWP_STOP_LIVEBG_ON_VIEW1 "stop_livebg_on_view1"
+#define LIVEWP_STOP_LIVEBG_ON_VIEW2 "stop_livebg_on_view2"
+#define LIVEWP_STOP_LIVEBG_ON_VIEW3 "stop_livebg_on_view3"
 
 /* For DBUS notification */
 #define NOTIFY_SIGNAL_INTERFACE "org.freedesktop.Notifications"
index 6ba5c96..5b0c519 100644 (file)
@@ -141,7 +141,7 @@ get_livewp_signal_cb(DBusConnection *conn, DBusMessage *msg, Animation_Wallpaper
     START_FUNCTION;
 #endif
 
-    /*fprintf (stderr, "PATH11111111111111111111 %s %s %s\n",   dbus_message_get_path(msg),   dbus_message_get_interface (msg), dbus_message_get_member (msg));*/
+    fprintf (stderr, "PATH11111111111111111111 %s %s %s\n",   dbus_message_get_path(msg),   dbus_message_get_interface (msg), dbus_message_get_member (msg));
     if (dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_RELOAD_CONFIG)){
         if(read_config(priv)){
                 fprintf(stderr, "\nCan not read config file.\n");
@@ -152,6 +152,16 @@ get_livewp_signal_cb(DBusConnection *conn, DBusMessage *msg, Animation_Wallpaper
 #endif
         }
     }
+#if  defined APPLICATION
+    fprintf(stderr, "VIEW %i\n", priv->view);
+    if ((priv->view == 0 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_STOP_LIVEBG_ON_VIEW0))||
+        (priv->view == 1 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_STOP_LIVEBG_ON_VIEW1))||   
+        (priv->view == 2 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_STOP_LIVEBG_ON_VIEW2))||   
+        (priv->view == 3 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_STOP_LIVEBG_ON_VIEW3))){
+
+        quit_from_program(priv);
+    }
+#endif
     //fprintf(stderr, "Type %i\n", dbus_message_get_type (msg));
     if (dbus_message_is_method_call(msg, NOTIFY_SIGNAL_INTERFACE, NOTIFY_MEMBER)){
         //fprintf(stderr,"read notifications.db notify\n");    
index d0c631f..8b57753 100644 (file)
@@ -65,6 +65,25 @@ static void set_live_bg (Display *display, Window xwindow, int mode)
                        XA_INTEGER, 32, PropModeReplace,
                        (unsigned char *) &mode, 1);
 }
+void
+quit_from_program (Animation_WallpaperPrivate *priv)
+{
+     
+     if (priv){
+            livewp_deinitialize_dbus(priv);
+            fprintf(stderr,"Quit from LiveWallpaper \n");
+            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);
+     }
+     gtk_main_quit();
+}
 
 int
 main(int argc, char *argv[])
@@ -77,7 +96,7 @@ main(int argc, char *argv[])
     int view = 0;
 
      
-    if (argc == 2)                                                                                                                                                                                                                                                         
+    if (argc == 2) 
         view = atoi(argv[1]);
     fprintf(stderr,"VIEW %i\n", view);
     if (view < 0 || view > 3)
@@ -120,19 +139,16 @@ main(int argc, char *argv[])
     priv->window = main_widget;
 
     priv->view = view;
-    desktop_plugin->priv->visible = TRUE;
+    priv->visible = TRUE;
     /* 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);
+    set_live_bg(GDK_WINDOW_XDISPLAY (main_widget->window), GDK_WINDOW_XID (main_widget->window), view + 1);
     init_scene_theme(desktop_plugin);
         
     priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
 
-    
-
-
-        gtk_main();
+    gtk_main();
     return 0;
 }