summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-12-03 14:20:22 -0800
committerStefano Karapetsas <[email protected]>2012-12-03 14:20:22 -0800
commita7aa069036f960a37cc6149ecdceab917dffa7a0 (patch)
treeb47b0816e8ed67229eb5c5fb6de5b2178889ed12
parent12908bcb598233adabd7492d92efdda3d2cbc47c (diff)
parent2665b684fda835cfa6a485b6e2c8c0a98190facb (diff)
downloadcaja-a7aa069036f960a37cc6149ecdceab917dffa7a0.tar.bz2
caja-a7aa069036f960a37cc6149ecdceab917dffa7a0.tar.xz
Merge pull request #63 from jasmineaura/develop
Bring Caja up to speed, stage2
-rw-r--r--eel/eel-background-box.c2
-rw-r--r--eel/eel-background.c1412
-rw-r--r--eel/eel-background.h102
-rw-r--r--libcaja-private/caja-directory-background.c741
-rw-r--r--libcaja-private/caja-directory-background.h15
-rw-r--r--libcaja-private/caja-global-preferences.h106
-rw-r--r--libcaja-private/caja-icon-dnd.c22
-rw-r--r--libcaja-private/org.mate.caja.gschema.xml.in5
-rw-r--r--src/caja-application.c9
-rw-r--r--src/caja-information-panel.c30
-rw-r--r--src/file-manager/fm-icon-view.c7
11 files changed, 1053 insertions, 1398 deletions
diff --git a/eel/eel-background-box.c b/eel/eel-background-box.c
index 5aeac5a6..d0b80c4e 100644
--- a/eel/eel-background-box.c
+++ b/eel/eel-background-box.c
@@ -43,7 +43,7 @@ eel_background_box_draw (GtkWidget *widget,
gtk_bin_get_child (GTK_BIN (widget)),
cr);
#else
- eel_background_expose (widget, event);
+ eel_background_draw (widget, event);
gtk_container_propagate_expose (GTK_CONTAINER (widget),
gtk_bin_get_child (GTK_BIN (widget)),
event);
diff --git a/eel/eel-background.c b/eel/eel-background.c
index ecfe3042..c2ee1828 100644
--- a/eel/eel-background.c
+++ b/eel/eel-background.c
@@ -3,6 +3,7 @@
eel-background.c: Object for the background of a widget.
Copyright (C) 2000 Eazel, Inc.
+ Copyright (C) 2012 Jasmine Hassan <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -19,7 +20,8 @@
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
- Author: Darin Adler <[email protected]>
+ Authors: Darin Adler <[email protected]>
+ Jasmine Hassan <[email protected]>
*/
#include <config.h>
@@ -39,10 +41,10 @@
#include <stdio.h>
#define MATE_DESKTOP_USE_UNSTABLE_API
#include <libmateui/mate-bg.h>
+#include <libcaja-private/caja-global-preferences.h>
#if !GTK_CHECK_VERSION(3, 0, 0)
#define cairo_surface_t GdkPixmap
-#define cairo_surface_reference g_object_ref
#define cairo_surface_destroy g_object_unref
#define cairo_xlib_surface_get_display GDK_PIXMAP_XDISPLAY
#define cairo_xlib_surface_get_drawable GDK_PIXMAP_XID
@@ -54,11 +56,6 @@
#define mate_bg_crossfade_set_end_surface mate_bg_crossfade_set_end_pixmap
#endif
-static void set_image_properties (EelBackground *background);
-
-static void init_fade (EelBackground *background, GtkWidget *widget);
-static void free_fade (EelBackground *background);
-
G_DEFINE_TYPE (EelBackground, eel_background, G_TYPE_OBJECT);
enum
@@ -73,17 +70,16 @@ static guint signals[LAST_SIGNAL];
struct EelBackgroundDetails
{
- char *color;
-
- MateBG *bg;
GtkWidget *widget;
+ MateBG *bg;
+ char *color;
/* Realized data: */
- cairo_surface_t *background_surface;
- gboolean background_surface_is_unset_root_surface;
+ cairo_surface_t *bg_surface;
+ gboolean unset_root_surface;
MateBGCrossfade *fade;
- int background_entire_width;
- int background_entire_height;
+ int bg_entire_width;
+ int bg_entire_height;
GdkColor default_color;
gboolean use_base;
@@ -103,921 +99,648 @@ struct EelBackgroundDetails
};
static void
-on_bg_changed (MateBG *bg, EelBackground *background)
+free_fade (EelBackground *self)
{
- init_fade (background, background->details->widget);
- g_signal_emit (G_OBJECT (background),
- signals[APPEARANCE_CHANGED], 0);
-}
-
-static void
-on_bg_transitioned (MateBG *bg, EelBackground *background)
-{
- free_fade (background);
- g_signal_emit (G_OBJECT (background),
- signals[APPEARANCE_CHANGED], 0);
-}
-
-static void
-eel_background_init (EelBackground *background)
-{
- background->details =
- G_TYPE_INSTANCE_GET_PRIVATE (background,
- EEL_TYPE_BACKGROUND,
- EelBackgroundDetails);
-
- background->details->default_color.red = 0xffff;
- background->details->default_color.green = 0xffff;
- background->details->default_color.blue = 0xffff;
- background->details->bg = mate_bg_new ();
- background->details->is_active = TRUE;
-
- g_signal_connect (background->details->bg, "changed",
- G_CALLBACK (on_bg_changed), background);
- g_signal_connect (background->details->bg, "transitioned",
- G_CALLBACK (on_bg_transitioned), background);
-
-}
-
-/* The safe way to clear an image from a background is:
- * eel_background_set_image_uri (NULL);
- * This fn is a private utility - it does NOT clear
- * the details->bg_uri setting.
- */
-static void
-eel_background_remove_current_image (EelBackground *background)
-{
- if (background->details->bg != NULL)
- {
- g_object_unref (G_OBJECT (background->details->bg));
- background->details->bg = NULL;
- }
-}
-
-static void
-free_fade (EelBackground *background)
-{
- if (background->details->fade != NULL)
+ if (self->details->fade != NULL)
{
- g_object_unref (background->details->fade);
- background->details->fade = NULL;
+ g_object_unref (self->details->fade);
+ self->details->fade = NULL;
}
}
static void
-free_background_surface (EelBackground *background)
+free_background_surface (EelBackground *self)
{
cairo_surface_t *surface;
- surface = background->details->background_surface;
+ surface = self->details->bg_surface;
if (surface != NULL)
{
/* If we created a root surface and didn't set it as background
it will live forever, so we need to kill it manually.
If set as root background it will be killed next time the
background is changed. */
- if (background->details->background_surface_is_unset_root_surface)
+ if (self->details->unset_root_surface)
{
XKillClient (cairo_xlib_surface_get_display (surface),
cairo_xlib_surface_get_drawable (surface));
}
cairo_surface_destroy (surface);
- background->details->background_surface = NULL;
+ self->details->bg_surface = NULL;
}
}
-
-static EelBackgroundImagePlacement
-placement_mate_to_eel (MateBGPlacement p)
-{
- switch (p)
- {
- case MATE_BG_PLACEMENT_CENTERED:
- return EEL_BACKGROUND_CENTERED;
- case MATE_BG_PLACEMENT_FILL_SCREEN:
- return EEL_BACKGROUND_SCALED;
- case MATE_BG_PLACEMENT_SCALED:
- return EEL_BACKGROUND_SCALED_ASPECT;
- case MATE_BG_PLACEMENT_ZOOMED:
- return EEL_BACKGROUND_ZOOM;
- case MATE_BG_PLACEMENT_TILED:
- return EEL_BACKGROUND_TILED;
- case MATE_BG_PLACEMENT_SPANNED:
- return EEL_BACKGROUND_SPANNED;
- }
-
- return EEL_BACKGROUND_TILED;
-}
-
-static MateBGPlacement
-placement_eel_to_mate (EelBackgroundImagePlacement p)
-{
- switch (p)
- {
- case EEL_BACKGROUND_CENTERED:
- return MATE_BG_PLACEMENT_CENTERED;
- case EEL_BACKGROUND_SCALED:
- return MATE_BG_PLACEMENT_FILL_SCREEN;
- case EEL_BACKGROUND_SCALED_ASPECT:
- return MATE_BG_PLACEMENT_SCALED;
- case EEL_BACKGROUND_ZOOM:
- return MATE_BG_PLACEMENT_ZOOMED;
- case EEL_BACKGROUND_TILED:
- return MATE_BG_PLACEMENT_TILED;
- case EEL_BACKGROUND_SPANNED:
- return MATE_BG_PLACEMENT_SPANNED;
- }
-
- return MATE_BG_PLACEMENT_TILED;
-}
-
-EelBackgroundImagePlacement
-eel_background_get_image_placement (EelBackground *background)
-{
- g_return_val_if_fail (EEL_IS_BACKGROUND (background), EEL_BACKGROUND_TILED);
-
- return placement_mate_to_eel (mate_bg_get_placement (background->details->bg));
-}
-
-void
-eel_background_set_image_placement (EelBackground *background,
- EelBackgroundImagePlacement new_placement)
-{
- g_return_if_fail (EEL_IS_BACKGROUND (background));
-
- mate_bg_set_placement (background->details->bg,
- placement_eel_to_mate (new_placement));
-}
-
-
static void
eel_background_finalize (GObject *object)
{
- EelBackground *background;
+ EelBackground *self = EEL_BACKGROUND (object);
- background = EEL_BACKGROUND (object);
+ g_free (self->details->color);
- g_free (background->details->color);
- eel_background_remove_current_image (background);
+ if (self->details->bg != NULL) {
+ g_object_unref (G_OBJECT (self->details->bg));
+ self->details->bg = NULL;
+ }
- free_background_surface (background);
+ free_background_surface (self);
- free_fade (background);
+ free_fade (self);
G_OBJECT_CLASS (eel_background_parent_class)->finalize (object);
}
static void
-eel_background_class_init (EelBackgroundClass *klass)
+eel_background_unrealize (EelBackground *self)
{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
-
- signals[APPEARANCE_CHANGED] =
- g_signal_new ("appearance_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EelBackgroundClass,
- appearance_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals[SETTINGS_CHANGED] =
- g_signal_new ("settings_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EelBackgroundClass,
- settings_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
- 1, G_TYPE_INT);
- signals[RESET] =
- g_signal_new ("reset",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EelBackgroundClass,
- reset),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- object_class->finalize = eel_background_finalize;
+ free_background_surface (self);
- g_type_class_add_private (klass, sizeof (EelBackgroundDetails));
+ self->details->bg_entire_width = 0;
+ self->details->bg_entire_height = 0;
+ self->details->default_color.red = 0xffff;
+ self->details->default_color.green = 0xffff;
+ self->details->default_color.blue = 0xffff;
}
-EelBackground *
-eel_background_new (void)
-{
- return EEL_BACKGROUND (g_object_new (EEL_TYPE_BACKGROUND, NULL));
-}
+#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, G_MAXUSHORT))
+#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
static void
-eel_background_unrealize (EelBackground *background)
+make_color_inactive (EelBackground *self,
+ GdkColor *color)
{
- free_background_surface (background);
+ double intensity, saturation;
+ gushort t;
- background->details->background_entire_width = 0;
- background->details->background_entire_height = 0;
- background->details->default_color.red = 0xffff;
- background->details->default_color.green = 0xffff;
- background->details->default_color.blue = 0xffff;
-}
+ if (self->details->is_active) {
+ return;
+ }
-static void
-drawable_get_adjusted_size (EelBackground *background,
- GdkWindow *window,
- int *width,
- int *height)
-{
- *width = gdk_window_get_width(GDK_WINDOW(window));
- *height = gdk_window_get_height(GDK_WINDOW(window));
+ saturation = 0.7;
+ intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11;
+ color->red = SATURATE (color->red);
+ color->green = SATURATE (color->green);
+ color->blue = SATURATE (color->blue);
- if (background->details->is_desktop)
+ if (intensity > G_MAXUSHORT / 2)
{
- GdkScreen *screen;
- screen = gdk_window_get_screen (window);
- *width = gdk_screen_get_width (screen);
- *height = gdk_screen_get_height (screen);
+ color->red *= 0.9;
+ color->green *= 0.9;
+ color->blue *= 0.9;
}
+ else
+ {
+ color->red *= 1.25;
+ color->green *= 1.25;
+ color->blue *= 1.25;
+ }
+
+ color->red = CLAMP_COLOR (color->red);
+ color->green = CLAMP_COLOR (color->green);
+ color->blue = CLAMP_COLOR (color->blue);
}
-static gboolean
-eel_background_ensure_realized (EelBackground *background, GdkWindow *window)
+gchar *
+eel_bg_get_desktop_color (EelBackground *self)
{
- gpointer data;
- GtkWidget *widget;
- GtkStyle *style;
- gboolean changed;
- int entire_width;
- int entire_height;
-
- drawable_get_adjusted_size (background, window, &entire_width, &entire_height);
+ MateBGColorType type;
+ GdkColor primary, secondary;
+ char *start_color, *end_color, *color_spec;
+ gboolean use_gradient = TRUE;
+ gboolean is_horizontal = FALSE;
- /* Set the default color */
+ mate_bg_get_color (self->details->bg, &type, &primary, &secondary);
- /* Get the widget to which the window belongs and its style as well */
- gdk_window_get_user_data (window, &data);
- widget = GTK_WIDGET (data);
- if (widget != NULL)
+ if (type == MATE_BG_COLOR_V_GRADIENT)
{
- style = gtk_widget_get_style (widget);
- if (background->details->use_base)
- {
- background->details->default_color = style->base[GTK_STATE_NORMAL];
- }
- else
- {
- background->details->default_color = style->bg[GTK_STATE_NORMAL];
- }
-
+ is_horizontal = FALSE;
}
-
- /* If the window size is the same as last time, don't update */
- if (entire_width == background->details->background_entire_width &&
- entire_height == background->details->background_entire_height)
+ else if (type == MATE_BG_COLOR_H_GRADIENT)
{
- return FALSE;
+ is_horizontal = TRUE;
}
-
- free_background_surface (background);
-
- changed = FALSE;
-
- set_image_properties (background);
-
- background->details->background_surface = mate_bg_create_surface (background->details->bg,
- window,
- entire_width, entire_height,
- background->details->is_desktop);
- background->details->background_surface_is_unset_root_surface = background->details->is_desktop;
-
- /* We got the surface and everything, so we don't care about a change
- that is pending (unless things actually change after this time) */
- g_object_set_data (G_OBJECT (background->details->bg),
- "ignore-pending-change", GINT_TO_POINTER (TRUE));
- changed = TRUE;
-
-
- background->details->background_entire_width = entire_width;
- background->details->background_entire_height = entire_height;
-
- return changed;
-}
-
-#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, G_MAXUSHORT))
-#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
-
-static void
-make_color_inactive (EelBackground *background, GdkColor *color)
-{
- double intensity, saturation;
- gushort t;
-
- if (!background->details->is_active)
+ else /* implicit (type == MATE_BG_COLOR_SOLID) */
{
- saturation = 0.7;
- intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11;
- color->red = SATURATE (color->red);
- color->green = SATURATE (color->green);
- color->blue = SATURATE (color->blue);
-
- if (intensity > G_MAXUSHORT / 2)
- {
- color->red *= 0.9;
- color->green *= 0.9;
- color->blue *= 0.9;
- }
- else
- {
- color->red *= 1.25;
- color->green *= 1.25;
- color->blue *= 1.25;
- }
-
- color->red = CLAMP_COLOR (color->red);
- color->green = CLAMP_COLOR (color->green);
- color->blue = CLAMP_COLOR (color->blue);
+ use_gradient = FALSE;
}
-}
-void
-#if GTK_CHECK_VERSION (3, 0, 0)
-eel_background_draw (GtkWidget *widget,
- cairo_t *cr)
-#else
-eel_background_expose (GtkWidget *widget,
- GdkEventExpose *event)
-#endif
-{
- int window_width;
- int window_height;
- GdkWindow *widget_window;
-
- widget_window = gtk_widget_get_window (widget);
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
- g_return_if_fail (event->window == widget_window);
-#endif
-
- EelBackground *background = eel_get_widget_background (widget);
+ start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary));
- drawable_get_adjusted_size (background, widget_window, &window_width, &window_height);
-
- eel_background_ensure_realized (background, widget_window);
- make_color_inactive (background, &background->details->default_color);
-
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
-#else
- cairo_t *cr = gdk_cairo_create (widget_window);
-#endif
-
- if (background->details->background_surface != NULL) {
- cairo_set_source_surface (cr, background->details->background_surface, 0, 0);
- cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
- } else {
- gdk_cairo_set_source_color (cr, &background->details->default_color);
+ if (use_gradient)
+ {
+ end_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary));
+ color_spec = eel_gradient_new (start_color, end_color, is_horizontal);
+ g_free (end_color);
}
+ else
+ {
+ color_spec = g_strdup (start_color);
+ }
+ g_free (start_color);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gdk_cairo_rectangle (cr, &event->area);
- cairo_clip (cr);
-#endif
-
- cairo_rectangle (cr, 0, 0, window_width, window_height);
- cairo_fill (cr);
-
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
- cairo_destroy (cr);
-#endif
+ return color_spec;
}
static void
-set_image_properties (EelBackground *background)
+set_image_properties (EelBackground *self)
{
GdkColor c;
- if (!background->details->color)
+
+ if (self->details->is_desktop && !self->details->color)
+ self->details->color = eel_bg_get_desktop_color (self);
+
+ if (!self->details->color)
{
- c = background->details->default_color;
- make_color_inactive (background, &c);
- mate_bg_set_color (background->details->bg, MATE_BG_COLOR_SOLID,
- &c, NULL);
+ c = self->details->default_color;
+ make_color_inactive (self, &c);
+ mate_bg_set_color (self->details->bg, MATE_BG_COLOR_SOLID, &c, NULL);
}
- else if (!eel_gradient_is_gradient (background->details->color))
+ else if (!eel_gradient_is_gradient (self->details->color))
{
- eel_gdk_color_parse_with_white_default (background->details->color, &c);
- make_color_inactive (background, &c);
- mate_bg_set_color (background->details->bg, MATE_BG_COLOR_SOLID, &c, NULL);
+ eel_gdk_color_parse_with_white_default (self->details->color, &c);
+ make_color_inactive (self, &c);
+ mate_bg_set_color (self->details->bg, MATE_BG_COLOR_SOLID, &c, NULL);
}
else
{
- GdkColor c1;
- GdkColor c2;
+ GdkColor c1, c2;
char *spec;
- spec = eel_gradient_get_start_color_spec (background->details->color);
+ spec = eel_gradient_get_start_color_spec (self->details->color);
eel_gdk_color_parse_with_white_default (spec, &c1);
- make_color_inactive (background, &c1);
+ make_color_inactive (self, &c1);
g_free (spec);
- spec = eel_gradient_get_end_color_spec (background->details->color);
+ spec = eel_gradient_get_end_color_spec (self->details->color);
eel_gdk_color_parse_with_white_default (spec, &c2);
- make_color_inactive (background, &c2);
+ make_color_inactive (self, &c2);
g_free (spec);
- if (eel_gradient_is_horizontal (background->details->color))
- mate_bg_set_color (background->details->bg, MATE_BG_COLOR_H_GRADIENT, &c1, &c2);
- else
- mate_bg_set_color (background->details->bg, MATE_BG_COLOR_V_GRADIENT, &c1, &c2);
-
+ if (eel_gradient_is_horizontal (self->details->color)) {
+ mate_bg_set_color (self->details->bg, MATE_BG_COLOR_H_GRADIENT, &c1, &c2);
+ } else {
+ mate_bg_set_color (self->details->bg, MATE_BG_COLOR_V_GRADIENT, &c1, &c2);
+ }
}
}
-char *
-eel_background_get_color (EelBackground *background)
+gchar *
+eel_background_get_color (EelBackground *self)
{
- g_return_val_if_fail (EEL_IS_BACKGROUND (background), NULL);
+ g_return_val_if_fail (EEL_IS_BACKGROUND (self), NULL);
- return g_strdup (background->details->color);
+ return g_strdup (self->details->color);
}
-char *
-eel_background_get_image_uri (EelBackground *background)
+/* @color: color or gradient to set */
+void
+eel_background_set_color (EelBackground *self,
+ const gchar *color)
{
- const char *filename;
-
- g_return_val_if_fail (EEL_IS_BACKGROUND (background), NULL);
-
- filename = mate_bg_get_filename (background->details->bg);
- if (filename)
+ if (g_strcmp0 (self->details->color, color) != 0)
{
- return g_filename_to_uri (filename, NULL, NULL);
+ g_free (self->details->color);
+ self->details->color = g_strdup (color);
+
+ set_image_properties (self);
}
- return NULL;
}
/* Use style->base as the default color instead of bg */
void
-eel_background_set_use_base (EelBackground *background,
- gboolean use_base)
+eel_background_set_use_base (EelBackground *self,
+ gboolean use_base)
{
- background->details->use_base = use_base;
+ self->details->use_base = use_base;
}
-void
-eel_background_set_color (EelBackground *background,
- const char *color)
+static void
+drawable_get_adjusted_size (EelBackground *self,
+ int *width,
+ int *height)
{
- if (g_strcmp0 (background->details->color, color) != 0)
+ if (self->details->is_desktop)
{
- g_free (background->details->color);
- background->details->color = g_strdup (color);
-
- set_image_properties (background);
+ GdkScreen *screen = gtk_widget_get_screen (self->details->widget);
+ *width = gdk_screen_get_width (screen);
+ *height = gdk_screen_get_height (screen);
+ }
+ else
+ {
+ GdkWindow *window = gtk_widget_get_window (self->details->widget);
+ *width = gdk_window_get_width (window);
+ *height = gdk_window_get_height (window);
}
}
static gboolean
-eel_background_set_image_uri_helper (EelBackground *background,
- const char *image_uri,
- gboolean emit_signal)
+eel_background_ensure_realized (EelBackground *self)
{
- char *filename;
+ GtkStyle *style;
+ int width, height;
+ GdkWindow *window;
- if (image_uri != NULL)
- {
- filename = g_filename_from_uri (image_uri, NULL, NULL);
+ /* Set the default color */
+ style = gtk_widget_get_style (self->details->widget);
+ if (self->details->use_base) {
+ self->details->default_color = style->base[GTK_STATE_NORMAL];
+ } else {
+ self->details->default_color = style->bg[GTK_STATE_NORMAL];
}
- else
+
+ /* If the window size is the same as last time, don't update */
+ drawable_get_adjusted_size (self, &width, &height);
+ if (width == self->details->bg_entire_width &&
+ height == self->details->bg_entire_height)
{
- filename = NULL;
+ return FALSE;
}
- mate_bg_set_filename (background->details->bg, filename);
+ free_background_surface (self);
- if (emit_signal)
- {
- g_signal_emit (background, signals[SETTINGS_CHANGED], 0, GDK_ACTION_COPY);
- }
+ /* Calls mate_bg_set_color, which sets "ignore-pending-change" to false,
+ and queues emission of changed signal if it's still false */
+ set_image_properties (self);
- set_image_properties (background);
+ window = gtk_widget_get_window (self->details->widget);
+ self->details->bg_surface = mate_bg_create_surface (self->details->bg,
+ window, width, height,
+ self->details->is_desktop);
+ self->details->unset_root_surface = self->details->is_desktop;
- g_free (filename);
+ /* We got the surface and everything, so we don't care about a change
+ that is pending (unless things actually change after this time) */
+ g_object_set_data (G_OBJECT (self->details->bg),
+ "ignore-pending-change",
+ GINT_TO_POINTER (TRUE));
+
+ self->details->bg_entire_width = width;
+ self->details->bg_entire_height = height;
return TRUE;
}
void
-eel_background_set_image_uri (EelBackground *background, const char *image_uri)
+eel_background_draw (GtkWidget *widget,
+# if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr)
+{
+# else
+ GdkEventExpose *event)
{
+# endif
+ int width, height;
+ GdkWindow *window = gtk_widget_get_window (widget);
+# if !GTK_CHECK_VERSION (3, 0, 0)
+ if (event->window != window)
+ return;
+# endif
- eel_background_set_image_uri_helper (background, image_uri, TRUE);
-}
+ EelBackground *self = eel_get_widget_background (widget);
-/* Use this fn to set both the image and color and avoid flash. The color isn't
- * changed till after the image is done loading, that way if an update occurs
- * before then, it will use the old color and image.
- */
-static void
-eel_background_set_image_uri_and_color (EelBackground *background, GdkDragAction action,
- const char *image_uri, const char *color)
-{
- eel_background_set_image_uri_helper (background, image_uri, FALSE);
- eel_background_set_color (background, color);
+ drawable_get_adjusted_size (self, &width, &height);
- /* We always emit, even if the color didn't change, because the image change
- * relies on us doing it here.
- */
+ eel_background_ensure_realized (self);
+ make_color_inactive (self, &self->details->default_color);
- g_signal_emit (background, signals[SETTINGS_CHANGED], 0, action);
-}
+# if GTK_CHECK_VERSION(3,0,0)
+ cairo_save (cr);
+# else
+ cairo_t *cr = gdk_cairo_create (window);
+# endif
-void
-eel_background_receive_dropped_background_image (EelBackground *background,
- GdkDragAction action,
- const char *image_uri)
-{
- /* Currently, we only support tiled images. So we set the placement.
- * We rely on eel_background_set_image_uri_and_color to emit
- * the SETTINGS_CHANGED & APPEARANCE_CHANGE signals.
- */
- eel_background_set_image_placement (background, EEL_BACKGROUND_TILED);
+ if (self->details->bg_surface != NULL) {
+ cairo_set_source_surface (cr, self->details->bg_surface, 0, 0);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+ } else {
+ gdk_cairo_set_source_color (cr, &self->details->default_color);
+ }
- eel_background_set_image_uri_and_color (background, action, image_uri, NULL);
-}
+# if !GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_rectangle (cr, &event->area);
+ cairo_clip (cr);
+# endif
-/**
- * eel_background_is_set:
- *
- * Check whether the background's color or image has been set.
- */
-gboolean
-eel_background_is_set (EelBackground *background)
-{
- g_assert (EEL_IS_BACKGROUND (background));
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
- return background->details->color != NULL
- || mate_bg_get_filename (background->details->bg) != NULL;
+# if GTK_CHECK_VERSION(3,0,0)
+ cairo_restore (cr);
+# else
+ cairo_destroy (cr);
+# endif
}
-/**
- * eel_background_reset:
- *
- * Emit the reset signal to forget any color or image that has been
- * set previously.
- */
-void
-eel_background_reset (EelBackground *background)
+static void
+set_root_surface (EelBackground *self,
+ GdkWindow *window,
+ GdkScreen *screen)
{
- g_return_if_fail (EEL_IS_BACKGROUND (background));
+ eel_background_ensure_realized (self);
+
+ if (self->details->use_common_surface) {
+ self->details->unset_root_surface = FALSE;
+ } else {
+ int width, height;
+ drawable_get_adjusted_size (self, &width, &height);
+ self->details->bg_surface = mate_bg_create_surface (self->details->bg, window,
+ width, height, TRUE);
+ }
- g_signal_emit (background, signals[RESET], 0);
+ if (self->details->bg_surface != NULL)
+ mate_bg_set_surface_as_root (screen, self->details->bg_surface);
}
static void
-set_root_surface (EelBackground *background,
- GdkWindow *window)
+init_fade (EelBackground *self)
{
- GdkScreen *screen;
+ GtkWidget *widget = self->details->widget;
+ gboolean do_fade;
- eel_background_ensure_realized (background, window);
- screen = gdk_window_get_screen (window);
+ if (!self->details->is_desktop || widget == NULL || !gtk_widget_get_realized (widget)) {
+ return;
+ }
- if (background->details->use_common_surface)
- {
- background->details->background_surface_is_unset_root_surface = FALSE;
+ do_fade = g_settings_get_boolean (mate_background_preferences,
+ MATE_BG_KEY_BACKGROUND_FADE);
+ if (!do_fade) {
+ return;
}
- else
+
+ if (self->details->fade == NULL)
{
- background->details->background_surface =
- mate_bg_create_surface (background->details->bg, window,
- gdk_screen_get_width (screen), gdk_screen_get_height (screen), TRUE);
+ int width, height;
+
+ /* If this was the result of a screen size change,
+ * we don't want to crossfade
+ */
+ drawable_get_adjusted_size (self, &width, &height);
+ if (width == self->details->bg_entire_width &&
+ height == self->details->bg_entire_height)
+ {
+ self->details->fade = mate_bg_crossfade_new (width, height);
+ g_signal_connect_swapped (self->details->fade,
+ "finished",
+ G_CALLBACK (free_fade),
+ self);
+ }
}
- mate_bg_set_surface_as_root (screen, background->details->background_surface);
+ if (self->details->fade != NULL && !mate_bg_crossfade_is_started (self->details->fade))
+ {
+ if (self->details->bg_surface == NULL)
+ {
+ cairo_surface_t *start_surface;
+ start_surface = mate_bg_get_surface_from_root (gtk_widget_get_screen (widget));
+ mate_bg_crossfade_set_start_surface (self->details->fade, start_surface);
+ cairo_surface_destroy (start_surface);
+ }
+ else
+ {
+ mate_bg_crossfade_set_start_surface (self->details->fade, self->details->bg_surface);
+ }
+ }
}
static void
on_fade_finished (MateBGCrossfade *fade,
- GdkWindow *window,
- EelBackground *background)
+ GdkWindow *window,
+ gpointer user_data)
{
- set_root_surface (background, window);
+ EelBackground *self = EEL_BACKGROUND (user_data);
+
+ set_root_surface (self, window, gdk_window_get_screen (window));
}
static gboolean
-fade_to_surface (EelBackground *background,
+fade_to_surface (EelBackground *self,
GdkWindow *window,
cairo_surface_t *surface)
{
- if (background->details->fade == NULL)
- {
- return FALSE;
- }
-
- if (!mate_bg_crossfade_set_end_surface (background->details->fade,
- surface))
+ if (self->details->fade == NULL ||
+ !mate_bg_crossfade_set_end_surface (self->details->fade, surface))
{
return FALSE;
}
- if (!mate_bg_crossfade_is_started (background->details->fade))
+ if (!mate_bg_crossfade_is_started (self->details->fade))
{
- mate_bg_crossfade_start (background->details->fade, window);
- if (background->details->is_desktop)
+ mate_bg_crossfade_start (self->details->fade, window);
+ if (self->details->is_desktop)
{
- g_signal_connect (background->details->fade,
+ g_signal_connect (self->details->fade,
"finished",
- G_CALLBACK (on_fade_finished), background);
+ G_CALLBACK (on_fade_finished), self);
}
}
- return mate_bg_crossfade_is_started (background->details->fade);
+ return mate_bg_crossfade_is_started (self->details->fade);
}
-
static void
-eel_background_set_up_widget (EelBackground *background, GtkWidget *widget)
+eel_background_set_up_widget (EelBackground *self)
{
GdkWindow *window;
- GdkWindow *widget_window;
- gboolean in_fade;
+ GtkWidget *widget = self->details->widget;
+ gboolean in_fade = FALSE;
if (!gtk_widget_get_realized (widget))
- {
return;
- }
- widget_window = gtk_widget_get_window (widget);
+ eel_background_ensure_realized (self);
+ make_color_inactive (self, &self->details->default_color);
- eel_background_ensure_realized (background, widget_window);
- make_color_inactive (background, &background->details->default_color);
+ if (self->details->bg_surface == NULL)
+ return;
- if (EEL_IS_CANVAS (widget))
- {
+ if (EEL_IS_CANVAS (widget)) {
window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
- }
- else
- {
- window = widget_window;
+ } else {
+ window = gtk_widget_get_window (widget);
}
- if (background->details->fade != NULL)
- {
- in_fade = fade_to_surface (background, window,
- background->details->background_surface);
- }
- else
- {
- in_fade = FALSE;
- }
+ if (self->details->fade != NULL)
+ in_fade = fade_to_surface (self, window, self->details->bg_surface);
if (!in_fade)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
+# if GTK_CHECK_VERSION (3, 0, 0)
cairo_pattern_t *pattern;
- pattern = cairo_pattern_create_for_surface (background->details->background_surface);
+ pattern = cairo_pattern_create_for_surface (self->details->bg_surface);
gdk_window_set_background_pattern (window, pattern);
cairo_pattern_destroy (pattern);
-#endif
- if (!background->details->is_desktop) {
- gdk_window_set_background (window, &background->details->default_color);
+# endif
+
+ if (self->details->is_desktop)
+ {
+# if !GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_set_back_pixmap (window, self->details->bg_surface, FALSE);
+# endif
+ set_root_surface (self, window, gtk_widget_get_screen (widget));
+ }
+ else
+ {
+ gdk_window_set_background (window, &self->details->default_color);
+# if !GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_set_back_pixmap (window, self->details->bg_surface, FALSE);
+# endif
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gdk_window_set_back_pixmap (window, background->details->background_surface, FALSE);
-#endif
- }
- if (background->details->is_desktop && !in_fade)
- {
- set_root_surface (background, window);
+ gdk_window_invalidate_rect (window, NULL, TRUE);
}
}
static gboolean
-on_background_changed (EelBackground *background)
+background_changed_cb (EelBackground *self)
{
- if (background->details->change_idle_id == 0)
- {
+ if (self->details->change_idle_id == 0) {
return FALSE;
}
+ self->details->change_idle_id = 0;
- background->details->change_idle_id = 0;
+ eel_background_unrealize (self);
+ eel_background_set_up_widget (self);
- eel_background_unrealize (background);
- eel_background_set_up_widget (background, background->details->widget);
-
- gtk_widget_queue_draw (background->details->widget);
+ gtk_widget_queue_draw (self->details->widget);
return FALSE;
}
static void
-init_fade (EelBackground *background, GtkWidget *widget)
+widget_queue_background_change (GtkWidget *widget,
+ gpointer user_data)
{
- if (widget == NULL || !gtk_widget_get_realized (widget))
- return;
-
- if (!background->details->is_desktop)
- {
- return;
- }
+ EelBackground *self = EEL_BACKGROUND (user_data);
- if (background->details->fade == NULL)
+ if (self->details->change_idle_id != 0)
{
- GdkWindow *window;
- int old_width, old_height, width, height;
-
- /* If this was the result of a screen size change,
- * we don't want to crossfade
- */
- window = gtk_widget_get_window (widget);
- old_width = gdk_window_get_width(GDK_WINDOW(window));
- old_height = gdk_window_get_height(GDK_WINDOW(window));
- drawable_get_adjusted_size (background, window,
- &width, &height);
- if (old_width == width && old_height == height)
- {
- background->details->fade = mate_bg_crossfade_new (width, height);
- g_signal_connect_swapped (background->details->fade,
- "finished",
- G_CALLBACK (free_fade),
- background);
- }
+ g_source_remove (self->details->change_idle_id);
}
- if (background->details->fade != NULL && !mate_bg_crossfade_is_started (background->details->fade))
- {
- cairo_surface_t *start_surface;
-
- if (background->details->background_surface == NULL)
- {
- start_surface = mate_bg_get_surface_from_root (gtk_widget_get_screen (widget));
- }
- else
- {
- start_surface = cairo_surface_reference (background->details->background_surface);
- }
- mate_bg_crossfade_set_start_surface (background->details->fade,
- start_surface);
- cairo_surface_destroy (start_surface);
- }
+ self->details->change_idle_id =
+ g_idle_add ((GSourceFunc) background_changed_cb, self);
}
+/* Callback used when the style of a widget changes. We have to regenerate its
+ * EelBackgroundStyle so that it will match the chosen GTK+ theme.
+ */
static void
-eel_widget_queue_background_change (GtkWidget *widget)
+widget_style_set_cb (GtkWidget *widget,
+ GtkStyle *previous_style,
+ gpointer user_data)
{
- EelBackground *background;
-
- background = eel_get_widget_background (widget);
+ if (previous_style != NULL)
+ widget_queue_background_change (widget, user_data);
+}
- if (background->details->change_idle_id > 0)
- {
- return;
- }
+static void
+eel_background_changed (MateBG *bg,
+ gpointer user_data)
+{
+ EelBackground *self = EEL_BACKGROUND (user_data);
- background->details->change_idle_id = g_idle_add ((GSourceFunc) on_background_changed, background);
+ init_fade (self);
+ g_signal_emit (G_OBJECT (self), signals[APPEARANCE_CHANGED], 0);
}
-/* Callback used when the style of a widget changes. We have to regenerate its
- * EelBackgroundStyle so that it will match the chosen GTK+ theme.
- */
static void
-widget_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, gpointer data)
+eel_background_transitioned (MateBG *bg, gpointer user_data)
{
- EelBackground *background;
+ EelBackground *self = EEL_BACKGROUND (user_data);
- background = EEL_BACKGROUND (data);
-
- if (previous_style != NULL)
- {
- eel_widget_queue_background_change (widget);
- }
+ free_fade (self);
+ g_signal_emit (G_OBJECT (self), signals[APPEARANCE_CHANGED], 0);
}
static void
screen_size_changed (GdkScreen *screen, EelBackground *background)
{
- g_signal_emit (background, signals[APPEARANCE_CHANGED], 0);
+ int w, h;
+
+ drawable_get_adjusted_size (background, &w, &h);
+ if (w != background->details->bg_entire_width ||
+ h != background->details->bg_entire_height)
+ {
+ g_signal_emit (background, signals[APPEARANCE_CHANGED], 0);
+ }
}
static void
-widget_realized_setup (GtkWidget *widget, gpointer data)
+widget_realized_setup (GtkWidget *widget,
+ EelBackground *self)
{
- EelBackground *background;
+ if (!self->details->is_desktop) {
+ return;
+ }
- background = EEL_BACKGROUND (data);
+ GdkScreen *screen = gtk_widget_get_screen (widget);
+ GdkWindow *window = gdk_screen_get_root_window (screen);
- if (background->details->is_desktop)
+ if (self->details->screen_size_handler > 0)
{
- GdkWindow *root_window;
- GdkScreen *screen;
-
- screen = gtk_widget_get_screen (widget);
-
- if (background->details->screen_size_handler > 0)
- {
- g_signal_handler_disconnect (screen,
- background->details->screen_size_handler);
- }
-
- background->details->screen_size_handler =
- g_signal_connect (screen, "size_changed",
- G_CALLBACK (screen_size_changed), background);
- if (background->details->screen_monitors_handler > 0)
- {
- g_signal_handler_disconnect (screen,
- background->details->screen_monitors_handler);
- }
- background->details->screen_monitors_handler =
- g_signal_connect (screen, "monitors-changed",
- G_CALLBACK (screen_size_changed), background);
+ g_signal_handler_disconnect (screen, self->details->screen_size_handler);
+ }
+ self->details->screen_size_handler =
+ g_signal_connect (screen, "size_changed", G_CALLBACK (screen_size_changed), self);
- root_window = gdk_screen_get_root_window(screen);
+ if (self->details->screen_monitors_handler > 0)
+ {
+ g_signal_handler_disconnect (screen, self->details->screen_monitors_handler);
+ }
+ self->details->screen_monitors_handler =
+ g_signal_connect (screen, "monitors-changed", G_CALLBACK (screen_size_changed), self);
- if (gdk_window_get_visual(root_window) == gtk_widget_get_visual(widget))
- {
- background->details->use_common_surface = TRUE;
- }
- else
- {
- background->details->use_common_surface = FALSE;
- }
+ self->details->use_common_surface =
+ (gdk_window_get_visual (window) == gtk_widget_get_visual (widget)) ? TRUE : FALSE;
- init_fade (background, widget);
- }
+ init_fade (self);
}
static void
-widget_realize_cb (GtkWidget *widget, gpointer data)
+widget_realize_cb (GtkWidget *widget,
+ gpointer user_data)
{
- EelBackground *background;
-
- background = EEL_BACKGROUND (data);
+ EelBackground *self = EEL_BACKGROUND (user_data);
- widget_realized_setup (widget, data);
+ widget_realized_setup (widget, self);
- eel_background_set_up_widget (background, widget);
+ eel_background_set_up_widget (self);
}
static void
-widget_unrealize_cb (GtkWidget *widget, gpointer data)
+widget_unrealize_cb (GtkWidget *widget,
+ gpointer user_data)
{
- EelBackground *background;
+ EelBackground *self = EEL_BACKGROUND (user_data);
- background = EEL_BACKGROUND (data);
-
- if (background->details->screen_size_handler > 0)
- {
+ if (self->details->screen_size_handler > 0) {
g_signal_handler_disconnect (gtk_widget_get_screen (GTK_WIDGET (widget)),
- background->details->screen_size_handler);
- background->details->screen_size_handler = 0;
+ self->details->screen_size_handler);
+ self->details->screen_size_handler = 0;
}
- if (background->details->screen_monitors_handler > 0)
- {
- g_signal_handler_disconnect (gtk_widget_get_screen (GTK_WIDGET (widget)),
- background->details->screen_monitors_handler);
- background->details->screen_monitors_handler = 0;
- }
- background->details->use_common_surface = FALSE;
-}
-void
-eel_background_set_desktop (EelBackground *background, GtkWidget *widget, gboolean is_desktop)
-{
- background->details->is_desktop = is_desktop;
-
- if (gtk_widget_get_realized (widget) && background->details->is_desktop)
- {
- widget_realized_setup (widget, background);
+ if (self->details->screen_monitors_handler > 0) {
+ g_signal_handler_disconnect (gtk_widget_get_screen (GTK_WIDGET (widget)),
+ self->details->screen_monitors_handler);
+ self->details->screen_monitors_handler = 0;
}
-}
-
-gboolean
-eel_background_is_desktop (EelBackground *background)
-{
- return background->details->is_desktop;
+ self->details->use_common_surface = FALSE;
}
static void
-on_widget_destroyed (GtkWidget *widget, EelBackground *background)
+on_widget_destroyed (GtkWidget *widget,
+ gpointer user_data)
{
- if (background->details->change_idle_id != 0)
- {
- g_source_remove (background->details->change_idle_id);
- background->details->change_idle_id = 0;
+ EelBackground *self = EEL_BACKGROUND (user_data);
+
+ if (self->details->change_idle_id != 0) {
+ g_source_remove (self->details->change_idle_id);
+ self->details->change_idle_id = 0;
}
- background->details->widget = NULL;
+ free_fade (self);
+ self->details->widget = NULL;
}
/* Gets the background attached to a widget.
@@ -1027,8 +750,8 @@ on_widget_destroyed (GtkWidget *widget, EelBackground *background)
just call eel_background methods on the widget.
If the widget is a canvas, nothing more needs to be done. For
- normal widgets, you need to call eel_background_expose() from your
- expose handler to draw the background.
+ normal widgets, you need to call eel_background_draw() from your
+ draw/expose handler to draw the background.
Later, we might want a call to find out if we already have a background,
or a way to share the same background among multiple widgets; both would
@@ -1037,13 +760,11 @@ on_widget_destroyed (GtkWidget *widget, EelBackground *background)
EelBackground *
eel_get_widget_background (GtkWidget *widget)
{
- gpointer data;
- EelBackground *background;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
/* Check for an existing background. */
- data = g_object_get_data (G_OBJECT (widget), "eel_background");
+ gpointer data = g_object_get_data (G_OBJECT (widget), "eel_background");
if (data != NULL)
{
g_assert (EEL_IS_BACKGROUND (data));
@@ -1051,56 +772,276 @@ eel_get_widget_background (GtkWidget *widget)
}
/* Store the background in the widget's data. */
- background = eel_background_new ();
+ EelBackground *self = eel_background_new ();
g_object_set_data_full (G_OBJECT (widget), "eel_background",
- background, g_object_unref);
- background->details->widget = widget;
- g_signal_connect_object (widget, "destroy", G_CALLBACK (on_widget_destroyed), background, 0);
-
- /* Arrange to get the signal whenever the background changes. */
- g_signal_connect_object (background, "appearance_changed",
- G_CALLBACK (eel_widget_queue_background_change), widget, G_CONNECT_SWAPPED);
- eel_widget_queue_background_change (widget);
+ self, g_object_unref);
+ self->details->widget = widget;
- g_signal_connect_object (widget, "style_set",
- G_CALLBACK (widget_style_set_cb),
- background,
- 0);
+ g_signal_connect_object (widget, "destroy",
+ G_CALLBACK (on_widget_destroyed), self, 0);
g_signal_connect_object (widget, "realize",
- G_CALLBACK (widget_realize_cb),
- background,
- 0);
+ G_CALLBACK (widget_realize_cb), self, 0);
g_signal_connect_object (widget, "unrealize",
- G_CALLBACK (widget_unrealize_cb),
- background,
- 0);
+ G_CALLBACK (widget_unrealize_cb), self, 0);
+
+ g_signal_connect_object (widget, "style_set",
+ G_CALLBACK (widget_style_set_cb), self, 0);
+
+ /* Arrange to get the signal whenever the background changes. */
+ g_signal_connect_object (self, "appearance_changed",
+ G_CALLBACK (widget_queue_background_change),
+ widget, G_CONNECT_SWAPPED);
+ widget_queue_background_change (widget, self);
+
+ return self;
+}
+
+static void
+eel_background_class_init (EelBackgroundClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- return background;
+ signals[APPEARANCE_CHANGED] =
+ g_signal_new ("appearance_changed", G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (EelBackgroundClass, appearance_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ signals[SETTINGS_CHANGED] =
+ g_signal_new ("settings_changed", G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (EelBackgroundClass, settings_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+
+ signals[RESET] =
+ g_signal_new ("reset", G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (EelBackgroundClass, reset),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ object_class->finalize = eel_background_finalize;
+
+ g_type_class_add_private (klass, sizeof (EelBackgroundDetails));
+}
+
+static void
+eel_background_init (EelBackground *self)
+{
+ self->details =
+ G_TYPE_INSTANCE_GET_PRIVATE (self,
+ EEL_TYPE_BACKGROUND,
+ EelBackgroundDetails);
+
+ self->details->bg = mate_bg_new ();
+ self->details->default_color.red = 0xffff;
+ self->details->default_color.green = 0xffff;
+ self->details->default_color.blue = 0xffff;
+ self->details->is_active = TRUE;
+
+ g_signal_connect (self->details->bg, "changed",
+ G_CALLBACK (eel_background_changed), self);
+ g_signal_connect (self->details->bg, "transitioned",
+ G_CALLBACK (eel_background_transitioned), self);
+
+}
+
+/**
+ * eel_background_is_set:
+ *
+ * Check whether the background's color or image has been set.
+ */
+gboolean
+eel_background_is_set (EelBackground *self)
+{
+ g_assert (EEL_IS_BACKGROUND (self));
+
+ return self->details->color != NULL ||
+ mate_bg_get_filename (self->details->bg) != NULL;
+}
+
+/**
+ * eel_background_reset:
+ *
+ * Emit the reset signal to forget any color or image that has been
+ * set previously.
+ */
+void
+eel_background_reset (EelBackground *self)
+{
+ g_return_if_fail (EEL_IS_BACKGROUND (self));
+
+ g_signal_emit (self, signals[RESET], 0);
+}
+
+void
+eel_background_set_desktop (EelBackground *self,
+ GtkWidget *widget,
+ gboolean is_desktop)
+{
+ self->details->is_desktop = is_desktop;
+
+ if (gtk_widget_get_realized (widget) && is_desktop)
+ {
+ widget_realized_setup (widget, self);
+ }
+}
+
+gboolean
+eel_background_is_desktop (EelBackground *self)
+{
+ return self->details->is_desktop;
+}
+
+void
+eel_background_set_active (EelBackground *self,
+ gboolean is_active)
+{
+ if (self->details->is_active != is_active)
+ {
+ self->details->is_active = is_active;
+ set_image_properties (self);
+ }
}
/* determine if a background is darker or lighter than average, to help clients know what
colors to draw on top with */
gboolean
-eel_background_is_dark (EelBackground *background)
+eel_background_is_dark (EelBackground *self)
{
- GdkScreen *screen;
GdkRectangle rect;
/* only check for the background on the 0th monitor */
- screen = gdk_screen_get_default ();
+ GdkScreen *screen = gdk_screen_get_default ();
gdk_screen_get_monitor_geometry (screen, 0, &rect);
- return mate_bg_is_dark (background->details->bg, rect.width, rect.height);
+ return mate_bg_is_dark (self->details->bg, rect.width, rect.height);
+}
+
+gchar *
+eel_background_get_image_uri (EelBackground *self)
+{
+ g_return_val_if_fail (EEL_IS_BACKGROUND (self), NULL);
+
+ const gchar *filename = mate_bg_get_filename (self->details->bg);
+
+ if (filename) {
+ return g_filename_to_uri (filename, NULL, NULL);
+ }
+ return NULL;
+}
+
+static void
+eel_bg_set_image_uri_helper (EelBackground *self,
+ const gchar *image_uri,
+ gboolean emit_signal)
+{
+ gchar *filename = g_strdup (""); /* GSettings expects a string, not NULL */
+
+ if (image_uri != NULL)
+ filename = g_filename_from_uri (image_uri, NULL, NULL);
+
+ mate_bg_set_filename (self->details->bg, filename);
+
+ if (emit_signal)
+ g_signal_emit (self, signals[SETTINGS_CHANGED], 0, GDK_ACTION_COPY);
+
+ set_image_properties (self);
+
+ g_free (filename);
+}
+
+/* Use this function to set an image only (no color).
+ * Also, to unset an image, use: eel_bg_set_image_uri (background, NULL)
+ */
+void
+eel_background_set_image_uri (EelBackground *self,
+ const gchar *image_uri)
+{
+ eel_bg_set_image_uri_helper (self, image_uri, TRUE);
+}
+
+/* Use this fn to set both the image and color and avoid flash. The color isn't
+ * changed till after the image is done loading, that way if an update occurs
+ * before then, it will use the old color and image.
+ */
+static void
+eel_bg_set_image_uri_and_color (EelBackground *self,
+ GdkDragAction action,
+ const gchar *image_uri,
+ const gchar *color)
+{
+ if (self->details->is_desktop &&
+ !mate_bg_get_draw_background (self->details->bg))
+ {
+ mate_bg_set_draw_background (self->details->bg, TRUE);
+ }
+
+ eel_bg_set_image_uri_helper (self, image_uri, FALSE);
+ eel_background_set_color (self, color);
+
+ /* We always emit, even if the color didn't change, because the image change
+ relies on us doing it here. */
+ g_signal_emit (self, signals[SETTINGS_CHANGED], 0, action);
+}
+
+void
+eel_bg_set_placement (EelBackground *self,
+ MateBGPlacement placement)
+{
+ if (self->details->bg)
+ mate_bg_set_placement (self->details->bg,
+ placement);
+}
+
+void
+eel_bg_save_to_gsettings (EelBackground *self,
+ GSettings *settings)
+{
+ if (self->details->bg)
+ mate_bg_save_to_gsettings (self->details->bg,
+ settings);
+}
+
+void
+eel_bg_load_from_gsettings (EelBackground *self,
+ GSettings *settings)
+{
+ if (self->details->bg)
+ mate_bg_load_from_gsettings (self->details->bg,
+ settings);
+}
+
+void
+eel_bg_load_from_system_gsettings (EelBackground *self,
+ GSettings *settings,
+ gboolean apply)
+{
+ if (self->details->bg)
+ mate_bg_load_from_system_gsettings (self->details->bg,
+ settings,
+ apply);
+}
+
+/* handle dropped images */
+void
+eel_background_set_dropped_image (EelBackground *self,
+ GdkDragAction action,
+ const gchar *image_uri)
+{
+ /* Currently, we only support tiled images. So we set the placement. */
+ mate_bg_set_placement (self->details->bg, MATE_BG_PLACEMENT_TILED);
+
+ eel_bg_set_image_uri_and_color (self, action, image_uri, NULL);
}
/* handle dropped colors */
void
-eel_background_receive_dropped_color (EelBackground *background,
- GtkWidget *widget,
- GdkDragAction action,
- int drop_location_x,
- int drop_location_y,
- const GtkSelectionData *selection_data)
+eel_background_set_dropped_color (EelBackground *self,
+ GtkWidget *widget,
+ GdkDragAction action,
+ int drop_location_x,
+ int drop_location_y,
+ const GtkSelectionData *selection_data)
{
guint16 *channels;
char *color_spec, *gradient_spec;
@@ -1108,7 +1049,7 @@ eel_background_receive_dropped_color (EelBackground *background,
int left_border, right_border, top_border, bottom_border;
GtkAllocation allocation;
- g_return_if_fail (EEL_IS_BACKGROUND (background));
+ g_return_if_fail (EEL_IS_BACKGROUND (self));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (selection_data != NULL);
@@ -1136,13 +1077,13 @@ eel_background_receive_dropped_color (EelBackground *background,
bottom_border = allocation.height - 32;
/* If a custom background color isn't set, get the GtkStyle's bg color. */
- if (!background->details->color)
+ if (!self->details->color)
{
gradient_spec = gdk_color_to_string (&gtk_widget_get_style (widget)->bg[GTK_STATE_NORMAL]);
}
else
{
- gradient_spec = g_strdup (background->details->color);
+ gradient_spec = g_strdup (self->details->color);
}
if (drop_location_x < left_border && drop_location_x <= right_border)
@@ -1169,48 +1110,37 @@ eel_background_receive_dropped_color (EelBackground *background,
g_free (color_spec);
g_free (gradient_spec);
- eel_background_set_image_uri_and_color (background, action, NULL, new_gradient_spec);
+ eel_bg_set_image_uri_and_color (self, action, NULL, new_gradient_spec);
g_free (new_gradient_spec);
}
-void
-eel_background_save_to_settings (EelBackground *background)
+EelBackground *
+eel_background_new (void)
{
- if (background->details->bg)
- mate_bg_save_to_preferences (background->details->bg);
+ return EEL_BACKGROUND (g_object_new (EEL_TYPE_BACKGROUND, NULL));
}
-void
-eel_background_set_active (EelBackground *background,
- gboolean is_active)
-{
- if (background->details->is_active != is_active)
- {
- background->details->is_active = is_active;
- set_image_properties (background);
- }
-}
-/* self check code */
+/*
+ * self check code
+ */
#if !defined (EEL_OMIT_SELF_CHECK)
void
eel_self_check_background (void)
{
- EelBackground *background;
-
- background = eel_background_new ();
+ EelBackground *self = eel_background_new ();
- eel_background_set_color (background, NULL);
- eel_background_set_color (background, "");
- eel_background_set_color (background, "red");
- eel_background_set_color (background, "red-blue");
- eel_background_set_color (background, "red-blue:h");
+ eel_background_set_color (self, NULL);
+ eel_background_set_color (self, "");
+ eel_background_set_color (self, "red");
+ eel_background_set_color (self, "red-blue");
+ eel_background_set_color (self, "red-blue:h");
- g_object_ref_sink (background);
- g_object_unref (background);
+ g_object_ref_sink (self);
+ g_object_unref (self);
}
#endif
diff --git a/eel/eel-background.h b/eel/eel-background.h
index 1c2218f3..74d370e7 100644
--- a/eel/eel-background.h
+++ b/eel/eel-background.h
@@ -3,6 +3,7 @@
eel-background.h: Object for the background of a widget.
Copyright (C) 2000 Eazel, Inc.
+ Copyright (C) 2012 Jasmine Hassan <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -20,6 +21,7 @@
Boston, MA 02110-1301, USA.
Authors: Darin Adler <[email protected]>
+ Jasmine Hassan <[email protected]>
*/
#ifndef EEL_BACKGROUND_H
@@ -45,6 +47,9 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmateui/mate-bg.h>
+
typedef struct EelBackground EelBackground;
typedef struct EelBackgroundClass EelBackgroundClass;
@@ -60,74 +65,71 @@ typedef struct EelBackgroundClass EelBackgroundClass;
#define EEL_BACKGROUND_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), EEL_TYPE_BACKGROUND, EelBackgroundClass))
-typedef enum
-{
- EEL_BACKGROUND_TILED = 0, /* zero makes this the default placement */
- EEL_BACKGROUND_CENTERED,
- EEL_BACKGROUND_SCALED,
- EEL_BACKGROUND_SCALED_ASPECT,
- EEL_BACKGROUND_ZOOM,
- EEL_BACKGROUND_SPANNED
-} EelBackgroundImagePlacement;
-
-GType eel_background_get_type (void);
-EelBackground * eel_background_new (void);
+GType eel_background_get_type (void);
+EelBackground * eel_background_new (void);
/* Calls to change a background. */
-void eel_background_set_use_base (EelBackground *background,
- gboolean use_base);
-void eel_background_set_color (EelBackground *background,
- const char *color_or_gradient);
-void eel_background_set_image_uri (EelBackground *background,
- const char *image_uri);
-
-void eel_background_reset (EelBackground *background);
-void eel_background_set_image_placement (EelBackground *background,
- EelBackgroundImagePlacement placement);
+void eel_background_set_use_base (EelBackground *self,
+ gboolean use_base);
+void eel_background_set_color (EelBackground *self,
+ const gchar *color_or_gradient);
+void eel_background_set_image_uri (EelBackground *self,
+ const gchar *image_uri);
+void eel_background_reset (EelBackground *self);
+void eel_bg_set_placement (EelBackground *self,
+ MateBGPlacement placement);
/* Should be TRUE for desktop background */
-void eel_background_set_desktop (EelBackground *background,
- GtkWidget *widget,
- gboolean is_desktop);
-gboolean eel_background_is_desktop (EelBackground *background);
+gboolean eel_background_is_desktop (EelBackground *self);
+void eel_background_set_desktop (EelBackground *self,
+ GtkWidget *widget,
+ gboolean is_desktop);
/* Calls to interrogate the current state of a background. */
-char * eel_background_get_color (EelBackground *background);
-char * eel_background_get_image_uri (EelBackground *background);
-EelBackgroundImagePlacement eel_background_get_image_placement (EelBackground *background);
-gboolean eel_background_is_dark (EelBackground *background);
-gboolean eel_background_is_set (EelBackground *background);
+gchar * eel_bg_get_desktop_color (EelBackground *self);
+gchar * eel_background_get_color (EelBackground *self);
+gchar * eel_background_get_image_uri (EelBackground *self);
+gboolean eel_background_is_dark (EelBackground *self);
+gboolean eel_background_is_set (EelBackground *self);
/* Helper function for widgets using EelBackground */
+void eel_background_draw (GtkWidget *widget,
#if GTK_CHECK_VERSION (3, 0, 0)
-void eel_background_draw (GtkWidget *widget,
- cairo_t *cr)
+ cairo_t *cr)
#else
-void eel_background_expose (GtkWidget *widget,
- GdkEventExpose *event);
+ GdkEventExpose *event);
#endif
/* Handles a dragged color being dropped on a widget to change the background color. */
-void eel_background_receive_dropped_color (EelBackground *background,
- GtkWidget *widget,
- GdkDragAction action,
- int drop_location_x,
- int drop_location_y,
- const GtkSelectionData *dropped_color);
+void eel_background_set_dropped_color (EelBackground *self,
+ GtkWidget *widget,
+ GdkDragAction action,
+ int drop_location_x,
+ int drop_location_y,
+ const GtkSelectionData
+ *dropped_color);
/* Handles a special-case image name that means "reset to default background" too. */
-void eel_background_receive_dropped_background_image (EelBackground *background,
- GdkDragAction action,
- const char *image_uri);
+void eel_background_set_dropped_image (EelBackground *self,
+ GdkDragAction action,
+ const gchar *image_uri);
/* Gets or creates a background so that it's attached to a widget. */
-EelBackground * eel_get_widget_background (GtkWidget *widget);
-void eel_background_save_to_settings (EelBackground *background);
+EelBackground * eel_get_widget_background (GtkWidget *widget);
+
+/* Thin-wrappers around mate_bg gsettings functions */
+void eel_bg_save_to_gsettings (EelBackground *self,
+ GSettings *settings);
+void eel_bg_load_from_gsettings (EelBackground *self,
+ GSettings *settings);
+void eel_bg_load_from_system_gsettings (EelBackground *self,
+ GSettings *settings,
+ gboolean apply);
-/* Set activity status of background. Inactive backgrounds are drawn in the theme's INSENSITIVE color. */
-void eel_background_set_active (EelBackground *background,
- gboolean is_active);
+/* Set bg's activity status. Inactive backgrounds are drawn in the theme's INSENSITIVE color. */
+void eel_background_set_active (EelBackground *self,
+ gboolean is_active);
typedef struct EelBackgroundDetails EelBackgroundDetails;
@@ -155,7 +157,7 @@ struct EelBackgroundClass
/* This signal is emitted when image loading is over - whether it
* was successfully loaded or not.
*/
- void (* image_loading_done) (EelBackground *background, gboolean successful_load);
+ void (* image_loading_done) (EelBackground *self, gboolean successful_load);
/* This signal is emitted when the background is reset by receiving
the reset property from a drag
diff --git a/libcaja-private/caja-directory-background.c b/libcaja-private/caja-directory-background.c
index a445aab7..58e78d72 100644
--- a/libcaja-private/caja-directory-background.c
+++ b/libcaja-private/caja-directory-background.c
@@ -2,9 +2,10 @@
/*
caja-directory-background.c: Helper for the background of a widget
- that is viewing a particular location.
+ that is viewing a particular location.
Copyright (C) 2000 Eazel, Inc.
+ Copyright (C) 2012 Jasmine Hassan <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -21,7 +22,8 @@
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
- Author: Darin Adler <[email protected]>
+ Authors: Darin Adler <[email protected]>
+ Jasmine Hassan <[email protected]>
*/
#include <config.h>
@@ -36,553 +38,203 @@
#include "caja-file-attributes.h"
#include <gtk/gtk.h>
#include <string.h>
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmateui/mate-bg.h>
-static void background_changed_callback (EelBackground *background,
- GdkDragAction action,
- CajaFile *file);
-static void background_reset_callback (EelBackground *background,
- CajaFile *file);
-
-static void saved_settings_changed_callback (CajaFile *file,
- EelBackground *background);
-
-static void caja_file_background_receive_settings_changes (EelBackground *background);
-
-static void caja_file_background_theme_changed (GSettings *settings,
- const gchar *key,
- gpointer user_data);
-
-void
-caja_connect_desktop_background_to_file_metadata (CajaIconContainer *icon_container,
- CajaFile *file)
-{
- EelBackground *background;
-
- background = eel_get_widget_background (GTK_WIDGET (icon_container));
-
- eel_background_set_desktop (background, GTK_WIDGET (icon_container), TRUE);
-
- /* Strictly speaking, we don't need to know about metadata changes, since
- * the desktop setting aren't stored there. But, hooking up to metadata
- * changes is actually a small part of what this fn does, and we do need
- * the other stuff (hooked up to background & theme changes, initialize
- * the background). Being notified of metadata changes on the file is a
- * waste, but won't hurt, so I don't think it's worth refactoring the fn
- * at this point.
- */
- caja_connect_background_to_file_metadata (GTK_WIDGET (icon_container), file, CAJA_DND_ACTION_SET_AS_FOLDER_BACKGROUND);
-
- caja_file_background_receive_settings_changes (background);
-}
+static void caja_background_changed_cb (EelBackground *background,
+ GdkDragAction action,
+ CajaFile *file);
static void
-caja_file_background_get_default_settings (char **color,
- char **image,
- EelBackgroundImagePlacement *placement)
+caja_background_get_default_settings (char **color,
+ char **image)
{
gboolean background_set;
background_set = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_BACKGROUND_SET);
if (background_set && color)
- {
*color = g_settings_get_string (caja_preferences, CAJA_PREFERENCES_BACKGROUND_COLOR);
- }
if (background_set && image)
- {
*image = g_settings_get_string (caja_preferences, CAJA_PREFERENCES_BACKGROUND_URI);
- }
-
- if (placement)
- {
- *placement = EEL_BACKGROUND_TILED;
- }
}
-
-#define BG_PREFERENCES_DRAW_BACKGROUND "draw-background"
-#define BG_PREFERENCES_PRIMARY_COLOR "primary-color"
-#define BG_PREFERENCES_SECONDARY_COLOR "secondary-color"
-#define BG_PREFERENCES_COLOR_SHADING_TYPE "color-shading-type"
-#define BG_PREFERENCES_PICTURE_OPTIONS "picture-options"
-#define BG_PREFERENCES_PICTURE_OPACITY "picture-opacity"
-#define BG_PREFERENCES_PICTURE_FILENAME "picture-filename"
-
static void
-read_color (const char *key, GdkColor *color)
+caja_background_load_from_file_metadata (CajaFile *file,
+ EelBackground *background)
{
- gchar *tmp;
-
- tmp = g_settings_get_string (mate_background_preferences, key);
-
- if (tmp != NULL)
- {
- if (!gdk_color_parse (tmp, color))
- gdk_color_parse ("black", color);
- g_free (tmp);
- }
- else
- {
- gdk_color_parse ("black", color);
- }
-}
-
-static void
-caja_file_background_read_desktop_settings (char **color,
- char **image,
- EelBackgroundImagePlacement *placement)
-{
- gboolean enabled;
- GdkColor primary, secondary;
- gchar *tmp, *filename;
- char *end_color;
- char *start_color;
- gboolean use_gradient;
- gboolean is_horizontal;
-
- filename = NULL;
-
- /* Get the image filename */
- enabled = g_settings_get_boolean (mate_background_preferences, BG_PREFERENCES_DRAW_BACKGROUND);
- if (enabled)
- {
- tmp = g_settings_get_string (mate_background_preferences, BG_PREFERENCES_PICTURE_FILENAME);
- if (tmp != NULL)
- {
- if (g_utf8_validate (tmp, -1, NULL) && g_file_test (tmp, G_FILE_TEST_EXISTS))
- {
- filename = g_strdup (tmp);
- }
- else
- {
- filename = g_filename_from_utf8 (tmp, -1, NULL, NULL, NULL);
- }
- }
- g_free (tmp);
-
- if (filename != NULL && filename[0] != '\0')
- {
- *image = g_filename_to_uri (filename, NULL, NULL);
- }
- else
- {
- *image = NULL;
- }
- g_free (filename);
- }
- else
- {
- *image = NULL;
- }
-
- /* Get the placement */
- tmp = g_settings_get_string (mate_background_preferences, BG_PREFERENCES_PICTURE_OPTIONS);
- if (tmp != NULL)
- {
- if (strcmp (tmp, "wallpaper") == 0)
- {
- *placement = EEL_BACKGROUND_TILED;
- }
- else if (strcmp (tmp, "centered") == 0)
- {
- *placement = EEL_BACKGROUND_CENTERED;
- }
- else if (strcmp (tmp, "scaled") == 0)
- {
- *placement = EEL_BACKGROUND_SCALED_ASPECT;
- }
- else if (strcmp (tmp, "stretched") == 0)
- {
- *placement = EEL_BACKGROUND_SCALED;
- }
- else if (strcmp (tmp, "zoom") == 0)
- {
- *placement = EEL_BACKGROUND_ZOOM;
- }
- else if (strcmp (tmp, "spanned") == 0)
- {
- *placement = EEL_BACKGROUND_SPANNED;
- }
- else if (strcmp (tmp, "none") == 0)
- {
- g_free (*image);
-
- *placement = EEL_BACKGROUND_CENTERED;
- *image = NULL;
- }
- else
- {
- *placement = EEL_BACKGROUND_CENTERED;
- }
- }
- else
- {
- *placement = EEL_BACKGROUND_CENTERED;
- }
- g_free (tmp);
-
- /* Get the color */
- tmp = g_settings_get_string (mate_background_preferences, BG_PREFERENCES_COLOR_SHADING_TYPE);
- if (tmp != NULL)
- {
- if (strcmp (tmp, "solid") == 0)
- {
- use_gradient = FALSE;
- is_horizontal = FALSE;
- }
- else if (strcmp (tmp, "vertical-gradient") == 0)
- {
- use_gradient = TRUE;
- is_horizontal = FALSE;
- }
- else if (strcmp (tmp, "horizontal-gradient") == 0)
- {
- use_gradient = TRUE;
- is_horizontal = TRUE;
- }
- else
- {
- use_gradient = FALSE;
- is_horizontal = FALSE;
- }
- }
- else
- {
- use_gradient = FALSE;
- is_horizontal = FALSE;
- }
- g_free (tmp);
-
- read_color (BG_PREFERENCES_PRIMARY_COLOR, &primary);
- read_color (BG_PREFERENCES_SECONDARY_COLOR, &secondary);
+ char *color, *image;
- start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary));
- end_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary));
+ g_assert (EEL_IS_BACKGROUND (background));
+ g_assert (CAJA_IS_FILE (file));
+ g_assert (g_object_get_data (G_OBJECT (background), "eel_background_file") == file);
- if (use_gradient)
- {
- *color = eel_gradient_new (start_color, end_color, is_horizontal);
- }
- else
- {
- *color = g_strdup (start_color);
- }
+ color = caja_file_get_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR, NULL);
+ image = caja_file_get_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, NULL);
- g_free (start_color);
- g_free (end_color);
-}
+ /* if there's none, read the default from the theme */
+ if (color == NULL && image == NULL)
+ caja_background_get_default_settings (&color, &image);
-static int
-call_settings_changed (EelBackground *background)
-{
- CajaFile *file;
- file = g_object_get_data (G_OBJECT (background), "eel_background_file");
- if (file)
- {
- saved_settings_changed_callback (file, background);
- }
- return FALSE;
-}
+ /* Block the other handler while we are responding to changes
+ * in the metadata so it doesn't try to change the metadata.
+ */
+ g_signal_handlers_block_by_func (background, G_CALLBACK (caja_background_changed_cb), file);
-static void
-desktop_background_settings_notify_cb (GSettings *settings, gchar *key, gpointer data)
-{
- EelBackground *background;
+ eel_background_set_color (background, color);
+ /* non-tiled only available for desktop, at least for now */
+ eel_bg_set_placement (background, MATE_BG_PLACEMENT_TILED);
+ eel_background_set_image_uri (background, image);
- background = EEL_BACKGROUND (data);
+ /* Unblock the handler. */
+ g_signal_handlers_unblock_by_func (background, G_CALLBACK (caja_background_changed_cb), file);
- call_settings_changed (background);
+ g_free (color);
+ g_free (image);
}
+/* handle the file changed signal */
static void
-desktop_background_weak_notify (gpointer data,
- GObject *object)
+caja_background_settings_notify_cb (CajaFile *file,
+ EelBackground *background)
{
- g_signal_handlers_disconnect_by_func(mate_background_preferences,
- G_CALLBACK (desktop_background_settings_notify_cb),
- object);
+ caja_background_load_from_file_metadata (file, background);
}
+/* handle the theme changing */
static void
-caja_file_background_receive_settings_changes (EelBackground *background)
+caja_background_theme_notify_cb (GSettings *settings,
+ const gchar *key,
+ gpointer user_data)
{
- g_signal_connect (mate_background_preferences,
- "changed",
- G_CALLBACK (desktop_background_settings_notify_cb),
- G_OBJECT (background));
-
- g_object_weak_ref (G_OBJECT (background),
- desktop_background_weak_notify, NULL);
-}
-
-/* return true if the background is not in the default state */
-gboolean
-caja_file_background_is_set (EelBackground *background)
-{
- char *color;
- char *image;
-
- gboolean is_set;
-
- color = eel_background_get_color (background);
- image = eel_background_get_image_uri (background);
-
- is_set = (color || image);
+ CajaFile *file;
+ EelBackground *background = EEL_BACKGROUND (user_data);
- g_free (color);
- g_free (image);
+ file = g_object_get_data (G_OBJECT (background), "eel_background_file");
- return is_set;
+ if (file)
+ caja_background_settings_notify_cb (file, background);
}
/* handle the background changed signal */
static void
-background_changed_callback (EelBackground *background,
- GdkDragAction action,
- CajaFile *file)
+caja_background_changed_cb (EelBackground *background,
+ GdkDragAction action,
+ CajaFile *file)
{
- char *color;
- char *image;
-
g_assert (EEL_IS_BACKGROUND (background));
g_assert (CAJA_IS_FILE (file));
g_assert (g_object_get_data (G_OBJECT (background), "eel_background_file") == file);
+ char *color = eel_background_get_color (background);
+ char *image = eel_background_get_image_uri (background);
- color = eel_background_get_color (background);
- image = eel_background_get_image_uri (background);
+ /* Block the other handler while we are writing metadata so it doesn't
+ * try to change the background.
+ */
+ g_signal_handlers_block_by_func (file, G_CALLBACK (caja_background_settings_notify_cb),
+ background);
- if (eel_background_is_desktop (background))
+ if (action != (GdkDragAction) CAJA_DND_ACTION_SET_AS_FOLDER_BACKGROUND &&
+ action != (GdkDragAction) CAJA_DND_ACTION_SET_AS_GLOBAL_BACKGROUND)
{
- eel_background_save_to_settings (background);
+ action = (GdkDragAction) GPOINTER_TO_INT (g_object_get_data (G_OBJECT (background),
+ "default_drag_action"));
}
- else
+
+ if (action == (GdkDragAction) CAJA_DND_ACTION_SET_AS_GLOBAL_BACKGROUND)
{
- /* Block the other handler while we are writing metadata so it doesn't
- * try to change the background.
- */
- g_signal_handlers_block_by_func (
- file, G_CALLBACK (saved_settings_changed_callback), background);
-
- if (action != (GdkDragAction) CAJA_DND_ACTION_SET_AS_FOLDER_BACKGROUND &&
- action != (GdkDragAction) CAJA_DND_ACTION_SET_AS_GLOBAL_BACKGROUND)
- {
- GdkDragAction default_drag_action;
-
- default_drag_action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (background), "default_drag_action"));
-
-
- action = default_drag_action;
- }
-
- if (action == (GdkDragAction) CAJA_DND_ACTION_SET_AS_GLOBAL_BACKGROUND)
- {
- caja_file_set_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR,
- NULL,
- NULL);
-
- caja_file_set_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE,
- NULL,
- NULL);
-
- g_signal_handlers_block_by_func (caja_preferences, G_CALLBACK (caja_file_background_theme_changed), background);
-
- g_settings_set_string (caja_preferences,
- CAJA_PREFERENCES_BACKGROUND_COLOR, color ? color : "");
- g_settings_set_string (caja_preferences,
- CAJA_PREFERENCES_BACKGROUND_URI,
- image ? image : "");
- g_settings_set_boolean (caja_preferences,
- CAJA_PREFERENCES_BACKGROUND_SET, TRUE);
-
- g_signal_handlers_unblock_by_func (caja_preferences, G_CALLBACK (caja_file_background_theme_changed), background);
- }
- else
- {
- caja_file_set_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR,
- NULL,
- color);
-
- caja_file_set_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE,
- NULL,
- image);
- }
-
- /* Unblock the handler. */
- g_signal_handlers_unblock_by_func (
- file, G_CALLBACK (saved_settings_changed_callback), background);
+ caja_file_set_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR, NULL, NULL);
+ caja_file_set_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, NULL, NULL);
+
+ g_signal_handlers_block_by_func (caja_preferences,
+ G_CALLBACK (caja_background_theme_notify_cb),
+ background);
+
+ g_settings_set_string (caja_preferences,
+ CAJA_PREFERENCES_BACKGROUND_COLOR, color ? color : "");
+ g_settings_set_string (caja_preferences,
+ CAJA_PREFERENCES_BACKGROUND_URI, image ? image : "");
+
+ g_settings_set_boolean (caja_preferences, CAJA_PREFERENCES_BACKGROUND_SET, TRUE);
+
+ g_signal_handlers_unblock_by_func (caja_preferences,
+ G_CALLBACK (caja_background_theme_notify_cb),
+ background);
+ } else {
+ caja_file_set_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR, NULL, color);
+ caja_file_set_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, NULL, image);
}
+ /* Unblock the handler. */
+ g_signal_handlers_unblock_by_func (file, G_CALLBACK (caja_background_settings_notify_cb),
+ background);
+
g_free (color);
g_free (image);
}
+/* handle the background reset signal by setting values from the current theme */
static void
-initialize_background_from_settings (CajaFile *file,
- EelBackground *background)
+caja_background_reset_cb (EelBackground *background,
+ CajaFile *file)
{
- char *color;
- char *image;
- EelBackgroundImagePlacement placement;
+ char *color, *image;
- g_assert (CAJA_IS_FILE (file));
- g_assert (EEL_IS_BACKGROUND (background));
- g_assert (g_object_get_data (G_OBJECT (background), "eel_background_file")
- == file);
+ /* Block the other handler while we are writing metadata so it doesn't
+ * try to change the background.
+ */
+ g_signal_handlers_block_by_func (file, G_CALLBACK (caja_background_settings_notify_cb),
+ background);
- if (eel_background_is_desktop (background))
+ color = caja_file_get_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR, NULL);
+ image = caja_file_get_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, NULL);
+ if (!color && !image)
{
- caja_file_background_read_desktop_settings (&color, &image, &placement);
+ g_signal_handlers_block_by_func (caja_preferences,
+ G_CALLBACK (caja_background_theme_notify_cb),
+ background);
+ g_settings_set_boolean (caja_preferences, CAJA_PREFERENCES_BACKGROUND_SET, FALSE);
+ g_signal_handlers_unblock_by_func (caja_preferences,
+ G_CALLBACK (caja_background_theme_notify_cb),
+ background);
}
else
{
- color = caja_file_get_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR,
- NULL);
- image = caja_file_get_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE,
- NULL);
- placement = EEL_BACKGROUND_TILED; /* non-tiled only avail for desktop, at least for now */
-
- /* if there's none, read the default from the theme */
- if (color == NULL && image == NULL)
- {
- caja_file_background_get_default_settings
- (&color, &image, &placement);
- }
+ /* reset the metadata */
+ caja_file_set_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR, NULL, NULL);
+ caja_file_set_metadata (file, CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, NULL, NULL);
}
-
- /* Block the other handler while we are responding to changes
- * in the metadata so it doesn't try to change the metadata.
- */
- g_signal_handlers_block_by_func
- (background,
- G_CALLBACK (background_changed_callback),
- file);
-
- eel_background_set_color (background, color);
- eel_background_set_image_uri (background, image);
- eel_background_set_image_placement (background, placement);
-
- /* Unblock the handler. */
- g_signal_handlers_unblock_by_func
- (background,
- G_CALLBACK (background_changed_callback),
- file);
-
g_free (color);
g_free (image);
-}
-/* handle the file changed signal */
-static void
-saved_settings_changed_callback (CajaFile *file,
- EelBackground *background)
-{
- initialize_background_from_settings (file, background);
-}
-
-/* handle the theme changing */
-static void
-caja_file_background_theme_changed (GSettings *settings,
- const gchar *key,
- gpointer user_data)
-{
- CajaFile *file;
- EelBackground *background;
-
- background = EEL_BACKGROUND (user_data);
- file = g_object_get_data (G_OBJECT (background), "eel_background_file");
- if (file)
- {
- saved_settings_changed_callback (file, background);
- }
-}
-
-/* handle the background reset signal by setting values from the current theme */
-static void
-background_reset_callback (EelBackground *background,
- CajaFile *file)
-{
- char *color;
- char *image;
-
- if (!eel_background_is_desktop (background))
- {
- /* Block the other handler while we are writing metadata so it doesn't
- * try to change the background.
- */
- g_signal_handlers_block_by_func (
- file,
- G_CALLBACK (saved_settings_changed_callback),
- background);
-
- color = caja_file_get_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR,
- NULL);
- image = caja_file_get_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE,
- NULL);
- if (!color && !image)
- {
- g_signal_handlers_block_by_func (caja_preferences, G_CALLBACK (caja_file_background_theme_changed), background);
- g_settings_set_boolean (caja_preferences,
- CAJA_PREFERENCES_BACKGROUND_SET,
- FALSE);
- g_signal_handlers_unblock_by_func (caja_preferences, G_CALLBACK (caja_file_background_theme_changed), background);
- }
- else
- {
- /* reset the metadata */
- caja_file_set_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_COLOR,
- NULL,
- NULL);
-
- caja_file_set_metadata (file,
- CAJA_METADATA_KEY_LOCATION_BACKGROUND_IMAGE,
- NULL,
- NULL);
- }
- g_free (color);
- g_free (image);
-
- /* Unblock the handler. */
- g_signal_handlers_unblock_by_func (
- file,
- G_CALLBACK (saved_settings_changed_callback),
- background);
- }
+ /* Unblock the handler. */
+ g_signal_handlers_unblock_by_func (file, G_CALLBACK (caja_background_settings_notify_cb),
+ background);
- saved_settings_changed_callback (file, background);
+ caja_background_settings_notify_cb (file, background);
}
/* handle the background destroyed signal */
static void
-background_weak_notify (gpointer data,
- GObject *background)
+caja_background_weak_notify (gpointer data,
+ GObject *background)
{
CajaFile *file = CAJA_FILE (data);
- g_signal_handlers_disconnect_by_func
- (file,
- G_CALLBACK (saved_settings_changed_callback), background);
+ g_signal_handlers_disconnect_by_func (file, G_CALLBACK (caja_background_settings_notify_cb),
+ background);
caja_file_monitor_remove (file, background);
- g_signal_handlers_disconnect_by_func (caja_preferences,
- caja_file_background_theme_changed,
+ g_signal_handlers_disconnect_by_func (caja_preferences, caja_background_theme_notify_cb,
background);
}
/* key routine that hooks up a background and location */
void
-caja_connect_background_to_file_metadata (GtkWidget *widget,
- CajaFile *file,
- GdkDragAction default_drag_action)
+caja_connect_background_to_file_metadata (GtkWidget *widget,
+ CajaFile *file,
+ GdkDragAction default_drag_action)
{
EelBackground *background;
gpointer old_file;
@@ -593,9 +245,7 @@ caja_connect_background_to_file_metadata (GtkWidget *widget,
/* Check if it is already connected. */
old_file = g_object_get_data (G_OBJECT (background), "eel_background_file");
if (old_file == file)
- {
return;
- }
/* Disconnect old signal handlers. */
if (old_file != NULL)
@@ -603,23 +253,19 @@ caja_connect_background_to_file_metadata (GtkWidget *widget,
g_assert (CAJA_IS_FILE (old_file));
g_signal_handlers_disconnect_by_func (background,
- G_CALLBACK (background_changed_callback),
- old_file);
-
+ G_CALLBACK (caja_background_changed_cb), old_file);
g_signal_handlers_disconnect_by_func (background,
- G_CALLBACK (background_reset_callback),
- old_file);
+ G_CALLBACK (caja_background_reset_cb), old_file);
- g_object_weak_unref (G_OBJECT (background), background_weak_notify, old_file);
+ g_object_weak_unref (G_OBJECT (background), caja_background_weak_notify, old_file);
g_signal_handlers_disconnect_by_func (old_file,
- G_CALLBACK (saved_settings_changed_callback),
+ G_CALLBACK (caja_background_settings_notify_cb),
background);
caja_file_monitor_remove (old_file, background);
- g_signal_handlers_disconnect_by_func (caja_preferences,
- caja_file_background_theme_changed,
+ g_signal_handlers_disconnect_by_func (caja_preferences, caja_background_theme_notify_cb,
background);
}
@@ -628,42 +274,135 @@ caja_connect_background_to_file_metadata (GtkWidget *widget,
g_object_set_data_full (G_OBJECT (background), "eel_background_file",
file, (GDestroyNotify) caja_file_unref);
- g_object_set_data (G_OBJECT (background), "default_drag_action", GINT_TO_POINTER (default_drag_action));
+ g_object_set_data (G_OBJECT (background), "default_drag_action",
+ GINT_TO_POINTER (default_drag_action));
/* Connect new signal handlers. */
if (file != NULL)
{
g_signal_connect_object (background, "settings_changed",
- G_CALLBACK (background_changed_callback), file, 0);
+ G_CALLBACK (caja_background_changed_cb), file, 0);
g_signal_connect_object (background, "reset",
- G_CALLBACK (background_reset_callback), file, 0);
+ G_CALLBACK (caja_background_reset_cb), file, 0);
g_signal_connect_object (file, "changed",
- G_CALLBACK (saved_settings_changed_callback), background, 0);
+ G_CALLBACK (caja_background_settings_notify_cb), background, 0);
- g_object_weak_ref (G_OBJECT (background), background_weak_notify, file);
+ g_object_weak_ref (G_OBJECT (background), caja_background_weak_notify, file);
/* arrange to receive file metadata */
- caja_file_monitor_add (file,
- background,
- CAJA_FILE_ATTRIBUTE_INFO);
+ caja_file_monitor_add (file, background, CAJA_FILE_ATTRIBUTE_INFO);
/* arrange for notification when the theme changes */
- g_signal_connect (caja_preferences,
- "changed::" CAJA_PREFERENCES_BACKGROUND_SET,
- G_CALLBACK(caja_file_background_theme_changed),
- background);
- g_signal_connect (caja_preferences,
- "changed::" CAJA_PREFERENCES_BACKGROUND_COLOR,
- G_CALLBACK(caja_file_background_theme_changed),
- background);
- g_signal_connect (caja_preferences,
- "changed::" CAJA_PREFERENCES_BACKGROUND_URI,
- G_CALLBACK(caja_file_background_theme_changed),
- background);
+ g_signal_connect (caja_preferences, "changed::" CAJA_PREFERENCES_BACKGROUND_SET,
+ G_CALLBACK(caja_background_theme_notify_cb), background);
+ g_signal_connect (caja_preferences, "changed::" CAJA_PREFERENCES_BACKGROUND_COLOR,
+ G_CALLBACK(caja_background_theme_notify_cb), background);
+ g_signal_connect (caja_preferences, "changed::" CAJA_PREFERENCES_BACKGROUND_URI,
+ G_CALLBACK(caja_background_theme_notify_cb), background);
}
/* Update the background based on the file metadata. */
- initialize_background_from_settings (file, background);
+ caja_background_load_from_file_metadata (file, background);
+}
+
+/**
+ * DESKTOP BACKGROUND HANDLING
+ */
+
+/* handle the desktop background "settings_changed" signal */
+static void
+desktop_background_changed_cb (EelBackground *background,
+ GdkDragAction action,
+ gpointer user_data)
+{
+ eel_bg_save_to_gsettings (background,
+ mate_background_preferences);
+}
+
+/* delayed initializor of desktop background after GSettings changes */
+static gboolean
+desktop_background_prefs_change_event_idle_cb (EelBackground *background)
+{
+ eel_bg_load_from_gsettings (background,
+ mate_background_preferences);
+
+ eel_background_set_color (background,
+ eel_bg_get_desktop_color (background));
+
+ g_object_unref (background);
+
+ return FALSE; /* remove from the list of event sources */
+}
+
+/* handle the desktop background "reset" signal: reset to schema's defaults */
+static void
+desktop_background_reset_cb (EelBackground *background,
+ gpointer user_data)
+{
+ /* Reset to defaults, and save */
+ eel_bg_load_from_system_gsettings (background,
+ mate_background_preferences,
+ TRUE);
+ /* Reload from saved settings */
+ g_idle_add ((GSourceFunc) desktop_background_prefs_change_event_idle_cb,
+ g_object_ref (background));
+}
+
+/* handle the desktop GSettings "change-event" (batch changes) signal */
+static gboolean
+desktop_background_prefs_change_event_cb (GSettings *settings,
+ gpointer keys,
+ gint n_keys,
+ gpointer user_data)
+{
+ EelBackground *background = user_data;
+
+ /* Defer signal processing to avoid making the dconf backend deadlock, and
+ * hold a ref to avoid accessing fields of an object that was destroyed.
+ */
+ g_idle_add ((GSourceFunc) desktop_background_prefs_change_event_idle_cb,
+ g_object_ref (background));
+
+ return FALSE; /* let the event propagate further */
+}
+
+static void
+desktop_background_weak_notify (gpointer data,
+ GObject *object)
+{
+ g_signal_handlers_disconnect_by_func (mate_background_preferences,
+ G_CALLBACK (desktop_background_prefs_change_event_cb),
+ object);
+}
+
+void
+caja_connect_desktop_background_to_settings (CajaIconContainer *icon_container)
+{
+ EelBackground *background;
+
+ background = eel_get_widget_background (GTK_WIDGET (icon_container));
+
+ eel_background_set_desktop (background,
+ GTK_WIDGET (icon_container), TRUE);
+
+ g_signal_connect_object (background, "settings_changed",
+ G_CALLBACK (desktop_background_changed_cb), NULL, 0);
+
+ g_signal_connect_object (background, "reset",
+ G_CALLBACK (desktop_background_reset_cb), NULL, 0);
+
+ eel_bg_load_from_gsettings (background,
+ mate_background_preferences);
+
+ /* Connect to "change-event" signal to receive *groups of changes* before
+ * they are split out into multiple emissions of the "changed" signal.
+ */
+ g_signal_connect (mate_background_preferences, "change-event",
+ G_CALLBACK (desktop_background_prefs_change_event_cb),
+ background);
+
+ g_object_weak_ref (G_OBJECT (background),
+ desktop_background_weak_notify, NULL);
}
diff --git a/libcaja-private/caja-directory-background.h b/libcaja-private/caja-directory-background.h
index 080655cf..c86e8136 100644
--- a/libcaja-private/caja-directory-background.h
+++ b/libcaja-private/caja-directory-background.h
@@ -5,6 +5,7 @@
that is viewing a particular directory.
Copyright (C) 2000 Eazel, Inc.
+ Copyright (C) 2012 Jasmine Hassan <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -21,16 +22,16 @@
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
- Author: Darin Adler <[email protected]>
+ Authors: Darin Adler <[email protected]>
+ Jasmine Hassan <[email protected]>
*/
#include <eel/eel-background.h>
#include <libcaja-private/caja-file.h>
#include <libcaja-private/caja-icon-container.h>
-void caja_connect_background_to_file_metadata (GtkWidget *widget,
- CajaFile *file,
- GdkDragAction default_drag_action);
-void caja_connect_desktop_background_to_file_metadata (CajaIconContainer *icon_container,
- CajaFile *file);
-gboolean caja_file_background_is_set (EelBackground *background);
+void caja_connect_background_to_file_metadata (GtkWidget *widget,
+ CajaFile *file,
+ GdkDragAction default_drag_action);
+
+void caja_connect_desktop_background_to_settings (CajaIconContainer *icon_container);
diff --git a/libcaja-private/caja-global-preferences.h b/libcaja-private/caja-global-preferences.h
index 0430a016..85fbe75f 100644
--- a/libcaja-private/caja-global-preferences.h
+++ b/libcaja-private/caja-global-preferences.h
@@ -30,79 +30,77 @@
G_BEGIN_DECLS
- /* Whether exit when last window destroyed */
-#define CAJA_PREFERENCES_EXIT_WITH_LAST_WINDOW "exit-with-last-window"
-
- /* Desktop Background options */
-#define CAJA_PREFERENCES_BACKGROUND_SET "background-set"
-#define CAJA_PREFERENCES_BACKGROUND_COLOR "background-color"
-#define CAJA_PREFERENCES_BACKGROUND_URI "background-uri"
-
- /* Side Pane Background options */
-#define CAJA_PREFERENCES_SIDE_PANE_BACKGROUND_SET "side-pane-background-set"
-#define CAJA_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR "side-pane-background-color"
-#define CAJA_PREFERENCES_SIDE_PANE_BACKGROUND_URI "side-pane-background-uri"
-
- /* Automount options */
-#define CAJA_PREFERENCES_MEDIA_AUTOMOUNT "automount"
-#define CAJA_PREFERENCES_MEDIA_AUTOMOUNT_OPEN "automount-open"
-
- /* Autorun options */
-#define CAJA_PREFERENCES_MEDIA_AUTORUN_NEVER "autorun-never"
-#define CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP "autorun-x-content-start-app"
-#define CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE "autorun-x-content-ignore"
-#define CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER "autorun-x-content-open-folder"
-
- /* Trash options */
+/* Whether exit when last window destroyed */
+#define CAJA_PREFERENCES_EXIT_WITH_LAST_WINDOW "exit-with-last-window"
+
+/* Desktop Background options */
+#define CAJA_PREFERENCES_BACKGROUND_SET "background-set"
+#define CAJA_PREFERENCES_BACKGROUND_COLOR "background-color"
+#define CAJA_PREFERENCES_BACKGROUND_URI "background-uri"
+
+/* Side Pane Background options */
+#define CAJA_PREFERENCES_SIDE_PANE_BACKGROUND_SET "side-pane-background-set"
+#define CAJA_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR "side-pane-background-color"
+#define CAJA_PREFERENCES_SIDE_PANE_BACKGROUND_URI "side-pane-background-uri"
+
+/* Automount options */
+#define CAJA_PREFERENCES_MEDIA_AUTOMOUNT "automount"
+#define CAJA_PREFERENCES_MEDIA_AUTOMOUNT_OPEN "automount-open"
+
+/* Autorun options */
+#define CAJA_PREFERENCES_MEDIA_AUTORUN_NEVER "autorun-never"
+#define CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP "autorun-x-content-start-app"
+#define CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE "autorun-x-content-ignore"
+#define CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER "autorun-x-content-open-folder"
+
+/* Trash options */
#define CAJA_PREFERENCES_CONFIRM_TRASH "confirm-trash"
#define CAJA_PREFERENCES_ENABLE_DELETE "enable-delete"
- /* Desktop options */
-#define CAJA_PREFERENCES_SHOW_DESKTOP "show-desktop"
-#define CAJA_PREFERENCES_DESKTOP_IS_HOME_DIR "desktop-is-home-dir"
+/* Desktop options */
+#define CAJA_PREFERENCES_DESKTOP_IS_HOME_DIR "desktop-is-home-dir"
- /* Display */
+/* Display */
#define CAJA_PREFERENCES_SHOW_HIDDEN_FILES "show-hidden-files"
#define CAJA_PREFERENCES_SHOW_ADVANCED_PERMISSIONS "show-advanced-permissions"
-#define CAJA_PREFERENCES_DATE_FORMAT "date-format"
+#define CAJA_PREFERENCES_DATE_FORMAT "date-format"
- /* Mouse */
+/* Mouse */
#define CAJA_PREFERENCES_MOUSE_USE_EXTRA_BUTTONS "mouse-use-extra-buttons"
#define CAJA_PREFERENCES_MOUSE_FORWARD_BUTTON "mouse-forward-button"
-#define CAJA_PREFERENCES_MOUSE_BACK_BUTTON "mouse-back-button"
-
- typedef enum
- {
- CAJA_DATE_FORMAT_LOCALE,
- CAJA_DATE_FORMAT_ISO,
- CAJA_DATE_FORMAT_INFORMAL
- }
- CajaDateFormat;
-
- typedef enum
- {
- CAJA_NEW_TAB_POSITION_AFTER_CURRENT_TAB,
- CAJA_NEW_TAB_POSITION_END,
- } CajaNewTabPosition;
-
- /* Sidebar panels */
+#define CAJA_PREFERENCES_MOUSE_BACK_BUTTON "mouse-back-button"
+
+typedef enum
+{
+ CAJA_DATE_FORMAT_LOCALE,
+ CAJA_DATE_FORMAT_ISO,
+ CAJA_DATE_FORMAT_INFORMAL
+} CajaDateFormat;
+
+typedef enum
+{
+ CAJA_NEW_TAB_POSITION_AFTER_CURRENT_TAB,
+ CAJA_NEW_TAB_POSITION_END,
+} CajaNewTabPosition;
+
+/* Sidebar panels */
#define CAJA_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES "show-only-directories"
- /* Single/Double click preference */
+/* Single/Double click preference */
#define CAJA_PREFERENCES_CLICK_POLICY "click-policy"
- /* Activating executable text files */
+/* Activating executable text files */
#define CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION "executable-text-activation"
- /* Installing new packages when unknown mime type activated */
+/* Installing new packages when unknown mime type activated */
#define CAJA_PREFERENCES_INSTALL_MIME_ACTIVATION "install-mime-activation"
- /* Spatial or browser mode */
+/* Spatial or browser mode */
#define CAJA_PREFERENCES_ALWAYS_USE_BROWSER "always-use-browser"
#define CAJA_PREFERENCES_NEW_TAB_POSITION "tabs-open-position"
#define CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY "always-use-location-entry"
- /* Which views should be displayed for new windows */
+/* Which views should be displayed for new windows */
#define CAJA_WINDOW_STATE_START_WITH_LOCATION_BAR "start-with-location-bar"
#define CAJA_WINDOW_STATE_START_WITH_STATUS_BAR "start-with-status-bar"
#define CAJA_WINDOW_STATE_START_WITH_SIDEBAR "start-with-sidebar"
@@ -112,12 +110,12 @@ G_BEGIN_DECLS
#define CAJA_WINDOW_STATE_MAXIMIZED "maximized"
#define CAJA_WINDOW_STATE_SIDEBAR_WIDTH "sidebar-width"
- /* Sorting order */
+/* Sorting order */
#define CAJA_PREFERENCES_SORT_DIRECTORIES_FIRST "sort-directories-first"
#define CAJA_PREFERENCES_DEFAULT_SORT_ORDER "default-sort-order"
#define CAJA_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER "default-sort-in-reverse-order"
- /* The default folder viewer - one of the two enums below */
+/* The default folder viewer - one of the two enums below */
#define CAJA_PREFERENCES_DEFAULT_FOLDER_VIEWER "default-folder-viewer"
enum
diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c
index bd642684..f114b46a 100644
--- a/libcaja-private/caja-icon-dnd.c
+++ b/libcaja-private/caja-icon-dnd.c
@@ -684,10 +684,9 @@ receive_dropped_color (CajaIconContainer *container,
"dropped color on icon container displaying %s", uri);
g_free (uri);
- eel_background_receive_dropped_color
- (eel_get_widget_background (GTK_WIDGET (container)),
- GTK_WIDGET (container),
- action, x, y, data);
+ eel_background_set_dropped_color (eel_get_widget_background (GTK_WIDGET (container)),
+ GTK_WIDGET (container),
+ action, x, y, data);
}
}
@@ -708,10 +707,8 @@ receive_dropped_tile_image (CajaIconContainer *container, GdkDragAction action,
"dropped tile image on icon container displaying %s", uri);
g_free (uri);
- eel_background_receive_dropped_background_image
- (eel_get_widget_background (GTK_WIDGET (container)),
- action,
- gtk_selection_data_get_data (data));
+ eel_background_set_dropped_image (eel_get_widget_background (GTK_WIDGET (container)),
+ action, gtk_selection_data_get_data (data));
}
}
@@ -1260,17 +1257,14 @@ caja_icon_container_receive_dropped_icons (CajaIconContainer *container,
action |= CAJA_DND_ACTION_SET_AS_BACKGROUND;
}
}
- real_action = caja_drag_drop_action_ask
- (GTK_WIDGET (container), action);
+ real_action = caja_drag_drop_action_ask (GTK_WIDGET (container), action);
}
if (real_action == (GdkDragAction) CAJA_DND_ACTION_SET_AS_BACKGROUND)
{
selected_item = container->details->dnd_info->drag_info.selection_list->data;
- eel_background_receive_dropped_background_image
- (eel_get_widget_background (GTK_WIDGET (container)),
- real_action,
- selected_item->uri);
+ eel_background_set_dropped_image (eel_get_widget_background (GTK_WIDGET (container)),
+ real_action, selected_item->uri);
return;
}
diff --git a/libcaja-private/org.mate.caja.gschema.xml.in b/libcaja-private/org.mate.caja.gschema.xml.in
index 6e9ad411..5ae3e1a1 100644
--- a/libcaja-private/org.mate.caja.gschema.xml.in
+++ b/libcaja-private/org.mate.caja.gschema.xml.in
@@ -181,11 +181,6 @@
<_summary>Reverse sort order in new windows</_summary>
<_description>If true, files in new windows will be sorted in reverse order. ie, if sorted by name, then instead of sorting the files from "a" to "z", they will be sorted from "z" to "a"; if sorted by size, instead of being incrementally they will be sorted decrementally.</_description>
</key>
- <key name="show-desktop" type="b">
- <default>true</default>
- <_summary>Caja handles drawing the desktop</_summary>
- <_description>If set to true, then Caja will draw the icons on the desktop.</_description>
- </key>
<key name="desktop-is-home-dir" type="b">
<default>false</default>
<_summary>Caja uses the users home folder as the desktop</_summary>
diff --git a/src/caja-application.c b/src/caja-application.c
index 47a956c4..f09e2720 100644
--- a/src/caja-application.c
+++ b/src/caja-application.c
@@ -74,6 +74,8 @@
#include <libcaja-private/caja-signaller.h>
#include <libcaja-extension/caja-menu-provider.h>
#include <libcaja-private/caja-autorun.h>
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmateui/mate-bg.h>
#include "glibcompat.h" /* for g_list_free_full */
@@ -964,7 +966,7 @@ caja_application_startup (CajaApplication *application,
char *accel_map_filename;
if (!no_desktop &&
- !g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_SHOW_DESKTOP))
+ !g_settings_get_boolean (mate_background_preferences, MATE_BG_KEY_SHOW_DESKTOP))
{
no_desktop = TRUE;
}
@@ -989,7 +991,8 @@ caja_application_startup (CajaApplication *application,
}
/* Monitor the preference to show or hide the desktop */
- g_signal_connect_swapped (caja_preferences, "changed::" CAJA_PREFERENCES_SHOW_DESKTOP,
+ g_signal_connect_swapped (mate_background_preferences,
+ "changed::" MATE_BG_KEY_SHOW_DESKTOP,
G_CALLBACK(desktop_changed_callback),
G_OBJECT (application));
@@ -1567,7 +1570,7 @@ desktop_changed_callback (gpointer user_data)
CajaApplication *application;
application = CAJA_APPLICATION (user_data);
- if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_SHOW_DESKTOP))
+ if (g_settings_get_boolean (mate_background_preferences, MATE_BG_KEY_SHOW_DESKTOP))
{
caja_application_open_desktop (application);
}
diff --git a/src/caja-information-panel.c b/src/caja-information-panel.c
index 5e7fb3dd..89891410 100644
--- a/src/caja-information-panel.c
+++ b/src/caja-information-panel.c
@@ -488,6 +488,7 @@ receive_dropped_uri_list (CajaInformationPanel *information_panel,
char **uris;
gboolean exactly_one;
GtkWindow *window;
+ EelBackground *background;
uris = g_uri_list_extract_uris ((gchar *) gtk_selection_data_get_data (selection_data));
exactly_one = uris[0] != NULL && (uris[1] == NULL || uris[1][0] == '\0');
@@ -504,22 +505,19 @@ receive_dropped_uri_list (CajaInformationPanel *information_panel,
{
if (action == GDK_ACTION_ASK)
{
- action = caja_drag_drop_background_ask (GTK_WIDGET (information_panel), CAJA_DND_ACTION_SET_AS_BACKGROUND | CAJA_DND_ACTION_SET_AS_GLOBAL_BACKGROUND);
+ action = caja_drag_drop_background_ask (GTK_WIDGET (information_panel),
+ CAJA_DND_ACTION_SET_AS_BACKGROUND | CAJA_DND_ACTION_SET_AS_GLOBAL_BACKGROUND);
}
if (action > 0)
{
- eel_background_receive_dropped_background_image
- (eel_get_widget_background (GTK_WIDGET (information_panel)),
- action,
- uris[0]);
+ background = eel_get_widget_background (GTK_WIDGET (information_panel));
+ eel_background_set_dropped_image (background, action, uris[0]);
}
}
else if (exactly_one)
{
- g_signal_emit (information_panel,
- signals[LOCATION_CHANGED], 0,
- uris[0]);
+ g_signal_emit (information_panel, signals[LOCATION_CHANGED], 0, uris[0]);
}
break;
case ICON_PART:
@@ -584,6 +582,7 @@ receive_dropped_color (CajaInformationPanel *information_panel,
{
guint16 *channels;
char color_spec[8];
+ EelBackground *background;
if (gtk_selection_data_get_length (selection_data) != 8 ||
gtk_selection_data_get_format (selection_data) != 16)
@@ -605,16 +604,15 @@ receive_dropped_color (CajaInformationPanel *information_panel,
case BACKGROUND_PART:
if (action == GDK_ACTION_ASK)
{
- action = caja_drag_drop_background_ask (GTK_WIDGET (information_panel), CAJA_DND_ACTION_SET_AS_BACKGROUND | CAJA_DND_ACTION_SET_AS_GLOBAL_BACKGROUND);
+ action = caja_drag_drop_background_ask (GTK_WIDGET (information_panel),
+ CAJA_DND_ACTION_SET_AS_BACKGROUND | CAJA_DND_ACTION_SET_AS_GLOBAL_BACKGROUND);
}
if (action > 0)
{
- /* Let the background change based on the dropped color. */
- eel_background_receive_dropped_color
- (eel_get_widget_background (GTK_WIDGET (information_panel)),
- GTK_WIDGET (information_panel),
- action, x, y, selection_data);
+ background = eel_get_widget_background (GTK_WIDGET (information_panel));
+ eel_background_set_dropped_color (background, GTK_WIDGET (information_panel),
+ action, x, y, selection_data);
}
break;
@@ -892,9 +890,7 @@ command_button_callback (GtkWidget *button, GAppInfo *application)
static void
metadata_button_callback (GtkWidget *button, const char *command_str)
{
- CajaInformationPanel *information_panel;
-
- information_panel = CAJA_INFORMATION_PANEL (g_object_get_data (G_OBJECT (button), "user_data"));
+ //CajaInformationPanel *self = CAJA_INFORMATION_PANEL (g_object_get_data (G_OBJECT (button), "user_data"));
}
/* utility routine that allocates the command buttons from the command list */
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 931df9f8..414aae37 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -1301,7 +1301,7 @@ fm_icon_view_begin_loading (FMDirectoryView *view)
*/
if (FM_IS_DESKTOP_ICON_VIEW (view))
{
- caja_connect_desktop_background_to_file_metadata (CAJA_ICON_CONTAINER (icon_container), file);
+ caja_connect_desktop_background_to_settings (CAJA_ICON_CONTAINER (icon_container));
}
else
{
@@ -1316,10 +1316,7 @@ fm_icon_view_begin_loading (FMDirectoryView *view)
default_action = CAJA_DND_ACTION_SET_AS_FOLDER_BACKGROUND;
}
- caja_connect_background_to_file_metadata
- (icon_container,
- file,
- default_action);
+ caja_connect_background_to_file_metadata (icon_container, file, default_action);
}