summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/mate-bg-crossfade.c10
-rw-r--r--libmate-desktop/mate-bg.c359
-rw-r--r--libmate-desktop/mate-bg.h31
-rw-r--r--libmate-desktop/mate-dconf.h2
-rw-r--r--libmate-desktop/mate-desktop-item.c4
-rw-r--r--libmate-desktop/mate-desktop-utils.c5
-rw-r--r--libmate-desktop/mate-rr-labeler.c70
-rw-r--r--libmate-desktop/mate-rr-labeler.h15
8 files changed, 476 insertions, 20 deletions
diff --git a/libmate-desktop/mate-bg-crossfade.c b/libmate-desktop/mate-bg-crossfade.c
index 3242004..716c782 100644
--- a/libmate-desktop/mate-bg-crossfade.c
+++ b/libmate-desktop/mate-bg-crossfade.c
@@ -277,9 +277,19 @@ tile_surface (cairo_surface_t *surface,
}
else
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_context;
+ style_context = gtk_style_context_new();
+ GdkRGBA color;
+ gtk_style_context_get(style_context, GTK_STATE_FLAG_NORMAL,
+ GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &color,
+ NULL);
+ gdk_cairo_set_source_rgba(cr, &color);
+#else
GtkStyle *style;
style = gtk_widget_get_default_style ();
gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_NORMAL]);
+#endif
}
cairo_paint (cr);
diff --git a/libmate-desktop/mate-bg.c b/libmate-desktop/mate-bg.c
index 83efcd3..0bb7dcb 100644
--- a/libmate-desktop/mate-bg.c
+++ b/libmate-desktop/mate-bg.c
@@ -101,8 +101,13 @@ struct _MateBG {
char *filename;
MateBGPlacement placement;
MateBGColorType color_type;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GdkRGBA primary;
+ GdkRGBA secondary;
+#else
GdkColor primary;
GdkColor secondary;
+#endif
gboolean is_enabled;
GFileMonitor* file_monitor;
@@ -150,17 +155,31 @@ static GdkPixbuf *pixbuf_scale_to_fit (GdkPixbuf *src,
static GdkPixbuf *pixbuf_scale_to_min (GdkPixbuf *src,
int min_width,
int min_height);
-
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void pixbuf_draw_gradient (GdkPixbuf *pixbuf,
gboolean horizontal,
GdkColor *c1,
GdkColor *c2,
GdkRectangle *rect);
+#endif
static void pixbuf_tile (GdkPixbuf *src,
- GdkPixbuf *dest);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr,
+ int width,
+ int height
+#else
+ GdkPixbuf *dest
+#endif
+ );
static void pixbuf_blend (GdkPixbuf *src,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr,
+ int dest_width,
+ int dest_height,
+#else
GdkPixbuf *dest,
+#endif
int src_x,
int src_y,
int width,
@@ -206,6 +225,20 @@ static FileSize *find_best_size (GSList *sizes,
gint width,
gint height);
+#if GTK_CHECK_VERSION(3, 0, 0)
+static void
+color_from_string(const char *string,
+ GdkRGBA *colorp)
+{
+ /* If all else fails use black */
+ if (!gdk_rgba_parse (colorp, string)) {
+ colorp->red = 0.0;
+ colorp->blue = 0.0;
+ colorp->green = 0.0;
+ colorp->alpha = 1.0;
+ }
+}
+#else
static void
color_from_string (const char *string,
GdkColor *colorp)
@@ -218,7 +251,15 @@ color_from_string (const char *string,
gdk_color_parse (string, colorp);
}
+#endif
+#if GTK_CHECK_VERSION(3, 0, 0)
+static char *
+color_to_string (const GdkRGBA *color)
+{
+ return gdk_rgba_to_string(color);
+}
+#else
static char *
color_to_string (const GdkColor *color)
{
@@ -227,6 +268,7 @@ color_to_string (const GdkColor *color)
color->green >> 8,
color->blue >> 8);
}
+#endif
static gboolean
do_changed (MateBG *bg)
@@ -360,7 +402,11 @@ mate_bg_load_from_gsettings (MateBG *bg,
char *tmp;
char *filename;
MateBGColorType ctype;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GdkRGBA c1,c2;
+#else
GdkColor c1, c2;
+#endif
MateBGPlacement placement;
g_return_if_fail (MATE_IS_BG (bg));
@@ -420,7 +466,11 @@ mate_bg_load_from_gsettings (MateBG *bg,
/* Placement */
placement = g_settings_get_enum (settings, MATE_BG_KEY_PICTURE_PLACEMENT);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ mate_bg_set_rgba (bg, ctype, &c1, &c2);
+#else
mate_bg_set_color (bg, ctype, &c1, &c2);
+#endif
mate_bg_set_placement (bg, placement);
mate_bg_set_filename (bg, filename);
@@ -545,6 +595,43 @@ mate_bg_new (void)
return g_object_new (MATE_TYPE_BG, NULL);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+void
+mate_bg_set_rgba (MateBG *bg,
+ MateBGColorType type,
+ GdkRGBA *primary,
+ GdkRGBA *secondary
+ )
+{
+ g_return_if_fail (bg != NULL);
+ g_return_if_fail (primary != NULL);
+
+ if (bg->color_type != type ||
+ !gdk_rgba_equal (&bg->primary, primary) ||
+ (secondary && !gdk_rgba_equal (&bg->secondary, secondary)))
+ {
+ bg->color_type = type;
+ bg->primary = *primary;
+ if (secondary) {
+ bg->secondary = *secondary;
+ }
+
+ queue_changed (bg);
+ }
+}
+
+static void
+color_to_rgba(const GdkColor* color, GdkRGBA* rgba)
+{
+ g_assert (color != NULL);
+ g_assert (rgba != NULL);
+ rgba->red = color->red/65535.0;
+ rgba->blue = color->blue/65535.0;
+ rgba->green = color->green/65535.0;
+ rgba->alpha = 1.0;
+}
+#endif
+
void
mate_bg_set_color (MateBG *bg,
MateBGColorType type,
@@ -554,15 +641,39 @@ mate_bg_set_color (MateBG *bg,
g_return_if_fail (bg != NULL);
g_return_if_fail (primary != NULL);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA primary_rgba;
+ GdkRGBA secondary_rgba;
+
+ color_to_rgba(primary, &primary_rgba);
+
+ if(secondary) {
+ color_to_rgba(secondary, &secondary_rgba);
+ }
+#endif
+
if (bg->color_type != type ||
+#if GTK_CHECK_VERSION (3, 0, 0)
+ !gdk_rgba_equal (&bg->primary, &primary_rgba) ||
+ (secondary && !gdk_rgba_equal (&bg->secondary, &secondary_rgba)))
+#else
!gdk_color_equal (&bg->primary, primary) ||
- (secondary && !gdk_color_equal (&bg->secondary, secondary))) {
+ (secondary && !gdk_color_equal (&bg->secondary, secondary)))
+#endif
+ {
bg->color_type = type;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ bg->primary = primary_rgba;
+ if (secondary) {
+ bg->secondary = secondary_rgba;
+ }
+#else
bg->primary = *primary;
if (secondary) {
bg->secondary = *secondary;
}
+#endif
queue_changed (bg);
}
@@ -589,11 +700,12 @@ mate_bg_get_placement (MateBG *bg)
return bg->placement;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
void
-mate_bg_get_color (MateBG *bg,
+mate_bg_get_rgba (MateBG *bg,
MateBGColorType *type,
- GdkColor *primary,
- GdkColor *secondary)
+ GdkRGBA *primary,
+ GdkRGBA *secondary)
{
g_return_if_fail (bg != NULL);
@@ -606,6 +718,31 @@ mate_bg_get_color (MateBG *bg,
if (secondary)
*secondary = bg->secondary;
}
+#endif
+
+void
+mate_bg_get_color (MateBG *bg,
+ MateBGColorType *type,
+ GdkColor *primary,
+ GdkColor *secondary)
+{
+ g_return_if_fail (bg != NULL);
+
+ if (type)
+ *type = bg->color_type;
+
+ if (primary) {
+ primary->red = bg->primary.red * 0xffff;
+ primary->green = bg->primary.green * 0xffff;
+ primary->blue = bg->primary.blue * 0xffff;
+ }
+
+ if (secondary) {
+ secondary->red = bg->secondary.red * 0xffff;
+ secondary->green = bg->secondary.green * 0xffff;
+ secondary->blue = bg->secondary.blue * 0xffff;
+ }
+}
void
mate_bg_set_draw_background (MateBG *bg,
@@ -817,12 +954,12 @@ mate_bg_set_filename (MateBG *bg,
}
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void
draw_color_area (MateBG *bg,
GdkPixbuf *dest,
GdkRectangle *rect)
{
- guint32 pixel;
GdkRectangle extent;
extent.x = 0;
@@ -833,7 +970,8 @@ draw_color_area (MateBG *bg,
gdk_rectangle_intersect (rect, &extent, rect);
switch (bg->color_type) {
- case MATE_BG_COLOR_SOLID:
+ case MATE_BG_COLOR_SOLID: {
+ guint32 pixel;
/* not really a big deal to ignore the area of interest */
pixel = ((bg->primary.red >> 8) << 24) |
((bg->primary.green >> 8) << 16) |
@@ -841,6 +979,7 @@ draw_color_area (MateBG *bg,
(0xff);
gdk_pixbuf_fill (dest, pixel);
+ }
break;
case MATE_BG_COLOR_H_GRADIENT:
@@ -855,12 +994,24 @@ draw_color_area (MateBG *bg,
break;
}
}
+#endif
static void
draw_color (MateBG *bg,
- GdkPixbuf *dest,
- GdkScreen *screen)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ gint width,
+ gint height
+#else
+ GdkPixbuf *dest
+#endif
+ )
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_cairo_set_source_rgba(cr, &(bg->primary));
+ cairo_rectangle(cr, 0, 0, width, height);
+ cairo_fill(cr);
+#else
GdkRectangle rect;
rect.x = 0;
@@ -868,8 +1019,11 @@ draw_color (MateBG *bg,
rect.width = gdk_pixbuf_get_width (dest);
rect.height = gdk_pixbuf_get_height (dest);
draw_color_area (bg, dest, &rect);
+#endif
}
+
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void
draw_color_each_monitor (MateBG *bg,
GdkPixbuf *dest,
@@ -885,6 +1039,7 @@ draw_color_each_monitor (MateBG *bg,
draw_color_area (bg, dest, &rect);
}
}
+#endif
static GdkPixbuf *
pixbuf_clip_to_fit (GdkPixbuf *src,
@@ -971,7 +1126,11 @@ static void
draw_image_area (MateBG *bg,
gint num_monitor,
GdkPixbuf *pixbuf,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr,
+#else
GdkPixbuf *dest,
+#endif
GdkRectangle *area)
{
int dest_width = area->width;
@@ -986,16 +1145,28 @@ draw_image_area (MateBG *bg,
switch (bg->placement) {
case MATE_BG_PLACEMENT_TILED:
+#if GTK_CHECK_VERSION (3, 0, 0)
+ pixbuf_tile (scaled, cr, dest_width, dest_height);
+#else
pixbuf_tile (scaled, dest);
+#endif
break;
case MATE_BG_PLACEMENT_ZOOMED:
case MATE_BG_PLACEMENT_CENTERED:
case MATE_BG_PLACEMENT_FILL_SCREEN:
case MATE_BG_PLACEMENT_SCALED:
+#if GTK_CHECK_VERSION (3, 0, 0)
+ pixbuf_blend (scaled, cr, dest_width, dest_height, 0, 0, w, h, x + area->x, y + area->y, 1.0);
+#else
pixbuf_blend (scaled, dest, 0, 0, w, h, x + area->x, y + area->y, 1.0);
+#endif
break;
case MATE_BG_PLACEMENT_SPANNED:
+#if GTK_CHECK_VERSION (3, 0, 0)
+ pixbuf_blend (scaled, cr, dest_width, dest_height, 0, 0, w, h, x, y, 1.0);
+#else
pixbuf_blend (scaled, dest, 0, 0, w, h, x, y, 1.0);
+#endif
break;
default:
g_assert_not_reached ();
@@ -1010,22 +1181,44 @@ draw_image_area (MateBG *bg,
static void
draw_image_for_thumb (MateBG *bg,
GdkPixbuf *pixbuf,
- GdkPixbuf *dest)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr,
+ gint width,
+ gint height
+#else
+ GdkPixbuf *dest
+#endif
+ )
{
GdkRectangle rect;
rect.x = 0;
rect.y = 0;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ rect.width = width;
+ rect.height = height;
+
+#else
rect.width = gdk_pixbuf_get_width (dest);
rect.height = gdk_pixbuf_get_height (dest);
+#endif
+#if GTK_CHECK_VERSION(3, 0, 0)
+ draw_image_area (bg, -1, pixbuf, cr, &rect);
+#else
draw_image_area (bg, -1, pixbuf, dest, &rect);
+#endif
}
static void
draw_once (MateBG *bg,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr,
+ gint width,
+ gint height,
+#else
GdkPixbuf *dest,
- GdkScreen *screen,
+#endif
gboolean is_root)
{
GdkRectangle rect;
@@ -1037,17 +1230,27 @@ draw_once (MateBG *bg,
rect.x = 0;
rect.y = 0;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ rect.width = width;
+ rect.height = height;
+#else
rect.width = gdk_pixbuf_get_width (dest);
rect.height = gdk_pixbuf_get_height (dest);
+#endif
pixbuf = get_pixbuf_for_size (bg, monitor, rect.width, rect.height);
if (pixbuf) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ draw_image_area (bg, monitor, pixbuf, cr, &rect);
+#else
draw_image_area (bg, monitor, pixbuf, dest, &rect);
+#endif
g_object_unref (pixbuf);
}
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void
draw_each_monitor (MateBG *bg,
GdkPixbuf *dest,
@@ -1070,25 +1273,48 @@ draw_each_monitor (MateBG *bg,
}
}
}
+#endif
void
mate_bg_draw (MateBG *bg,
+#if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ gint width,
+ gint height,
+#else
GdkPixbuf *dest,
GdkScreen *screen,
+#endif
gboolean is_root)
{
if (!bg)
return;
if (is_root && (bg->placement != MATE_BG_PLACEMENT_SPANNED)) {
+#if GTK_CHECK_VERSION(3, 0, 0)
+ draw_color (bg, cr, width, height);
+#else
draw_color_each_monitor (bg, dest, screen);
+#endif
if (bg->filename) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ draw_once (bg, cr, width, height, is_root);
+#else
draw_each_monitor (bg, dest, screen);
+#endif
}
} else {
- draw_color (bg, dest, screen);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ draw_color (bg, cr, width, height);
+#else
+ draw_color (bg, dest);
+#endif
if (bg->filename) {
- draw_once (bg, dest, screen, is_root);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ draw_once (bg, cr, width, height, is_root);
+#else
+ draw_once (bg, dest, is_root);
+#endif
}
}
}
@@ -1205,10 +1431,17 @@ mate_bg_create_pixmap (MateBG *bg,
cr = cairo_create (surface);
if (!bg->filename && bg->color_type == MATE_BG_COLOR_SOLID) {
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &(bg->primary));
+#else
gdk_cairo_set_source_color (cr, &(bg->primary));
+#endif
}
else
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_cairo_set_source_window(cr, window, 0, 0);
+#else
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
@@ -1216,6 +1449,7 @@ mate_bg_create_pixmap (MateBG *bg,
mate_bg_draw (bg, pixbuf, gdk_window_get_screen (window), is_root);
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
g_object_unref (pixbuf);
+#endif
}
cairo_paint (cr);
@@ -1234,7 +1468,11 @@ mate_bg_is_dark (MateBG *bg,
int width,
int height)
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
int intensity;
GdkPixbuf *pixbuf;
@@ -1261,9 +1499,14 @@ mate_bg_is_dark (MateBG *bg,
g_object_unref (pixbuf);
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+ // todo
+ intensity = 20;
+#else
intensity = (color.red * 77 +
color.green * 150 +
color.blue * 28) >> 16;
+#endif
return intensity < 160; /* biased slightly to be dark */
}
@@ -1401,24 +1644,44 @@ mate_bg_create_thumbnail (MateBG *bg,
int dest_width,
int dest_height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_surface_t *surface;
+#endif
GdkPixbuf *result;
GdkPixbuf *thumb;
g_return_val_if_fail (bg != NULL, NULL);
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, dest_width, dest_height);
+ cairo_t *cr = cairo_create(surface);
+ draw_color (bg, cr, dest_width, dest_height);
+#else
result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, dest_width, dest_height);
- draw_color (bg, result, screen);
+ draw_color (bg, result);
+#endif
if (bg->filename) {
thumb = create_img_thumbnail (bg, factory, screen, dest_width, dest_height, -1);
if (thumb) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ draw_image_for_thumb (bg, thumb, cr, dest_width, dest_height);
+#else
draw_image_for_thumb (bg, thumb, result);
+#endif
g_object_unref (thumb);
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_destroy(cr);
+ result = gdk_pixbuf_get_from_surface(surface, 0, 0, dest_width, dest_height);
+ cairo_surface_destroy (surface);
+#endif
+
return result;
}
@@ -1790,7 +2053,11 @@ blend (GdkPixbuf *p1,
GdkPixbuf *p2,
double alpha)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf(p1, 0, NULL);
+#else
GdkPixbuf *result = gdk_pixbuf_copy (p1);
+#endif
GdkPixbuf *tmp;
if (gdk_pixbuf_get_width (p2) != gdk_pixbuf_get_width (p1) ||
@@ -1804,7 +2071,18 @@ blend (GdkPixbuf *p1,
tmp = g_object_ref (p2);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr = cairo_create(surface);
+ int width = gdk_pixbuf_get_width(p1);
+ int height = gdk_pixbuf_get_height(p1);
+ pixbuf_blend (tmp, cr, width, height, 0, 0, -1, -1, 0, 0, alpha);
+ cairo_destroy (cr);
+
+ GdkPixbuf *result = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
+ cairo_surface_destroy (surface);
+#else
pixbuf_blend (tmp, result, 0, 0, -1, -1, 0, 0, alpha);
+#endif
g_object_unref (tmp);
@@ -2609,6 +2887,7 @@ pixbuf_scale_to_min (GdkPixbuf *src, int min_width, int min_height)
return dest;
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
static guchar *
create_gradient (const GdkColor *primary,
const GdkColor *secondary,
@@ -2639,14 +2918,12 @@ pixbuf_draw_gradient (GdkPixbuf *pixbuf,
int height;
int rowstride;
guchar *dst;
- guchar *dst_limit;
int n_channels = 3;
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
width = rect->width;
height = rect->height;
dst = gdk_pixbuf_get_pixels (pixbuf) + rect->x * n_channels + rowstride * rect->y;
- dst_limit = dst + height * rowstride;
if (horizontal) {
guchar *gradient = create_gradient (primary, secondary, width);
@@ -2682,10 +2959,17 @@ pixbuf_draw_gradient (GdkPixbuf *pixbuf,
g_free (gradient);
}
}
+#endif
static void
pixbuf_blend (GdkPixbuf *src,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_t *cr,
+ int dest_width,
+ int dest_height,
+#else
GdkPixbuf *dest,
+#endif
int src_x,
int src_y,
int src_width,
@@ -2694,8 +2978,10 @@ pixbuf_blend (GdkPixbuf *src,
int dest_y,
double alpha)
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
int dest_width = gdk_pixbuf_get_width (dest);
int dest_height = gdk_pixbuf_get_height (dest);
+#endif
int offset_x = dest_x - src_x;
int offset_y = dest_y - src_y;
@@ -2719,29 +3005,47 @@ pixbuf_blend (GdkPixbuf *src,
src_height = dest_height - dest_y;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_pixbuf(cr, src, offset_x, offset_y);
+ cairo_rectangle (cr, offset_x, offset_y, src_width, src_height);
+ cairo_paint_with_alpha (cr, alpha);
+ cairo_fill (cr);
+#else
gdk_pixbuf_composite (src, dest,
dest_x, dest_y,
src_width, src_height,
offset_x, offset_y,
1, 1, GDK_INTERP_NEAREST,
alpha * 0xFF + 0.5);
+#endif
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+pixbuf_tile (GdkPixbuf *src, cairo_t *cr, int dest_width, int dest_height)
+#else
pixbuf_tile (GdkPixbuf *src, GdkPixbuf *dest)
+#endif
{
int x, y;
int tile_width, tile_height;
+#if !GTK_CHECK_VERSION (3, 0, 0)
int dest_width = gdk_pixbuf_get_width (dest);
int dest_height = gdk_pixbuf_get_height (dest);
+#endif
tile_width = gdk_pixbuf_get_width (src);
tile_height = gdk_pixbuf_get_height (src);
for (y = 0; y < dest_height; y += tile_height) {
for (x = 0; x < dest_width; x += tile_width) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ pixbuf_blend (src, cr, dest_width, dest_height, 0, 0,
+ tile_width, tile_height, x, y, 1.0);
+#else
pixbuf_blend (src, dest, 0, 0,
tile_width, tile_height, x, y, 1.0);
+#endif
}
}
}
@@ -3212,6 +3516,9 @@ mate_bg_create_frame_thumbnail (MateBG *bg,
int frame_num)
{
SlideShow *show;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_surface_t *surface;
+#endif
GdkPixbuf *result;
GdkPixbuf *thumb;
GList *l;
@@ -3247,10 +3554,16 @@ mate_bg_create_frame_thumbnail (MateBG *bg,
if (!found)
return NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, dest_width, dest_height);
+ cairo_t *cr = cairo_create(surface);
+ draw_color(bg, cr, dest_width, dest_height);
+#else
result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, dest_width, dest_height);
- draw_color (bg, result, screen);
+ draw_color (bg, result);
+#endif
if (bg->filename) {
thumb = create_img_thumbnail (bg, factory, screen,
@@ -3258,11 +3571,21 @@ mate_bg_create_frame_thumbnail (MateBG *bg,
frame_num + skipped);
if (thumb) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ draw_image_for_thumb (bg, thumb, cr, dest_width, dest_height);
+#else
draw_image_for_thumb (bg, thumb, result);
+#endif
g_object_unref (thumb);
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_destroy (cr);
+ result = gdk_pixbuf_get_from_surface (surface, 0, 0, dest_width, dest_height);
+ cairo_surface_destroy (surface);
+#endif
+
return result;
}
diff --git a/libmate-desktop/mate-bg.h b/libmate-desktop/mate-bg.h
index f69454d..c15afca 100644
--- a/libmate-desktop/mate-bg.h
+++ b/libmate-desktop/mate-bg.h
@@ -40,6 +40,15 @@
extern "C" {
#endif
+
+#ifndef MATE_DEPRECATED_FOR
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define MATE_DEPRECATED_FOR(func) G_DEPRECATED_FOR(func)
+#else
+#define MATE_DEPRECATED_FOR(func)
+#endif
+#endif
+
#define MATE_TYPE_BG (mate_bg_get_type ())
#define MATE_BG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_BG, MateBG))
#define MATE_BG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_BG, MateBGClass))
@@ -101,6 +110,13 @@ void mate_bg_set_filename (MateBG *bg,
const char *filename);
void mate_bg_set_placement (MateBG *bg,
MateBGPlacement placement);
+#if GTK_CHECK_VERSION (3, 0, 0)
+void mate_bg_set_rgba (MateBG *bg,
+ MateBGColorType type,
+ GdkRGBA *primary,
+ GdkRGBA *secondary);
+#endif
+MATE_DEPRECATED_FOR(mate_bg_set_rgba)
void mate_bg_set_color (MateBG *bg,
MateBGColorType type,
GdkColor *primary,
@@ -110,6 +126,15 @@ void mate_bg_set_draw_background (MateBG *bg,
/* Getters */
gboolean mate_bg_get_draw_background (MateBG *bg);
MateBGPlacement mate_bg_get_placement (MateBG *bg);
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+void mate_bg_get_rgba (MateBG *bg,
+ MateBGColorType *type,
+ GdkRGBA *primary,
+ GdkRGBA *secondary);
+#endif
+
+MATE_DEPRECATED_FOR(mate_bg_get_rgba)
void mate_bg_get_color (MateBG *bg,
MateBGColorType *type,
GdkColor *primary,
@@ -118,8 +143,14 @@ const gchar * mate_bg_get_filename (MateBG *bg);
/* Drawing and thumbnailing */
void mate_bg_draw (MateBG *bg,
+#if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ gint width,
+ gint height,
+#else
GdkPixbuf *dest,
GdkScreen *screen,
+#endif
gboolean is_root);
#if GTK_CHECK_VERSION(3, 0, 0)
diff --git a/libmate-desktop/mate-dconf.h b/libmate-desktop/mate-dconf.h
index 6bb7304..5b31562 100644
--- a/libmate-desktop/mate-dconf.h
+++ b/libmate-desktop/mate-dconf.h
@@ -41,7 +41,7 @@ gboolean mate_dconf_recursive_reset (const gchar *dir,
gchar **mate_dconf_list_subdirs (const gchar *dir,
gboolean remove_trailing_slash);
-void mate_dconf_sync ();
+void mate_dconf_sync (void);
G_END_DECLS
diff --git a/libmate-desktop/mate-desktop-item.c b/libmate-desktop/mate-desktop-item.c
index eb004d9..06f585a 100644
--- a/libmate-desktop/mate-desktop-item.c
+++ b/libmate-desktop/mate-desktop-item.c
@@ -1480,7 +1480,11 @@ static void
sn_error_trap_pop (SnDisplay *display,
Display *xdisplay)
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_error_trap_pop_ignored();
+#else
gdk_error_trap_pop ();
+#endif
}
static char **
diff --git a/libmate-desktop/mate-desktop-utils.c b/libmate-desktop/mate-desktop-utils.c
index 985278f..cac00ee 100644
--- a/libmate-desktop/mate-desktop-utils.c
+++ b/libmate-desktop/mate-desktop-utils.c
@@ -195,7 +195,12 @@ mate_gdk_spawn_command_line_on_screen (GdkScreen *screen, const gchar *command,
appinfo = g_app_info_create_from_commandline (command, NULL, G_APP_INFO_CREATE_NONE, error);
if (appinfo) {
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GdkDisplay *display = gdk_screen_get_display(screen);
+ context = gdk_display_get_app_launch_context(display);
+#else
context = gdk_app_launch_context_new ();
+#endif
gdk_app_launch_context_set_screen (context, screen);
res = g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), error);
g_object_unref (context);
diff --git a/libmate-desktop/mate-rr-labeler.c b/libmate-desktop/mate-rr-labeler.c
index 2b33526..c490ed2 100644
--- a/libmate-desktop/mate-rr-labeler.c
+++ b/libmate-desktop/mate-rr-labeler.c
@@ -45,7 +45,11 @@ struct _MateRRLabeler {
int num_outputs;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GdkRGBA *palette;
+#else
GdkColor *palette;
+#endif
GtkWidget **windows;
GdkScreen *screen;
@@ -225,7 +229,11 @@ make_palette (MateRRLabeler *labeler)
g_assert (labeler->num_outputs > 0);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ labeler->palette = g_new (GdkRGBA, labeler->num_outputs);
+#else
labeler->palette = g_new (GdkColor, labeler->num_outputs);
+#endif
start_hue = 0.0; /* red */
end_hue = 2.0/3; /* blue */
@@ -240,9 +248,16 @@ make_palette (MateRRLabeler *labeler)
gtk_hsv_to_rgb (h, s, v, &r, &g, &b);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ labeler->palette[i].red = r;
+ labeler->palette[i].green = g;
+ labeler->palette[i].blue = b;
+ labeler->palette[i].alpha = 1.0;
+#else
labeler->palette[i].red = (int) (65535 * r + 0.5);
labeler->palette[i].green = (int) (65535 * g + 0.5);
labeler->palette[i].blue = (int) (65535 * b + 0.5);
+#endif
}
}
@@ -256,7 +271,11 @@ label_window_draw_event_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
label_window_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
#endif
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GdkRGBA *color;
+#else
GdkColor *color;
+#endif
GtkAllocation allocation;
color = g_object_get_data (G_OBJECT (widget), "color");
@@ -279,7 +298,11 @@ label_window_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, gpointer
/* fill */
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, color);
+#else
gdk_cairo_set_source_color (cr, color);
+#endif
cairo_rectangle (cr,
LABEL_WINDOW_EDGE_THICKNESS,
LABEL_WINDOW_EDGE_THICKNESS,
@@ -315,13 +338,21 @@ position_window (MateRRLabeler *labeler,
}
static GtkWidget *
+#if GTK_CHECK_VERSION(3, 0, 0)
+create_label_window (MateRRLabeler *labeler, MateOutputInfo *output, GdkRGBA *color)
+#else
create_label_window (MateRRLabeler *labeler, MateOutputInfo *output, GdkColor *color)
+#endif
{
GtkWidget *window;
GtkWidget *widget;
char *str;
const char *display_name;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
+#else
GdkColor black = { 0, 0, 0, 0 };
+#endif
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (window, TRUE);
@@ -363,7 +394,11 @@ create_label_window (MateRRLabeler *labeler, MateOutputInfo *output, GdkColor *c
* theme's colors, since the label is always shown against a light
* pastel background. See bgo#556050
*/
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_override_color( widget, gtk_widget_get_state_flags (widget), &black);
+#else
gtk_widget_modify_fg (widget, gtk_widget_get_state (widget), &black);
+#endif
gtk_container_add (GTK_CONTAINER (window), widget);
@@ -441,8 +476,9 @@ mate_rr_labeler_hide (MateRRLabeler *labeler)
}
+#if GTK_CHECK_VERSION (3, 0, 0)
void
-mate_rr_labeler_get_color_for_output (MateRRLabeler *labeler, MateOutputInfo *output, GdkColor *color_out)
+mate_rr_labeler_get_rgba_for_output (MateRRLabeler *labeler, MateOutputInfo *output, GdkRGBA *color_out)
{
int i;
@@ -458,6 +494,38 @@ mate_rr_labeler_get_color_for_output (MateRRLabeler *labeler, MateOutputInfo *ou
g_warning ("trying to get the color for unknown MateOutputInfo %p; returning magenta!", output);
+ color_out->red = 1.0;
+ color_out->green = 0;
+ color_out->blue = 1.0;
+ color_out->alpha = 1.0;
+}
+#endif
+
+void
+mate_rr_labeler_get_color_for_output (MateRRLabeler *labeler, MateOutputInfo *output, GdkColor *color_out)
+{
+ int i;
+
+ g_return_if_fail (MATE_IS_RR_LABELER (labeler));
+ g_return_if_fail (output != NULL);
+ g_return_if_fail (color_out != NULL);
+
+ for (i = 0; i < labeler->num_outputs; i++)
+ if (labeler->config->outputs[i] == output) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ color_out->red = labeler->palette[i].red * 0xffff;
+ color_out->green = labeler->palette[i].green * 0xffff;
+ color_out->blue = labeler->palette[i].blue * 0xffff;
+#else
+ color_out->red = labeler->palette[i].red;
+ color_out->green = labeler->palette[i].green;
+ color_out->blue = labeler->palette[i].blue;
+#endif
+ return;
+ }
+
+ g_warning ("trying to get the color for unknown MateOutputInfo %p; returning magenta!", output);
+
color_out->red = 0xffff;
color_out->green = 0;
color_out->blue = 0xffff;
diff --git a/libmate-desktop/mate-rr-labeler.h b/libmate-desktop/mate-rr-labeler.h
index 33ecb5f..d3688be 100644
--- a/libmate-desktop/mate-rr-labeler.h
+++ b/libmate-desktop/mate-rr-labeler.h
@@ -32,6 +32,8 @@
#include "mate-rr-config.h"
+#include <gtk/gtk.h>
+
#define MATE_TYPE_RR_LABELER (mate_rr_labeler_get_type ())
#define MATE_RR_LABELER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_RR_LABELER, MateRRLabeler))
#define MATE_RR_LABELER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_RR_LABELER, MateRRLabelerClass))
@@ -39,6 +41,14 @@
#define MATE_IS_RR_LABELER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_RR_LABELER))
#define MATE_RR_LABELER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_RR_LABELER, MateRRLabelerClass))
+#ifndef MATE_DEPRECATED_FOR
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define MATE_DEPRECATED_FOR(func) G_DEPRECATED_FOR(func)
+#else
+#define MATE_DEPRECATED_FOR(func)
+#endif
+#endif
+
typedef struct _MateRRLabeler MateRRLabeler;
typedef struct _MateRRLabelerClass MateRRLabelerClass;
@@ -48,6 +58,11 @@ MateRRLabeler *mate_rr_labeler_new (MateRRConfig *config);
void mate_rr_labeler_hide (MateRRLabeler *labeler);
+#if GTK_CHECK_VERSION (3, 0, 0)
+void mate_rr_labeler_get_rgba_for_output (MateRRLabeler *labeler, MateOutputInfo *output, GdkRGBA *color_out);
+#endif
+
+MATE_DEPRECATED_FOR(mate_rr_labeler_get_rgba_for_output)
void mate_rr_labeler_get_color_for_output (MateRRLabeler *labeler, MateOutputInfo *output, GdkColor *color_out);
#endif