diff options
-rw-r--r-- | eel/eel-debug-drawing.c | 46 | ||||
-rw-r--r-- | eel/eel-gdk-extensions.c | 2 | ||||
-rw-r--r-- | eel/eel-gdk-pixbuf-extensions.c | 16 | ||||
-rw-r--r-- | eel/eel-gdk-pixbuf-extensions.h | 5 | ||||
-rw-r--r-- | eel/eel-gtk-container.c | 8 | ||||
-rw-r--r-- | eel/eel-gtk-container.h | 4 | ||||
-rw-r--r-- | eel/eel-labeled-image.c | 63 | ||||
-rw-r--r-- | eel/eel-wrap-table.c | 48 |
8 files changed, 185 insertions, 7 deletions
diff --git a/eel/eel-debug-drawing.c b/eel/eel-debug-drawing.c index 05675dff..b334f66f 100644 --- a/eel/eel-debug-drawing.c +++ b/eel/eel-debug-drawing.c @@ -117,8 +117,34 @@ debug_pixbuf_viewer_size_request (GtkWidget *widget, GtkRequisition *requisition requisition->height = MAX (2, dimensions.height); } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +debug_pixbuf_viewer_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GtkRequisition req; + debug_pixbuf_viewer_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +debug_pixbuf_viewer_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + debug_pixbuf_viewer_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static int +#if GTK_CHECK_VERSION (3, 0, 0) +debug_pixbuf_viewer_draw (GtkWidget *widget, cairo_t *cr) +#else debug_pixbuf_viewer_expose_event (GtkWidget *widget, GdkEventExpose *event) +#endif { DebugPixbufViewer *viewer; EelIRect clipped_dirty_area; @@ -127,8 +153,12 @@ debug_pixbuf_viewer_expose_event (GtkWidget *widget, GdkEventExpose *event) GtkAllocation allocation; g_assert (DEBUG_IS_PIXBUF_VIEWER (widget)); +#if GTK_CHECK_VERSION (3, 0, 0) + g_assert (cr != NULL); +#else g_assert (event != NULL); g_assert (event->window == gtk_widget_get_window (widget)); +#endif g_assert (gtk_widget_get_realized (widget)); viewer = DEBUG_PIXBUF_VIEWER (widget); @@ -145,9 +175,15 @@ debug_pixbuf_viewer_expose_event (GtkWidget *widget, GdkEventExpose *event) bounds.y1 = bounds.y0 + gdk_pixbuf_get_height (viewer->pixbuf); /* Clip the dirty area to the screen; bail if no work to do */ +#if GTK_CHECK_VERSION (3, 0, 0) + clipped_dirty_area = eel_gdk_window_clip_dirty_area_to_screen (gtk_widget_get_window (widget), + dirty_area); +#else dirty_area = eel_gdk_rectangle_to_eel_irect (event->area); clipped_dirty_area = eel_gdk_window_clip_dirty_area_to_screen (event->window, dirty_area); +#endif + if (!eel_irect_is_empty (&clipped_dirty_area)) { EelIRect clipped_bounds; @@ -160,7 +196,11 @@ debug_pixbuf_viewer_expose_event (GtkWidget *widget, GdkEventExpose *event) g_assert (clipped_bounds.y0 >= bounds.y0); eel_gdk_pixbuf_draw_to_drawable (viewer->pixbuf, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else event->window, +#endif clipped_bounds.x0 - bounds.x0, clipped_bounds.y0 - bounds.y0, clipped_bounds); @@ -182,8 +222,14 @@ debug_pixbuf_viewer_class_init (DebugPixbufViewerClass *pixbuf_viewer_class) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (pixbuf_viewer_class); object_class->finalize = debug_pixbuf_viewer_finalize; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->get_preferred_width = debug_pixbuf_viewer_get_preferred_width; + widget_class->get_preferred_height = debug_pixbuf_viewer_get_preferred_height; + widget_class->draw = debug_pixbuf_viewer_draw; +#else widget_class->size_request = debug_pixbuf_viewer_size_request; widget_class->expose_event = debug_pixbuf_viewer_expose_event; +#endif } static void diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index ed694277..3d68d9a5 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -504,7 +504,7 @@ eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, pango_cairo_show_layout (cr, layout); #if GTK_CHECK_VERSION(3,0,0) - cairo_restore + cairo_restore (cr); #else cairo_destroy (cr); #endif diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c index c913cb10..6870e932 100644 --- a/eel/eel-gdk-pixbuf-extensions.c +++ b/eel/eel-gdk-pixbuf-extensions.c @@ -622,10 +622,14 @@ 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) + EelIRect destination_area) { EelDimensions dimensions; EelIRect target; @@ -634,10 +638,16 @@ eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, int target_height; int source_width; int source_height; - cairo_t *cr; +#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); @@ -673,7 +683,9 @@ 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, diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h index 382cd6cd..7d31defe 100644 --- a/eel/eel-gdk-pixbuf-extensions.h +++ b/eel/eel-gdk-pixbuf-extensions.h @@ -30,6 +30,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk/gdk.h> #include <gio/gio.h> +#include <gtk/gtk.h> #define EEL_OPACITY_FULLY_TRANSPARENT 0 #define EEL_OPACITY_FULLY_OPAQUE 255 @@ -92,7 +93,11 @@ 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); diff --git a/eel/eel-gtk-container.c b/eel/eel-gtk-container.c index cb841fd5..9a1df176 100644 --- a/eel/eel-gtk-container.c +++ b/eel/eel-gtk-container.c @@ -43,7 +43,11 @@ 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)); @@ -54,7 +58,11 @@ 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 f5ca876d..c11ca3e2 100644 --- a/eel/eel-gtk-container.h +++ b/eel/eel-gtk-container.h @@ -31,7 +31,11 @@ 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-labeled-image.c b/eel/eel-labeled-image.c index 12dad9c1..7eff21a9 100644 --- a/eel/eel-labeled-image.c +++ b/eel/eel-labeled-image.c @@ -320,6 +320,28 @@ 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, + gint *natural_width) +{ + GtkRequisition req; + eel_labeled_image_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +eel_labeled_image_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + eel_labeled_image_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void eel_labeled_image_size_allocate (GtkWidget *widget, GtkAllocation *allocation) @@ -347,8 +369,13 @@ 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) +#else eel_labeled_image_expose_event (GtkWidget *widget, GdkEventExpose *event) +#endif { EelLabeledImage *labeled_image; EelIRect label_bounds; @@ -357,7 +384,9 @@ eel_labeled_image_expose_event (GtkWidget *widget, g_assert (EEL_IS_LABELED_IMAGE (widget)); g_assert (gtk_widget_get_realized (widget)); +#if !GTK_CHECK_VERSION (3, 0, 0) g_assert (event != NULL); +#endif labeled_image = EEL_LABELED_IMAGE (widget); @@ -369,10 +398,16 @@ eel_labeled_image_expose_event (GtkWidget *widget, label_bounds = eel_labeled_image_get_label_bounds (EEL_LABELED_IMAGE (widget)); gtk_paint_flat_box (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else window, +#endif gtk_widget_get_state (widget), GTK_SHADOW_NONE, +#if !GTK_CHECK_VERSION (3, 0, 0) &event->area, +#endif widget, "eel-labeled-image", label_bounds.x0, label_bounds.y0, @@ -384,22 +419,38 @@ eel_labeled_image_expose_event (GtkWidget *widget, { eel_gtk_container_child_expose_event (GTK_CONTAINER (widget), labeled_image->details->label, +#if GTK_CHECK_VERSION (3, 0, 0) + cr); +#else event); +#endif } if (labeled_image_show_image (labeled_image)) { eel_gtk_container_child_expose_event (GTK_CONTAINER (widget), labeled_image->details->image, +#if GTK_CHECK_VERSION (3, 0, 0) + cr); +#else event); +#endif } if (gtk_widget_has_focus (widget)) { label_bounds = eel_labeled_image_get_image_bounds (EEL_LABELED_IMAGE (widget)); - gtk_paint_focus (style, window, + gtk_paint_focus (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + window, +#endif GTK_STATE_NORMAL, - &event->area, widget, +#if !GTK_CHECK_VERSION (3, 0, 0) + &event->area, +#endif + widget, "eel-focusable-labeled-image", label_bounds.x0, label_bounds.y0, label_bounds.x1 - label_bounds.x0, @@ -528,9 +579,15 @@ eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class) #endif /* GtkWidgetClass */ - widget_class->size_request = eel_labeled_image_size_request; 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; widget_class->get_accessible = eel_labeled_image_get_accessible; diff --git a/eel/eel-wrap-table.c b/eel/eel-wrap-table.c index 42253acd..26e06ef8 100644 --- a/eel/eel-wrap-table.c +++ b/eel/eel-wrap-table.c @@ -196,6 +196,28 @@ 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, + gint *natural_width) +{ + GtkRequisition req; + eel_wrap_table_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +eel_wrap_table_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + eel_wrap_table_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void eel_wrap_table_size_allocate (GtkWidget *widget, GtkAllocation *allocation) @@ -213,24 +235,37 @@ 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; @@ -411,9 +446,15 @@ eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class) gobject_class->get_property = eel_wrap_table_get_property; /* GtkWidgetClass */ - widget_class->size_request = eel_wrap_table_size_request; 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; @@ -755,8 +796,13 @@ wrap_table_child_focus_in (GtkWidget *widget, gtk_widget_translate_coordinates (widget, container, 0, 0, &x, &y); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_adjustment_set_value (hadj, MIN (x, gtk_adjustment_get_upper(hadj) - gtk_adjustment_get_page_size(hadj))); + gtk_adjustment_set_value (vadj, MIN (y, gtk_adjustment_get_upper(vadj) - gtk_adjustment_get_page_size(vadj))); +#else gtk_adjustment_set_value (hadj, MIN (x, hadj->upper - hadj->page_size)); gtk_adjustment_set_value (vadj, MIN (y, vadj->upper - vadj->page_size)); +#endif } return FALSE; |