summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/libmateui/mate-bg-crossfade.h15
-rw-r--r--libmate-desktop/libmateui/mate-bg.h26
-rw-r--r--libmate-desktop/mate-bg-crossfade.c84
-rw-r--r--libmate-desktop/mate-bg.c199
4 files changed, 222 insertions, 102 deletions
diff --git a/libmate-desktop/libmateui/mate-bg-crossfade.h b/libmate-desktop/libmateui/mate-bg-crossfade.h
index 6da8795..2f8b3cb 100644
--- a/libmate-desktop/libmateui/mate-bg-crossfade.h
+++ b/libmate-desktop/libmateui/mate-bg-crossfade.h
@@ -30,6 +30,7 @@
#endif
#include <gdk/gdk.h>
+#include <gtk/gtk.h>
#ifdef __cplusplus
extern "C" {
@@ -62,10 +63,16 @@ struct _MateBGCrossfadeClass
GType mate_bg_crossfade_get_type (void);
MateBGCrossfade *mate_bg_crossfade_new (int width, int height);
-gboolean mate_bg_crossfade_set_start_pixmap (MateBGCrossfade *fade,
- GdkPixmap *pixmap);
-gboolean mate_bg_crossfade_set_end_pixmap (MateBGCrossfade *fade,
- GdkPixmap *pixmap);
+
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gboolean mate_bg_crossfade_set_start_pixmap(MateBGCrossfade* fade, cairo_surface_t* pixmap);
+ gboolean mate_bg_crossfade_set_end_pixmap(MateBGCrossfade* fade, cairo_surface_t* pixmap);
+#else
+ gboolean mate_bg_crossfade_set_start_pixmap(MateBGCrossfade* fade, GdkPixmap* pixmap);
+ gboolean mate_bg_crossfade_set_end_pixmap(MateBGCrossfade* fade, GdkPixmap* pixmap);
+#endif
+
void mate_bg_crossfade_start (MateBGCrossfade *fade,
GdkWindow *window);
gboolean mate_bg_crossfade_is_started (MateBGCrossfade *fade);
diff --git a/libmate-desktop/libmateui/mate-bg.h b/libmate-desktop/libmateui/mate-bg.h
index 0506d86..42b0997 100644
--- a/libmate-desktop/libmateui/mate-bg.h
+++ b/libmate-desktop/libmateui/mate-bg.h
@@ -93,11 +93,13 @@ void mate_bg_draw (MateBG *bg,
GdkPixbuf *dest,
GdkScreen *screen,
gboolean is_root);
-GdkPixmap * mate_bg_create_pixmap (MateBG *bg,
- GdkWindow *window,
- int width,
- int height,
- gboolean root);
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* mate_bg_create_pixmap(MateBG* bg, GdkWindow* window, int width, int height, gboolean root);
+#else
+ GdkPixmap* mate_bg_create_pixmap(MateBG* bg, GdkWindow* window, int width, int height, gboolean root);
+#endif
+
gboolean mate_bg_get_image_size (MateBG *bg,
MateDesktopThumbnailFactory *factory,
int best_width,
@@ -125,12 +127,16 @@ GdkPixbuf * mate_bg_create_frame_thumbnail (MateBG *bg,
* if we decide to stabilize the API then we may want to make
* these object methods, drop mate_bg_create_pixmap, etc.
*/
-void mate_bg_set_pixmap_as_root (GdkScreen *screen,
- GdkPixmap *pixmap);
-MateBGCrossfade *mate_bg_set_pixmap_as_root_with_crossfade (GdkScreen *screen,
- GdkPixmap *pixmap);
-GdkPixmap *mate_bg_get_pixmap_from_root (GdkScreen *screen);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ void mate_bg_set_pixmap_as_root(GdkScreen* screen, cairo_surface_t* pixmap);
+ MateBGCrossfade* mate_bg_set_pixmap_as_root_with_crossfade(GdkScreen* screen, cairo_surface_t* pixmap);
+ cairo_surface_t* mate_bg_get_pixmap_from_root(GdkScreen* screen);
+#else
+ void mate_bg_set_pixmap_as_root(GdkScreen* screen, GdkPixmap* pixmap);
+ MateBGCrossfade* mate_bg_set_pixmap_as_root_with_crossfade(GdkScreen* screen, GdkPixmap* pixmap);
+ GdkPixmap* mate_bg_get_pixmap_from_root(GdkScreen* screen);
+#endif
#ifdef __cplusplus
}
diff --git a/libmate-desktop/mate-bg-crossfade.c b/libmate-desktop/mate-bg-crossfade.c
index 2f72046..0642c5b 100644
--- a/libmate-desktop/mate-bg-crossfade.c
+++ b/libmate-desktop/mate-bg-crossfade.c
@@ -19,7 +19,6 @@
*
* Author: Ray Strode <[email protected]>
*/
-
#include <string.h>
#include <math.h>
#include <stdarg.h>
@@ -44,8 +43,15 @@ struct _MateBGCrossfadePrivate
GdkWindow *window;
int width;
int height;
- GdkPixmap *fading_pixmap;
- GdkPixmap *end_pixmap;
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* fading_pixmap;
+ cairo_surface_t* end_pixmap;
+ #else
+ GdkPixmap* fading_pixmap;
+ GdkPixmap* end_pixmap;
+ #endif
+
gdouble start_time;
gdouble total_duration;
guint timeout_id;
@@ -219,49 +225,59 @@ mate_bg_crossfade_init (MateBGCrossfade *fade)
*
* Return value: the new #MateBGCrossfade
**/
-MateBGCrossfade *
-mate_bg_crossfade_new (int width,
- int height)
+MateBGCrossfade* mate_bg_crossfade_new(int width, int height)
{
- GObject *object;
+ GObject* object;
- object = g_object_new (MATE_TYPE_BG_CROSSFADE,
- "width", width,
- "height", height, NULL);
+ object = g_object_new(MATE_TYPE_BG_CROSSFADE,
+ "width", width,
+ "height", height,
+ NULL);
- return (MateBGCrossfade *) object;
+ return (MateBGCrossfade*) object;
}
-static GdkPixmap *
-tile_pixmap (GdkPixmap *pixmap,
- int width,
- int height)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ static cairo_surface_t* tile_pixmap(cairo_surface_t* pixmap, int width, int height)
+#else
+ static GdkPixmap* tile_pixmap(GdkPixmap* pixmap, int width, int height)
+#endif
{
- GdkPixmap *copy;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* copy;
+ #else
+ GdkPixmap* copy;
+ #endif
+
cairo_t *cr;
- copy = gdk_pixmap_new (pixmap, width, height, pixmap == NULL? 24 : -1);
+ copy = gdk_pixmap_new(pixmap, width, height, pixmap == NULL? 24 : -1);
- cr = gdk_cairo_create (copy);
+ cr = gdk_cairo_create(copy);
- if (pixmap != NULL) {
+ if (pixmap != NULL)
+ {
cairo_pattern_t *pattern;
gdk_cairo_set_source_pixmap (cr, pixmap, 0.0, 0.0);
pattern = cairo_get_source (cr);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
- } else {
+ }
+ else
+ {
GtkStyle *style;
style = gtk_widget_get_default_style ();
- gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_NORMAL]);
}
cairo_paint (cr);
- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
+ {
g_object_unref (copy);
copy = NULL;
}
- cairo_destroy (cr);
+
+ cairo_destroy(cr);
return copy;
}
@@ -278,9 +294,11 @@ tile_pixmap (GdkPixmap *pixmap,
* Return value: %TRUE if successful, or %FALSE if the pixmap
* could not be copied.
**/
-gboolean
-mate_bg_crossfade_set_start_pixmap (MateBGCrossfade *fade,
- GdkPixmap *pixmap)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gboolean mate_bg_crossfade_set_start_pixmap(MateBGCrossfade* fade, cairo_surface_t* pixmap)
+#else
+ gboolean mate_bg_crossfade_set_start_pixmap(MateBGCrossfade* fade, GdkPixmap* pixmap)
+#endif
{
/* I am disabling this because background fade break the mate-file-manager
* Estoy deshabilitando esto por que el efecto de desvanecimiento del fondo de pantalla, hace
@@ -331,9 +349,11 @@ get_current_time (void)
* Return value: %TRUE if successful, or %FALSE if the pixmap
* could not be copied.
**/
-gboolean
-mate_bg_crossfade_set_end_pixmap (MateBGCrossfade *fade,
- GdkPixmap *pixmap)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gboolean mate_bg_crossfade_set_end_pixmap(MateBGCrossfade* fade, cairo_surface_t* pixmap)
+#else
+ gboolean mate_bg_crossfade_set_end_pixmap(MateBGCrossfade* fade, GdkPixmap* pixmap)
+#endif
{
g_return_val_if_fail (MATE_IS_BG_CROSSFADE (fade), FALSE);
@@ -361,7 +381,11 @@ animations_are_disabled (MateBGCrossfade *fade)
g_assert (fade->priv->window != NULL);
- screen = gdk_drawable_get_screen (fade->priv->window);
+ #if GTK_CHECK_VERSION(2, 24, 0)
+ screen = gdk_window_get_screen(fade->priv->window);
+ #else // since 2.2
+ screen = gdk_drawable_get_screen(GDK_DRAWABLE(fade->priv->window));
+ #endif
settings = gtk_settings_get_for_screen (screen);
diff --git a/libmate-desktop/mate-bg.c b/libmate-desktop/mate-bg.c
index 3b0f684..a46fc27 100644
--- a/libmate-desktop/mate-bg.c
+++ b/libmate-desktop/mate-bg.c
@@ -34,6 +34,7 @@ Author: Soren Sandmann <[email protected]>
#include <gio/gio.h>
+#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
@@ -128,7 +129,11 @@ static guint signals[N_SIGNALS] = {0};
G_DEFINE_TYPE(MateBG, mate_bg, G_TYPE_OBJECT)
-static GdkPixmap* make_root_pixmap(GdkScreen* screen, gint width, gint height);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ static cairo_surface_t* make_root_pixmap(GdkScreen* screen, gint width, gint height);
+#else
+ static GdkPixmap* make_root_pixmap(GdkScreen* screen, gint width, gint height);
+#endif
/* Pixbuf utils */
static guint32 pixbuf_average_value (GdkPixbuf *pixbuf);
@@ -138,11 +143,14 @@ static GdkPixbuf *pixbuf_scale_to_fit (GdkPixbuf *src,
static GdkPixbuf *pixbuf_scale_to_min (GdkPixbuf *src,
int min_width,
int min_height);
-static void pixbuf_draw_gradient (GdkPixbuf *pixbuf,
- gboolean horizontal,
- GdkColor *c1,
- GdkColor *c2,
- GdkRectangle *rect);
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ static void pixbuf_draw_gradient(GdkPixbuf* pixbuf, gboolean horizontal, GdkColor* c1, GdkColor* c2, cairo_rectangle_int_t* rect);
+#else
+ static void pixbuf_draw_gradient(GdkPixbuf* pixbuf, gboolean horizontal, GdkColor* c1, GdkColor* c2, GdkRectangle* rect);
+#endif
+
+
static void pixbuf_tile (GdkPixbuf *src,
GdkPixbuf *dest);
static void pixbuf_blend (GdkPixbuf *src,
@@ -635,20 +643,27 @@ mate_bg_set_filename (MateBG *bg,
}
}
-static void
-draw_color_area (MateBG *bg,
- GdkPixbuf *dest,
- GdkRectangle *rect)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ static void draw_color_area(MateBG* bg, GdkPixbuf* dest, cairo_rectangle_int_t* rect)
+#else
+ static void draw_color_area(MateBG* bg, GdkPixbuf* dest, GdkRectangle* rect)
+#endif
{
guint32 pixel;
- GdkRectangle extent;
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_rectangle_int_t extent;
+ #else
+ GdkRectangle extent;
+ #endif
+
extent.x = 0;
extent.y = 0;
extent.width = gdk_pixbuf_get_width (dest);
extent.height = gdk_pixbuf_get_height (dest);
- gdk_rectangle_intersect (rect, &extent, rect);
+ gdk_rectangle_intersect(rect, &extent, rect);
switch (bg->color_type) {
case MATE_BG_COLOR_SOLID:
@@ -679,7 +694,12 @@ draw_color (MateBG *bg,
GdkPixbuf *dest,
GdkScreen *screen)
{
- GdkRectangle rect;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_rectangle_int_t rect;
+ #else
+ GdkRectangle rect;
+ #endif
+
rect.x = 0;
rect.y = 0;
rect.width = gdk_pixbuf_get_width (dest);
@@ -692,7 +712,11 @@ draw_color_each_monitor (MateBG *bg,
GdkPixbuf *dest,
GdkScreen *screen)
{
- GdkRectangle rect;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_rectangle_int_t rect;
+ #else
+ GdkRectangle rect;
+ #endif
gint num_monitors;
int monitor;
@@ -783,11 +807,12 @@ get_scaled_pixbuf (MateBGPlacement placement,
return new;
}
-static void
-draw_image_area (MateBGPlacement placement,
- GdkPixbuf *pixbuf,
- GdkPixbuf *dest,
- GdkRectangle *area)
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ static void draw_image_area(MateBGPlacement placement, GdkPixbuf* pixbuf, GdkPixbuf* dest, cairo_rectangle_int_t* area)
+#else
+ static void draw_image_area(MateBGPlacement placement, GdkPixbuf* pixbuf, GdkPixbuf* dest, GdkRectangle* area)
+#endif
{
int dest_width = area->width;
int dest_height = area->height;
@@ -825,7 +850,11 @@ draw_image (MateBGPlacement placement,
GdkPixbuf *pixbuf,
GdkPixbuf *dest)
{
- GdkRectangle rect;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_rectangle_int_t rect;
+ #else
+ GdkRectangle rect;
+ #endif
rect.x = 0;
rect.y = 0;
@@ -840,7 +869,12 @@ draw_once (MateBG *bg,
GdkPixbuf *dest,
GdkScreen *screen)
{
- GdkRectangle rect;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_rectangle_int_t rect;
+ #else
+ GdkRectangle rect;
+ #endif
+
GdkPixbuf *pixbuf;
rect.x = 0;
@@ -863,7 +897,11 @@ draw_each_monitor (MateBG *bg,
GdkPixbuf *dest,
GdkScreen *screen)
{
- GdkRectangle rect;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_rectangle_int_t rect;
+ #else
+ GdkRectangle rect;
+ #endif
gint num_monitors;
int monitor;
@@ -965,15 +1003,19 @@ mate_bg_get_pixmap_size (MateBG *bg,
*
* Since: 2.20
**/
-GdkPixmap *
-mate_bg_create_pixmap (MateBG *bg,
- GdkWindow *window,
- int width,
- int height,
- gboolean is_root)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* mate_bg_create_pixmap(MateBG* bg, GdkWindow* window, int width, int height, gboolean is_root)
+#else
+ GdkPixmap* mate_bg_create_pixmap(MateBG* bg, GdkWindow* window, int width, int height, gboolean is_root)
+#endif
{
int pm_width, pm_height;
- GdkPixmap *pixmap;
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* pixmap;
+ #else
+ GdkPixmap* pixmap;
+ #endif
cairo_t *cr;
g_return_val_if_fail (bg != NULL, NULL);
@@ -993,8 +1035,13 @@ mate_bg_create_pixmap (MateBG *bg,
mate_bg_get_pixmap_size (bg, width, height, &pm_width, &pm_height);
if (is_root) {
- pixmap = make_root_pixmap (gdk_drawable_get_screen (window),
- pm_width, pm_height);
+
+ #if GTK_CHECK_VERSION(2, 24, 0)
+ pixmap = make_root_pixmap(gdk_window_get_screen(window), pm_width, pm_height);
+ #else // since 2.2
+ pixmap = make_root_pixmap(gdk_drawable_get_screen(GDK_DRAWABLE(window)), pm_width, pm_height);
+ #endif
+
}
else {
pixmap = gdk_pixmap_new (window, pm_width, pm_height, -1);
@@ -1007,9 +1054,14 @@ mate_bg_create_pixmap (MateBG *bg,
else {
GdkPixbuf *pixbuf;
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
- width, height);
- mate_bg_draw (bg, pixbuf, gdk_drawable_get_screen (GDK_DRAWABLE (window)), is_root);
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height);
+
+ #if GTK_CHECK_VERSION(2, 24, 0)
+ mate_bg_draw(bg, pixbuf, gdk_window_get_screen(window), is_root);
+ #else // since 2.2
+ mate_bg_draw(bg, pixbuf, gdk_drawable_get_screen(GDK_DRAWABLE(window)), is_root);
+ #endif
+
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
g_object_unref (pixbuf);
}
@@ -1068,13 +1120,23 @@ mate_bg_is_dark (MateBG *bg,
* Create a persistent pixmap. We create a separate display
* and set the closedown mode on it to RetainPermanent.
*/
-static GdkPixmap *
-make_root_pixmap (GdkScreen *screen, gint width, gint height)
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ static cairo_surface_t* make_root_pixmap(GdkScreen* screen, gint width, gint height)
+#else
+ static GdkPixmap* make_root_pixmap(GdkScreen* screen, gint width, gint height)
+#endif
{
- Display *display;
- const char *display_name;
+ Display* display;
+ const char* display_name;
Pixmap result;
- GdkPixmap *gdk_pixmap;
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* gdk_pixmap;
+ #else
+ GdkPixmap* gdk_pixmap;
+ #endif
+
int screen_num;
int depth;
@@ -1233,8 +1295,11 @@ mate_bg_create_thumbnail (MateBG *bg,
*
* Return value: a #GdkPixmap if successful or %NULL
**/
-GdkPixmap *
-mate_bg_get_pixmap_from_root (GdkScreen *screen)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* mate_bg_get_pixmap_from_root(GdkScreen* screen)
+#else
+ GdkPixmap* mate_bg_get_pixmap_from_root(GdkScreen* screen)
+#endif
{
int result;
gint format;
@@ -1244,8 +1309,14 @@ mate_bg_get_pixmap_from_root (GdkScreen *screen)
Atom type;
Display *display;
int screen_num;
- GdkPixmap *pixmap;
- GdkPixmap *source_pixmap;
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* pixmap;
+ cairo_surface_t* source_pixmap;
+ #else
+ GdkPixmap* pixmap;
+ GdkPixmap* source_pixmap;
+ #endif
int width, height;
cairo_t *cr;
cairo_pattern_t *pattern;
@@ -1311,9 +1382,11 @@ mate_bg_get_pixmap_from_root (GdkScreen *screen)
return pixmap;
}
-static void
-mate_bg_set_root_pixmap_id (GdkScreen *screen,
- GdkPixmap *pixmap)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ static void mate_bg_set_root_pixmap_id(GdkScreen* screen, cairo_surface_t* pixmap)
+#else
+ static void mate_bg_set_root_pixmap_id(GdkScreen* screen, GdkPixmap* pixmap)
+#endif
{
int result;
gint format;
@@ -1374,8 +1447,11 @@ mate_bg_set_root_pixmap_id (GdkScreen *screen,
* same conventions we do). @pixmap should come from a call
* to mate_bg_create_pixmap().
**/
-void
-mate_bg_set_pixmap_as_root (GdkScreen *screen, GdkPixmap *pixmap)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ void mate_bg_set_pixmap_as_root(GdkScreen* screen, cairo_surface_t* pixmap)
+#else
+ void mate_bg_set_pixmap_as_root(GdkScreen* screen, GdkPixmap* pixmap)
+#endif
{
Display *display;
int screen_num;
@@ -1413,13 +1489,21 @@ mate_bg_set_pixmap_as_root (GdkScreen *screen, GdkPixmap *pixmap)
*
* Return value: a #MateBGCrossfade object
**/
-MateBGCrossfade *
-mate_bg_set_pixmap_as_root_with_crossfade (GdkScreen *screen,
- GdkPixmap *pixmap)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ MateBGCrossfade* mate_bg_set_pixmap_as_root_with_crossfade(GdkScreen* screen, cairo_surface_t* pixmap)
+#else
+ MateBGCrossfade* mate_bg_set_pixmap_as_root_with_crossfade(GdkScreen* screen, GdkPixmap* pixmap)
+#endif
{
GdkDisplay *display;
GdkWindow *root_window;
- GdkPixmap *old_pixmap;
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_t* old_pixmap;
+ #else
+ GdkPixmap* old_pixmap;
+ #endif
+
int width, height;
MateBGCrossfade *fade;
@@ -2305,12 +2389,11 @@ create_gradient (const GdkColor *primary,
return result;
}
-static void
-pixbuf_draw_gradient (GdkPixbuf *pixbuf,
- gboolean horizontal,
- GdkColor *primary,
- GdkColor *secondary,
- GdkRectangle *rect)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ static void pixbuf_draw_gradient(GdkPixbuf* pixbuf, gboolean horizontal, GdkColor* primary, GdkColor* secondary, cairo_rectangle_int_t* rect)
+#else
+ static void pixbuf_draw_gradient(GdkPixbuf* pixbuf, gboolean horizontal, GdkColor* primary, GdkColor* secondary, GdkRectangle* rect)
+#endif
{
int width;
int height;