This is an automated email from the git hooks/post-receive script. b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r in repository apps/xfce4-screensaver.
commit c6d00bb95176e6746ea10658279e5f17eed085bb Author: Alexander Butenko <a.bute...@gmail.com> Date: Wed Jun 19 08:13:25 2019 -0400 Refactor settings handling Signed-off-by: Sean Davis <smd.seanda...@gmail.com> --- src/Makefile.am | 2 + src/gs-manager.c | 391 +++++----------------------------------------------- src/gs-manager.h | 26 ---- src/gs-monitor.c | 33 +---- src/gs-window-x11.c | 277 ++++--------------------------------- src/gs-window.h | 22 +-- src/test-window.c | 11 +- 7 files changed, 70 insertions(+), 692 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 37f2b25..7d0b836 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,6 +93,8 @@ test_window_SOURCES = \ gs-marshal.h \ gs-debug.c \ gs-debug.h \ + gs-prefs.c \ + gs-prefs.h \ subprocs.c \ subprocs.h \ $(NULL) diff --git a/src/gs-manager.c b/src/gs-manager.c index 766af53..21d7089 100644 --- a/src/gs-manager.c +++ b/src/gs-manager.c @@ -35,7 +35,7 @@ #include "gs-grab.h" #include "gs-job.h" #include "gs-manager.h" -#include "gs-prefs.h" /* for GSSaverMode */ +#include "gs-prefs.h" #include "gs-theme-manager.h" #include "gs-window.h" #include "xfce-bg.h" @@ -52,22 +52,10 @@ struct GSManagerPrivate { XfceBG *bg; /* Policy */ + GSPrefs *prefs; glong lock_timeout; glong cycle_timeout; - glong logout_timeout; - - guint saver_enabled : 1; - guint lock_enabled : 1; - guint lock_with_saver_enabled : 1; - guint logout_enabled : 1; - guint keyboard_enabled : 1; - guint user_switch_enabled : 1; - guint status_message_enabled : 1; guint throttled : 1; - - char *logout_command; - char *keyboard_command; - char *status_message; /* State */ @@ -82,8 +70,6 @@ struct GSManagerPrivate { guint lock_timeout_id; guint cycle_timeout_id; - GSList *themes; - GSSaverMode saver_mode; GSGrab *grab; guint deepsleep_idle_id; gboolean deepsleep; @@ -99,17 +85,6 @@ enum { enum { PROP_0, - PROP_LOCK_ENABLED, - PROP_LOCK_WITH_SAVER_ENABLED, - PROP_LOGOUT_ENABLED, - PROP_USER_SWITCH_ENABLED, - PROP_KEYBOARD_ENABLED, - PROP_LOCK_TIMEOUT, - PROP_CYCLE_TIMEOUT, - PROP_LOGOUT_TIMEOUT, - PROP_LOGOUT_COMMAND, - PROP_KEYBOARD_COMMAND, - PROP_STATUS_MESSAGE_ENABLED, PROP_STATUS_MESSAGE, PROP_ACTIVE, PROP_THROTTLED, @@ -154,19 +129,18 @@ select_theme (GSManager *manager) { g_return_val_if_fail (manager != NULL, NULL); g_return_val_if_fail (GS_IS_MANAGER (manager), NULL); - if (!manager->priv->saver_enabled || - manager->priv->saver_mode == GS_MODE_BLANK_ONLY) { + if (!manager->priv->prefs->saver_enabled || manager->priv->prefs->mode == GS_MODE_BLANK_ONLY) { return NULL; } - if (manager->priv->themes) { + if (manager->priv->prefs->themes) { int number = 0; - if (manager->priv->saver_mode == GS_MODE_RANDOM) { + if (manager->priv->prefs->mode == GS_MODE_RANDOM) { g_random_set_seed (time (NULL)); - number = g_random_int_range (0, g_slist_length (manager->priv->themes)); + number = g_random_int_range (0, g_slist_length (manager->priv->prefs->themes)); } - theme = g_slist_nth_data (manager->priv->themes, number); + theme = g_slist_nth_data (manager->priv->prefs->themes, number); } return theme; @@ -339,37 +313,6 @@ manager_stop_jobs (GSManager *manager) { } void -gs_manager_set_mode (GSManager *manager, - GSSaverMode mode) { - g_return_if_fail (GS_IS_MANAGER (manager)); - - manager->priv->saver_mode = mode; -} - -static void -free_themes (GSManager *manager) { - if (manager->priv->themes) { - g_slist_foreach (manager->priv->themes, (GFunc)g_free, NULL); - g_slist_free (manager->priv->themes); - } -} - -void -gs_manager_set_themes (GSManager *manager, - GSList *themes) { - GSList *l; - - g_return_if_fail (GS_IS_MANAGER (manager)); - - free_themes (manager); - manager->priv->themes = NULL; - - for (l = themes; l; l = l->next) { - manager->priv->themes = g_slist_append (manager->priv->themes, g_strdup (l->data)); - } -} - -void gs_manager_set_throttled (GSManager *manager, gboolean throttled) { g_return_if_fail (GS_IS_MANAGER (manager)); @@ -453,85 +396,10 @@ gs_manager_set_saver_active (GSManager *manager, } } -void -gs_manager_set_saver_enabled (GSManager *manager, - gboolean saver_enabled) { - g_return_if_fail (GS_IS_MANAGER (manager)); - - if (manager->priv->saver_enabled != saver_enabled) { - manager->priv->saver_enabled = saver_enabled; - } -} - -void -gs_manager_set_lock_enabled (GSManager *manager, - gboolean lock_enabled) { - g_return_if_fail (GS_IS_MANAGER (manager)); - - if (manager->priv->lock_enabled != lock_enabled) { - manager->priv->lock_enabled = lock_enabled; - } -} - -void -gs_manager_set_lock_with_saver_enabled (GSManager *manager, - gboolean lock_with_saver_enabled) { - g_return_if_fail (GS_IS_MANAGER (manager)); - - if (manager->priv->lock_with_saver_enabled != lock_with_saver_enabled) { - manager->priv->lock_with_saver_enabled = lock_with_saver_enabled; - } -} - -void -gs_manager_set_logout_enabled (GSManager *manager, - gboolean logout_enabled) { - g_return_if_fail (GS_IS_MANAGER (manager)); - - if (manager->priv->logout_enabled != logout_enabled) { - GSList *l; - - manager->priv->logout_enabled = logout_enabled; - for (l = manager->priv->windows; l; l = l->next) { - gs_window_set_logout_enabled (l->data, logout_enabled); - } - } -} - -void -gs_manager_set_keyboard_enabled (GSManager *manager, - gboolean enabled) { - g_return_if_fail (GS_IS_MANAGER (manager)); - - if (manager->priv->keyboard_enabled != enabled) { - GSList *l; - - manager->priv->keyboard_enabled = enabled; - for (l = manager->priv->windows; l; l = l->next) { - gs_window_set_keyboard_enabled (l->data, enabled); - } - } -} - -void -gs_manager_set_user_switch_enabled (GSManager *manager, - gboolean user_switch_enabled) { - g_return_if_fail (GS_IS_MANAGER (manager)); - - if (manager->priv->user_switch_enabled != user_switch_enabled) { - GSList *l; - - manager->priv->user_switch_enabled = user_switch_enabled; - for (l = manager->priv->windows; l; l = l->next) { - gs_window_set_user_switch_enabled (l->data, user_switch_enabled); - } - } -} - static gboolean activate_lock_timeout (GSManager *manager) { - if (manager->priv->lock_enabled && - manager->priv->lock_with_saver_enabled) + if (manager->priv->prefs->lock_enabled && + manager->priv->prefs->lock_with_saver_enabled) { gs_debug ("Locking screen after idling timeout"); gs_manager_set_lock_active (manager, TRUE); @@ -553,9 +421,9 @@ remove_lock_timer (GSManager *manager) { static void add_lock_timer (GSManager *manager, glong timeout) { - if (!manager->priv->lock_enabled) + if (!manager->priv->prefs->lock_enabled) return; - if (!manager->priv->lock_with_saver_enabled) + if (!manager->priv->prefs->lock_with_saver_enabled) return; gboolean locked; @@ -594,75 +462,6 @@ gs_manager_set_lock_timeout (GSManager *manager, } void -gs_manager_set_logout_timeout (GSManager *manager, - glong logout_timeout) { - g_return_if_fail (GS_IS_MANAGER (manager)); - - if (manager->priv->logout_timeout != logout_timeout) { - GSList *l; - - manager->priv->logout_timeout = logout_timeout; - for (l = manager->priv->windows; l; l = l->next) { - gs_window_set_logout_timeout (l->data, logout_timeout); - } - } -} - -void -gs_manager_set_logout_command (GSManager *manager, - const char *command) { - GSList *l; - - g_return_if_fail (GS_IS_MANAGER (manager)); - - g_free (manager->priv->logout_command); - - if (command) { - manager->priv->logout_command = g_strdup (command); - } else { - manager->priv->logout_command = NULL; - } - - for (l = manager->priv->windows; l; l = l->next) { - gs_window_set_logout_command (l->data, manager->priv->logout_command); - } -} - -void -gs_manager_set_keyboard_command (GSManager *manager, - const char *command) { - GSList *l; - - g_return_if_fail (GS_IS_MANAGER (manager)); - - g_free (manager->priv->keyboard_command); - - if (command) { - manager->priv->keyboard_command = g_strdup (command); - } else { - manager->priv->keyboard_command = NULL; - } - - for (l = manager->priv->windows; l; l = l->next) { - gs_window_set_keyboard_command (l->data, manager->priv->keyboard_command); - } -} - -void -gs_manager_set_status_message_enabled (GSManager *manager, - gboolean status_message_enabled) { - GSList *l; - - g_return_if_fail (GS_IS_MANAGER (manager)); - - manager->priv->status_message_enabled = status_message_enabled; - - for (l = manager->priv->windows; l; l = l->next) { - gs_window_set_status_message_enabled (l->data, manager->priv->status_message_enabled); - } -} - -void gs_manager_set_status_message (GSManager *manager, const char *message) { GSList *l; @@ -755,6 +554,11 @@ gs_manager_set_cycle_timeout (GSManager *manager, } } +static void _gs_manager_update_from_prefs(GSManager* manager, GSPrefs* prefs) { + gs_manager_set_lock_timeout(manager, prefs->lock_timeout); + gs_manager_set_cycle_timeout(manager, prefs->cycle); +} + static void gs_manager_set_property (GObject *object, guint prop_id, @@ -768,41 +572,11 @@ gs_manager_set_property (GObject *object, case PROP_THROTTLED: gs_manager_set_throttled (self, g_value_get_boolean (value)); break; - case PROP_LOCK_ENABLED: - gs_manager_set_lock_enabled (self, g_value_get_boolean (value)); - break; - case PROP_LOCK_WITH_SAVER_ENABLED: - gs_manager_set_lock_with_saver_enabled (self, g_value_get_boolean (value)); - break; - case PROP_LOCK_TIMEOUT: - gs_manager_set_lock_timeout (self, g_value_get_long (value)); - break; - case PROP_LOGOUT_ENABLED: - gs_manager_set_logout_enabled (self, g_value_get_boolean (value)); - break; - case PROP_KEYBOARD_ENABLED: - gs_manager_set_keyboard_enabled (self, g_value_get_boolean (value)); - break; - case PROP_USER_SWITCH_ENABLED: - gs_manager_set_user_switch_enabled (self, g_value_get_boolean (value)); - break; - case PROP_LOGOUT_TIMEOUT: - gs_manager_set_logout_timeout (self, g_value_get_long (value)); - break; - case PROP_LOGOUT_COMMAND: - gs_manager_set_logout_command (self, g_value_get_string (value)); - break; - case PROP_KEYBOARD_COMMAND: - gs_manager_set_keyboard_command (self, g_value_get_string (value)); - break; - case PROP_STATUS_MESSAGE_ENABLED: - gs_manager_set_status_message_enabled (self, g_value_get_boolean (value)); - break; case PROP_STATUS_MESSAGE: gs_manager_set_status_message (self, g_value_get_string (value)); break; - case PROP_CYCLE_TIMEOUT: - gs_manager_set_cycle_timeout (self, g_value_get_long (value)); + case PROP_ACTIVE: + gs_manager_set_active (self, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -823,42 +597,9 @@ gs_manager_get_property (GObject *object, case PROP_THROTTLED: g_value_set_boolean (value, self->priv->throttled); break; - case PROP_LOCK_ENABLED: - g_value_set_boolean (value, self->priv->lock_enabled); - break; - case PROP_LOCK_WITH_SAVER_ENABLED: - g_value_set_boolean (value, self->priv->lock_with_saver_enabled); - break; - case PROP_LOCK_TIMEOUT: - g_value_set_long (value, self->priv->lock_timeout); - break; - case PROP_LOGOUT_ENABLED: - g_value_set_boolean (value, self->priv->logout_enabled); - break; - case PROP_KEYBOARD_ENABLED: - g_value_set_boolean (value, self->priv->keyboard_enabled); - break; - case PROP_USER_SWITCH_ENABLED: - g_value_set_boolean (value, self->priv->user_switch_enabled); - break; - case PROP_LOGOUT_TIMEOUT: - g_value_set_long (value, self->priv->logout_timeout); - break; - case PROP_LOGOUT_COMMAND: - g_value_set_string (value, self->priv->logout_command); - break; - case PROP_KEYBOARD_COMMAND: - g_value_set_string (value, self->priv->keyboard_command); - break; - case PROP_STATUS_MESSAGE_ENABLED: - g_value_set_boolean (value, self->priv->status_message_enabled); - break; case PROP_STATUS_MESSAGE: g_value_set_string (value, self->priv->status_message); break; - case PROP_CYCLE_TIMEOUT: - g_value_set_long (value, self->priv->cycle_timeout); - break; case PROP_ACTIVE: g_value_set_boolean (value, self->priv->active); break; @@ -925,75 +666,19 @@ gs_manager_class_init (GSManagerClass *klass) { FALSE, G_PARAM_READABLE)); g_object_class_install_property (object_class, - PROP_LOCK_ENABLED, - g_param_spec_boolean ("lock-enabled", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LOCK_WITH_SAVER_ENABLED, - g_param_spec_boolean ("lock-with-saver-enabled", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LOCK_TIMEOUT, - g_param_spec_long ("lock-timeout", - NULL, - NULL, - -1, - G_MAXLONG, - 0, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LOGOUT_ENABLED, - g_param_spec_boolean ("logout-enabled", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_USER_SWITCH_ENABLED, - g_param_spec_boolean ("user-switch-enabled", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_LOGOUT_TIMEOUT, - g_param_spec_long ("logout-timeout", - NULL, - NULL, - -1, - G_MAXLONG, - 0, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LOGOUT_COMMAND, - g_param_spec_string ("logout-command", - NULL, - NULL, - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_CYCLE_TIMEOUT, - g_param_spec_long ("cycle-timeout", - NULL, - NULL, - 10000, - G_MAXLONG, - 300000, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, PROP_THROTTLED, g_param_spec_boolean ("throttled", NULL, NULL, TRUE, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_STATUS_MESSAGE, + g_param_spec_string ("status-message", + NULL, + NULL, + NULL, + G_PARAM_READWRITE)); } static void @@ -1005,6 +690,10 @@ gs_manager_init (GSManager *manager) { manager->priv->bg = xfce_bg_new (); + manager->priv->prefs = gs_prefs_new(); + g_signal_connect_swapped(manager->priv->prefs, "changed", G_CALLBACK(_gs_manager_update_from_prefs), manager); + _gs_manager_update_from_prefs (manager, manager->priv->prefs); + xfce_bg_load_from_preferences (manager->priv->bg, NULL); add_deepsleep_idle(manager); @@ -1403,6 +1092,7 @@ connect_window_signals (GSManager *manager, G_CALLBACK (window_grab_broken_cb), manager, G_CONNECT_AFTER); } + static void gs_manager_create_window_for_monitor (GSManager *manager, GdkMonitor *monitor) { @@ -1419,20 +1109,9 @@ gs_manager_create_window_for_monitor (GSManager *manager, gs_debug ("Creating a Window [%d,%d] (%dx%d) for monitor %d", rect.x, rect.y, rect.width, rect.height, manager_get_monitor_index (monitor)); - window = gs_window_new (monitor, - manager->priv->lock_enabled, - manager->priv->lock_with_saver_enabled); - - gs_window_set_user_switch_enabled (window, manager->priv->user_switch_enabled); - gs_window_set_logout_enabled (window, manager->priv->logout_enabled); - gs_window_set_logout_timeout (window, manager->priv->logout_timeout); - gs_window_set_logout_command (window, manager->priv->logout_command); - gs_window_set_keyboard_enabled (window, manager->priv->keyboard_enabled); - gs_window_set_keyboard_command (window, manager->priv->keyboard_command); - gs_window_set_status_message_enabled (window, manager->priv->status_message_enabled); + window = gs_window_new (monitor); gs_window_set_status_message (window, manager->priv->status_message); gs_window_set_lock_active (window, manager->priv->lock_active); - connect_window_signals (manager, window); manager->priv->windows = g_slist_insert (manager->priv->windows, window, manager_get_monitor_index(monitor)); @@ -1520,11 +1199,7 @@ gs_manager_finalize (GObject *object) { if (manager->priv->bg != NULL) { g_object_unref (manager->priv->bg); } - - free_themes (manager); - g_free (manager->priv->logout_command); - g_free (manager->priv->keyboard_command); - g_free (manager->priv->status_message); + g_signal_handlers_disconnect_by_func(manager->priv->prefs, _gs_manager_update_from_prefs, manager); remove_deepsleep_idle (manager); remove_timers(manager); @@ -1537,8 +1212,6 @@ gs_manager_finalize (GObject *object) { manager->priv->active = FALSE; manager->priv->activate_time = 0; - manager->priv->lock_enabled = FALSE; - manager->priv->lock_with_saver_enabled = FALSE; g_object_unref (manager->priv->grab); g_object_unref (manager->priv->theme_manager); diff --git a/src/gs-manager.h b/src/gs-manager.h index 0dae341..62cc112 100644 --- a/src/gs-manager.h +++ b/src/gs-manager.h @@ -70,40 +70,14 @@ void gs_manager_get_saver_active (GSManager *manager, gboolean *saver_active); void gs_manager_set_saver_active (GSManager *manager, gboolean saver_active); -void gs_manager_set_keyboard_enabled (GSManager *manager, - gboolean enabled); -void gs_manager_set_keyboard_command (GSManager *manager, - const char *command); -void gs_manager_set_status_message_enabled(GSManager *manager, - gboolean status_message_enabled); void gs_manager_set_status_message (GSManager *manager, const char *message); -void gs_manager_set_saver_enabled (GSManager *manager, - gboolean saver_enabled); -void gs_manager_set_lock_enabled (GSManager *manager, - gboolean lock_enabled); -void gs_manager_get_lock_with_saver_enabled (GSManager *manager, - gboolean *lock_with_saver_enabled); -void gs_manager_set_lock_with_saver_enabled (GSManager *manager, - gboolean lock_with_saver_enabled); void gs_manager_set_lock_timeout (GSManager *manager, glong lock_timeout); -void gs_manager_set_logout_enabled (GSManager *manager, - gboolean logout_enabled); -void gs_manager_set_user_switch_enabled (GSManager *manager, - gboolean user_switch_enabled); -void gs_manager_set_logout_timeout (GSManager *manager, - glong logout_timeout); -void gs_manager_set_logout_command (GSManager *manager, - const char *command); void gs_manager_set_throttled (GSManager *manager, gboolean throttled); void gs_manager_set_cycle_timeout (GSManager *manager, glong cycle_timeout); -void gs_manager_set_themes (GSManager *manager, - GSList *themes); -void gs_manager_set_mode (GSManager *manager, - GSSaverMode mode); void gs_manager_show_message (GSManager *manager, const char *summary, const char *body, diff --git a/src/gs-monitor.c b/src/gs-monitor.c index 54414b5..835b538 100644 --- a/src/gs-monitor.c +++ b/src/gs-monitor.c @@ -194,35 +194,12 @@ static void listener_simulate_user_activity_cb(GSListener* listener, GSMonitor* } static void _gs_monitor_update_from_prefs(GSMonitor* monitor, GSPrefs* prefs) { - gboolean lock_enabled; - gboolean lock_with_saver_enabled; - gboolean user_switch_enabled; - - lock_enabled = monitor->priv->prefs->lock_enabled; - lock_with_saver_enabled = monitor->priv->prefs->lock_with_saver_enabled; - user_switch_enabled = monitor->priv->prefs->user_switch_enabled; - - gs_manager_set_lock_enabled(monitor->priv->manager, lock_enabled); - gs_manager_set_lock_with_saver_enabled(monitor->priv->manager, lock_with_saver_enabled); - gs_manager_set_lock_timeout(monitor->priv->manager, monitor->priv->prefs->lock_timeout); - gs_manager_set_logout_enabled(monitor->priv->manager, monitor->priv->prefs->logout_enabled); - gs_manager_set_user_switch_enabled(monitor->priv->manager, user_switch_enabled); - gs_manager_set_status_message_enabled(monitor->priv->manager, monitor->priv->prefs->status_message_enabled); - gs_manager_set_keyboard_enabled(monitor->priv->manager, monitor->priv->prefs->keyboard_enabled); - gs_manager_set_logout_timeout(monitor->priv->manager, monitor->priv->prefs->logout_timeout); - gs_manager_set_logout_command(monitor->priv->manager, monitor->priv->prefs->logout_command); - gs_manager_set_keyboard_command(monitor->priv->manager, monitor->priv->prefs->keyboard_command); - gs_manager_set_cycle_timeout(monitor->priv->manager, monitor->priv->prefs->cycle); - gs_manager_set_mode(monitor->priv->manager, monitor->priv->prefs->mode); - gs_manager_set_saver_enabled(monitor->priv->manager, monitor->priv->prefs->saver_enabled); - gs_manager_set_themes(monitor->priv->manager, monitor->priv->prefs->themes); - /* enable activation when allowed */ - gs_listener_set_activation_enabled(monitor->priv->listener, monitor->priv->prefs->idle_activation_enabled); - gs_listener_set_sleep_activation_enabled(monitor->priv->listener, monitor->priv->prefs->sleep_activation_enabled); - gs_listener_x11_set_activation_enabled(monitor->priv->listener_x11, monitor->priv->prefs->idle_activation_enabled); - gs_listener_x11_set_timeout(monitor->priv->listener_x11, monitor->priv->prefs->timeout); - gs_listener_x11_set_saver_enabled(monitor->priv->listener_x11, monitor->priv->prefs->saver_enabled); + gs_listener_set_activation_enabled(monitor->priv->listener, prefs->idle_activation_enabled); + gs_listener_set_sleep_activation_enabled(monitor->priv->listener, prefs->sleep_activation_enabled); + gs_listener_x11_set_activation_enabled(monitor->priv->listener_x11, prefs->idle_activation_enabled); + gs_listener_x11_set_timeout(monitor->priv->listener_x11, prefs->timeout); + gs_listener_x11_set_saver_enabled(monitor->priv->listener_x11, prefs->saver_enabled); } static void disconnect_listener_signals(GSMonitor* monitor) { diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c index 3de6811..60ce0af 100644 --- a/src/gs-window-x11.c +++ b/src/gs-window-x11.c @@ -39,6 +39,7 @@ #include "gs-debug.h" #include "gs-marshal.h" +#include "gs-prefs.h" #include "gs-window.h" #include "subprocs.h" @@ -48,6 +49,8 @@ static void gs_window_finalize (GObject *object); static gboolean popup_dialog_idle (GSWindow *window); static void gs_window_dialog_finish (GSWindow *window); +static void gs_window_set_obscured (GSWindow *window, + gboolean obscured); static void remove_command_watches (GSWindow *window); enum { @@ -65,19 +68,10 @@ struct GSWindowPrivate { guint obscured : 1; guint dialog_up : 1; - guint lock_enabled : 1; - guint lock_with_saver_enabled : 1; - guint user_switch_enabled : 1; - guint logout_enabled : 1; - guint keyboard_enabled : 1; - guint status_message_enabled : 1; - - guint64 logout_timeout; gboolean lock_active; gboolean saver_active; - char *logout_command; - char *keyboard_command; char *status_message; + GSPrefs *prefs; GtkWidget *vbox; GtkWidget *drawing_area; @@ -129,15 +123,7 @@ enum { PROP_0, PROP_OBSCURED, PROP_DIALOG_UP, - PROP_LOCK_ENABLED, - PROP_LOCK_WITH_SAVER_ENABLED, - PROP_LOGOUT_ENABLED, - PROP_KEYBOARD_ENABLED, - PROP_KEYBOARD_COMMAND, - PROP_LOGOUT_COMMAND, - PROP_LOGOUT_TIMEOUT, PROP_MONITOR, - PROP_STATUS_MESSAGE }; static guint signals[LAST_SIGNAL] = { 0, }; @@ -1245,24 +1231,24 @@ static void embed_keyboard (GSWindow *window) { gboolean res; - if (!window->priv->keyboard_enabled - || window->priv->keyboard_command == NULL) + if (!window->priv->prefs->keyboard_enabled + || window->priv->prefs->keyboard_command == NULL) return; gs_debug ("Adding embedded keyboard widget"); /* FIXME: verify command is safe */ - gs_debug ("Running command: %s", window->priv->keyboard_command); + gs_debug ("Running command: %s", window->priv->prefs->keyboard_command); res = spawn_on_window (window, - window->priv->keyboard_command, + window->priv->prefs->keyboard_command, &window->priv->keyboard_pid, (GIOFunc)keyboard_command_watch, window, &window->priv->keyboard_watch_id); if (!res) { - gs_debug ("Could not start command: %s", window->priv->keyboard_command); + gs_debug ("Could not start command: %s", window->priv->prefs->keyboard_command); } } @@ -1291,7 +1277,7 @@ create_lock_socket (GSWindow *window, gtk_socket_add_id (GTK_SOCKET (window->priv->lock_socket), id); - if (window->priv->keyboard_enabled) { + if (window->priv->prefs->keyboard_enabled) { embed_keyboard (window); } } @@ -1482,17 +1468,17 @@ static gboolean is_logout_enabled (GSWindow *window) { double elapsed; - if (!window->priv->logout_enabled) { + if (!window->priv->prefs->logout_enabled) { return FALSE; } - if (!window->priv->logout_command) { + if (!window->priv->prefs->logout_command) { return FALSE; } elapsed = g_timer_elapsed (window->priv->timer, NULL); - if (window->priv->logout_timeout < (elapsed * 1000)) { + if (window->priv->prefs->logout_timeout < (elapsed * 1000)) { return TRUE; } @@ -1501,12 +1487,12 @@ is_logout_enabled (GSWindow *window) { static gboolean is_user_switch_enabled (GSWindow *window) { - return window->priv->user_switch_enabled; + return window->priv->prefs->user_switch_enabled; } static gboolean is_status_message_enabled (GSWindow *window) { - return window->priv->status_message_enabled; + return window->priv->prefs->status_message_enabled; } static gint @@ -1543,7 +1529,7 @@ popup_dialog (GSWindow *window) { if (is_logout_enabled(window)) { command = g_string_append (command, " --enable-logout"); - g_string_append_printf (command, " --logout-command='%s'", window->priv->logout_command); + g_string_append_printf (command, " --logout-command='%s'", window->priv->prefs->logout_command); } if (is_status_message_enabled(window) && window->priv->status_message) { @@ -1648,32 +1634,6 @@ gs_window_cancel_unlock_request (GSWindow *window) { popdown_dialog (window); } -void -gs_window_set_lock_enabled (GSWindow *window, - gboolean lock_enabled) { - g_return_if_fail (GS_IS_WINDOW (window)); - - if (window->priv->lock_enabled == lock_enabled) { - return; - } - - window->priv->lock_enabled = lock_enabled; - g_object_notify (G_OBJECT (window), "lock-enabled"); -} - -void -gs_window_set_lock_with_saver_enabled (GSWindow *window, - gboolean lock_with_saver_enabled) { - g_return_if_fail (GS_IS_WINDOW (window)); - - if (window->priv->lock_with_saver_enabled == lock_with_saver_enabled) { - return; - } - - window->priv->lock_with_saver_enabled = lock_with_saver_enabled; - g_object_notify (G_OBJECT (window), "lock-with-saver-enabled"); -} - GdkDisplay * gs_window_get_display (GSWindow *window) { g_return_val_if_fail (GS_IS_WINDOW (window), NULL); @@ -1682,78 +1642,6 @@ gs_window_get_display (GSWindow *window) { } void -gs_window_set_keyboard_enabled (GSWindow *window, - gboolean enabled) { - g_return_if_fail (GS_IS_WINDOW (window)); - - window->priv->keyboard_enabled = enabled; -} - -void -gs_window_set_keyboard_command (GSWindow *window, - const char *command) { - g_return_if_fail (GS_IS_WINDOW (window)); - - g_free (window->priv->keyboard_command); - - if (command != NULL) { - window->priv->keyboard_command = g_strdup (command); - } else { - window->priv->keyboard_command = NULL; - } -} - -void -gs_window_set_logout_enabled (GSWindow *window, - gboolean logout_enabled) { - g_return_if_fail (GS_IS_WINDOW (window)); - - window->priv->logout_enabled = logout_enabled; -} - -void -gs_window_set_user_switch_enabled (GSWindow *window, - gboolean user_switch_enabled) { - g_return_if_fail (GS_IS_WINDOW (window)); - - window->priv->user_switch_enabled = user_switch_enabled; -} - -void -gs_window_set_status_message_enabled (GSWindow *window, - gboolean status_message_enabled) { - g_return_if_fail (GS_IS_WINDOW (window)); - - window->priv->status_message_enabled = status_message_enabled; -} - -void -gs_window_set_logout_timeout (GSWindow *window, - glong timeout) { - g_return_if_fail (GS_IS_WINDOW (window)); - - if (timeout < 0) { - window->priv->logout_timeout = 0; - } else { - window->priv->logout_timeout = timeout; - } -} - -void -gs_window_set_logout_command (GSWindow *window, - const char *command) { - g_return_if_fail (GS_IS_WINDOW (window)); - - g_free (window->priv->logout_command); - - if (command) { - window->priv->logout_command = g_strdup (command); - } else { - window->priv->logout_command = NULL; - } -} - -void gs_window_set_status_message (GSWindow *window, const char *status_message) { g_return_if_fail (GS_IS_WINDOW (window)); @@ -1798,33 +1686,15 @@ gs_window_set_property (GObject *object, self = GS_WINDOW (object); switch (prop_id) { - case PROP_LOCK_ENABLED: - gs_window_set_lock_enabled (self, g_value_get_boolean (value)); - break; - case PROP_LOCK_WITH_SAVER_ENABLED: - gs_window_set_lock_with_saver_enabled (self, g_value_get_boolean (value)); - break; - case PROP_KEYBOARD_ENABLED: - gs_window_set_keyboard_enabled (self, g_value_get_boolean (value)); - break; - case PROP_KEYBOARD_COMMAND: - gs_window_set_keyboard_command (self, g_value_get_string (value)); - break; - case PROP_LOGOUT_ENABLED: - gs_window_set_logout_enabled (self, g_value_get_boolean (value)); - break; - case PROP_LOGOUT_COMMAND: - gs_window_set_logout_command (self, g_value_get_string (value)); - break; - case PROP_STATUS_MESSAGE: - gs_window_set_status_message (self, g_value_get_string (value)); - break; - case PROP_LOGOUT_TIMEOUT: - gs_window_set_logout_timeout (self, g_value_get_long (value)); - break; case PROP_MONITOR: gs_window_set_monitor (self, g_value_get_pointer (value)); break; + case PROP_OBSCURED: + gs_window_set_obscured (self, g_value_get_boolean (value)); + break; + case PROP_DIALOG_UP: + window_set_dialog_up (self, g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1841,30 +1711,6 @@ gs_window_get_property (GObject *object, self = GS_WINDOW (object); switch (prop_id) { - case PROP_LOCK_ENABLED: - g_value_set_boolean (value, self->priv->lock_enabled); - break; - case PROP_LOCK_WITH_SAVER_ENABLED: - g_value_set_boolean (value, self->priv->lock_with_saver_enabled); - break; - case PROP_KEYBOARD_ENABLED: - g_value_set_boolean (value, self->priv->keyboard_enabled); - break; - case PROP_KEYBOARD_COMMAND: - g_value_set_string (value, self->priv->keyboard_command); - break; - case PROP_LOGOUT_ENABLED: - g_value_set_boolean (value, self->priv->logout_enabled); - break; - case PROP_LOGOUT_COMMAND: - g_value_set_string (value, self->priv->logout_command); - break; - case PROP_STATUS_MESSAGE: - g_value_set_string (value, self->priv->status_message); - break; - case PROP_LOGOUT_TIMEOUT: - g_value_set_long (value, self->priv->logout_timeout); - break; case PROP_MONITOR: g_value_set_pointer (value, (gpointer) self->priv->monitor); break; @@ -2097,8 +1943,8 @@ gs_window_is_dialog_up (GSWindow *window) { } static void -window_set_obscured (GSWindow *window, - gboolean obscured) { +gs_window_set_obscured (GSWindow *window, + gboolean obscured) { if (window->priv->obscured == obscured) { return; } @@ -2112,12 +1958,12 @@ gs_window_real_visibility_notify_event (GtkWidget *widget, GdkEventVisibility *event) { switch (event->state) { case GDK_VISIBILITY_FULLY_OBSCURED: - window_set_obscured (GS_WINDOW (widget), TRUE); + gs_window_set_obscured (GS_WINDOW (widget), TRUE); break; case GDK_VISIBILITY_PARTIAL: break; case GDK_VISIBILITY_UNOBSCURED: - window_set_obscured (GS_WINDOW (widget), FALSE); + gs_window_set_obscured (GS_WINDOW (widget), FALSE); break; default: break; @@ -2185,65 +2031,6 @@ gs_window_class_init (GSWindowClass *klass) { FALSE, G_PARAM_READABLE)); g_object_class_install_property (object_class, - PROP_LOCK_ENABLED, - g_param_spec_boolean ("lock-enabled", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LOCK_WITH_SAVER_ENABLED, - g_param_spec_boolean ("lock-with-saver-enabled", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LOGOUT_ENABLED, - g_param_spec_boolean ("logout-enabled", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LOGOUT_TIMEOUT, - g_param_spec_long ("logout-timeout", - NULL, - NULL, - -1, - G_MAXLONG, - 0, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LOGOUT_COMMAND, - g_param_spec_string ("logout-command", - NULL, - NULL, - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_STATUS_MESSAGE, - g_param_spec_string ("status-message", - NULL, - NULL, - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_KEYBOARD_ENABLED, - g_param_spec_boolean ("keyboard-enabled", - NULL, - NULL, - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_KEYBOARD_COMMAND, - g_param_spec_string ("keyboard-command", - NULL, - NULL, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_MONITOR, g_param_spec_pointer ("monitor", "Gdk monitor", @@ -2280,6 +2067,8 @@ gs_window_init (GSWindow *window) { window->priv->last_x = -1; window->priv->last_y = -1; + window->priv->prefs = gs_prefs_new(); + gtk_window_set_decorated (GTK_WINDOW (window), FALSE); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE); @@ -2340,9 +2129,6 @@ gs_window_finalize (GObject *object) { g_return_if_fail (window->priv != NULL); - g_free (window->priv->logout_command); - g_free (window->priv->keyboard_command); - if (window->priv->info_bar_timer_id > 0) { g_source_remove (window->priv->info_bar_timer_id); window->priv->info_bar_timer_id = 0; @@ -2364,14 +2150,11 @@ gs_window_finalize (GObject *object) { if (window->priv->background_surface) { cairo_surface_destroy (window->priv->background_surface); } - G_OBJECT_CLASS (gs_window_parent_class)->finalize (object); } GSWindow * -gs_window_new (GdkMonitor *monitor, - gboolean lock_enabled, - gboolean lock_with_saver_enabled) { +gs_window_new (GdkMonitor *monitor) { GObject *result; GdkDisplay *display = gdk_monitor_get_display (monitor); GdkScreen *screen = gdk_display_get_default_screen (display); @@ -2380,8 +2163,6 @@ gs_window_new (GdkMonitor *monitor, "type", GTK_WINDOW_POPUP, "screen", screen, "monitor", monitor, - "lock-enabled", lock_enabled, - "lock-with-saver-enabled", lock_with_saver_enabled, "app-paintable", TRUE, NULL); diff --git a/src/gs-window.h b/src/gs-window.h index e6b8e47..fb809b4 100644 --- a/src/gs-window.h +++ b/src/gs-window.h @@ -65,28 +65,10 @@ void gs_window_set_monitor (GSWindow *window, GdkMonitor *monitor); GdkMonitor *gs_window_get_monitor (GSWindow *window); -void gs_window_set_lock_enabled (GSWindow *window, - gboolean lock_enabled); -void gs_window_set_lock_with_saver_enabled (GSWindow *window, - gboolean lock_with_saver_enabled); -void gs_window_set_logout_enabled (GSWindow *window, - gboolean logout_enabled); -void gs_window_set_keyboard_enabled (GSWindow *window, - gboolean enabled); -void gs_window_set_keyboard_command (GSWindow *window, - const char *command); -void gs_window_set_user_switch_enabled (GSWindow *window, - gboolean user_switch_enabled); -void gs_window_set_status_message_enabled (GSWindow *window, - gboolean status_message_enabled); -void gs_window_set_logout_timeout (GSWindow *window, - glong timeout); void gs_window_set_lock_active (GSWindow *window, gboolean active); void gs_window_set_saver_active (GSWindow *window, gboolean active); -void gs_window_set_logout_command (GSWindow *window, - const char *command); void gs_window_set_status_message (GSWindow *window, const char *status_message); void gs_window_show_message (GSWindow *window, @@ -97,9 +79,7 @@ void gs_window_show_message (GSWindow *window, void gs_window_request_unlock (GSWindow *window); void gs_window_cancel_unlock_request (GSWindow *window); -GSWindow * gs_window_new (GdkMonitor *monitor, - gboolean lock_enabled, - gboolean lock_with_saver_enabled); +GSWindow * gs_window_new (GdkMonitor *monitor); void gs_window_show (GSWindow *window); void gs_window_destroy (GSWindow *window); GdkWindow * gs_window_get_gdk_window (GSWindow *window); diff --git a/src/test-window.c b/src/test-window.c index 4f54c27..2369b6f 100644 --- a/src/test-window.c +++ b/src/test-window.c @@ -112,22 +112,13 @@ connect_window_signals (GSWindow *window) { static void test_window (void) { GSWindow *window; - gboolean lock_active; - gboolean lock_with_saver_active; - gboolean user_switch_enabled; GdkDisplay *display; GdkMonitor *monitor; - lock_active = TRUE; - lock_with_saver_active = TRUE; - user_switch_enabled = TRUE; display = gdk_display_get_default (); monitor = gdk_display_get_primary_monitor (display); - window = gs_window_new (monitor, lock_active, lock_with_saver_active); - - gs_window_set_user_switch_enabled (window, user_switch_enabled); - + window = gs_window_new (monitor); connect_window_signals (window); gs_window_show (window); -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits