From 25e2bddb5898341f0eb32f8aa7df79ce02678b27 Mon Sep 17 00:00:00 2001 From: vlad Date: Thu, 2 Sep 2010 21:23:13 +0300 Subject: [PATCH] one theme in all views almost done --- applet/src/livewp-config.c | 24 +++++++++++++++++++----- applet/src/livewp-config.h | 1 + applet/src/livewp-home-widget.c | 36 ++++++++++++++++++++++-------------- applet/src/livewp-home-widget.h | 2 +- applet/src/livewp-settings.c | 9 +++++++-- 5 files changed, 50 insertions(+), 22 deletions(-) diff --git a/applet/src/livewp-config.c b/applet/src/livewp-config.c index 0e4500d..97ee239 100644 --- a/applet/src/livewp-config.c +++ b/applet/src/livewp-config.c @@ -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){ diff --git a/applet/src/livewp-config.h b/applet/src/livewp-config.h index 2f60514..0583780 100644 --- a/applet/src/livewp-config.h +++ b/applet/src/livewp-config.h @@ -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 diff --git a/applet/src/livewp-home-widget.c b/applet/src/livewp-home-widget.c index e7de045..4181cbb 100644 --- a/applet/src/livewp-home-widget.c +++ b/applet/src/livewp-home-widget.c @@ -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; } + } } diff --git a/applet/src/livewp-home-widget.h b/applet/src/livewp-home-widget.h index c6ac2f3..ecc172d 100644 --- a/applet/src/livewp-home-widget.h +++ b/applet/src/livewp-home-widget.h @@ -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 diff --git a/applet/src/livewp-settings.c b/applet/src/livewp-settings.c index 0471269..fa81c7b 100644 --- a/applet/src/livewp-settings.c +++ b/applet/src/livewp-settings.c @@ -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); -- 1.7.9.5