[eog] EogWindow: Make the zoom button follow the view's mode



commit 9d9f6b0e84a174cc32dc1b7af3226ca9e2d15ba9
Author: Felix Riemann <friemann gnome org>
Date:   Mon Feb 16 21:58:38 2015 +0100

    EogWindow: Make the zoom button follow the view's mode

 src/eog-window.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/eog-window.c b/src/eog-window.c
index 301896e..a309788 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -229,6 +229,21 @@ _eog_zoom_shrink_to_boolean (GBinding *binding, const GValue *source,
        return TRUE;
 }
 
+static gboolean
+_eog_zoom_button_variant_to_boolean (GBinding *binding, const GValue *source,
+                                    GValue *target, gpointer user_data)
+{
+       GVariant *variant = g_value_get_variant (source);
+       g_return_val_if_fail(g_variant_is_of_type (variant,
+                                                  G_VARIANT_TYPE_BOOLEAN),
+                            FALSE);
+
+       // Use inverted logic, as the button behaves inverted as well
+       g_value_set_boolean(target, !g_variant_get_boolean(variant));
+
+       return TRUE;
+}
+
 static void
 eog_window_set_gallery_mode (EogWindow           *window,
                             EogWindowGalleryPos  position,
@@ -4350,6 +4365,11 @@ eog_window_construct_ui (EogWindow *window)
                                             G_BINDING_SYNC_CREATE,
                                             _eog_zoom_shrink_to_boolean,
                                             NULL, NULL, NULL);
+               g_object_bind_property_full (action, "state",
+                                            zoom_button, "active",
+                                            G_BINDING_SYNC_CREATE,
+                                            _eog_zoom_button_variant_to_boolean,
+                                            NULL, NULL, NULL);
        }
        g_settings_bind (priv->view_settings, EOG_CONF_VIEW_SCROLL_WHEEL_ZOOM,
                         priv->view, "scrollwheel-zoom", G_SETTINGS_BIND_GET);


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