diff options
author | infirit <[email protected]> | 2014-07-29 18:26:49 +0200 |
---|---|---|
committer | infirit <[email protected]> | 2014-07-29 18:26:49 +0200 |
commit | fb511ab67fa5072f674a9fc0d43916fb99792e6b (patch) | |
tree | 6a430a6e5583d9cd630a5ee57ef1939a8daf3400 | |
parent | f1da7aaa9b1cbc5f0ea703bbd5719d9c64dc2b15 (diff) | |
download | eom-fb511ab67fa5072f674a9fc0d43916fb99792e6b.tar.bz2 eom-fb511ab67fa5072f674a9fc0d43916fb99792e6b.tar.xz |
Have GSettings use enum for transparency style
Based on eog commit e8f2f6ecdd99dc5dce35a044e84738fe73f937e0
From Felix Riemann <[email protected]>
ps infirit: eom never had this value in the convert file
-rw-r--r-- | data/org.mate.eom.gschema.xml.in.in | 6 | ||||
-rw-r--r-- | src/eom-preferences-dialog.c | 59 | ||||
-rw-r--r-- | src/eom-scroll-view.c | 34 |
3 files changed, 28 insertions, 71 deletions
diff --git a/data/org.mate.eom.gschema.xml.in.in b/data/org.mate.eom.gschema.xml.in.in index 3579727..de8c94f 100644 --- a/data/org.mate.eom.gschema.xml.in.in +++ b/data/org.mate.eom.gschema.xml.in.in @@ -31,10 +31,10 @@ <_summary>Extrapolate Image</_summary> <_description>Whether the image should be extrapolated on zoom-in. This leads to blurry quality and is somewhat slower than non-extrapolated images.</_description> </key> - <key name="transparency" type="s"> - <default>'CHECK_PATTERN'</default> + <key name="transparency" enum="org.mate.eom.EomTransparencyStyle"> + <default>'checked'</default> <_summary>Transparency indicator</_summary> - <_description>Determines how transparency should be indicated. Valid values are CHECK_PATTERN, COLOR and NONE. If COLOR is chosen, then the trans-color key determines the color value used.</_description> + <_description>Determines how transparency should be indicated. Valid values are checked, color and none. If color is chosen, then the trans-color key determines the color value used.</_description> </key> <key name="scroll-wheel-zoom" type="b"> <default>true</default> diff --git a/src/eom-preferences-dialog.c b/src/eom-preferences-dialog.c index 7039fb0..869c6eb 100644 --- a/src/eom-preferences-dialog.c +++ b/src/eom-preferences-dialog.c @@ -28,6 +28,7 @@ #include "eom-preferences-dialog.h" #include "eom-plugin-manager.h" +#include "eom-scroll-view.h" #include "eom-util.h" #include "eom-config-keys.h" @@ -97,21 +98,17 @@ pd_color_to_string_mapping (const GValue *value, } static void -pd_radio_toggle_cb (GtkWidget *widget, GSettings *settings) +pd_transp_radio_toggle_cb (GtkWidget *widget, gpointer data) { - char *key = NULL; - char *value = NULL; + gpointer value = NULL; if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) return; - key = g_object_get_data (G_OBJECT (widget), GSETTINGS_OBJECT_KEY); value = g_object_get_data (G_OBJECT (widget), GSETTINGS_OBJECT_VALUE); - if (key == NULL || value == NULL) - return; - - g_settings_set_string (settings, key, value); + g_settings_set_enum (G_SETTINGS (data), EOM_CONF_VIEW_TRANSPARENCY, + GPOINTER_TO_INT (value)); } static void @@ -158,7 +155,6 @@ eom_preferences_dialog_constructor (GType type, GtkWidget *plugin_manager_container; GObject *object; GdkColor color; - gchar *value; object = G_OBJECT_CLASS (eom_preferences_dialog_parent_class)->constructor (type, n_construct_properties, construct_params); @@ -225,59 +221,48 @@ eom_preferences_dialog_constructor (GType type, NULL, NULL); g_object_set_data (G_OBJECT (color_radio), - GSETTINGS_OBJECT_KEY, - EOM_CONF_VIEW_TRANSPARENCY); - - g_object_set_data (G_OBJECT (color_radio), GSETTINGS_OBJECT_VALUE, - "COLOR"); + GINT_TO_POINTER (EOM_TRANSP_COLOR)); g_signal_connect (G_OBJECT (color_radio), "toggled", - G_CALLBACK (pd_radio_toggle_cb), + G_CALLBACK (pd_transp_radio_toggle_cb), priv->view_settings); g_object_set_data (G_OBJECT (checkpattern_radio), - GSETTINGS_OBJECT_KEY, - EOM_CONF_VIEW_TRANSPARENCY); - - g_object_set_data (G_OBJECT (checkpattern_radio), GSETTINGS_OBJECT_VALUE, - "CHECK_PATTERN"); + GINT_TO_POINTER (EOM_TRANSP_CHECKED)); g_signal_connect (G_OBJECT (checkpattern_radio), "toggled", - G_CALLBACK (pd_radio_toggle_cb), + G_CALLBACK (pd_transp_radio_toggle_cb), priv->view_settings); g_object_set_data (G_OBJECT (background_radio), - GSETTINGS_OBJECT_KEY, - EOM_CONF_VIEW_TRANSPARENCY); - - g_object_set_data (G_OBJECT (background_radio), GSETTINGS_OBJECT_VALUE, - "NONE"); + GINT_TO_POINTER (EOM_TRANSP_BACKGROUND)); g_signal_connect (G_OBJECT (background_radio), "toggled", - G_CALLBACK (pd_radio_toggle_cb), + G_CALLBACK (pd_transp_radio_toggle_cb), priv->view_settings); - value = g_settings_get_string (priv->view_settings, - EOM_CONF_VIEW_TRANSPARENCY); - - if (g_ascii_strcasecmp (value, "COLOR") == 0) { + switch (g_settings_get_enum (priv->view_settings, + EOM_CONF_VIEW_TRANSPARENCY)) + { + case EOM_TRANSP_COLOR: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (color_radio), TRUE); - } - else if (g_ascii_strcasecmp (value, "CHECK_PATTERN") == 0) { + break; + case EOM_TRANSP_CHECKED: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkpattern_radio), TRUE); - } - else { + break; + default: + // Log a warning and use EOM_TRANSP_BACKGROUND as fallback + g_warn_if_reached (); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (background_radio), TRUE); + break; } - g_free (value); - g_settings_bind_with_mapping (priv->view_settings, EOM_CONF_VIEW_TRANS_COLOR, color_button, "color", diff --git a/src/eom-scroll-view.c b/src/eom-scroll-view.c index 6d8e1eb..d1d22c5 100644 --- a/src/eom-scroll-view.c +++ b/src/eom-scroll-view.c @@ -2440,32 +2440,6 @@ 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, EOM_TRANSP_COLOR); - else if (g_ascii_strcasecmp (str, "CHECK_PATTERN") == 0) - g_value_set_enum (value, EOM_TRANSP_CHECKED); - else if (g_ascii_strcasecmp (str, "NONE") == 0) - g_value_set_enum (value, EOM_TRANSP_BACKGROUND); - else - return FALSE; - - return TRUE; -} - static void eom_scroll_view_init (EomScrollView *view) { @@ -2587,11 +2561,9 @@ eom_scroll_view_init (EomScrollView *view) G_SETTINGS_BIND_GET, sv_string_to_color_mapping, sv_color_to_string_mapping, NULL, NULL); - g_settings_bind_with_mapping (settings, EOM_CONF_VIEW_TRANSPARENCY, - view, "transparency-style", - G_SETTINGS_BIND_GET, - sv_string_to_transp_mapping, - NULL, NULL, NULL); + g_settings_bind (settings, EOM_CONF_VIEW_TRANSPARENCY, view, + "transparency-style", G_SETTINGS_BIND_GET); + g_object_unref (settings); priv->override_bg_color = NULL; |