one theme in all views almost done
authorvlad <vlad@vlanout.(none)>
Thu, 2 Sep 2010 18:23:13 +0000 (21:23 +0300)
committervlad <vlad@vlanout.(none)>
Thu, 2 Sep 2010 18:23:13 +0000 (21:23 +0300)
applet/src/livewp-config.c
applet/src/livewp-config.h
applet/src/livewp-home-widget.c
applet/src/livewp-home-widget.h
applet/src/livewp-settings.c

index 0e4500d..97ee239 100644 (file)
@@ -139,16 +139,30 @@ read_config(Animation_WallpaperPrivate *priv) {
         gconf_value_free(value);
     } 
     /* get parameter one theme in all view */
+    priv->one_in_all_view = get_one_in_all_views_from_config();
+    return 0;
+}
+/*******************************************************************************/
+gboolean
+get_one_in_all_views_from_config(void){
+    GConfClient *gconf_client;
+    GConfValue *value = NULL;
+    gboolean result;
+
+    gconf_client = gconf_client_get_default();
+    if (!gconf_client) {
+        fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
+        return FALSE;
+    }
+    /* get parameter one theme in all view */
     value = gconf_client_get(gconf_client, GCONF_KEY_ONE_IN_ALL_VIEW, NULL);
     if (value) {
-        priv->one_in_all_view = gconf_value_get_bool(value);
+        result = gconf_value_get_bool(value);
         gconf_value_free(value);
     } else
-       priv->one_in_all_view = FALSE;
-
-    return 0;
+        result = FALSE;
+    return result;
 }
-
 /*******************************************************************************/
 void
 save_one_in_all_views_to_config(gboolean one_in_all_views){
index 2f60514..0583780 100644 (file)
@@ -47,5 +47,6 @@ void fill_priv(Animation_WallpaperPrivate *priv);
 gint current_active_view(void);
 GSList * get_list_exthemes(void);
 void save_one_in_all_views_to_config(gboolean one_in_all_views);
+gboolean get_one_in_all_views_from_config(void);
 
 #endif
index e7de045..4181cbb 100644 (file)
@@ -67,11 +67,16 @@ lw_applet_realize (GtkWidget *widget)
            case 3: child_argv[1] = "4";
                break;
     }
-
-    desktop_plugin->priv->pid = fork();
-    if (desktop_plugin->priv->pid == 0){
-       execvp("/usr/bin/livewp", child_argv);
-       fprintf(stderr,"Problem with new process");
+    desktop_plugin->priv->one_in_all_view = get_one_in_all_views_from_config();
+    /* Check one theme in all view mode */
+    if (!desktop_plugin->priv->one_in_all_view || 
+        (desktop_plugin->priv->one_in_all_view && id == 0)){
+           /* Start a new process */
+           desktop_plugin->priv->pid = fork();
+           if (desktop_plugin->priv->pid == 0){
+               execvp("/usr/bin/livewp", child_argv);
+               fprintf(stderr,"Problem with new process");
+           }
     }
 
     desktop_plugin_visible_notify((GObject *)widget, NULL, desktop_plugin);
@@ -147,16 +152,18 @@ desktop_plugin_visible_notify (GObject    *object,
     g_object_get (object, "is-on-current-desktop", &visible, NULL);
     /* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
     if (priv){
-       /*    
-        if (visible){
-                       send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
-                                 LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW);
-        }else{ 
+             if (priv->one_in_all_view){
+                    if (visible)
                        send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
-                                 LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW);
-        }
-        */    
-        
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW1);
+                    else{
+                       /* start any application on current view */
+                       if ((priv->view + 1) == current_active_view())
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW1);
+                    }
+                    return;
+             }
             switch (priv->view + 1){
                case 1: if (visible)
                                send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
@@ -187,6 +194,7 @@ desktop_plugin_visible_notify (GObject    *object,
                                          LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW4);
                        break;
             }
+
      }
     
 }
index c6ac2f3..ecc172d 100644 (file)
@@ -74,5 +74,5 @@ gint current_active_view(void);
 //gboolean long_timeout (AWallpaperPlugin *desktop_plugin);
 void desktop_plugin_visible_notify (GObject *object, GParamSpec *spec, AWallpaperPlugin *desktop_plugin);
 void send_dbus_signal (Animation_WallpaperPrivate *priv, const gchar *interface, const gchar *path, const gchar *member);
-
+gboolean get_one_in_all_views_from_config(void);
 #endif
index 0471269..fa81c7b 100644 (file)
@@ -437,6 +437,7 @@ show_settings(GtkWidget *widget, Animation_WallpaperPrivate *priv){
     lw_main_settings(priv, NULL);
 }
 /*******************************************************************************/
+void
 create_themes_buttons_hbox(Animation_WallpaperPrivate *priv){
     GtkWidget *hbox = NULL;
     GtkWidget *area_hbox = NULL;
@@ -492,7 +493,7 @@ lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data){
     window = gtk_dialog_new();
     priv->window = window;
 
-    one_in_all_view_button = priv->one_in_all_view;
+    one_in_all_view = priv->one_in_all_view;
     gtk_window_set_title(GTK_WINDOW(window), _("Live Wallpaper Settings"));
     gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
     gtk_window_set_modal(GTK_WINDOW(window), TRUE);
@@ -545,11 +546,15 @@ lw_main_settings(Animation_WallpaperPrivate *priv, gpointer data){
     if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(one_in_all_view_button)) != one_in_all_view){
         save_one_in_all_views_to_config(hildon_check_button_get_active (HILDON_CHECK_BUTTON(one_in_all_view_button)));
         if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(one_in_all_view_button))){
+            stop_applet(1);
             stop_applet(2);
             stop_applet(3);
             stop_applet(4);
+            start_applet(1);
+            start_applet(2);
+            start_applet(3);
+            start_applet(4);
         }
-        send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, LIVEWP_SIGNAL_PATH, LIVEWP_RELOAD_CONFIG);
     }
     if (window)
         gtk_widget_destroy(window);