[eog/wip/gaction-migration] EogWindow: remove the string matching from ui_settings_changed_cb



commit 8ea5e61c147ec80aa1065bd6ac0be57de0ac0e60
Author: Jente Hidskes <hjdskes gmail com>
Date:   Thu Dec 18 19:01:07 2014 +0100

    EogWindow: remove the string matching from ui_settings_changed_cb
    
    The changed setting is now passed as a detailed signal instead
    of having to do string matching inside eog_window_ui_settings_changed_cb.
    In order to facilitate this change, the connecting of the callbacks had
    to be moved down a few lines to after the GActions are added to the window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741050

 src/eog-window.c |   40 +++++++++++++++++++---------------------
 1 files changed, 19 insertions(+), 21 deletions(-)
---
diff --git a/src/eog-window.c b/src/eog-window.c
index 1070700..092b7f8 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -4037,23 +4037,13 @@ eog_window_ui_settings_changed_cb (GSettings *settings,
                                                                   gchar     *key,
                                                                   gpointer   user_data)
 {
-       EogWindow *window;
        GVariant *new_state = NULL;
        GVariant *old_state;
-       GAction *action = NULL;
-
-       g_return_if_fail (EOG_IS_WINDOW (user_data));
+       GAction *action;
 
-       window = EOG_WINDOW (user_data);
-       if (g_ascii_strcasecmp (key, EOG_CONF_UI_IMAGE_GALLERY) == 0) {
-               action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewImageGallery");
-       } else if (g_ascii_strcasecmp (key, EOG_CONF_UI_SIDEBAR) == 0) {
-               action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewSidebar");
-       } else if (g_ascii_strcasecmp (key, EOG_CONF_UI_STATUSBAR) == 0) {
-               action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewStatusbar");
-       }
+       g_return_if_fail (G_IS_ACTION (user_data));
 
-       g_assert (action != NULL);
+       action = G_ACTION (user_data);
 
        new_state = g_settings_get_value (settings, key);
        g_assert (new_state != NULL);
@@ -4618,14 +4608,6 @@ eog_window_init (EogWindow *window)
        priv->view_settings = g_settings_new (EOG_CONF_VIEW);
        priv->lockdown_settings = g_settings_new (EOG_CONF_DESKTOP_LOCKDOWN_SCHEMA);
 
-       /* Creating a binding between the ui settings and the related GActions does
-        * not trigger the state changed handler since the state is updated directly
-        * via the "state" property. Requesting a state change via this callback,
-        * however, works. */
-       g_signal_connect (priv->ui_settings, "changed",
-                                         G_CALLBACK (eog_window_ui_settings_changed_cb),
-                                         window);
-
        window->priv->store = NULL;
        window->priv->image = NULL;
 
@@ -4670,6 +4652,22 @@ eog_window_init (EogWindow *window)
                                         window_actions, G_N_ELEMENTS (window_actions),
                                         window);
 
+       /* Creating a binding between the ui settings and the related GActions does
+        * not trigger the state changed handler since the state is updated directly
+        * via the "state" property. Requesting a state change via these callbacks,
+        * however, works. */
+       g_signal_connect (priv->ui_settings, "changed::"EOG_CONF_UI_IMAGE_GALLERY,
+                                         G_CALLBACK (eog_window_ui_settings_changed_cb),
+                                         g_action_map_lookup_action (G_ACTION_MAP (window), 
"ViewImageGallery"));
+
+       g_signal_connect (priv->ui_settings, "changed::"EOG_CONF_UI_SIDEBAR,
+                                         G_CALLBACK (eog_window_ui_settings_changed_cb),
+                                         g_action_map_lookup_action (G_ACTION_MAP (window), "ViewSidebar"));
+       
+       g_signal_connect (priv->ui_settings, "changed::"EOG_CONF_UI_STATUSBAR,
+                                         G_CALLBACK (eog_window_ui_settings_changed_cb),
+                                         g_action_map_lookup_action (G_ACTION_MAP (window), 
"ViewStatusbar"));
+
        action = g_action_map_lookup_action (G_ACTION_MAP (window),
                                             "current-image");
        if (G_LIKELY (action != NULL))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]