diff options
Diffstat (limited to 'eel/eel-canvas.c')
-rw-r--r-- | eel/eel-canvas.c | 405 |
1 files changed, 4 insertions, 401 deletions
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) |