diff options
Diffstat (limited to 'eel')
-rw-r--r-- | eel/eel-accessibility.c | 71 | ||||
-rw-r--r-- | eel/eel-accessibility.h | 7 | ||||
-rw-r--r-- | eel/eel-background-box.c | 17 | ||||
-rw-r--r-- | eel/eel-background.c | 162 | ||||
-rw-r--r-- | eel/eel-background.h | 4 | ||||
-rw-r--r-- | eel/eel-canvas-rect-ellipse.c | 216 | ||||
-rw-r--r-- | eel/eel-canvas-rect-ellipse.h | 5 | ||||
-rw-r--r-- | eel/eel-canvas.c | 405 | ||||
-rw-r--r-- | eel/eel-canvas.h | 17 | ||||
-rw-r--r-- | eel/eel-editable-label.c | 447 | ||||
-rw-r--r-- | eel/eel-editable-label.h | 9 | ||||
-rw-r--r-- | eel/eel-gdk-extensions.c | 143 | ||||
-rw-r--r-- | eel/eel-gdk-extensions.h | 25 | ||||
-rw-r--r-- | eel/eel-gdk-pixbuf-extensions.c | 35 | ||||
-rw-r--r-- | eel/eel-gdk-pixbuf-extensions.h | 9 | ||||
-rw-r--r-- | eel/eel-graphic-effects.c | 10 | ||||
-rw-r--r-- | eel/eel-graphic-effects.h | 8 | ||||
-rw-r--r-- | eel/eel-gtk-container.c | 8 | ||||
-rw-r--r-- | eel/eel-gtk-container.h | 5 | ||||
-rw-r--r-- | eel/eel-gtk-extensions.c | 38 | ||||
-rw-r--r-- | eel/eel-gtk-extensions.h | 7 | ||||
-rw-r--r-- | eel/eel-image-table.c | 16 | ||||
-rw-r--r-- | eel/eel-labeled-image.c | 225 | ||||
-rw-r--r-- | eel/eel-wrap-table.c | 30 |
24 files changed, 48 insertions, 1871 deletions
diff --git a/eel/eel-accessibility.c b/eel/eel-accessibility.c index da586ddc..b669979f 100644 --- a/eel/eel-accessibility.c +++ b/eel/eel-accessibility.c @@ -63,58 +63,6 @@ eel_accessibility_set_up_label_widget_relation (GtkWidget *label, GtkWidget *wid * * Return value: the registered type, or 0 on failure. **/ -#if !GTK_CHECK_VERSION(3, 0, 0) -GType -eel_accessibility_create_derived_type (const char *type_name, - GType existing_gobject_with_proxy, - EelAccessibilityClassInitFn class_init) -{ - GType type; - GType parent_atk_type; - GTypeInfo tinfo = { 0 }; - GTypeQuery query; - AtkObjectFactory *factory; - - if ((type = g_type_from_name (type_name))) - { - return type; - } - - factory = atk_registry_get_factory - (atk_get_default_registry (), - existing_gobject_with_proxy); - if (!factory) - { - return G_TYPE_INVALID; - } - - parent_atk_type = atk_object_factory_get_accessible_type (factory); - if (!parent_atk_type) - { - return G_TYPE_INVALID; - } - - /* - * Figure out the size of the class and instance - * we are deriving from - */ - g_type_query (parent_atk_type, &query); - - if (class_init) - { - tinfo.class_init = (GClassInitFunc) class_init; - } - - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - - /* Register the type */ - type = g_type_register_static ( - parent_atk_type, type_name, &tinfo, 0); - - return type; -} -#endif static GQuark get_quark_accessible (void) @@ -208,25 +156,6 @@ eel_accessibility_destroy (gpointer data, * * Return value: @atk_object. **/ -#if !GTK_CHECK_VERSION(3, 0, 0) -AtkObject * -eel_accessibility_set_atk_object_return (gpointer object, - AtkObject *atk_object) -{ - atk_object_initialize (atk_object, object); - - if (!ATK_IS_GOBJECT_ACCESSIBLE (atk_object)) - { - g_object_set_qdata_full - (object, get_quark_accessible (), atk_object, - (GDestroyNotify)eel_accessibility_destroy); - g_object_set_qdata - (G_OBJECT (atk_object), get_quark_gobject (), object); - } - - return atk_object; -} -#endif static GailTextUtil * get_simple_text (gpointer object) diff --git a/eel/eel-accessibility.h b/eel/eel-accessibility.h index a1f68d56..b9d96e4d 100644 --- a/eel/eel-accessibility.h +++ b/eel/eel-accessibility.h @@ -38,13 +38,6 @@ typedef void (*EelAccessibilityClassInitFn) (AtkObjectClass *klass); AtkObject *eel_accessibility_get_atk_object (gpointer object); AtkObject *eel_accessibility_for_object (gpointer object); gpointer eel_accessibility_get_gobject (AtkObject *object); -#if !GTK_CHECK_VERSION(3, 0, 0) -AtkObject *eel_accessibility_set_atk_object_return (gpointer object, - AtkObject *atk_object); -GType eel_accessibility_create_derived_type (const char *type_name, - GType existing_gobject_with_proxy, - EelAccessibilityClassInitFn class_init); -#endif void eel_accessibility_set_name (gpointer object, const char *name); void eel_accessibility_set_description (gpointer object, diff --git a/eel/eel-background-box.c b/eel/eel-background-box.c index d0b80c4e..72aabec8 100644 --- a/eel/eel-background-box.c +++ b/eel/eel-background-box.c @@ -31,23 +31,12 @@ G_DEFINE_TYPE (EelBackgroundBox, eel_background_box, GTK_TYPE_EVENT_BOX) static gboolean eel_background_box_draw (GtkWidget *widget, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr) -#else - GdkEventExpose *event) -#endif { -#if GTK_CHECK_VERSION (3, 0, 0) eel_background_draw (widget, cr); gtk_container_propagate_draw (GTK_CONTAINER (widget), gtk_bin_get_child (GTK_BIN (widget)), cr); -#else - eel_background_draw (widget, event); - gtk_container_propagate_expose (GTK_CONTAINER (widget), - gtk_bin_get_child (GTK_BIN (widget)), - event); -#endif return TRUE; } @@ -60,12 +49,8 @@ static void eel_background_box_class_init (EelBackgroundBoxClass *klass) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->draw = eel_background_box_draw; -#else - widget_class->expose_event = eel_background_box_draw; -#endif + } GtkWidget* diff --git a/eel/eel-background.c b/eel/eel-background.c index f652e98e..2734cdce 100644 --- a/eel/eel-background.c +++ b/eel/eel-background.c @@ -31,28 +31,13 @@ #include "eel-lib-self-check-functions.h" #include <gtk/gtk.h> #include <eel/eel-canvas.h> -#if GTK_CHECK_VERSION (3, 0, 0) # include <cairo-xlib.h> -#endif #include <gdk/gdkx.h> #include <gio/gio.h> #include <math.h> #include <stdio.h> #include <libcaja-private/caja-global-preferences.h> -#if !GTK_CHECK_VERSION(3, 0, 0) -#define cairo_surface_t GdkPixmap -#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 -#define cairo_set_source_surface gdk_cairo_set_source_pixmap -#define mate_bg_create_surface mate_bg_create_pixmap -#define mate_bg_set_surface_as_root mate_bg_set_pixmap_as_root -#define mate_bg_get_surface_from_root mate_bg_get_pixmap_from_root -#define mate_bg_crossfade_set_start_surface mate_bg_crossfade_set_start_pixmap -#define mate_bg_crossfade_set_end_surface mate_bg_crossfade_set_end_pixmap -#endif - G_DEFINE_TYPE (EelBackground, eel_background, G_TYPE_OBJECT); enum @@ -77,12 +62,7 @@ struct EelBackgroundDetails MateBGCrossfade *fade; int bg_entire_width; int bg_entire_height; -#if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA default_color; -#else - GdkColor default_color; -#endif - gboolean use_base; /* Is this background attached to desktop window */ @@ -167,11 +147,7 @@ eel_background_unrealize (EelBackground *self) static void make_color_inactive (EelBackground *self, -#if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA *color) -#else - GdkColor *color) -#endif { double intensity, saturation; gushort t; @@ -206,11 +182,7 @@ gchar * eel_bg_get_desktop_color (EelBackground *self) { MateBGColorType type; -#if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA primary, secondary; -#else - GdkColor primary, secondary; -#endif char *start_color, *end_color, *color_spec; gboolean use_gradient = TRUE; gboolean is_horizontal = FALSE; @@ -230,19 +202,11 @@ eel_bg_get_desktop_color (EelBackground *self) use_gradient = FALSE; } -#if GTK_CHECK_VERSION (3, 0, 0) start_color = eel_gdk_rgb_to_color_spec (eel_gdk_rgba_to_rgb (&primary)); if (use_gradient) { end_color = eel_gdk_rgb_to_color_spec (eel_gdk_rgba_to_rgb (&secondary)); -#else - start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary)); - - if (use_gradient) - { - end_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary)); -#endif color_spec = eel_gradient_new (start_color, end_color, is_horizontal); g_free (end_color); } @@ -255,7 +219,6 @@ eel_bg_get_desktop_color (EelBackground *self) return color_spec; } -#if GTK_CHECK_VERSION (3, 0, 0) static void set_image_properties (EelBackground *self) { @@ -298,51 +261,6 @@ set_image_properties (EelBackground *self) } } } -#else -static void -set_image_properties (EelBackground *self) -{ - GdkColor c; - - if (self->details->is_desktop && !self->details->color) - self->details->color = eel_bg_get_desktop_color (self); - - if (!self->details->color) - { - 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 (self->details->color)) - { - 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, c2; - char *spec; - - spec = eel_gradient_get_start_color_spec (self->details->color); - eel_gdk_color_parse_with_white_default (spec, &c1); - make_color_inactive (self, &c1); - g_free (spec); - - spec = eel_gradient_get_end_color_spec (self->details->color); - eel_gdk_color_parse_with_white_default (spec, &c2); - make_color_inactive (self, &c2); - g_free (spec); - - 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); - } - } -} -#endif - gchar * eel_background_get_color (EelBackground *self) @@ -398,7 +316,6 @@ eel_background_ensure_realized (EelBackground *self) { int width, height; GdkWindow *window; -#if GTK_CHECK_VERSION (3, 0, 0) GtkStyleContext *style; /* Set the default color */ @@ -412,17 +329,6 @@ eel_background_ensure_realized (EelBackground *self) gtk_style_context_get_state (style), &self->details->default_color); gtk_style_context_restore (style); -#else - GtkStyle *style; - - /* 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]; - } -#endif /* If the window size is the same as last time, don't update */ drawable_get_adjusted_size (self, &width, &height); @@ -450,7 +356,6 @@ eel_background_ensure_realized (EelBackground *self) void eel_background_draw (GtkWidget *widget, -# if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr) { int width, height; @@ -479,42 +384,6 @@ eel_background_draw (GtkWidget *widget, cairo_restore (cr); } -# else - GdkEventExpose *event) -{ - int width, height; - GdkWindow *window = gtk_widget_get_window (widget); - GdkColor color; - - if (event->window != window) - return; - - EelBackground *self = eel_get_widget_background (widget); - - drawable_get_adjusted_size (self, &width, &height); - - eel_background_ensure_realized (self); - color = self->details->default_color; - make_color_inactive (self, &color); - - cairo_t *cr = gdk_cairo_create (window); - - 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, &color); - } - - gdk_cairo_rectangle (cr, &event->area); - cairo_clip (cr); - - cairo_rectangle (cr, 0, 0, width, height); - cairo_fill (cr); - - cairo_destroy (cr); -} -# endif static void set_root_surface (EelBackground *self, @@ -627,11 +496,8 @@ eel_background_set_up_widget (EelBackground *self) { GdkWindow *window; GtkWidget *widget = self->details->widget; -# if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA color; -#else - GdkColor color; -#endif + gboolean in_fade = FALSE; if (!gtk_widget_get_realized (widget)) @@ -655,30 +521,21 @@ eel_background_set_up_widget (EelBackground *self) if (!in_fade) { -# if GTK_CHECK_VERSION (3, 0, 0) cairo_pattern_t *pattern; pattern = cairo_pattern_create_for_surface (self->details->bg_surface); gdk_window_set_background_pattern (window, pattern); cairo_pattern_destroy (pattern); -# 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 { -#if GTK_CHECK_VERSION (3, 0, 0) + gdk_window_set_background_rgba (window, &color); -#else - gdk_window_set_background (window, &color); -#endif -# if !GTK_CHECK_VERSION (3, 0, 0) - gdk_window_set_back_pixmap (window, self->details->bg_surface, FALSE); -# endif + } gdk_window_invalidate_rect (window, NULL, TRUE); @@ -1173,21 +1030,16 @@ eel_background_set_dropped_color (EelBackground *self, top_border = 32; bottom_border = allocation.height - 32; -#if GTK_CHECK_VERSION (3, 0, 0) /* If a custom background color isn't set, get the GtkStyleContext's bg color. */ -#else - /* If a custom background color isn't set, get the GtkStyle's bg color. */ -#endif + if (!self->details->color) { -#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *style = gtk_widget_get_style_context (widget); GdkRGBA bg; gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &bg); gradient_spec = gdk_rgba_to_string (&bg); -#else - gradient_spec = gdk_color_to_string (>k_widget_get_style (widget)->bg[GTK_STATE_NORMAL]); -#endif + } else { diff --git a/eel/eel-background.h b/eel/eel-background.h index 9303835e..b16fc88b 100644 --- a/eel/eel-background.h +++ b/eel/eel-background.h @@ -95,11 +95,7 @@ gboolean eel_background_is_set (EelBackground /* Helper function for widgets using EelBackground */ void eel_background_draw (GtkWidget *widget, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr); -#else - GdkEventExpose *event); -#endif /* Handles a dragged color being dropped on a widget to change the background color. */ void eel_background_set_dropped_color (EelBackground *self, diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index b1300679..40237cf5 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -53,15 +53,7 @@ enum PROP_Y1, PROP_X2, PROP_Y2, -#if !GTK_CHECK_VERSION(3,0,0) - PROP_FILL_COLOR, - PROP_FILL_COLOR_GDK, -#endif PROP_FILL_COLOR_RGBA, -#if !GTK_CHECK_VERSION(3,0,0) - PROP_OUTLINE_COLOR, - PROP_OUTLINE_COLOR_GDK, -#endif PROP_OUTLINE_COLOR_RGBA, PROP_OUTLINE_STIPPLING, PROP_WIDTH_PIXELS, @@ -170,52 +162,18 @@ eel_canvas_re_class_init (EelCanvasREClass *klass) G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, -#if GTK_CHECK_VERSION(3,0,0) PROP_FILL_COLOR_RGBA, g_param_spec_boxed ("fill-color-rgba", NULL, NULL, GDK_TYPE_RGBA, -#else - PROP_FILL_COLOR, - g_param_spec_string ("fill-color", NULL, NULL, - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property - (gobject_class, - PROP_FILL_COLOR_GDK, - g_param_spec_boxed ("fill-color-gdk", NULL, NULL, - GDK_TYPE_COLOR, - G_PARAM_READWRITE)); - g_object_class_install_property - (gobject_class, - PROP_FILL_COLOR_RGBA, - g_param_spec_uint ("fill-color-rgba", NULL, NULL, - 0, G_MAXUINT, 0, - G_PARAM_READWRITE)); - g_object_class_install_property - (gobject_class, - PROP_OUTLINE_COLOR, - g_param_spec_string ("outline-color", NULL, NULL, - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property - (gobject_class, - PROP_OUTLINE_COLOR_GDK, - g_param_spec_boxed ("outline-color-gdk", NULL, NULL, - GDK_TYPE_COLOR, -#endif + G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_OUTLINE_COLOR_RGBA, -#if GTK_CHECK_VERSION(3,0,0) g_param_spec_boxed ("outline-color-rgba", NULL, NULL, GDK_TYPE_RGBA, G_PARAM_READWRITE)); -#else - g_param_spec_uint ("outline-color-rgba", NULL, NULL, - 0, G_MAXUINT, 0, - G_PARAM_READWRITE)); -#endif + g_object_class_install_property (gobject_class, PROP_OUTLINE_STIPPLING, @@ -317,10 +275,6 @@ eel_canvas_re_set_property (GObject *object, { EelCanvasItem *item; EelCanvasRE *re; -#if !GTK_CHECK_VERSION(3,0,0) - GdkColor color = { 0, 0, 0, 0, }; - GdkColor *pcolor; -#endif g_return_if_fail (object != NULL); g_return_if_fail (EEL_IS_CANVAS_RE (object)); @@ -354,7 +308,6 @@ eel_canvas_re_set_property (GObject *object, eel_canvas_item_request_update (item); break; -#if GTK_CHECK_VERSION(3,0,0) case PROP_FILL_COLOR_RGBA: { GdkRGBA *color; @@ -384,95 +337,6 @@ eel_canvas_re_set_property (GObject *object, eel_canvas_item_request_redraw (item); break; } -#else - case PROP_FILL_COLOR: - case PROP_FILL_COLOR_GDK: - case PROP_FILL_COLOR_RGBA: - switch (param_id) - { - case PROP_FILL_COLOR: - if (g_value_get_string (value) && - gdk_color_parse (g_value_get_string (value), &color)) - eel_canvas_re_set_fill (re, TRUE); - else - eel_canvas_re_set_fill (re, FALSE); - - re->fill_color = ((color.red & 0xff00) << 16 | - (color.green & 0xff00) << 8 | - (color.blue & 0xff00) | - 0xff); - break; - - case PROP_FILL_COLOR_GDK: - pcolor = g_value_get_boxed (value); - eel_canvas_re_set_fill (re, pcolor != NULL); - - if (pcolor) - { - color = *pcolor; - } - - re->fill_color = ((color.red & 0xff00) << 16 | - (color.green & 0xff00) << 8 | - (color.blue & 0xff00) | - 0xff); - break; - - case PROP_FILL_COLOR_RGBA: - eel_canvas_re_set_fill (re, TRUE); - re->fill_color = g_value_get_uint (value); - break; - } -#ifdef VERBOSE - g_print ("re fill color = %08x\n", re->fill_color); -#endif - eel_canvas_item_request_redraw (item); - break; - - case PROP_OUTLINE_COLOR: - case PROP_OUTLINE_COLOR_GDK: - case PROP_OUTLINE_COLOR_RGBA: - switch (param_id) - { - case PROP_OUTLINE_COLOR: - if (g_value_get_string (value) && - gdk_color_parse (g_value_get_string (value), &color)) - eel_canvas_re_set_outline (re, TRUE); - else - eel_canvas_re_set_outline (re, FALSE); - - re->outline_color = ((color.red & 0xff00) << 16 | - (color.green & 0xff00) << 8 | - (color.blue & 0xff00) | - 0xff); - break; - - case PROP_OUTLINE_COLOR_GDK: - pcolor = g_value_get_boxed (value); - eel_canvas_re_set_outline (re, pcolor != NULL); - - if (pcolor) - { - color = *pcolor; - } - - re->outline_color = ((color.red & 0xff00) << 16 | - (color.green & 0xff00) << 8 | - (color.blue & 0xff00) | - 0xff); - break; - - case PROP_OUTLINE_COLOR_RGBA: - eel_canvas_re_set_outline (re, TRUE); - re->outline_color = g_value_get_uint (value); - break; - } -#ifdef VERBOSE - g_print ("re outline color %x %x %x\n", color.red, color.green, color.blue); -#endif - eel_canvas_item_request_redraw (item); - break; -#endif case PROP_OUTLINE_STIPPLING: re->outline_stippling = g_value_get_boolean (value); @@ -500,26 +364,6 @@ eel_canvas_re_set_property (GObject *object, } } -#if !GTK_CHECK_VERSION(3,0,0) -/* Allocates a GdkColor structure filled with the specified pixel, and puts it into the specified - * value for returning it in the get_property method. - */ -static void -get_color_value (EelCanvasRE *re, gulong pixel, GValue *value) -{ - GdkColor color; - - color.red = (pixel >> 16) & 0xFF; - color.green = (pixel >> 8) & 0xFF; - color.blue = pixel & 0xFF; - color.red |= color.red << 8; - color.green |= color.green << 8; - color.blue |= color.blue << 8; - - g_value_set_boxed (value, &color); -} -#endif - static void eel_canvas_re_get_property (GObject *object, guint param_id, @@ -551,29 +395,12 @@ eel_canvas_re_get_property (GObject *object, g_value_set_double (value, re->y2); break; -#if GTK_CHECK_VERSION(3,0,0) case PROP_FILL_COLOR_RGBA: g_value_set_boxed (value, &re->fill_color); break; case PROP_OUTLINE_COLOR_RGBA: g_value_set_boxed (value, &re->outline_color); -#else - case PROP_FILL_COLOR_GDK: - get_color_value (re, re->fill_color, value); - break; - - case PROP_OUTLINE_COLOR_GDK: - get_color_value (re, re->outline_color, value); - break; - - case PROP_FILL_COLOR_RGBA: - g_value_set_uint (value, re->fill_color); - break; - - case PROP_OUTLINE_COLOR_RGBA: - g_value_set_uint (value, re->outline_color); -#endif break; case PROP_OUTLINE_STIPPLING: @@ -660,11 +487,8 @@ static void eel_canvas_rect_init (EelCanvasRect *rect); static void eel_canvas_rect_finalize (GObject *object); static void eel_canvas_rect_realize (EelCanvasItem *item); -#if GTK_CHECK_VERSION(3,0,0) static void eel_canvas_rect_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region); -#else -static void eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose); -#endif + static double eel_canvas_rect_point (EelCanvasItem *item, double x, double y, int cx, int cy, EelCanvasItem **actual_item); @@ -780,29 +604,15 @@ eel_canvas_rect_realize (EelCanvasItem *item) static void eel_canvas_set_source_color (cairo_t *cr, -#if GTK_CHECK_VERSION(3,0,0) GdkRGBA *rgba) { gdk_cairo_set_source_rgba (cr, rgba); -#else - guint rgba) -{ - cairo_set_source_rgba (cr, - ((rgba >> 24) & 0xff) / 255., - ((rgba >> 16) & 0xff) / 255., - ((rgba >> 8) & 0xff) / 255., - ((rgba >> 0) & 0xff) / 255.); -#endif } #define DASH_ON 0.8 #define DASH_OFF 1.7 static void -#if GTK_CHECK_VERSION(3,0,0) eel_canvas_rect_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region) -#else -eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) -#endif { EelCanvasRE *re; double x1, y1, x2, y2; @@ -828,21 +638,11 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose return; } -#if GTK_CHECK_VERSION(3,0,0) cairo_save (cr); -#else - cairo_t *cr = gdk_cairo_create (drawable); - gdk_cairo_region (cr, expose->region); - cairo_clip (cr); -#endif if (re->fill_set) { -#if GTK_CHECK_VERSION(3,0,0) eel_canvas_set_source_color (cr, &re->fill_color); -#else - eel_canvas_set_source_color (cr, re->fill_color); -#endif cairo_rectangle (cr, cx1, cy1, cx2 - cx1 + 1, @@ -852,11 +652,8 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose if (re->outline_set) { -#if GTK_CHECK_VERSION(3,0,0) eel_canvas_set_source_color (cr, &re->outline_color); -#else - eel_canvas_set_source_color (cr, re->outline_color); -#endif + if (re->width_pixels) { cairo_set_line_width (cr, (int) re->width); } else { @@ -875,12 +672,7 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose cy2 - cy1); cairo_stroke (cr); } - -#if GTK_CHECK_VERSION(3,0,0) cairo_restore (cr); -#else - cairo_destroy (cr); -#endif } static double diff --git a/eel/eel-canvas-rect-ellipse.h b/eel/eel-canvas-rect-ellipse.h index 2d1dac59..e391dfb4 100644 --- a/eel/eel-canvas-rect-ellipse.h +++ b/eel/eel-canvas-rect-ellipse.h @@ -84,13 +84,8 @@ extern "C" { double x1, y1, x2, y2; /* Corners of item */ double width; /* Outline width */ -#if GTK_CHECK_VERSION(3,0,0) GdkRGBA fill_color; GdkRGBA outline_color; -#else - guint fill_color; /* Fill color, RGBA */ - guint outline_color; /* Outline color, RGBA */ -#endif gboolean outline_stippling; diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index 162c0b44..ddc15036 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -68,25 +68,13 @@ #include <stdio.h> #include <gdk/gdkprivate.h> #include <gtk/gtk.h> -#if GTK_CHECK_VERSION(3,2,0) #include <gtk/gtk-a11y.h> -#endif #include <glib/gi18n-lib.h> -#if GTK_CHECK_VERSION(3,0,0) -# include <cairo/cairo-gobject.h> -#endif +#include <cairo/cairo-gobject.h> #include "eel-canvas.h" #include "eel-marshal.h" -#if !GTK_CHECK_VERSION(3, 0, 0) -#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment -#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment -#define gtk_scrollable_set_hadjustment gtk_layout_set_hadjustment -#define gtk_scrollable_set_vadjustment gtk_layout_set_vadjustment -#define GTK_SCROLLABLE GTK_LAYOUT -#endif - static void eel_canvas_request_update (EelCanvas *canvas); static void group_add (EelCanvasGroup *group, EelCanvasItem *item); @@ -344,20 +332,11 @@ eel_canvas_item_dispose (GObject *object) item->canvas->need_repick = TRUE; } -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 20, 0) eel_canvas_item_ungrab (item); #else eel_canvas_item_ungrab (item, GDK_CURRENT_TIME); #endif -#else - if (item == item->canvas->grabbed_item) - { - GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (item->canvas)); - item->canvas->grabbed_item = NULL; - gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME); - } -#endif if (item == item->canvas->focused_item) item->canvas->focused_item = NULL; @@ -928,7 +907,6 @@ seat_grab_prepare_window (GdkSeat *seat, * gdk_pointer_grab(). **/ #endif -#if GTK_CHECK_VERSION(3, 0, 0) GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item, GdkEventMask event_mask, @@ -982,29 +960,6 @@ eel_canvas_item_grab (EelCanvasItem *item, cursor, timestamp); #endif -#else -int -eel_canvas_item_grab (EelCanvasItem *item, guint event_mask, GdkCursor *cursor, guint32 etime) -{ - int retval; - - g_return_val_if_fail (EEL_IS_CANVAS_ITEM (item), GDK_GRAB_NOT_VIEWABLE); - g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)), - GDK_GRAB_NOT_VIEWABLE); - - if (item->canvas->grabbed_item) - return GDK_GRAB_ALREADY_GRABBED; - - if (!(item->flags & EEL_CANVAS_ITEM_MAPPED)) - return GDK_GRAB_NOT_VIEWABLE; - - retval = gdk_pointer_grab (gtk_layout_get_bin_window (&item->canvas->layout), - FALSE, - event_mask, - NULL, - cursor, - etime); -#endif if (retval != GDK_GRAB_SUCCESS) return retval; @@ -1034,7 +989,6 @@ eel_canvas_item_grab (EelCanvasItem *item, guint event_mask, GdkCursor *cursor, * mouse. **/ #endif -#if GTK_CHECK_VERSION(3, 0, 0) void #if GTK_CHECK_VERSION(3, 20, 0) eel_canvas_item_ungrab (EelCanvasItem *item) @@ -1073,22 +1027,6 @@ eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime) gdk_device_ungrab (device, etime); } #endif -#else -void -eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime) -{ - GdkDisplay *display; - - g_return_if_fail (EEL_IS_CANVAS_ITEM (item)); - - if (item->canvas->grabbed_item != item) - return; - - display = gtk_widget_get_display (GTK_WIDGET (item->canvas)); - item->canvas->grabbed_item = NULL; - gdk_display_pointer_ungrab (display, etime); -} -#endif /** * eel_canvas_item_w2i: @@ -1367,14 +1305,9 @@ static void eel_canvas_group_update (EelCanvasItem *item, static void eel_canvas_group_unrealize (EelCanvasItem *item); static void eel_canvas_group_map (EelCanvasItem *item); static void eel_canvas_group_unmap (EelCanvasItem *item); -#if GTK_CHECK_VERSION(3,0,0) static void eel_canvas_group_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region); -#else -static void eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable, - GdkEventExpose *expose); -#endif static double eel_canvas_group_point (EelCanvasItem *item, double x, double y, int cx, int cy, EelCanvasItem **actual_item); @@ -1695,14 +1628,9 @@ eel_canvas_group_unmap (EelCanvasItem *item) /* Draw handler for canvas groups */ static void -#if GTK_CHECK_VERSION(3,0,0) eel_canvas_group_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region) -#else -eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable, - GdkEventExpose *expose) -#endif { EelCanvasGroup *group; GList *list; @@ -1724,13 +1652,8 @@ eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable, child_rect.width = child->x2 - child->x1 + 1; child_rect.height = child->y2 - child->y1 + 1; -#if GTK_CHECK_VERSION (3, 0, 0) if (cairo_region_contains_rectangle (region, &child_rect) != CAIRO_REGION_OVERLAP_OUT) EEL_CANVAS_ITEM_GET_CLASS (child)->draw (child, cr, region); -#else - if (gdk_region_rect_in (expose->region, &child_rect) != GDK_OVERLAP_RECTANGLE_OUT) - (* EEL_CANVAS_ITEM_GET_CLASS (child)->draw) (child, drawable, expose); -#endif } } } @@ -1958,11 +1881,7 @@ enum static void eel_canvas_class_init (EelCanvasClass *klass); static void eel_canvas_init (EelCanvas *canvas); -#if GTK_CHECK_VERSION (3, 0, 0) static void eel_canvas_destroy (GtkWidget *object); -#else -static void eel_canvas_destroy (GtkObject *object); -#endif static void eel_canvas_map (GtkWidget *widget); static void eel_canvas_unmap (GtkWidget *widget); static void eel_canvas_realize (GtkWidget *widget); @@ -1973,13 +1892,8 @@ static gint eel_canvas_button (GtkWidget *widget, GdkEventButton *event); static gint eel_canvas_motion (GtkWidget *widget, GdkEventMotion *event); -#if GTK_CHECK_VERSION (3, 0, 0) static gint eel_canvas_draw (GtkWidget *widget, cairo_t *cr); -#else -static gint eel_canvas_expose (GtkWidget *widget, - GdkEventExpose *event); -#endif static gint eel_canvas_key (GtkWidget *widget, GdkEventKey *event); static gint eel_canvas_crossing (GtkWidget *widget, @@ -1990,14 +1904,7 @@ static gint eel_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event); static void eel_canvas_request_update_real (EelCanvas *canvas); static void eel_canvas_draw_background (EelCanvas *canvas, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr); -#else - int x, - int y, - int width, - int height); -#endif static GtkLayoutClass *canvas_parent_class; @@ -2161,7 +2068,6 @@ eel_canvas_accessible_ref_child (AtkObject *obj, return atk_object; } -#if GTK_CHECK_VERSION(3, 0, 0) G_DEFINE_TYPE (EelCanvasAccessible, eel_canvas_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE) static void @@ -2179,125 +2085,6 @@ static void eel_canvas_accessible_init (EelCanvasAccessible *accessible) { } -#else -static void -eel_canvas_accessible_class_init (AtkObjectClass *klass) -{ - accessible_parent_class = g_type_class_peek_parent (klass); - - klass->initialize = eel_canvas_accessible_initialize; - klass->get_n_children = eel_canvas_accessible_get_n_children; - klass->ref_child = eel_canvas_accessible_ref_child; -} - -static GType -eel_canvas_accessible_get_type (void) -{ - static GType type = 0; - - if (!type) - { - AtkObjectFactory *factory; - GType parent_atk_type; - GTypeQuery query; - GTypeInfo tinfo = { 0 }; - - factory = atk_registry_get_factory (atk_get_default_registry(), - GTK_TYPE_WIDGET); - if (!factory) - { - return G_TYPE_INVALID; - } - parent_atk_type = atk_object_factory_get_accessible_type (factory); - if (!parent_atk_type) - { - return G_TYPE_INVALID; - } - g_type_query (parent_atk_type, &query); - tinfo.class_init = (GClassInitFunc) eel_canvas_accessible_class_init; - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - type = g_type_register_static (parent_atk_type, - "EelCanvasAccessibility", - &tinfo, 0); - } - return type; -} - -static AtkObject * -eel_canvas_accessible_create (GObject *for_object) -{ - GType type; - AtkObject *accessible; - EelCanvas *canvas; - - canvas = EEL_CANVAS (for_object); - g_return_val_if_fail (canvas != NULL, NULL); - - type = eel_canvas_accessible_get_type (); - - if (type == G_TYPE_INVALID) - { - return atk_no_op_object_new (for_object); - } - - accessible = g_object_new (type, NULL); - atk_object_initialize (accessible, for_object); - return accessible; -} - -static GType -eel_canvas_accessible_factory_get_accessible_type (void) -{ - return eel_canvas_accessible_get_type (); -} - -static AtkObject* -eel_canvas_accessible_factory_create_accessible (GObject *obj) -{ - AtkObject *accessible; - - g_return_val_if_fail (G_IS_OBJECT (obj), NULL); - - accessible = eel_canvas_accessible_create (obj); - - return accessible; -} - -static void -eel_canvas_accessible_factory_class_init (AtkObjectFactoryClass *klass) -{ - klass->create_accessible = eel_canvas_accessible_factory_create_accessible; - klass->get_accessible_type = eel_canvas_accessible_factory_get_accessible_type; -} - -static GType -eel_canvas_accessible_factory_get_type (void) -{ - static GType type = 0; - - if (!type) - { - static const GTypeInfo tinfo = - { - sizeof (AtkObjectFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) eel_canvas_accessible_factory_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (AtkObjectFactory), - 0, /* n_preallocs */ - NULL - }; - type = g_type_register_static (ATK_TYPE_OBJECT_FACTORY, - "EelCanvasAccessibilityFactory", - &tinfo, 0); - } - - return type; -} -#endif /* Class initialization function for EelCanvasClass */ static void @@ -2314,11 +2101,7 @@ eel_canvas_class_init (EelCanvasClass *klass) gobject_class->set_property = eel_canvas_set_property; gobject_class->get_property = eel_canvas_get_property; -#if !GTK_CHECK_VERSION (3, 0, 0) - GTK_OBJECT_CLASS (klass)->destroy = eel_canvas_destroy; -#else widget_class->destroy = eel_canvas_destroy; -#endif widget_class->map = eel_canvas_map; widget_class->unmap = eel_canvas_unmap; widget_class->realize = eel_canvas_realize; @@ -2327,11 +2110,7 @@ eel_canvas_class_init (EelCanvasClass *klass) widget_class->button_press_event = eel_canvas_button; widget_class->button_release_event = eel_canvas_button; widget_class->motion_notify_event = eel_canvas_motion; -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->draw = eel_canvas_draw; -#else - widget_class->expose_event = eel_canvas_expose; -#endif widget_class->key_press_event = eel_canvas_key; widget_class->key_release_event = eel_canvas_key; widget_class->enter_notify_event = eel_canvas_crossing; @@ -2348,23 +2127,11 @@ eel_canvas_class_init (EelCanvasClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (EelCanvasClass, draw_background), NULL, NULL, -#if GTK_CHECK_VERSION (3, 0, 0) g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, CAIRO_GOBJECT_TYPE_CONTEXT); -#else - eel_marshal_VOID__INT_INT_INT_INT, - G_TYPE_NONE, 4, - G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT); -#endif -#if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_class_set_accessible_type (widget_class, eel_canvas_accessible_get_type ()); -#else - atk_registry_set_factory_type (atk_get_default_registry (), - EEL_TYPE_CANVAS, - eel_canvas_accessible_factory_get_type ()); -#endif } /* Callback used when the root item of a canvas is destroyed. The user should @@ -2444,12 +2211,8 @@ shutdown_transients (EelCanvas *canvas) { #if GTK_CHECK_VERSION(3, 20, 0) eel_canvas_item_ungrab (canvas->grabbed_item); -#elif GTK_CHECK_VERSION(3, 0, 0) - eel_canvas_item_ungrab (canvas->grabbed_item, GDK_CURRENT_TIME); #else - GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (canvas)); - canvas->grabbed_item = NULL; - gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME); + eel_canvas_item_ungrab (canvas->grabbed_item, GDK_CURRENT_TIME); #endif } @@ -2458,11 +2221,7 @@ shutdown_transients (EelCanvas *canvas) /* Destroy handler for EelCanvas */ static void -#if GTK_CHECK_VERSION (3, 0, 0) eel_canvas_destroy (GtkWidget *object) -#else -eel_canvas_destroy (GtkObject *object) -#endif { EelCanvas *canvas; @@ -2487,13 +2246,8 @@ eel_canvas_destroy (GtkObject *object) shutdown_transients (canvas); -#if GTK_CHECK_VERSION (3, 0, 0) if (GTK_WIDGET_CLASS (canvas_parent_class)->destroy) (* GTK_WIDGET_CLASS (canvas_parent_class)->destroy) (object); -#else - if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy) - (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object); -#endif } /** @@ -3083,11 +2837,9 @@ eel_canvas_button (GtkWidget *widget, GdkEventButton *event) canvas = EEL_CANVAS (widget); -#if GTK_CHECK_VERSION(3, 0, 0) /* Don't handle extra mouse button events */ if (event->button > 5) return FALSE; -#endif /* * dispatch normally regardless of the event's window if an item has @@ -3235,8 +2987,6 @@ eel_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) return FALSE; } - -#if GTK_CHECK_VERSION(3,0,0) static cairo_region_t * eel_cairo_get_clip_region (cairo_t *cr) { @@ -3276,19 +3026,12 @@ eel_cairo_get_clip_region (cairo_t *cr) cairo_rectangle_list_destroy (list); return region; } -#endif /* Expose handler for the canvas */ -#if GTK_CHECK_VERSION(3,0,0) static gboolean eel_canvas_draw (GtkWidget *widget, cairo_t *cr) -#else -static gint -eel_canvas_expose (GtkWidget *widget, GdkEventExpose *event) -#endif { EelCanvas *canvas = EEL_CANVAS (widget); -#if GTK_CHECK_VERSION(3,0,0) GdkWindow *bin_window; cairo_region_t *region; @@ -3309,14 +3052,9 @@ eel_canvas_expose (GtkWidget *widget, GdkEventExpose *event) cairo_restore (cr); return FALSE; } -#else - if (!gtk_widget_is_drawable (widget) || (event->window != gtk_layout_get_bin_window (&canvas->layout))) return FALSE; -#endif -#if defined VERBOSE && GTK_CHECK_VERSION(3,0,0) +#if defined VERBOSE g_print ("Draw\n"); -#elif defined VERBOSE - g_print ("Expose\n"); #endif /* If there are any outstanding items that need updating, do them now */ if (canvas->idle_id) @@ -3342,39 +3080,23 @@ eel_canvas_expose (GtkWidget *widget, GdkEventExpose *event) anything that is gonna get redrawn as invalid */ g_signal_emit (G_OBJECT (canvas), canvas_signals[DRAW_BACKGROUND], 0, -#if GTK_CHECK_VERSION(3,0,0) cr); -#else - event->area.x, event->area.y, - event->area.width, event->area.height); -#endif if (canvas->root->flags & EEL_CANVAS_ITEM_MAPPED) EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->draw (canvas->root, -#if GTK_CHECK_VERSION(3,0,0) cr, region); -#else - gtk_layout_get_bin_window (&canvas->layout), - event); -#endif /* Chain up to get exposes on child widgets */ -#if GTK_CHECK_VERSION(3,0,0) cairo_restore (cr); if (GTK_WIDGET_CLASS (canvas_parent_class)->draw) GTK_WIDGET_CLASS (canvas_parent_class)->draw (widget, cr); cairo_region_destroy (region); -#else - GTK_WIDGET_CLASS (canvas_parent_class)->expose_event (widget, event); -#endif return FALSE; } - -#if GTK_CHECK_VERSION(3,0,0) static void eel_canvas_draw_background (EelCanvas *canvas, cairo_t *cr) @@ -3395,21 +3117,6 @@ eel_canvas_draw_background (EelCanvas *canvas, cairo_fill (cr); cairo_restore (cr); } -#else /* GTK_CHECK_VERSION(3,0,0) */ -static void -eel_canvas_draw_background (EelCanvas *canvas, - int x, int y, int width, int height) -{ - cairo_t *cr = gdk_cairo_create (gtk_layout_get_bin_window (&canvas->layout)); - - /* By default, we use the style background. */ - gdk_cairo_set_source_color (cr, >k_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]); - cairo_rectangle (cr, x, y, width, height); - cairo_fill (cr); - - cairo_destroy (cr); -} -#endif /* GTK_CHECK_VERSION(3,0,0) */ static void do_update (EelCanvas *canvas) @@ -3456,20 +3163,12 @@ idle_handler (gpointer data) { EelCanvas *canvas; -#if !GTK_CHECK_VERSION(3, 0, 0) - GDK_THREADS_ENTER (); -#endif - canvas = EEL_CANVAS (data); do_update (canvas); /* Reset idle id */ canvas->idle_id = 0; -#if !GTK_CHECK_VERSION (3, 0, 0) - GDK_THREADS_LEAVE (); -#endif - return FALSE; } @@ -3678,18 +3377,11 @@ eel_canvas_set_pixels_per_unit (EelCanvas *canvas, double n) attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; -#if GTK_CHECK_VERSION(3,0,0) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; -#else - attributes.colormap = gtk_widget_get_colormap (widget); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; -#endif window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); -#if !GTK_CHECK_VERSION(3,0,0) - gdk_window_set_back_pixmap (window, NULL, FALSE); -#endif + gdk_window_set_user_data (window, widget); gdk_window_show (window); @@ -4083,11 +3775,7 @@ eel_canvas_item_accessible_is_item_in_window (EelCanvasItem *item, int window_width, window_height; gdk_window_get_geometry (gtk_widget_get_window (widget), NULL, NULL, -#if GTK_CHECK_VERSION (3, 0, 0) &window_width, &window_height); -#else - &window_width, &window_height, NULL); -#endif /* * Check whether rectangles intersect */ @@ -4302,7 +3990,6 @@ eel_canvas_item_accessible_ref_state_set (AtkObject *accessible) return state_set; } -#if GTK_CHECK_VERSION(3, 0, 0) static GType eel_canvas_item_accessible_get_type (void); typedef struct _EelCanvasItemAccessible EelCanvasItemAccessible; @@ -4338,61 +4025,7 @@ static void eel_canvas_item_accessible_init (EelCanvasItemAccessible *accessible) { } -#else -static void -eel_canvas_item_accessible_class_init (AtkObjectClass *klass) -{ - accessible_item_parent_class = g_type_class_peek_parent (klass); - - klass->initialize = eel_canvas_item_accessible_initialize; - klass->ref_state_set = eel_canvas_item_accessible_ref_state_set; -} -static GType -eel_canvas_item_accessible_get_type (void) -{ - static GType type = 0; - - if (!type) - { - static const GInterfaceInfo atk_component_info = - { - (GInterfaceInitFunc) eel_canvas_item_accessible_component_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - AtkObjectFactory *factory; - GType parent_atk_type; - GTypeQuery query; - GTypeInfo tinfo = { 0 }; - - factory = atk_registry_get_factory (atk_get_default_registry(), - G_TYPE_INITIALLY_UNOWNED); - if (!factory) - { - return G_TYPE_INVALID; - } - parent_atk_type = atk_object_factory_get_accessible_type (factory); - if (!parent_atk_type) - { - return G_TYPE_INVALID; - } - g_type_query (parent_atk_type, &query); - tinfo.class_init = (GClassInitFunc) eel_canvas_item_accessible_class_init; - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - type = g_type_register_static (parent_atk_type, - "EelCanvasItemAccessibility", - &tinfo, 0); - - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, - &atk_component_info); - - } - - return type; -} -#endif static AtkObject * eel_canvas_item_accessible_create (GObject *for_object) { @@ -4439,7 +4072,6 @@ eel_canvas_item_accessible_factory_class_init (AtkObjectFactoryClass *klass) klass->get_accessible_type = eel_canvas_item_accessible_factory_get_accessible_type; } -#if GTK_CHECK_VERSION(3, 0, 0) static GType eel_canvas_item_accessible_factory_get_type (void); typedef AtkObjectFactory EelCanvasItemAccessibleFactory; @@ -4452,35 +4084,6 @@ eel_canvas_item_accessible_factory_init (EelCanvasItemAccessibleFactory *accessi { } -#else -static GType -eel_canvas_item_accessible_factory_get_type (void) -{ - static GType type = 0; - - if (!type) - { - static const GTypeInfo tinfo = - { - sizeof (AtkObjectFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) eel_canvas_item_accessible_factory_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (AtkObjectFactory), - 0, /* n_preallocs */ - NULL - }; - type = g_type_register_static (ATK_TYPE_OBJECT_FACTORY, - "EelCanvasItemAccessibilityFactory", - &tinfo, 0); - } - - return type; -} -#endif - /* Class initialization function for EelCanvasItemClass */ static void eel_canvas_item_class_init (EelCanvasItemClass *klass) diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h index b168aed8..d26d3daf 100644 --- a/eel/eel-canvas.h +++ b/eel/eel-canvas.h @@ -38,9 +38,7 @@ #define EEL_CANVAS_H #include <gtk/gtk.h> -#if GTK_CHECK_VERSION(3, 0, 0) #include <gtk/gtk-a11y.h> -#endif #include <gdk/gdk.h> #include <stdarg.h> @@ -162,11 +160,7 @@ extern "C" { * coordinates of the drawable, a temporary pixmap, where things get * drawn. (width, height) are the dimensions of the drawable. */ -#if GTK_CHECK_VERSION(3,0,0) void (* draw) (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region); -#else - void (* draw) (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose); -#endif /* Calculate the distance from an item to the specified point. It also * returns a canvas item which is the item itself in the case of the @@ -265,7 +259,6 @@ extern "C" { * XGrabPointer(). */ #endif -#if GTK_CHECK_VERSION (3, 0, 0) GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item, GdkEventMask event_mask, GdkCursor *cursor, @@ -274,10 +267,6 @@ extern "C" { #else guint32 etime); #endif -#else - int eel_canvas_item_grab (EelCanvasItem *item, unsigned int event_mask, - GdkCursor *cursor, guint32 etime); -#endif #if GTK_CHECK_VERSION(3, 20, 0) /* Ungrabs the seat -- the specified item must be the same that was passed to @@ -466,11 +455,7 @@ extern "C" { /* Draw the background for the area given. */ void (* draw_background) (EelCanvas *canvas, -#if GTK_CHECK_VERSION(3,0,0) cairo_t *cr); -#else - int x, int y, int width, int height); -#endif /* Private Virtual methods for groping the canvas inside matecomponent */ void (* request_update) (EelCanvas *canvas); @@ -558,7 +543,6 @@ extern "C" { void eel_canvas_world_to_window (EelCanvas *canvas, double worldx, double worldy, double *winx, double *winy); -#if GTK_CHECK_VERSION(3, 0, 0) GType eel_canvas_accessible_get_type (void); typedef struct _EelCanvasAccessible EelCanvasAccessible; @@ -573,7 +557,6 @@ extern "C" { { GtkContainerAccessibleClass parent_class; }; -#endif #ifdef __cplusplus } diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 37564275..ee1e792a 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -35,21 +35,9 @@ #include <glib/gi18n-lib.h> #include <pango/pango.h> #include <gtk/gtk.h> -#if GTK_CHECK_VERSION(3, 0, 0) #include <gtk/gtk-a11y.h> -#endif #include <gdk/gdkkeysyms.h> -/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */ -#if !GTK_CHECK_VERSION (3, 0, 0) -#define cairo_region_t GdkRegion -#define cairo_region_destroy gdk_region_destroy -#define GtkEditableInterface GtkEditableClass -#endif - -#if !GTK_CHECK_VERSION(3,0,0) -#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) -#endif /* g_memmove is removed in glib 2.40 */ #if GLIB_CHECK_VERSION (2, 39, 0) @@ -92,36 +80,27 @@ static void eel_editable_label_get_property (GObject GValue *value, GParamSpec *pspec); static void eel_editable_label_finalize (GObject *object); -#if GTK_CHECK_VERSION(3,0,0) + static void eel_editable_label_get_preferred_width (GtkWidget *widget, gint *minimum, gint *natural); static void eel_editable_label_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural); -#else -static void eel_editable_label_size_request (GtkWidget *widget, - GtkRequisition *requisition); -#endif + static void eel_editable_label_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void eel_editable_label_state_changed (GtkWidget *widget, GtkStateType state); -#if GTK_CHECK_VERSION(3,0,0) + static void eel_editable_label_style_updated (GtkWidget *widget); -#else -static void eel_editable_label_style_set (GtkWidget *widget, - GtkStyle *previous_style); -#endif + static void eel_editable_label_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir); -#if GTK_CHECK_VERSION(3,0,0) + static gint eel_editable_label_draw (GtkWidget *widget, cairo_t *cr); -#else -static gint eel_editable_label_expose (GtkWidget *widget, - GdkEventExpose *event); -#endif + static void eel_editable_label_realize (GtkWidget *widget); static void eel_editable_label_unrealize (GtkWidget *widget); static void eel_editable_label_map (GtkWidget *widget); @@ -140,11 +119,8 @@ static gint eel_editable_label_focus_in (GtkWidget GdkEventFocus *event); static gint eel_editable_label_focus_out (GtkWidget *widget, GdkEventFocus *event); -#if GTK_CHECK_VERSION(3, 0, 0) static GType eel_editable_label_accessible_get_type (void); -#else -static AtkObject *eel_editable_label_get_accessible (GtkWidget *widget); -#endif + static void eel_editable_label_commit_cb (GtkIMContext *context, const gchar *str, EelEditableLabel *label); @@ -217,11 +193,8 @@ static void editable_real_set_position (GtkEditable *editable, gint position); static gint editable_get_position (GtkEditable *editable); -#if GTK_CHECK_VERSION (3, 0, 0) G_DEFINE_TYPE_WITH_CODE (EelEditableLabel, eel_editable_label, GTK_TYPE_WIDGET, -#else -G_DEFINE_TYPE_WITH_CODE (EelEditableLabel, eel_editable_label, GTK_TYPE_MISC, -#endif + G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, eel_editable_label_editable_init)); static void @@ -258,25 +231,14 @@ eel_editable_label_class_init (EelEditableLabelClass *class) gobject_class->get_property = eel_editable_label_get_property; gobject_class->finalize = eel_editable_label_finalize; -#if GTK_CHECK_VERSION(3,0,0) + widget_class->get_preferred_width = eel_editable_label_get_preferred_width; widget_class->get_preferred_height = eel_editable_label_get_preferred_height; -#else - widget_class->size_request = eel_editable_label_size_request; -#endif widget_class->size_allocate = eel_editable_label_size_allocate; widget_class->state_changed = eel_editable_label_state_changed; -#if GTK_CHECK_VERSION(3,0,0) widget_class->style_updated = eel_editable_label_style_updated; -#else - widget_class->style_set = eel_editable_label_style_set; -#endif widget_class->direction_changed = eel_editable_label_direction_changed; -#if GTK_CHECK_VERSION(3,0,0) widget_class->draw = eel_editable_label_draw; -#else - widget_class->expose_event = eel_editable_label_expose; -#endif widget_class->realize = eel_editable_label_realize; widget_class->unrealize = eel_editable_label_unrealize; widget_class->map = eel_editable_label_map; @@ -289,11 +251,8 @@ eel_editable_label_class_init (EelEditableLabelClass *class) widget_class->key_release_event = eel_editable_label_key_release; widget_class->focus_in_event = eel_editable_label_focus_in; widget_class->focus_out_event = eel_editable_label_focus_out; -#if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_class_set_accessible_type (widget_class, eel_editable_label_accessible_get_type ()); -#else - widget_class->get_accessible = eel_editable_label_get_accessible; -#endif + class->move_cursor = eel_editable_label_move_cursor; class->delete_from_cursor = eel_editable_label_delete_from_cursor; @@ -663,10 +622,9 @@ eel_editable_label_init (EelEditableLabel *label) label->n_bytes = 0; gtk_widget_set_can_focus (GTK_WIDGET (label), TRUE); -#if GTK_CHECK_VERSION(3,0,0) + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (label)), GTK_STYLE_CLASS_ENTRY); -#endif /* This object is completely private. No external entity can gain a reference * to it; so we create it here and destroy it in finalize(). @@ -964,12 +922,8 @@ static gint get_label_wrap_width (EelEditableLabel *label) { PangoLayout *layout; -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *style = gtk_widget_get_style_context (GTK_WIDGET (label)); PangoFontDescription *desc; -#else - GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (label)); -#endif LabelWrapWidth *wrap_width = g_object_get_data (G_OBJECT (style), "gtk-label-wrap-width"); if (!wrap_width) @@ -979,37 +933,25 @@ get_label_wrap_width (EelEditableLabel *label) wrap_width, label_wrap_width_free); } -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_get (style, gtk_widget_get_state_flags (GTK_WIDGET (label)), GTK_STYLE_PROPERTY_FONT, &desc, NULL); if (wrap_width->font_desc && pango_font_description_equal (wrap_width->font_desc, desc)) goto out; -#else - if (wrap_width->font_desc && pango_font_description_equal (wrap_width->font_desc, style->font_desc)) - return wrap_width->width; -#endif if (wrap_width->font_desc) pango_font_description_free (wrap_width->font_desc); -#if GTK_CHECK_VERSION(3,0,0) wrap_width->font_desc = pango_font_description_copy (desc); -#else - wrap_width->font_desc = pango_font_description_copy (style->font_desc); -#endif layout = gtk_widget_create_pango_layout (GTK_WIDGET (label), "This long string gives a good enough length for any line to have."); pango_layout_get_size (layout, &wrap_width->width, NULL); g_object_unref (layout); -#if GTK_CHECK_VERSION(3,0,0) out: pango_font_description_free (desc); -#endif - return wrap_width->width; } @@ -1177,14 +1119,9 @@ eel_editable_label_size_request (GtkWidget *widget, gint width, height; PangoRectangle logical_rect; gint set_width; -#if GTK_CHECK_VERSION(3,0,0) gint xpad, ypad; -#else - gfloat xpad, ypad; -#endif -#if GTK_CHECK_VERSION (3, 0, 0) gint margin_start, margin_end, margin_top, margin_bottom; -#endif + g_assert (EEL_IS_EDITABLE_LABEL (widget)); g_assert (requisition != NULL); @@ -1209,7 +1146,6 @@ eel_editable_label_size_request (GtkWidget *widget, eel_editable_label_ensure_layout (label, TRUE); -#if GTK_CHECK_VERSION(3,0,0) margin_start = gtk_widget_get_margin_start (widget); margin_end = gtk_widget_get_margin_end (widget); margin_top = gtk_widget_get_margin_top (widget); @@ -1217,10 +1153,6 @@ eel_editable_label_size_request (GtkWidget *widget, xpad = margin_start + margin_end; ypad = margin_top + margin_bottom; -#else - gtk_misc_get_alignment (&label->misc, - &xpad, &ypad); -#endif width = xpad * 2; height = ypad * 2; @@ -1238,7 +1170,6 @@ eel_editable_label_size_request (GtkWidget *widget, requisition->height = height; } -#if GTK_CHECK_VERSION(3,0,0) static void eel_editable_label_get_preferred_width (GtkWidget *widget, gint *minimum, @@ -1262,7 +1193,6 @@ eel_editable_label_get_preferred_height (GtkWidget *widget, *minimum = *natural = requisition.height; } -#endif static void eel_editable_label_size_allocate (GtkWidget *widget, @@ -1288,12 +1218,7 @@ eel_editable_label_state_changed (GtkWidget *widget, } static void -#if GTK_CHECK_VERSION(3,0,0) eel_editable_label_style_updated (GtkWidget *widget) -#else -eel_editable_label_style_set (GtkWidget *widget, - GtkStyle *previous_style) -#endif { EelEditableLabel *label; @@ -1301,9 +1226,7 @@ eel_editable_label_style_set (GtkWidget *widget, label = EEL_EDITABLE_LABEL (widget); -#if GTK_CHECK_VERSION(3,0,0) GTK_WIDGET_CLASS (eel_editable_label_parent_class)->style_updated (widget); -#endif /* We have to clear the layout, fonts etc. may have changed */ eel_editable_label_recompute (label); @@ -1313,17 +1236,10 @@ eel_editable_label_style_set (GtkWidget *widget, */ if (gtk_widget_get_realized (widget)) { -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *style; style = gtk_widget_get_style_context (widget); gtk_style_context_set_background (style, gtk_widget_get_window (widget)); -#else - GtkStyle *style; - - style = gtk_widget_get_style (widget); - gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]); -#endif } } @@ -1339,7 +1255,6 @@ eel_editable_label_direction_changed (GtkWidget *widget, GTK_WIDGET_CLASS (eel_editable_label_parent_class)->direction_changed (widget, previous_dir); } -#if GTK_CHECK_VERSION (3, 0, 0) static gfloat gtk_align_to_gfloat (GtkAlign align) { @@ -1355,14 +1270,12 @@ gtk_align_to_gfloat (GtkAlign align) return 0.0; } } -#endif static void get_layout_location (EelEditableLabel *label, gint *xp, gint *yp) { -#if GTK_CHECK_VERSION (3, 0, 0) GtkWidget *widget; gfloat xalign, yalign; GtkRequisition req; @@ -1394,33 +1307,6 @@ get_layout_location (EelEditableLabel *label, y = floor (0.5 + ypad + ((allocation.height - req.height) * yalign) + 0.5); -#else - GtkMisc *misc; - GtkWidget *widget; - gfloat xalign, yalign; - GtkRequisition req; - gint x, y, xpad, ypad; - GtkAllocation allocation; - - widget = GTK_WIDGET (label); - misc = GTK_MISC (label); - gtk_misc_get_alignment (misc, &xalign, &yalign); - - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR) - xalign = 1.0 - xalign; - - gtk_widget_get_preferred_size (widget, &req, NULL); - gtk_misc_get_padding (misc, &xpad, &ypad); - - gtk_widget_get_allocation (widget, &allocation); - x = floor (xpad - + ((allocation.width - req.width) * xalign) - + 0.5); - - y = floor (ypad - + ((allocation.height - req.height) * yalign) - + 0.5); -#endif if (xp) *xp = x; @@ -1429,11 +1315,7 @@ get_layout_location (EelEditableLabel *label, *yp = y; } -#if GTK_CHECK_VERSION(3,0,0) static gint -#else -static void -#endif eel_editable_label_get_cursor_pos (EelEditableLabel *label, PangoRectangle *strong_pos, PangoRectangle *weak_pos) @@ -1450,10 +1332,8 @@ eel_editable_label_get_cursor_pos (EelEditableLabel *label, g_utf8_offset_to_pointer (preedit_text, label->preedit_cursor) - preedit_text; pango_layout_get_cursor_pos (label->layout, index, strong_pos, weak_pos); -#if GTK_CHECK_VERSION(3,0,0) return index; -#endif } /* Copied from gtkutil private function */ @@ -1587,7 +1467,6 @@ eel_editable_label_get_block_cursor_location (EelEditableLabel *label, /* These functions are copies from gtk+, as they are not exported from gtk+ */ static void -#if GTK_CHECK_VERSION(3,0,0) eel_editable_label_draw_cursor (EelEditableLabel *label, cairo_t *cr, gint xoffset, gint yoffset) { if (gtk_widget_is_drawable (GTK_WIDGET (label))) @@ -1658,130 +1537,12 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, cairo_t *cr, gint xoff } cairo_restore (cr); -#else -eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yoffset) -{ - if (gtk_widget_is_drawable (GTK_WIDGET (label))) - { - GtkWidget *widget = GTK_WIDGET (label); - - GtkTextDirection keymap_direction; - GtkTextDirection widget_direction; - gboolean split_cursor; - gboolean block; - gboolean block_at_line_end; - gint range[2]; - PangoRectangle strong_pos, weak_pos; - PangoRectangle *cursor1 = NULL; - PangoRectangle *cursor2 = NULL; - GdkRectangle cursor_location; - GtkTextDirection dir1 = GTK_TEXT_DIR_NONE; - GtkTextDirection dir2 = GTK_TEXT_DIR_NONE; - - keymap_direction = - (gdk_keymap_get_direction (gdk_keymap_get_default ()) == PANGO_DIRECTION_LTR) ? - GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL; - - widget_direction = gtk_widget_get_direction (widget); - - if (label->overwrite_mode && - eel_editable_label_get_block_cursor_location (label, range, - &strong_pos, - &block_at_line_end)) - block = TRUE; - else - block = FALSE; - - if (!block) - { - eel_editable_label_get_cursor_pos (label, &strong_pos, &weak_pos); - - g_object_get (gtk_widget_get_settings (widget), - "gtk-split-cursor", &split_cursor, - NULL); - - dir1 = widget_direction; - - if (split_cursor) - { - cursor1 = &strong_pos; - - if (strong_pos.x != weak_pos.x || - strong_pos.y != weak_pos.y) - { - dir2 = (widget_direction == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR; - cursor2 = &weak_pos; - } - } - else - { - if (keymap_direction == widget_direction) - cursor1 = &strong_pos; - else - cursor1 = &weak_pos; - } - - cursor_location.x = xoffset + PANGO_PIXELS (cursor1->x); - cursor_location.y = yoffset + PANGO_PIXELS (cursor1->y); - cursor_location.width = 0; - cursor_location.height = PANGO_PIXELS (cursor1->height); - - gtk_draw_insertion_cursor (widget, - gtk_widget_get_window (widget), - NULL, &cursor_location, - TRUE, dir1, dir2 != GTK_TEXT_DIR_NONE); - - if (dir2 != GTK_TEXT_DIR_NONE) - { - cursor_location.x = xoffset + PANGO_PIXELS (cursor2->x); - cursor_location.y = yoffset + PANGO_PIXELS (cursor2->y); - cursor_location.width = 0; - cursor_location.height = PANGO_PIXELS (cursor2->height); - - gtk_draw_insertion_cursor (widget, - gtk_widget_get_window (widget), - NULL, &cursor_location, - FALSE, dir2, TRUE); - } - } - else /* Block cursor */ - { - cairo_region_t *clip; - - cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); - - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_rectangle (cr, - xoffset + PANGO_PIXELS (strong_pos.x), - yoffset + PANGO_PIXELS (strong_pos.y), - PANGO_PIXELS (strong_pos.width), - PANGO_PIXELS (strong_pos.height)); - - if (!block_at_line_end) - { - clip = gdk_pango_layout_get_clip_region (label->layout, - xoffset, yoffset, - range, 1); - - gdk_cairo_region (cr, clip); - cairo_clip (cr); - gdk_cairo_set_source_color (cr, - >k_widget_get_style (widget)->base[GTK_STATE_NORMAL]); - cairo_move_to (cr, xoffset, yoffset); - pango_cairo_show_layout (cr, label->layout); - - cairo_region_destroy (clip); - } - - cairo_destroy (cr); -#endif } } } static gint -#if GTK_CHECK_VERSION(3,0,0) eel_editable_label_draw (GtkWidget *widget, cairo_t *cr) { @@ -1881,104 +1642,6 @@ eel_editable_label_draw (GtkWidget *widget, gtk_widget_get_allocated_height (widget)); gtk_style_context_restore (style); -#else -eel_editable_label_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - EelEditableLabel *label; - GtkStyle *style; - g_assert (event != NULL); - gint x, y; - - g_assert (EEL_IS_EDITABLE_LABEL (widget)); - - label = EEL_EDITABLE_LABEL (widget); - style = gtk_widget_get_style (widget); - - eel_editable_label_ensure_layout (label, TRUE); - - if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget) && - label->text) - { - get_layout_location (label, &x, &y); - - gtk_paint_layout (style, - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - TRUE, - &event->area, - widget, - "label", - x, y, - label->layout); - - if (label->selection_anchor != label->selection_end) - { - gint range[2]; - const char *text; - cairo_region_t *clip; - GtkStateType state; - - range[0] = label->selection_anchor; - range[1] = label->selection_end; - - /* Handle possible preedit string */ - if (label->preedit_length > 0 && - range[1] > label->selection_anchor) - { - text = pango_layout_get_text (label->layout) + label->selection_anchor; - range[1] += g_utf8_offset_to_pointer (text, label->preedit_length) - text; - } - - if (range[0] > range[1]) - { - gint tmp = range[0]; - range[0] = range[1]; - range[1] = tmp; - } - - clip = gdk_pango_layout_get_clip_region (label->layout, - x, y, - range, - 1); - - cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); - gdk_cairo_region (cr, clip); - cairo_clip (cr); - - state = GTK_STATE_SELECTED; - if (!gtk_widget_has_focus (widget)) - state = GTK_STATE_ACTIVE; - - gdk_cairo_set_source_color (cr, &style->base[state]); - cairo_paint (cr); - - gdk_cairo_set_source_color (cr, &style->text[state]); - cairo_move_to (cr, x, y); - pango_cairo_show_layout (cr, label->layout); - - cairo_destroy (cr); - - cairo_region_destroy (clip); - } - else if (gtk_widget_has_focus (widget)) - eel_editable_label_draw_cursor (label, x, y); - - if (label->draw_outline) - { - GtkAllocation allocation; - - gtk_widget_get_allocation (widget, &allocation); - cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); - gdk_cairo_set_source_color (cr, &style->text [gtk_widget_get_state (widget)]); - cairo_set_line_width (cr, 1.0); - cairo_rectangle (cr, 0.5, 0.5, - allocation.width - 1, - allocation.height - 1); - cairo_stroke (cr); - - cairo_destroy (cr); -#endif } } @@ -1994,11 +1657,7 @@ eel_editable_label_realize (GtkWidget *widget) gint attributes_mask; GtkAllocation allocation; GdkWindow *window; -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *style; -#else - GtkStyle *style; -#endif gtk_widget_set_realized (widget, TRUE); label = EEL_EDITABLE_LABEL (widget); @@ -2011,9 +1670,6 @@ eel_editable_label_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.visual = gtk_widget_get_visual (widget); -#if !GTK_CHECK_VERSION(3,0,0) - attributes.colormap = gtk_widget_get_colormap (widget); -#endif display = gtk_widget_get_display (GTK_WIDGET (label)); attributes.cursor = gdk_cursor_new_for_display (display, GDK_XTERM); attributes.event_mask = gtk_widget_get_events (widget) | @@ -2027,30 +1683,17 @@ eel_editable_label_realize (GtkWidget *widget) GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); -#if GTK_CHECK_VERSION(3,0,0) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_CURSOR; -#else - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR; -#endif window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, widget); -#if GTK_CHECK_VERSION(3,0,0) g_object_unref (attributes.cursor); style = gtk_widget_get_style_context (widget); gtk_style_context_set_background (style, gtk_widget_get_window (widget)); -#else - gdk_cursor_unref (attributes.cursor); - - style = gtk_style_attach (gtk_widget_get_style (widget) , gtk_widget_get_window (widget)); - gtk_widget_set_style (widget, style); - - gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]); -#endif gtk_im_context_set_client_window (label->im_context, gtk_widget_get_window (widget)); } @@ -2274,14 +1917,9 @@ eel_editable_label_motion (GtkWidget *widget, if ((event->state & GDK_BUTTON1_MASK) == 0) return FALSE; -#if GTK_CHECK_VERSION (3, 0, 0) gdk_window_get_device_position (gtk_widget_get_window (widget), event->device, &x, &y, NULL); -#else - gdk_window_get_pointer (gtk_widget_get_window (widget), - &x, &y, NULL); -#endif get_layout_index (label, x, y, &index); @@ -3417,12 +3055,7 @@ popup_position_func (GtkMenu *menu, gdk_window_get_origin (gtk_widget_get_window (widget), x, y); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size (widget, &req, NULL); -#else - /*gtk_widget_size_request (label->popup_menu, &req);*/ - gtk_widget_get_requisition (widget, &req); -#endif gtk_widget_get_allocation (widget, &allocation); *x += allocation.width / 2; @@ -3776,7 +3409,6 @@ typedef struct gint position; } EelEditableLabelAccessiblePaste; -#if GTK_CHECK_VERSION(3, 0, 0) typedef struct _EelEditableLabelAccessible EelEditableLabelAccessible; typedef struct _EelEditableLabelAccessibleClass EelEditableLabelAccessibleClass; @@ -3789,7 +3421,6 @@ struct _EelEditableLabelAccessibleClass { GtkWidgetAccessibleClass parent_class; }; -#endif static gchar* eel_editable_label_accessible_get_text (AtkText *text, @@ -4644,7 +4275,6 @@ eel_editable_label_accessible_finalize (GObject *object) G_OBJECT_CLASS (a11y_parent_class)->finalize (object); } -#if GTK_CHECK_VERSION(3, 0, 0) static void eel_editable_label_accessible_class_init (EelEditableLabelAccessibleClass *klass) { @@ -4671,57 +4301,4 @@ G_DEFINE_TYPE_WITH_CODE (EelEditableLabelAccessible, atk_editable_text_interface_init) G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init)); -#else -static void -eel_editable_label_accessible_class_init (AtkObjectClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - a11y_parent_class = g_type_class_peek_parent (klass); - - klass->initialize = eel_editable_label_accessible_initialize; - klass->get_name = eel_editable_label_accessible_get_name; - klass->ref_state_set = eel_editable_label_accessible_ref_state_set; - gobject_class->finalize = eel_editable_label_accessible_finalize; -} - -static AtkObject * -eel_editable_label_get_accessible (GtkWidget *widget) -{ - static GType type = 0; - AtkObject *accessible; - if ((accessible = eel_accessibility_get_atk_object (widget))) - return accessible; - - if (!type) - { - const GInterfaceInfo atk_editable_text_info = - { - (GInterfaceInitFunc) atk_editable_text_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - const GInterfaceInfo atk_text_info = - { - (GInterfaceInitFunc) atk_text_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - type = eel_accessibility_create_derived_type ("EelEditableLabelAccessible", - G_TYPE_FROM_INSTANCE (widget), - eel_editable_label_accessible_class_init); - - if (!type) - return NULL; - - g_type_add_interface_static (type, ATK_TYPE_EDITABLE_TEXT, &atk_editable_text_info); - g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info); - } - - accessible = g_object_new (type, NULL); - - return eel_accessibility_set_atk_object_return (widget, accessible); -} -#endif diff --git a/eel/eel-editable-label.h b/eel/eel-editable-label.h index 9be7f8c9..9350b060 100644 --- a/eel/eel-editable-label.h +++ b/eel/eel-editable-label.h @@ -53,11 +53,7 @@ extern "C" { struct _EelEditableLabel { -#if GTK_CHECK_VERSION (3, 0, 0) GtkWidget widget; -#else - GtkMisc misc; -#endif /*< private >*/ guint jtype : 2; @@ -88,11 +84,8 @@ extern "C" { struct _EelEditableLabelClass { -#if GTK_CHECK_VERSION (3, 0, 0) GtkWidgetClass parent_class; -#else - GtkMiscClass parent_class; -#endif + void (* move_cursor) (EelEditableLabel *label, GtkMovementStep step, diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index 448e933a..8e86ddef 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -312,7 +312,6 @@ eel_gradient_set_bottom_color_spec (const char *gradient_spec, return eel_gradient_set_edge_color (gradient_spec, bottom_color, FALSE, TRUE); } -#if GTK_CHECK_VERSION (3, 0, 0) /** * eel_gdk_rgba_parse_with_white_default * @color: Pointer to place to put resulting color. @@ -345,40 +344,6 @@ eel_gdk_rgba_parse_with_white_default (GdkRGBA *color, color->blue = 1.0; } } -#else -/** - * eel_gdk_color_parse_with_white_default - * @color_spec: A color spec, or NULL. - * @color: Pointer to place to put resulting color. - * - * The same as gdk_color_parse, except sets the color to white if - * the spec. can't be parsed, instead of returning a boolean flag. - */ -void -eel_gdk_color_parse_with_white_default (const char *color_spec, - GdkColor *color) -{ - gboolean got_color; - - g_return_if_fail (color != NULL); - - got_color = FALSE; - if (color_spec != NULL) - { - if (gdk_color_parse (color_spec, color)) - { - got_color = TRUE; - } - } - - if (!got_color) - { - color->red = 0xFFFF; - color->green = 0xFFFF; - color->blue = 0xFFFF; - } -} -#endif guint32 eel_rgb16_to_rgb (gushort r, gushort g, gushort b) @@ -392,7 +357,6 @@ eel_rgb16_to_rgb (gushort r, gushort g, gushort b) return result; } -#if GTK_CHECK_VERSION (3, 0, 0) /** * eel_gdk_rgba_to_rgb * @color: A GdkRGBA style color. @@ -430,43 +394,7 @@ eel_gdk_rgb_to_rgba (guint32 color) return result; } -#else -/** - * eel_gdk_color_to_rgb - * @color: A GdkColor style color. - * Returns: An rgb value. - * - * Converts from a GdkColor style color to a gdk_rgb one. - * Alpha gets set to fully opaque - */ -guint32 -eel_gdk_color_to_rgb (const GdkColor *color) -{ - return eel_rgb16_to_rgb (color->red, color->green, color->blue); -} - -/** - * eel_gdk_rgb_to_color - * @color: a gdk_rgb style value. - * - * Converts from a gdk_rgb value style to a GdkColor one. - * The gdk_rgb color alpha channel is ignored. - * - * Return value: A GdkColor structure version of the given RGB color. - */ -GdkColor -eel_gdk_rgb_to_color (guint32 color) -{ - GdkColor result; - result.red = ((color >> 16) & 0xFF) * 0x101; - result.green = ((color >> 8) & 0xFF) * 0x101; - result.blue = (color & 0xff) * 0x101; - result.pixel = 0; - - return result; -} -#endif /** * eel_gdk_rgb_to_color_spec @@ -483,7 +411,7 @@ eel_gdk_rgb_to_color_spec (const guint32 color) return g_strdup_printf ("#%06X", (guint) (color & 0xFFFFFF)); } -#if GTK_CHECK_VERSION(3,0,0) + /** * eel_gdk_rgba_is_dark: * @@ -497,21 +425,6 @@ eel_gdk_rgba_is_dark (const GdkRGBA *color) intensity = ((((int) (color->red) >> 8) * 77) + (((int) (color->green) >> 8) * 150) + (((int) (color->blue) >> 8) * 28)) >> 8; -#else -/** - * eel_gdk_color_is_dark: - * - * Return true if the given color is `dark' - */ -gboolean -eel_gdk_color_is_dark (GdkColor *color) -{ - int intensity; - - intensity = (((color->red >> 8) * 77) - + ((color->green >> 8) * 150) - + ((color->blue >> 8) * 28)) >> 8; -#endif return intensity < 128; } @@ -561,7 +474,6 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return, return gdk_flags; } -#if GTK_CHECK_VERSION(3,0,0) void eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr, GdkRGBA *text_color, @@ -582,33 +494,9 @@ eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr, cairo_restore (cr); } -#else -void -eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, - GdkColor *text_color, - GdkColor *shadow_color, - int x, - int y, - PangoLayout *layout) -{ - cairo_t *cr; - cr = gdk_cairo_create (drawable); - - gdk_cairo_set_source_color (cr, shadow_color); - cairo_move_to (cr, x+1, y+1); - pango_cairo_show_layout (cr, layout); - - gdk_cairo_set_source_color (cr, text_color); - cairo_move_to (cr, x, y); - pango_cairo_show_layout (cr, layout); - - cairo_destroy (cr); -} -#endif #if ! defined (EEL_OMIT_SELF_CHECK) -#if GTK_CHECK_VERSION(3,0,0) static char * eel_gdk_rgba_as_hex_string (GdkRGBA color) { @@ -636,33 +524,6 @@ eel_self_check_gdk_rgb_to_color (guint32 color) return eel_gdk_rgba_as_hex_string (result); } -#else -static char * -eel_gdk_color_as_hex_string (GdkColor color) -{ - return g_strdup_printf ("%04X%04X%04X", - color.red, color.green, color.blue); -} - -static char * -eel_self_check_parse (const char *color_spec) -{ - GdkColor color; - - eel_gdk_color_parse_with_white_default (color_spec, &color); - return eel_gdk_color_as_hex_string (color); -} - -static char * -eel_self_check_gdk_rgb_to_color (guint32 color) -{ - GdkColor result; - - result = eel_gdk_rgb_to_color (color); - - return eel_gdk_color_as_hex_string (result); -} -#endif void eel_self_check_gdk_extensions (void) @@ -747,7 +608,7 @@ eel_self_check_gdk_extensions (void) EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a-c:v", "c"), "a-c"); EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a:-b:h", "d"), "a:-d"); - /* eel_gdk_color_parse_with_white_default */ + /* eel_gdk_rgba_parse_with_white_default */ EEL_CHECK_STRING_RESULT (eel_self_check_parse (""), "FFFFFFFFFFFF"); EEL_CHECK_STRING_RESULT (eel_self_check_parse ("a"), "FFFFFFFFFFFF"); EEL_CHECK_STRING_RESULT (eel_self_check_parse ("white"), "FFFFFFFFFFFF"); diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h index 0e8af740..b849af6b 100644 --- a/eel/eel-gdk-extensions.h +++ b/eel/eel-gdk-extensions.h @@ -102,30 +102,19 @@ char * eel_gradient_set_bottom_color_spec (const char /* A version of parse_color that substitutes a default color instead of returning a boolean to indicate it cannot be parsed. */ -#if GTK_CHECK_VERSION (3, 0, 0) void eel_gdk_rgba_parse_with_white_default (GdkRGBA *parsed_color, const char *color_spec); -#else -void eel_gdk_color_parse_with_white_default (const char *color_spec, - GdkColor *parsed_color); -#endif + guint32 eel_rgb16_to_rgb (gushort r, gushort g, gushort b); -#if GTK_CHECK_VERSION (3, 0, 0) guint32 eel_gdk_rgba_to_rgb (const GdkRGBA *color); GdkRGBA eel_gdk_rgb_to_rgba (guint32 color); -#else -guint32 eel_gdk_color_to_rgb (const GdkColor *color); -GdkColor eel_gdk_rgb_to_color (guint32 color); -#endif + char * eel_gdk_rgb_to_color_spec (guint32 color); -#if GTK_CHECK_VERSION(3,0,0) gboolean eel_gdk_rgba_is_dark (const GdkRGBA *color); -#else -gboolean eel_gdk_color_is_dark (GdkColor *color); -#endif + /* Wrapper for XParseGeometry */ EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string, @@ -133,15 +122,11 @@ EelGdkGeometryFlags eel_gdk_parse_geometry (const char int *y_return, guint *width_return, guint *height_return); -#if GTK_CHECK_VERSION(3,0,0) + void eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr, GdkRGBA *text_color, GdkRGBA *shadow_color, -#else -void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, - GdkColor *text_color, - GdkColor *shadow_color, -#endif + int x, int y, PangoLayout *layout); diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c index bbbffc3a..f86ad086 100644 --- a/eel/eel-gdk-pixbuf-extensions.c +++ b/eel/eel-gdk-pixbuf-extensions.c @@ -622,11 +622,7 @@ eel_gdk_pixbuf_unref_if_not_null (GdkPixbuf *pixbuf_or_null) void eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr, -#else - GdkDrawable *drawable, -#endif int source_x, int source_y, EelIRect destination_area) @@ -638,16 +634,10 @@ eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, int target_height; int source_width; int source_height; -#if !GTK_CHECK_VERSION (3, 0, 0) - cairo_t *cr; -#endif g_return_if_fail (eel_gdk_pixbuf_is_valid (pixbuf)); -#if GTK_CHECK_VERSION (3, 0, 0) g_return_if_fail (cr != NULL); -#else - g_return_if_fail (drawable != NULL); -#endif + g_return_if_fail (!eel_irect_is_empty (&destination_area)); dimensions = eel_gdk_pixbuf_get_dimensions (pixbuf); @@ -683,9 +673,6 @@ eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, target.x1 = target.x0 + MIN (target_width, source_width); target.y1 = target.y0 + MIN (target_height, source_height); -#if !GTK_CHECK_VERSION (3, 0, 0) - cr = gdk_cairo_create (drawable); -#endif gdk_cairo_set_source_pixbuf (cr, (GdkPixbuf *) pixbuf, source.x0 - target.x0, source.y0 - target.y0); cairo_rectangle (cr, target.x0, target.y0, @@ -1265,11 +1252,8 @@ eel_gdk_pixbuf_render (GdkPixbuf *pixbuf, guint saturation, guint brightness, guint lighten_value, -#if GTK_CHECK_VERSION(3,0,0) GdkRGBA *color) -#else - guint color) -#endif + { GdkPixbuf *temp_pixbuf, *old_pixbuf; @@ -1281,27 +1265,14 @@ eel_gdk_pixbuf_render (GdkPixbuf *pixbuf, else if (render_mode == 2) { /* colorize icon */ -#if GTK_CHECK_VERSION(3,0,0) temp_pixbuf = eel_create_colorized_pixbuf (pixbuf, color); -#else - temp_pixbuf = eel_create_colorized_pixbuf (pixbuf, - EEL_RGBA_COLOR_GET_R (color), - EEL_RGBA_COLOR_GET_G (color), - EEL_RGBA_COLOR_GET_B (color)); -#endif } else if (render_mode == 3) { /* monochromely colorize icon */ old_pixbuf = eel_create_darkened_pixbuf (pixbuf, 0, 255); -#if GTK_CHECK_VERSION(3,0,0) temp_pixbuf = eel_create_colorized_pixbuf (old_pixbuf, color); -#else - temp_pixbuf = eel_create_colorized_pixbuf (old_pixbuf, - EEL_RGBA_COLOR_GET_R (color), - EEL_RGBA_COLOR_GET_G (color), - EEL_RGBA_COLOR_GET_B (color)); -#endif + g_object_unref (old_pixbuf); } else diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h index 87f79a7a..c82b6214 100644 --- a/eel/eel-gdk-pixbuf-extensions.h +++ b/eel/eel-gdk-pixbuf-extensions.h @@ -93,11 +93,7 @@ void eel_gdk_pixbuf_unref_if_not_null (GdkPixbuf /* Copy a pixbuf to an area of a GdkDrawable */ void eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr, -#else - GdkDrawable *drawable, -#endif int source_x, int source_y, EelIRect destination_area); @@ -151,10 +147,7 @@ GdkPixbuf * eel_gdk_pixbuf_render (GdkPixbuf *pixbuf guint saturation, guint brightness, guint lighten_value, -#if GTK_CHECK_VERSION(3,0,0) GdkRGBA *color); -#else - guint color); -#endif + #endif /* EEL_GDK_PIXBUF_EXTENSIONS_H */ diff --git a/eel/eel-graphic-effects.c b/eel/eel-graphic-effects.c index 39309de9..f25cbb6f 100644 --- a/eel/eel-graphic-effects.c +++ b/eel/eel-graphic-effects.c @@ -172,13 +172,7 @@ eel_create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken) GdkPixbuf * eel_create_colorized_pixbuf (GdkPixbuf *src, -#if GTK_CHECK_VERSION(3,0,0) GdkRGBA *color) -#else - int red_value, - int green_value, - int blue_value) -#endif { int i, j; int width, height, has_alpha, src_row_stride, dst_row_stride; @@ -188,9 +182,7 @@ eel_create_colorized_pixbuf (GdkPixbuf *src, guchar *pixdest; GdkPixbuf *dest; -#if GTK_CHECK_VERSION(3,0,0) gint red_value, green_value, blue_value; -#endif g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL); g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src) @@ -199,11 +191,9 @@ eel_create_colorized_pixbuf (GdkPixbuf *src, && gdk_pixbuf_get_n_channels (src) == 4), NULL); g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL); -#if GTK_CHECK_VERSION(3,0,0) red_value = eel_round (color->red * 255); green_value = eel_round (color->green * 255); blue_value = eel_round (color->blue * 255); -#endif dest = create_new_pixbuf (src); diff --git a/eel/eel-graphic-effects.h b/eel/eel-graphic-effects.h index 7291629b..3a9027fe 100644 --- a/eel/eel-graphic-effects.h +++ b/eel/eel-graphic-effects.h @@ -27,9 +27,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include <gtk/gtk.h> -#if GTK_CHECK_VERSION(3,0,0) #include <gdk/gdk.h> -#endif /* return a lightened pixbuf for pre-lighting */ @@ -42,13 +40,7 @@ GdkPixbuf *eel_create_darkened_pixbuf (GdkPixbuf *source_pixbuf, /* return a pixbuf colorized with the color specified by the parameters */ GdkPixbuf* eel_create_colorized_pixbuf (GdkPixbuf *source_pixbuf, -#if GTK_CHECK_VERSION(3,0,0) GdkRGBA *color); -#else - int red_value, - int green_value, - int blue_value); -#endif /* stretch a image frame */ GdkPixbuf *eel_stretch_frame_image (GdkPixbuf *frame_image, diff --git a/eel/eel-gtk-container.c b/eel/eel-gtk-container.c index 9a1df176..0244ecc1 100644 --- a/eel/eel-gtk-container.c +++ b/eel/eel-gtk-container.c @@ -43,11 +43,7 @@ void eel_gtk_container_child_expose_event (GtkContainer *container, GtkWidget *child, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr) -#else - GdkEventExpose *event) -#endif { g_return_if_fail (GTK_IS_CONTAINER (container)); @@ -58,11 +54,7 @@ eel_gtk_container_child_expose_event (GtkContainer *container, g_return_if_fail (GTK_IS_WIDGET (child)); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_container_propagate_draw (container, child, cr); -#else - gtk_container_propagate_expose (container, child, event); -#endif } /** diff --git a/eel/eel-gtk-container.h b/eel/eel-gtk-container.h index c11ca3e2..ab65873b 100644 --- a/eel/eel-gtk-container.h +++ b/eel/eel-gtk-container.h @@ -31,11 +31,8 @@ void eel_gtk_container_child_expose_event (GtkContainer *container, GtkWidget *child, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr); -#else - GdkEventExpose *event); -#endif + void eel_gtk_container_child_map (GtkContainer *container, GtkWidget *child); void eel_gtk_container_child_unmap (GtkContainer *container, diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index 4969d7aa..800fe6cd 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -353,40 +353,6 @@ eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button) return button; } -#if !GTK_CHECK_VERSION (3, 0, 0) -/* The standard gtk_adjustment_set_value ignores page size, which - * disagrees with the logic used by scroll bars, for example. - */ -void -eel_gtk_adjustment_set_value (GtkAdjustment *adjustment, - float value) -{ - float upper_page_start, clamped_value; - - g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); - - upper_page_start = MAX (gtk_adjustment_get_upper (adjustment) - - gtk_adjustment_get_page_size (adjustment), - gtk_adjustment_get_lower (adjustment)); - clamped_value = CLAMP (value, gtk_adjustment_get_lower (adjustment), upper_page_start); - if (clamped_value != gtk_adjustment_get_value (adjustment)) - { - gtk_adjustment_set_value (adjustment, clamped_value); - gtk_adjustment_value_changed (adjustment); - } -} - -/* Clamp a value if the minimum or maximum has changed. */ -void -eel_gtk_adjustment_clamp_value (GtkAdjustment *adjustment) -{ - g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); - - eel_gtk_adjustment_set_value (adjustment, - gtk_adjustment_get_value (adjustment)); -} -#endif - /** * eel_gtk_label_make_bold. * @@ -408,11 +374,7 @@ eel_gtk_label_make_bold (GtkLabel *label) * theme or user prefs, since the font desc only has the * weight flag turned on. */ -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_override_font (GTK_WIDGET (label), font_desc); -#else - gtk_widget_modify_font (GTK_WIDGET (label), font_desc); -#endif pango_font_description_free (font_desc); } diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index fd85c2db..aec680f3 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -63,12 +63,7 @@ GtkWidget * eel_gtk_menu_tool_button_get_button (GtkMenuTo /* GtkLabel */ void eel_gtk_label_make_bold (GtkLabel *label); -#if !GTK_CHECK_VERSION (3, 0, 0) -/* GtkAdjustment */ -void eel_gtk_adjustment_set_value (GtkAdjustment *adjustment, - float value); -void eel_gtk_adjustment_clamp_value (GtkAdjustment *adjustment); -#endif + /* GtkTreeView */ void eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view, gboolean should_activate); diff --git a/eel/eel-image-table.c b/eel/eel-image-table.c index be0a7d54..31cec4dd 100644 --- a/eel/eel-image-table.c +++ b/eel/eel-image-table.c @@ -62,11 +62,8 @@ static guint image_table_signals[LAST_SIGNAL] = { 0 }; /* Ancestor methods */ GtkWidget * find_windowed_ancestor (GtkWidget *widget); -#if GTK_CHECK_VERSION (3, 0, 0) + static void signal_connect_while_realized (GtkWidget *object, -#else -static void signal_connect_while_realized (GtkObject *object, -#endif const char *name, GCallback callback, gpointer callback_data, @@ -132,9 +129,6 @@ eel_image_table_realize (GtkWidget *widget) | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK); -#if !GTK_CHECK_VERSION (3, 0, 0) -#define windowed_ancestor GTK_OBJECT(windowed_ancestor) -#endif signal_connect_while_realized (windowed_ancestor, "enter_notify_event", @@ -431,11 +425,7 @@ while_realized_disconnecter (GObject *object, * or &widget are destroyed. **/ static void -#if GTK_CHECK_VERSION (3, 0, 0) signal_connect_while_realized (GtkWidget *object, -#else -signal_connect_while_realized (GtkObject *object, -#endif const char *name, GCallback callback, gpointer callback_data, @@ -443,11 +433,7 @@ signal_connect_while_realized (GtkObject *object, { RealizeDisconnectInfo *info; -#if GTK_CHECK_VERSION (3, 0, 0) g_return_if_fail (GTK_IS_WIDGET (object)); -#else - g_return_if_fail (GTK_IS_OBJECT (object)); -#endif g_return_if_fail (name != NULL); g_return_if_fail (name[0] != '\0'); g_return_if_fail (callback != NULL); diff --git a/eel/eel-labeled-image.c b/eel/eel-labeled-image.c index e357db60..d58d808e 100644 --- a/eel/eel-labeled-image.c +++ b/eel/eel-labeled-image.c @@ -31,9 +31,7 @@ #include "eel-gtk-extensions.h" #include "eel-accessibility.h" #include <gtk/gtk.h> -#if GTK_CHECK_VERSION(3, 0, 0) #include <gtk/gtk-a11y.h> -#endif #include <gdk/gdkkeysyms.h> #include <atk/atkimage.h> @@ -43,10 +41,6 @@ #define DEFAULT_X_ALIGNMENT 0.5 #define DEFAULT_Y_ALIGNMENT 0.5 -#if !GTK_CHECK_VERSION(3,0,0) -#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) -#endif - /* Signals */ enum { @@ -95,11 +89,7 @@ static GType eel_labeled_image_radio_button_get_type (void); static GType eel_labeled_image_toggle_button_get_type (void); /* GtkWidgetClass methods */ -#if GTK_CHECK_VERSION(3, 0, 0) static GType eel_labeled_image_accessible_get_type (void); -#else -static AtkObject *eel_labeled_image_get_accessible (GtkWidget *widget); -#endif /* Private EelLabeledImage methods */ static EelDimensions labeled_image_get_image_dimensions (const EelLabeledImage *labeled_image); @@ -138,11 +128,7 @@ eel_labeled_image_init (EelLabeledImage *labeled_image) } static void -#if GTK_CHECK_VERSION (3, 0, 0) eel_labeled_image_destroy (GtkWidget *object) -#else -eel_labeled_image_destroy (GtkObject *object) -#endif { EelLabeledImage *labeled_image; @@ -158,11 +144,7 @@ eel_labeled_image_destroy (GtkObject *object) gtk_widget_destroy (labeled_image->details->label); } -#if GTK_CHECK_VERSION (3, 0, 0) GTK_WIDGET_CLASS (eel_labeled_image_parent_class)->destroy (object); -#else - GTK_OBJECT_CLASS (eel_labeled_image_parent_class)->destroy (object); -#endif } /* GObjectClass methods */ @@ -330,7 +312,6 @@ eel_labeled_image_size_request (GtkWidget *widget, 2 * labeled_image->details->y_padding; } -#if GTK_CHECK_VERSION (3, 0, 0) static void eel_labeled_image_get_preferred_width (GtkWidget *widget, gint *minimum_width, @@ -350,7 +331,6 @@ eel_labeled_image_get_preferred_height (GtkWidget *widget, eel_labeled_image_size_request (widget, &req); *minimum_height = *natural_height = req.height; } -#endif static void eel_labeled_image_size_allocate (GtkWidget *widget, @@ -379,7 +359,6 @@ eel_labeled_image_size_allocate (GtkWidget *widget, } static int -#if GTK_CHECK_VERSION (3, 0, 0) eel_labeled_image_draw (GtkWidget *widget, cairo_t *cr) { @@ -445,71 +424,6 @@ eel_labeled_image_draw (GtkWidget *widget, return FALSE; } -#else -eel_labeled_image_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - EelLabeledImage *labeled_image; - EelIRect label_bounds; - GtkStyle *style; - GdkWindow *window; - - g_assert (EEL_IS_LABELED_IMAGE (widget)); - g_assert (gtk_widget_get_realized (widget)); - g_assert (event != NULL); - - labeled_image = EEL_LABELED_IMAGE (widget); - - style = gtk_widget_get_style (widget); - window = gtk_widget_get_window (widget); - if (gtk_widget_get_state (widget) == GTK_STATE_SELECTED || - gtk_widget_get_state (widget) == GTK_STATE_ACTIVE) - { - label_bounds = eel_labeled_image_get_label_bounds (EEL_LABELED_IMAGE (widget)); - - gtk_paint_flat_box (style, - window, - gtk_widget_get_state (widget), - GTK_SHADOW_NONE, - &event->area, - widget, - "eel-labeled-image", - label_bounds.x0, label_bounds.y0, - label_bounds.x1 - label_bounds.x0, - label_bounds.y1 - label_bounds.y0); - } - - if (labeled_image_show_label (labeled_image)) - { - eel_gtk_container_child_expose_event (GTK_CONTAINER (widget), - labeled_image->details->label, - event); - } - - if (labeled_image_show_image (labeled_image)) - { - eel_gtk_container_child_expose_event (GTK_CONTAINER (widget), - labeled_image->details->image, - event); - } - - if (gtk_widget_has_focus (widget)) - { - label_bounds = eel_labeled_image_get_image_bounds (EEL_LABELED_IMAGE (widget)); - gtk_paint_focus (style, - window, - GTK_STATE_NORMAL, - &event->area, - widget, - "eel-focusable-labeled-image", - label_bounds.x0, label_bounds.y0, - label_bounds.x1 - label_bounds.x0, - label_bounds.y1 - label_bounds.y0); - } - - return FALSE; -} -#endif static void eel_labeled_image_map (GtkWidget *widget) @@ -623,29 +537,20 @@ eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class) gobject_class->set_property = eel_labeled_image_set_property; gobject_class->get_property = eel_labeled_image_get_property; -#if !GTK_CHECK_VERSION (3, 0, 0) - GTK_OBJECT_CLASS (labeled_image_class)->destroy = eel_labeled_image_destroy; -#else widget_class->destroy = eel_labeled_image_destroy; -#endif + /* GtkWidgetClass */ widget_class->size_allocate = eel_labeled_image_size_allocate; -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->get_preferred_width = eel_labeled_image_get_preferred_width; widget_class->get_preferred_height = eel_labeled_image_get_preferred_height; widget_class->draw = eel_labeled_image_draw; -#else - widget_class->size_request = eel_labeled_image_size_request; - widget_class->expose_event = eel_labeled_image_expose_event; -#endif + widget_class->map = eel_labeled_image_map; widget_class->unmap = eel_labeled_image_unmap; -#if GTK_CHECK_VERSION(3, 0, 0) + gtk_widget_class_set_accessible_type (widget_class, eel_labeled_image_accessible_get_type ()); -#else - widget_class->get_accessible = eel_labeled_image_get_accessible; -#endif + /* GtkContainerClass */ container_class->add = eel_labeled_image_add; @@ -1213,13 +1118,8 @@ labeled_image_update_alignments (EelLabeledImage *labeled_image) if (labeled_image->details->fill) { -#if GTK_CHECK_VERSION (3, 0, 0) x_alignment = gtk_widget_get_halign (labeled_image->details->image); y_alignment = gtk_widget_get_valign (labeled_image->details->image); -#else - gtk_misc_get_alignment (GTK_MISC (labeled_image->details->image), - &x_alignment, &y_alignment); -#endif /* Only the image is shown */ if (!labeled_image_show_label (labeled_image)) @@ -1254,14 +1154,8 @@ labeled_image_update_alignments (EelLabeledImage *labeled_image) } } -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_halign (labeled_image->details->image, x_alignment); gtk_widget_set_valign (labeled_image->details->image, y_alignment); -#else - gtk_misc_set_alignment (GTK_MISC (labeled_image->details->image), - x_alignment, - y_alignment); -#endif } } } @@ -1655,19 +1549,12 @@ eel_labeled_image_set_selected (EelLabeledImage *labeled_image, GtkStateType state; g_return_if_fail (EEL_IS_LABELED_IMAGE (labeled_image)); -#if GTK_CHECK_VERSION (3, 0, 0) state = selected ? GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_NORMAL; gtk_widget_set_state_flags (GTK_WIDGET (labeled_image), state, TRUE); gtk_widget_set_state_flags (labeled_image->details->image, state, TRUE); gtk_widget_set_state_flags (labeled_image->details->label, state, TRUE); -#else - state = selected ? GTK_STATE_SELECTED : GTK_STATE_NORMAL; - gtk_widget_set_state (GTK_WIDGET (labeled_image), state); - gtk_widget_set_state (labeled_image->details->image, state); - gtk_widget_set_state (labeled_image->details->label, state); -#endif } /** @@ -1682,11 +1569,7 @@ eel_labeled_image_get_selected (EelLabeledImage *labeled_image) { g_return_val_if_fail (EEL_IS_LABELED_IMAGE (labeled_image), FALSE); -#if GTK_CHECK_VERSION (3, 0, 0) return gtk_widget_get_state_flags (GTK_WIDGET (labeled_image)) == GTK_STATE_FLAG_SELECTED; -#else - return gtk_widget_get_state (GTK_WIDGET (labeled_image)) == GTK_STATE_SELECTED; -#endif } /** @@ -2324,9 +2207,8 @@ eel_labeled_image_accessible_initialize (AtkObject *accessible, gpointer widget) { a11y_parent_class->initialize (accessible, widget); -#if GTK_CHECK_VERSION(3, 0, 0) atk_object_set_role (accessible, ATK_ROLE_IMAGE); -#endif + } static EelLabeledImage * @@ -2388,7 +2270,6 @@ eel_labeled_image_accessible_image_interface_init (AtkImageIface *iface) iface->get_image_size = eel_labeled_image_accessible_image_get_size; } -#if GTK_CHECK_VERSION(3, 0, 0) typedef struct _EelLabeledImageAccessible EelLabeledImageAccessible; typedef struct _EelLabeledImageAccessibleClass EelLabeledImageAccessibleClass; @@ -2421,106 +2302,10 @@ static void eel_labeled_image_accessible_init (EelLabeledImageAccessible *accessible) { } -#else -static void -eel_labeled_image_accessible_class_init (AtkObjectClass *klass) -{ - a11y_parent_class = g_type_class_peek_parent (klass); - - klass->get_name = eel_labeled_image_accessible_get_name; - klass->initialize = eel_labeled_image_accessible_initialize; -} - -enum -{ - BUTTON, - CHECK, - TOGGLE, - RADIO, - PLAIN, - LAST_ONE -}; - -static AtkObject * -eel_labeled_image_get_accessible (GtkWidget *widget) -{ - int i; - static GType types[LAST_ONE] = { 0 }; - const char *tname; - AtkRole role; - AtkObject *accessible; - - if ((accessible = eel_accessibility_get_atk_object (widget))) - return accessible; - - if (GTK_IS_CHECK_BUTTON (widget)) - { - i = BUTTON; - role = ATK_ROLE_CHECK_BOX; - tname = "EelLabeledImageCheckButtonAccessible"; - - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) - { - i = CHECK; - role = ATK_ROLE_TOGGLE_BUTTON; - tname = "EelLabeledImageToggleButtonAccessible"; - - } - else if (GTK_IS_RADIO_BUTTON (widget)) - { - i = RADIO; - role = ATK_ROLE_RADIO_BUTTON; - tname = "EelLabeledImageRadioButtonAccessible"; - - } - else if (GTK_IS_BUTTON (widget)) - { - i = TOGGLE; - role = ATK_ROLE_PUSH_BUTTON; - tname = "EelLabeledImagePushButtonAccessible"; - - } - else /* plain */ - { - i = PLAIN; - role = ATK_ROLE_IMAGE; - tname = "EelLabeledImagePlainAccessible"; - } - - if (!types [i]) - { - const GInterfaceInfo atk_image_info = - { - (GInterfaceInitFunc) eel_labeled_image_accessible_image_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - types [i] = eel_accessibility_create_derived_type - (tname, G_TYPE_FROM_INSTANCE (widget), - eel_labeled_image_accessible_class_init); - - if (!types [i]) - return NULL; - - g_type_add_interface_static ( - types [i], ATK_TYPE_IMAGE, &atk_image_info); - } - - accessible = g_object_new (types [i], NULL); - atk_object_set_role (accessible, role); - - return eel_accessibility_set_atk_object_return (widget, accessible); -} -#endif static void eel_labeled_image_button_class_init (GtkWidgetClass *klass) { -#if !GTK_CHECK_VERSION(3, 0, 0) - klass->get_accessible = eel_labeled_image_get_accessible; -#endif } static GType diff --git a/eel/eel-wrap-table.c b/eel/eel-wrap-table.c index 56c1e5e9..0d77b442 100644 --- a/eel/eel-wrap-table.c +++ b/eel/eel-wrap-table.c @@ -30,10 +30,6 @@ #include "eel-gtk-extensions.h" #include <gtk/gtk.h> -#if !GTK_CHECK_VERSION(3,0,0) -#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) -#endif - /* Arguments */ enum { @@ -200,7 +196,6 @@ eel_wrap_table_size_request (GtkWidget *widget, requisition->height = content_dimensions.height + gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2; } -#if GTK_CHECK_VERSION (3, 0, 0) static void eel_wrap_table_get_preferred_width (GtkWidget *widget, gint *minimum_width, @@ -220,7 +215,6 @@ eel_wrap_table_get_preferred_height (GtkWidget *widget, eel_wrap_table_size_request (widget, &req); *minimum_height = *natural_height = req.height; } -#endif static void eel_wrap_table_size_allocate (GtkWidget *widget, @@ -239,37 +233,23 @@ eel_wrap_table_size_allocate (GtkWidget *widget, } static int -#if GTK_CHECK_VERSION (3, 0, 0) eel_wrap_table_draw (GtkWidget *widget, cairo_t *cr) -#else -eel_wrap_table_expose_event (GtkWidget *widget, - GdkEventExpose *event) -#endif { EelWrapTable *wrap_table; GList *iterator; g_assert (EEL_IS_WRAP_TABLE (widget)); g_assert (gtk_widget_get_realized (widget)); -#if !GTK_CHECK_VERSION (3, 0, 0) - g_assert (event != NULL); -#endif wrap_table = EEL_WRAP_TABLE (widget); for (iterator = wrap_table->details->children; iterator; iterator = iterator->next) { g_assert (GTK_IS_WIDGET (iterator->data)); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_container_propagate_draw (GTK_CONTAINER (widget), GTK_WIDGET (iterator->data), cr); -#else - gtk_container_propagate_expose (GTK_CONTAINER (widget), - GTK_WIDGET (iterator->data), - event); -#endif } return FALSE; @@ -451,14 +431,9 @@ eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class) /* GtkWidgetClass */ widget_class->size_allocate = eel_wrap_table_size_allocate; -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->get_preferred_width = eel_wrap_table_get_preferred_width; widget_class->get_preferred_height = eel_wrap_table_get_preferred_height; widget_class->draw = eel_wrap_table_draw; -#else - widget_class->size_request = eel_wrap_table_size_request; - widget_class->expose_event = eel_wrap_table_expose_event; -#endif widget_class->map = eel_wrap_table_map; widget_class->unmap = eel_wrap_table_unmap; widget_class->realize = eel_wrap_table_realize; @@ -798,13 +773,8 @@ wrap_table_child_focus_in (GtkWidget *widget, if (!wrap_table_child_visible_in (widget, viewport)) { -#if GTK_CHECK_VERSION (3, 0, 0) hadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (viewport)); vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (viewport)); -#else - hadj = gtk_viewport_get_hadjustment (GTK_VIEWPORT (viewport)); - vadj = gtk_viewport_get_vadjustment (GTK_VIEWPORT (viewport)); -#endif gtk_widget_translate_coordinates (widget, container, 0, 0, &x, &y); |