summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/eom-scroll-view.c70
-rw-r--r--src/eom-scroll-view.h3
-rw-r--r--src/eom-window.c56
3 files changed, 58 insertions, 71 deletions
diff --git a/src/eom-scroll-view.c b/src/eom-scroll-view.c
index 3f63564..374dd8e 100644
--- a/src/eom-scroll-view.c
+++ b/src/eom-scroll-view.c
@@ -84,6 +84,7 @@ enum {
PROP_ANTIALIAS_OUT,
PROP_BACKGROUND_COLOR,
PROP_SCROLLWHEEL_ZOOM,
+ PROP_TRANSP_COLOR,
PROP_USE_BG_COLOR,
PROP_ZOOM_MULTIPLIER
};
@@ -2137,13 +2138,28 @@ eom_scroll_view_set_antialiasing_out (EomScrollView *view, gboolean state)
}
}
+static void
+_transp_background_changed (EomScrollView *view)
+{
+ EomScrollViewPrivate *priv = view->priv;
+
+ if (priv->pixbuf != NULL && gdk_pixbuf_get_has_alpha (priv->pixbuf)) {
+ if (priv->background_surface) {
+ cairo_surface_destroy (priv->background_surface);
+ /* Will be recreated if needed during redraw */
+ priv->background_surface = NULL;
+ }
+ gtk_widget_queue_draw (GTK_WIDGET (priv->display));
+ }
+
+}
+
void
-eom_scroll_view_set_transparency (EomScrollView *view, EomTransparencyStyle style, GdkColor *color)
+eom_scroll_view_set_transparency_color (EomScrollView *view, GdkColor *color)
{
- EomScrollViewPrivate *priv;
guint32 col = 0;
guint32 red, green, blue;
- gboolean changed = FALSE;
+ EomScrollViewPrivate *priv;
g_return_if_fail (EOM_IS_SCROLL_VIEW (view));
@@ -2156,23 +2172,28 @@ eom_scroll_view_set_transparency (EomScrollView *view, EomTransparencyStyle styl
col = red + green + blue;
}
- if (priv->transp_style != style) {
- priv->transp_style = style;
- changed = TRUE;
- }
-
- if (priv->transp_style == EOM_TRANSP_COLOR && priv->transp_color != col) {
+ if (priv->transp_style != col) {
priv->transp_color = col;
- changed = TRUE;
+ if (priv->transp_style == EOM_TRANSP_COLOR)
+ _transp_background_changed (view);
+
+ g_object_notify (G_OBJECT (view), "transparency-color");
}
+}
- if (changed && priv->pixbuf != NULL && gdk_pixbuf_get_has_alpha (priv->pixbuf)) {
- if (priv->background_surface) {
- cairo_surface_destroy (priv->background_surface);
- /* Will be recreated if needed during redraw */
- priv->background_surface = NULL;
- }
- gtk_widget_queue_draw (GTK_WIDGET (priv->display));
+void
+eom_scroll_view_set_transparency (EomScrollView *view,
+ EomTransparencyStyle style)
+{
+ EomScrollViewPrivate *priv;
+
+ g_return_if_fail (EOM_IS_SCROLL_VIEW (view));
+
+ priv = view->priv;
+
+ if (priv->transp_style != style) {
+ priv->transp_style = style;
+ _transp_background_changed (view);
}
}
@@ -2545,7 +2566,11 @@ eom_scroll_view_init (EomScrollView *view)
"antialiasing-in", G_SETTINGS_BIND_GET);
g_settings_bind (settings, EOM_CONF_VIEW_INTERPOLATE, view,
"antialiasing-out", G_SETTINGS_BIND_GET);
-
+ g_settings_bind_with_mapping (settings, EOM_CONF_VIEW_TRANS_COLOR,
+ view, "transparency-color",
+ G_SETTINGS_BIND_GET,
+ sv_string_to_color_mapping,
+ sv_color_to_string_mapping, NULL, NULL);
g_object_unref (settings);
priv->override_bg_color = NULL;
@@ -2669,6 +2694,9 @@ eom_scroll_view_set_property (GObject *object, guint property_id,
case PROP_SCROLLWHEEL_ZOOM:
eom_scroll_view_set_scroll_wheel_zoom (view, g_value_get_boolean (value));
break;
+ case PROP_TRANSP_COLOR:
+ eom_scroll_view_set_transparency_color (view, g_value_get_boxed (value));
+ break;
case PROP_ZOOM_MULTIPLIER:
eom_scroll_view_set_zoom_multiplier (view, g_value_get_double (value));
break;
@@ -2730,6 +2758,12 @@ eom_scroll_view_class_init (EomScrollViewClass *klass)
g_param_spec_boolean ("scrollwheel-zoom", NULL, NULL, TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
+ g_object_class_install_property (
+ gobject_class, PROP_TRANSP_COLOR,
+ g_param_spec_boxed ("transparency-color", NULL, NULL,
+ GDK_TYPE_COLOR,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_NAME));
+
view_signals [SIGNAL_ZOOM_CHANGED] =
g_signal_new ("zoom_changed",
EOM_TYPE_SCROLL_VIEW,
diff --git a/src/eom-scroll-view.h b/src/eom-scroll-view.h
index 56f8a1b..7ed6181 100644
--- a/src/eom-scroll-view.h
+++ b/src/eom-scroll-view.h
@@ -47,7 +47,8 @@ void eom_scroll_view_set_zoom_upscale (EomScrollView *view, gboolean upscale
void eom_scroll_view_set_zoom_multiplier (EomScrollView *view, gdouble multiplier);
void eom_scroll_view_set_antialiasing_in (EomScrollView *view, gboolean state);
void eom_scroll_view_set_antialiasing_out (EomScrollView *view, gboolean state);
-void eom_scroll_view_set_transparency (EomScrollView *view, EomTransparencyStyle style, GdkColor *color);
+void eom_scroll_view_set_transparency_color (EomScrollView *view, GdkColor *color);
+void eom_scroll_view_set_transparency (EomScrollView *view, EomTransparencyStyle style);
gboolean eom_scroll_view_scrollbars_visible (EomScrollView *view);
void eom_scroll_view_set_popup (EomScrollView *view, GtkMenu *menu);
void eom_scroll_view_set_background_color (EomScrollView *view,
diff --git a/src/eom-window.c b/src/eom-window.c
index aad323a..e00897b 100644
--- a/src/eom-window.c
+++ b/src/eom-window.c
@@ -244,56 +244,16 @@ eom_window_transparency_changed_cb (GSettings *settings, gchar *key, gpointer us
if (value == NULL) {
return;
} else if (g_ascii_strcasecmp (value, "COLOR") == 0) {
- GdkColor color;
- gchar *color_str;
-
- color_str = g_settings_get_string (priv->view_settings, EOM_CONF_VIEW_TRANS_COLOR);
- if (gdk_color_parse (color_str, &color)) {
- eom_scroll_view_set_transparency (EOM_SCROLL_VIEW (priv->view),
- EOM_TRANSP_COLOR, &color);
- }
- g_free (color_str);
+ eom_scroll_view_set_transparency (EOM_SCROLL_VIEW (priv->view),
+ EOM_TRANSP_COLOR);
} else if (g_ascii_strcasecmp (value, "CHECK_PATTERN") == 0) {
eom_scroll_view_set_transparency (EOM_SCROLL_VIEW (priv->view),
- EOM_TRANSP_CHECKED, NULL);
+ EOM_TRANSP_CHECKED);
} else {
eom_scroll_view_set_transparency (EOM_SCROLL_VIEW (priv->view),
- EOM_TRANSP_BACKGROUND, NULL);
- }
- g_free (value);
-}
-
-static void
-eom_window_trans_color_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
-{
- EomWindowPrivate *priv;
- GdkColor color;
- gchar *color_str = NULL;
- gchar *value = NULL;
-
- g_return_if_fail (EOM_IS_WINDOW (user_data));
-
- eom_debug (DEBUG_PREFERENCES);
-
- priv = EOM_WINDOW (user_data)->priv;
-
- g_return_if_fail (EOM_IS_SCROLL_VIEW (priv->view));
-
- value = g_settings_get_string (priv->view_settings, EOM_CONF_VIEW_TRANSPARENCY);
-
- if (!value || g_ascii_strcasecmp (value, "COLOR") != 0) {
- g_free (value);
- return;
- }
-
- color_str = g_settings_get_string (settings, key);
-
- if (gdk_color_parse (color_str, &color)) {
- eom_scroll_view_set_transparency (EOM_SCROLL_VIEW (priv->view),
- EOM_TRANSP_COLOR, &color);
+ EOM_TRANSP_BACKGROUND);
}
g_free (value);
- g_free (color_str);
}
static void
@@ -4456,9 +4416,6 @@ eom_window_construct_ui (EomWindow *window)
eom_window_transparency_changed_cb (priv->view_settings,
EOM_CONF_VIEW_TRANSPARENCY,
window);
- eom_window_trans_color_changed_cb (priv->view_settings,
- EOM_CONF_VIEW_TRANS_COLOR,
- window);
eom_window_collection_mode_changed_cb (priv->ui_settings,
EOM_CONF_UI_IMAGE_COLLECTION_POSITION,
window);
@@ -4503,11 +4460,6 @@ eom_window_init (EomWindow *window)
G_CALLBACK (eom_window_transparency_changed_cb),
window);
- g_signal_connect (priv->view_settings,
- "changed::" EOM_CONF_VIEW_TRANS_COLOR,
- G_CALLBACK (eom_window_trans_color_changed_cb),
- window);
-
g_signal_connect (priv->ui_settings,
"changed::" EOM_CONF_UI_IMAGE_COLLECTION_POSITION,
G_CALLBACK (eom_window_collection_mode_changed_cb),