[eog] Set transparency style using GSettings
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog] Set transparency style using GSettings
- Date: Sun, 18 Jul 2010 17:54:11 +0000 (UTC)
commit acdafc3563c5c88d3c2d2a25e4602d774dad92fa
Author: Felix Riemann <friemann gnome org>
Date: Sun Jul 18 19:46:06 2010 +0200
Set transparency style using GSettings
Another callback less from EogWindow.
This will be migrated to use GSetting's enum support soon.
src/eog-scroll-view.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
src/eog-window.c | 42 ------------------------------------------
2 files changed, 49 insertions(+), 42 deletions(-)
---
diff --git a/src/eog-scroll-view.c b/src/eog-scroll-view.c
index d1a6616..37a653a 100644
--- a/src/eog-scroll-view.c
+++ b/src/eog-scroll-view.c
@@ -12,6 +12,7 @@
#endif
#include "eog-config-keys.h"
+#include "eog-enum-types.h"
#include "eog-marshal.h"
#include "eog-scroll-view.h"
#include "eog-debug.h"
@@ -78,6 +79,7 @@ enum {
PROP_BACKGROUND_COLOR,
PROP_SCROLLWHEEL_ZOOM,
PROP_TRANSP_COLOR,
+ PROP_TRANSPARENCY_STYLE,
PROP_USE_BG_COLOR,
PROP_ZOOM_MULTIPLIER
};
@@ -1990,6 +1992,7 @@ eog_scroll_view_set_transparency (EogScrollView *view,
if (priv->transp_style != style) {
priv->transp_style = style;
_transp_background_changed (view);
+ g_object_notify (G_OBJECT (view), "transparency-style");
}
}
@@ -2247,6 +2250,33 @@ sv_color_to_string_mapping (const GValue *value,
return variant;
}
+static gboolean
+sv_string_to_transp_mapping (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ const gchar *str;
+
+ g_return_val_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING), FALSE);
+
+ str = g_variant_get_string (variant, NULL);
+
+ if (!str)
+ return FALSE;
+
+ if (g_ascii_strcasecmp (str, "COLOR") == 0)
+ g_value_set_enum (value, EOG_TRANSP_COLOR);
+ else if (g_ascii_strcasecmp (str, "CHECK_PATTERN") == 0)
+ g_value_set_enum (value, EOG_TRANSP_CHECKED);
+ else if (g_ascii_strcasecmp (str, "NONE") == 0)
+ g_value_set_enum (value, EOG_TRANSP_BACKGROUND);
+ else
+ return FALSE;
+
+ return TRUE;
+}
+
+
static void
eog_scroll_view_init (EogScrollView *view)
@@ -2286,6 +2316,12 @@ eog_scroll_view_init (EogScrollView *view)
G_SETTINGS_BIND_GET,
sv_string_to_color_mapping,
sv_color_to_string_mapping, NULL, NULL);
+ g_settings_bind_with_mapping (settings, EOG_CONF_VIEW_TRANSPARENCY,
+ view, "transparency-style",
+ G_SETTINGS_BIND_GET,
+ sv_string_to_transp_mapping,
+ NULL, NULL, NULL);
+
g_object_unref (settings);
priv->override_bg_color = NULL;
@@ -2356,6 +2392,9 @@ eog_scroll_view_get_property (GObject *object, guint property_id,
case PROP_SCROLLWHEEL_ZOOM:
g_value_set_boolean (value, priv->scroll_wheel_zoom);
break;
+ case PROP_TRANSPARENCY_STYLE:
+ g_value_set_enum (value, priv->transp_style);
+ break;
case PROP_ZOOM_MULTIPLIER:
g_value_set_double (value, priv->zoom_multiplier);
break;
@@ -2392,6 +2431,9 @@ eog_scroll_view_set_property (GObject *object, guint property_id,
case PROP_TRANSP_COLOR:
eog_scroll_view_set_transparency_color (view, g_value_get_boxed (value));
break;
+ case PROP_TRANSPARENCY_STYLE:
+ eog_scroll_view_set_transparency (view, g_value_get_enum (value));
+ break;
case PROP_ZOOM_MULTIPLIER:
eog_scroll_view_set_zoom_multiplier (view, g_value_get_double (value));
break;
@@ -2460,6 +2502,13 @@ eog_scroll_view_class_init (EogScrollViewClass *klass)
g_param_spec_boxed ("transparency-color", NULL, NULL,
GDK_TYPE_COLOR,
G_PARAM_WRITABLE | G_PARAM_STATIC_NAME));
+
+ g_object_class_install_property (
+ gobject_class, PROP_TRANSPARENCY_STYLE,
+ g_param_spec_enum ("transparency-style", NULL, NULL,
+ EOG_TYPE_TRANSPARENCY_STYLE,
+ EOG_TRANSP_CHECKED,
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
view_signals [SIGNAL_ZOOM_CHANGED] =
g_signal_new ("zoom_changed",
diff --git a/src/eog-window.c b/src/eog-window.c
index 2f9d8da..9c51e11 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -265,41 +265,6 @@ eog_window_interp_out_type_changed_cb (GSettings *settings,
}
static void
-eog_window_transparency_changed_cb (GSettings *settings,
- gchar *key,
- gpointer user_data)
-{
- EogWindowPrivate *priv;
- gchar *value = NULL;
-
- g_return_if_fail (EOG_IS_WINDOW (user_data));
-
- eog_debug (DEBUG_PREFERENCES);
-
- priv = EOG_WINDOW (user_data)->priv;
-
- g_return_if_fail (EOG_IS_SCROLL_VIEW (priv->view));
-
- value = g_settings_get_string (settings, key);
-
-
- if (G_UNLIKELY (value == NULL)) {
- return;
- } else if (g_ascii_strcasecmp (value, "COLOR") == 0) {
- eog_scroll_view_set_transparency (EOG_SCROLL_VIEW (priv->view),
- EOG_TRANSP_COLOR);
- } else if (g_ascii_strcasecmp (value, "CHECK_PATTERN") == 0) {
- eog_scroll_view_set_transparency (EOG_SCROLL_VIEW (priv->view),
- EOG_TRANSP_CHECKED);
- } else {
- eog_scroll_view_set_transparency (EOG_SCROLL_VIEW (priv->view),
- EOG_TRANSP_BACKGROUND);
- }
-
- g_free (value);
-}
-
-static void
eog_window_gallery_mode_changed_cb (GSettings *settings,
gchar *key,
gpointer user_data)
@@ -4322,8 +4287,6 @@ eog_window_construct_ui (EogWindow *window)
eog_window_interp_out_type_changed_cb (priv->view_settings,
EOG_CONF_VIEW_INTERPOLATE,
window);
- eog_window_transparency_changed_cb (priv->view_settings,
- EOG_CONF_VIEW_TRANSPARENCY, window);
eog_window_gallery_mode_changed_cb (priv->ui_settings,
EOG_CONF_UI_IMAGE_GALLERY_POSITION,
window);
@@ -4380,11 +4343,6 @@ eog_window_init (EogWindow *window)
(GCallback) eog_window_interp_out_type_changed_cb,
window);
- g_signal_connect (priv->view_settings,
- "changed::" EOG_CONF_VIEW_TRANSPARENCY,
- (GCallback) eog_window_transparency_changed_cb,
- window);
-
g_signal_connect (priv->ui_settings,
"changed::" EOG_CONF_UI_IMAGE_GALLERY_POSITION,
(GCallback) eog_window_gallery_mode_changed_cb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]