From a55021bcef7eb082b48e56aac361bd35a3a77b64 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 14 Jun 2010 21:38:53 -0400 Subject: Revert "Fix all remaining GTK3 issues." This reverts commit fd8b55edaa88906b588aa07d9eadcacd34a7a774. Something in this commit seriously hosed ETable, making Evolution pretty much unusable. Reverting this until I can track down the problem. --- addressbook/gui/widgets/e-minicard-label.c | 4 +- addressbook/gui/widgets/e-minicard.c | 14 +- calendar/gui/e-day-view.c | 30 +- calendar/gui/e-week-view.c | 10 +- calendar/gui/ea-week-view.c | 2 +- e-util/gtk-compat.h | 1 - libgnomecanvas/gailcanvas.c | 10 +- libgnomecanvas/gailcanvasitem.c | 8 +- libgnomecanvas/gnome-canvas-line.c | 6 +- libgnomecanvas/gnome-canvas-rich-text.c | 29 +- libgnomecanvas/gnome-canvas-shape.c | 17 +- libgnomecanvas/gnome-canvas-text.c | 17 +- libgnomecanvas/gnome-canvas.c | 451 +++++++++-------------------- libgnomecanvas/gnome-canvas.h | 26 +- widgets/misc/e-canvas-background.c | 2 +- widgets/misc/e-canvas-vbox.c | 6 +- widgets/misc/e-canvas.c | 28 +- widgets/table/e-table-group-container.c | 2 +- widgets/table/e-table-item.c | 79 ++--- widgets/text/e-reflow.c | 6 +- 20 files changed, 240 insertions(+), 508 deletions(-) diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c index 5c1eba1f43..0eb166bcf3 100644 --- a/addressbook/gui/widgets/e-minicard-label.c +++ b/addressbook/gui/widgets/e-minicard-label.c @@ -414,9 +414,7 @@ e_minicard_label_resize_children(EMinicardLabel *e_minicard_label) static void set_colors (EMinicardLabel *label) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (label); - - if ((item->flags & GNOME_CANVAS_ITEM_REALIZED)) { + if ((GTK_OBJECT_FLAGS (label) & GNOME_CANVAS_ITEM_REALIZED)) { GnomeCanvas *canvas; GtkStyle *style; diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 92a415b88f..213d600746 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -321,7 +321,7 @@ e_minicard_set_property (GObject *object, guint prop_id, const GValue *value, G if (e_minicard->width != g_value_get_double (value)) { e_minicard->width = g_value_get_double (value); e_minicard_resize_children(e_minicard); - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) + if (GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED) e_canvas_item_request_reflow(item); } break; @@ -467,9 +467,7 @@ e_minicard_finalize (GObject *object) static void e_minicard_style_set (EMinicard *minicard, GtkStyle *previous_style) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (minicard); - - if ((item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if ((GTK_OBJECT_FLAGS( minicard ) & GNOME_CANVAS_ITEM_REALIZED)) set_selected (minicard, minicard->selected); } @@ -912,12 +910,9 @@ get_left_width (EMinicard *e_minicard, gboolean is_list) static void remodel( EMinicard *e_minicard ) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (e_minicard); gint count = 0; - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED)) return; - if (e_minicard->contact) { EContactField field; GList *list; @@ -1017,8 +1012,7 @@ static void e_minicard_reflow(GnomeCanvasItem *item, gint flags) { EMinicard *e_minicard = E_MINICARD(item); - - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { + if (GTK_OBJECT_FLAGS (e_minicard) & GNOME_CANVAS_ITEM_REALIZED) { GList *list; gdouble text_height; gint old_height; diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index de4b9b3b68..010f5bdb32 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -1931,11 +1931,7 @@ e_day_view_focus_in (GtkWidget *widget, GdkEventFocus *event) day_view = E_DAY_VIEW (widget); - /* XXX Can't access flags directly anymore, but is it really needed? - * If so, could we call gtk_widget_send_focus_change() instead? */ -#if 0 GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); -#endif gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->main_canvas); @@ -1954,11 +1950,7 @@ e_day_view_focus_out (GtkWidget *widget, GdkEventFocus *event) day_view = E_DAY_VIEW (widget); - /* XXX Can't access flags directly anymore, but is it really needed? - * If so, could we call gtk_widget_send_focus_change() instead? */ -#if 0 GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); -#endif gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->main_canvas); @@ -7108,8 +7100,10 @@ e_day_view_auto_scroll_handler (gpointer data) e_day_view_update_selection (day_view, day, row); } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { e_day_view_update_resize (day_view, row); - } else if (day_view->drag_item->flags & GNOME_CANVAS_ITEM_VISIBLE) { - e_day_view_update_main_canvas_drag (day_view, row, day); + } else if (day_view->drag_item->object.flags + & GNOME_CANVAS_ITEM_VISIBLE) { + e_day_view_update_main_canvas_drag (day_view, row, + day); } } @@ -7517,7 +7511,8 @@ e_day_view_update_top_canvas_drag (EDayView *day_view, /* If the position hasn't changed, just return. */ if (day_view->drag_last_day == day - && (day_view->drag_long_event_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) + && (day_view->drag_long_event_item->object.flags + & GNOME_CANVAS_ITEM_VISIBLE)) return; day_view->drag_last_day = day; @@ -7544,7 +7539,7 @@ e_day_view_update_top_canvas_drag (EDayView *day_view, item_x + E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD, item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD); - if (!(day_view->drag_long_event_rect_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_long_event_rect_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { gnome_canvas_item_raise_to_top (day_view->drag_long_event_rect_item); gnome_canvas_item_show (day_view->drag_long_event_rect_item); } @@ -7552,7 +7547,8 @@ e_day_view_update_top_canvas_drag (EDayView *day_view, /* Set the text, if necessary. We don't want to set the text every time it moves, so we check if it is currently invisible and only set the text then. */ - if (!(day_view->drag_long_event_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_long_event_item->object.flags + & GNOME_CANVAS_ITEM_VISIBLE)) { const gchar *summary; if (event && is_comp_data_valid (event)) { @@ -7633,7 +7629,7 @@ e_day_view_update_main_canvas_drag (EDayView *day_view, /* If the position hasn't changed, just return. */ if (day_view->drag_last_day == day && day_view->drag_last_row == row - && (day_view->drag_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) + && (day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) return; day_view->drag_last_day = day; @@ -7704,12 +7700,12 @@ e_day_view_update_main_canvas_drag (EDayView *day_view, item_x + E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_EVENT_X_PAD, item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD); - if (!(day_view->drag_bar_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_bar_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { gnome_canvas_item_raise_to_top (day_view->drag_bar_item); gnome_canvas_item_show (day_view->drag_bar_item); } - if (!(day_view->drag_rect_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_rect_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { gnome_canvas_item_raise_to_top (day_view->drag_rect_item); gnome_canvas_item_show (day_view->drag_rect_item); } @@ -7717,7 +7713,7 @@ e_day_view_update_main_canvas_drag (EDayView *day_view, /* Set the text, if necessary. We don't want to set the text every time it moves, so we check if it is currently invisible and only set the text then. */ - if (!(day_view->drag_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { const gchar *summary; if (event && is_comp_data_valid (event)) { diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index db6d861c28..accafd9ac2 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -1363,11 +1363,7 @@ e_week_view_focus_in (GtkWidget *widget, GdkEventFocus *event) week_view = E_WEEK_VIEW (widget); - /* XXX Can't access flags directly anymore, but is it really needed? - * If so, could we call gtk_widget_send_focus_change() instead? */ -#if 0 GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); -#endif gtk_widget_queue_draw (week_view->main_canvas); @@ -1385,11 +1381,7 @@ e_week_view_focus_out (GtkWidget *widget, GdkEventFocus *event) week_view = E_WEEK_VIEW (widget); - /* XXX Can't access flags directly anymore, but is it really needed? - * If so, could we call gtk_widget_send_focus_change() instead? */ -#if 0 GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); -#endif gtk_widget_queue_draw (week_view->main_canvas); @@ -4684,7 +4676,7 @@ e_week_view_is_jump_button_visible (EWeekView *week_view, gint day) g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); if ((day >= 0) && (day < E_WEEK_VIEW_MAX_WEEKS * 7)) - return week_view->jump_buttons[day]->flags & GNOME_CANVAS_ITEM_VISIBLE; + return week_view->jump_buttons[day]->object.flags & GNOME_CANVAS_ITEM_VISIBLE; return FALSE; } diff --git a/calendar/gui/ea-week-view.c b/calendar/gui/ea-week-view.c index 19028cf189..fcbae83cb7 100644 --- a/calendar/gui/ea-week-view.c +++ b/calendar/gui/ea-week-view.c @@ -242,7 +242,7 @@ ea_week_view_get_n_children (AtkObject *accessible) /* add the number of visible jump buttons */ for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) { - if (week_view->jump_buttons[i]->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (week_view->jump_buttons[i]->object.flags & GNOME_CANVAS_ITEM_VISIBLE) ++count; } diff --git a/e-util/gtk-compat.h b/e-util/gtk-compat.h index 6b93eed320..2b96d9c4b2 100644 --- a/e-util/gtk-compat.h +++ b/e-util/gtk-compat.h @@ -14,7 +14,6 @@ #define gdk_drag_context_get_suggested_action(context) (context)->suggested_action #define gdk_drag_context_get_selected_action(context) (context)->action #define gdk_drag_context_list_targets(context) (context)->targets -#define gdk_visual_get_depth(visual) (visual)->depth #define gtk_accessible_get_widget(accessible) \ (GTK_ACCESSIBLE (accessible)->widget) diff --git a/libgnomecanvas/gailcanvas.c b/libgnomecanvas/gailcanvas.c index 02abd10deb..4ec0b67de3 100644 --- a/libgnomecanvas/gailcanvas.c +++ b/libgnomecanvas/gailcanvas.c @@ -29,8 +29,6 @@ #include "gailcanvasitemfactory.h" #include "gailcanvaswidgetfactory.h" -#include - static void gail_canvas_class_init (GailCanvasClass *klass); static void gail_canvas_real_initialize (AtkObject *obj, gpointer data); @@ -182,13 +180,13 @@ gail_canvas_real_initialize (AtkObject *obj, canvas = GNOME_CANVAS (data); - adj = gtk_layout_get_hadjustment (GTK_LAYOUT (canvas)); + adj = canvas->layout.hadjustment; g_signal_connect (adj, "value_changed", G_CALLBACK (adjustment_changed), canvas); - adj = gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)); + adj = canvas->layout.vadjustment; g_signal_connect (adj, "value_changed", G_CALLBACK (adjustment_changed), @@ -208,7 +206,7 @@ gail_canvas_get_n_children (AtkObject* obj) g_return_val_if_fail (GAIL_IS_CANVAS (obj), 0); accessible = GTK_ACCESSIBLE (obj); - widget = gtk_accessible_get_widget (accessible); + widget = accessible->widget; if (widget == NULL) /* State is defunct */ return 0; @@ -237,7 +235,7 @@ gail_canvas_ref_child (AtkObject *obj, g_return_val_if_fail (GAIL_IS_CANVAS (obj), NULL); accessible = GTK_ACCESSIBLE (obj); - widget = gtk_accessible_get_widget (accessible); + widget = accessible->widget; if (widget == NULL) /* State is defunct */ return NULL; diff --git a/libgnomecanvas/gailcanvasitem.c b/libgnomecanvas/gailcanvasitem.c index 5ae7c8bee3..f059e1909c 100644 --- a/libgnomecanvas/gailcanvasitem.c +++ b/libgnomecanvas/gailcanvasitem.c @@ -199,7 +199,7 @@ gail_canvas_item_ref_state_set (AtkObject *obj) { item = GNOME_CANVAS_ITEM (g_obj); - if (item->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (item->object.flags & GNOME_CANVAS_ITEM_VISIBLE) { atk_state_set_add_state (state_set, ATK_STATE_VISIBLE); if (is_item_on_screen (item)) @@ -482,16 +482,14 @@ is_item_in_window (GnomeCanvasItem *item, gint height) { GtkWidget *widget; - GdkWindow *window; gboolean retval; widget = GTK_WIDGET (item->canvas); - window = gtk_widget_get_window (widget); - if (window) + if (widget->window) { int window_width, window_height; - gdk_window_get_geometry (window, NULL, NULL, + gdk_window_get_geometry (widget->window, NULL, NULL, &window_width, &window_height, NULL); /* * Check whether rectangles intersect diff --git a/libgnomecanvas/gnome-canvas-line.c b/libgnomecanvas/gnome-canvas-line.c index fa7c74ccc1..48cafb71c7 100644 --- a/libgnomecanvas/gnome-canvas-line.c +++ b/libgnomecanvas/gnome-canvas-line.c @@ -1096,18 +1096,14 @@ gnome_canvas_line_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_pa static void gnome_canvas_line_realize (GnomeCanvasItem *item) { - GtkLayout *layout; GnomeCanvasLine *line; - GdkWindow *bin_window; line = GNOME_CANVAS_LINE (item); if (parent_class->realize) (* parent_class->realize) (item); - layout = GTK_LAYOUT (item->canvas); - bin_window = gtk_layout_get_bin_window (layout); - line->gc = gdk_gc_new (bin_window); + line->gc = gdk_gc_new (item->canvas->layout.bin_window); #if 0 (* GNOME_CANVAS_ITEM_CLASS (item->object.klass)->update) (item, NULL, NULL, 0); diff --git a/libgnomecanvas/gnome-canvas-rich-text.c b/libgnomecanvas/gnome-canvas-rich-text.c index db0e52fde1..2a50f2ed4d 100644 --- a/libgnomecanvas/gnome-canvas-rich-text.c +++ b/libgnomecanvas/gnome-canvas-rich-text.c @@ -1522,14 +1522,8 @@ gnome_canvas_rich_text_event(GnomeCanvasItem *item, GdkEvent *event) return gnome_canvas_rich_text_button_release_event( item, (GdkEventButton *) event); case GDK_FOCUS_CHANGE: - { - GtkLayout *layout; - GdkWindow *bin_window; - - layout = GTK_LAYOUT (item->canvas); - bin_window = gtk_layout_get_bin_window (layout); - - if (((GdkEventFocus *) event)->window != bin_window) + if (((GdkEventFocus *) event)->window != + item->canvas->layout.bin_window) return FALSE; if (((GdkEventFocus *) event)->in) @@ -1538,7 +1532,6 @@ gnome_canvas_rich_text_event(GnomeCanvasItem *item, GdkEvent *event) else return gnome_canvas_rich_text_focus_out_event( item, (GdkEventFocus *) event); - } default: return FALSE; } @@ -1712,13 +1705,8 @@ scale_fonts(GtkTextTag *tag, gpointer data) { GnomeCanvasRichText *text = GNOME_CANVAS_RICH_TEXT(data); - /* XXX GtkTextTag::values is sealed with apparently no way - * to access it. This looks like a small optimization - * anyway. */ -#if 0 if (!tag->values) return; -#endif g_object_set( G_OBJECT(tag), "scale", @@ -1931,7 +1919,7 @@ gnome_canvas_rich_text_ensure_layout(GnomeCanvasRichText *text) style = gtk_text_attributes_new(); gnome_canvas_rich_text_set_attributes_from_style( - text, style, gtk_widget_get_style (canvas)); + text, style, canvas->style); style->pixels_above_lines = text->_priv->pixels_above_lines; style->pixels_below_lines = text->_priv->pixels_below_lines; @@ -2132,8 +2120,6 @@ gnome_canvas_rich_text_draw(GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height) { GnomeCanvasRichText *text = GNOME_CANVAS_RICH_TEXT(item); - GtkStyle *style; - GtkWidget *widget; double i2w[6], w2c[6], i2c[6]; double ax, ay; int x1, y1, x2, y2; @@ -2159,16 +2145,13 @@ gnome_canvas_rich_text_draw(GnomeCanvasItem *item, GdkDrawable *drawable, y2 = c2.y; gtk_text_layout_set_screen_width(text->_priv->layout, x2 - x1); - - widget = GTK_WIDGET (item->canvas); - style = gtk_widget_get_style (widget); - + /* FIXME: should last arg be NULL? */ gtk_text_layout_draw( text->_priv->layout, - widget, + GTK_WIDGET(item->canvas), drawable, - style->text_gc[GTK_STATE_NORMAL], + GTK_WIDGET (item->canvas)->style->text_gc[GTK_STATE_NORMAL], x - x1, y - y1, 0, 0, (x2 - x1) - (x - x1), (y2 - y1) - (y - y1), NULL); diff --git a/libgnomecanvas/gnome-canvas-shape.c b/libgnomecanvas/gnome-canvas-shape.c index b951cbc014..79d8124525 100644 --- a/libgnomecanvas/gnome-canvas-shape.c +++ b/libgnomecanvas/gnome-canvas-shape.c @@ -648,18 +648,12 @@ gnome_canvas_shape_realize (GnomeCanvasItem *item) (* parent_class->realize) (item); if (!item->canvas->aa) { - GtkLayout *layout; - GdkWindow *bin_window; - gcbp_ensure_gdk (shape); - layout = GTK_LAYOUT (item->canvas); - bin_window = gtk_layout_get_bin_window (layout); - - g_assert (bin_window != NULL); + g_assert(item->canvas->layout.bin_window != NULL); - shape->priv->gdk->fill_gc = gdk_gc_new (bin_window); - shape->priv->gdk->outline_gc = gdk_gc_new (bin_window); + shape->priv->gdk->fill_gc = gdk_gc_new (item->canvas->layout.bin_window); + shape->priv->gdk->outline_gc = gdk_gc_new (item->canvas->layout.bin_window); } } @@ -1434,11 +1428,10 @@ gcbp_ensure_mask (GnomeCanvasShape * shape, gint width, gint height) if ((width > ctx->width) || (height > ctx->height)) { /* Ctx is too small */ - GtkWidget *widget; + GdkWindow * window; - widget = GTK_WIDGET (GNOME_CANVAS_ITEM (shape)->canvas); - window = gtk_widget_get_window (widget); + window = ((GtkWidget *) (((GnomeCanvasItem *) shape)->canvas))->window; if (ctx->clear_gc) g_object_unref (ctx->clear_gc); if (ctx->xor_gc) g_object_unref (ctx->xor_gc); diff --git a/libgnomecanvas/gnome-canvas-text.c b/libgnomecanvas/gnome-canvas-text.c index c7e58aef0d..81cc357e41 100644 --- a/libgnomecanvas/gnome-canvas-text.c +++ b/libgnomecanvas/gnome-canvas-text.c @@ -1307,13 +1307,9 @@ gnome_canvas_text_get_property (GObject *object, static void gnome_canvas_text_apply_font_desc (GnomeCanvasText *text) { - PangoFontDescription *font_desc; - GtkWidget *widget; - GtkStyle *style; - - widget = GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas); - style = gtk_widget_get_style (widget); - font_desc = pango_font_description_copy (style->font_desc); + PangoFontDescription *font_desc = + pango_font_description_copy ( + GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas)->style->font_desc); if (text->font_desc) pango_font_description_merge (font_desc, text->font_desc, TRUE); @@ -1427,8 +1423,6 @@ gnome_canvas_text_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_pa static void gnome_canvas_text_realize (GnomeCanvasItem *item) { - GtkLayout *layout; - GdkWindow *bin_window; GnomeCanvasText *text; text = GNOME_CANVAS_TEXT (item); @@ -1436,10 +1430,7 @@ gnome_canvas_text_realize (GnomeCanvasItem *item) if (parent_class->realize) (* parent_class->realize) (item); - layout = GTK_LAYOUT (item->canvas); - bin_window = gtk_layout_get_bin_window (layout); - - text->gc = gdk_gc_new (bin_window); + text->gc = gdk_gc_new (item->canvas->layout.bin_window); } /* Unrealize handler for the text item */ diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c index 3241283719..5345a59200 100644 --- a/libgnomecanvas/gnome-canvas.c +++ b/libgnomecanvas/gnome-canvas.c @@ -91,7 +91,6 @@ #include "gnome-canvas-marshal.h" #include "gnome-canvas-marshal.c" -#include /* We must run our idle update handler *before* GDK wants to redraw. */ #define CANVAS_IDLE_PRIORITY (GDK_PRIORITY_REDRAW - 5) @@ -169,7 +168,7 @@ gnome_canvas_item_get_type (void) static void gnome_canvas_item_init (GnomeCanvasItem *item) { - item->flags |= GNOME_CANVAS_ITEM_VISIBLE; + item->object.flags |= GNOME_CANVAS_ITEM_VISIBLE; } /** @@ -301,7 +300,7 @@ gnome_canvas_item_construct (GnomeCanvasItem *item, GnomeCanvasGroup *parent, static void redraw_if_visible (GnomeCanvasItem *item) { - if (item->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (item->object.flags & GNOME_CANVAS_ITEM_VISIBLE) gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2 + 1, item->y2 + 1); } @@ -340,10 +339,10 @@ gnome_canvas_item_dispose (GObject *object) /* Normal destroy stuff */ - if (item->flags & GNOME_CANVAS_ITEM_MAPPED) + if (item->object.flags & GNOME_CANVAS_ITEM_MAPPED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->unmap) (item); - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) + if (item->object.flags & GNOME_CANVAS_ITEM_REALIZED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->unrealize) (item); if (item->parent) @@ -362,7 +361,7 @@ gnome_canvas_item_dispose (GObject *object) static void gnome_canvas_item_realize (GnomeCanvasItem *item) { - item->flags |= GNOME_CANVAS_ITEM_REALIZED; + GTK_OBJECT_SET_FLAGS (item, GNOME_CANVAS_ITEM_REALIZED); gnome_canvas_item_request_update (item); } @@ -371,31 +370,31 @@ gnome_canvas_item_realize (GnomeCanvasItem *item) static void gnome_canvas_item_unrealize (GnomeCanvasItem *item) { - item->flags &= ~GNOME_CANVAS_ITEM_REALIZED; + GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_REALIZED); } /* Map handler for canvas items */ static void gnome_canvas_item_map (GnomeCanvasItem *item) { - item->flags |= GNOME_CANVAS_ITEM_MAPPED; + GTK_OBJECT_SET_FLAGS (item, GNOME_CANVAS_ITEM_MAPPED); } /* Unmap handler for canvas items */ static void gnome_canvas_item_unmap (GnomeCanvasItem *item) { - item->flags &= ~GNOME_CANVAS_ITEM_MAPPED; + GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_MAPPED); } /* Update handler for canvas items */ static void gnome_canvas_item_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) { - item->flags &= ~GNOME_CANVAS_ITEM_NEED_UPDATE; - item->flags &= ~GNOME_CANVAS_ITEM_NEED_AFFINE; - item->flags &= ~GNOME_CANVAS_ITEM_NEED_CLIP; - item->flags &= ~GNOME_CANVAS_ITEM_NEED_VIS; + GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_NEED_UPDATE); + GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_NEED_AFFINE); + GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_NEED_CLIP); + GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_NEED_VIS); } #define noHACKISH_AFFINE @@ -424,13 +423,13 @@ gnome_canvas_item_invoke_update (GnomeCanvasItem *item, double *p2cpx, ArtSVP *c #endif child_flags = flags; - if (!(item->flags & GNOME_CANVAS_ITEM_VISIBLE)) + if (!(item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) child_flags &= ~GNOME_CANVAS_UPDATE_IS_VISIBLE; /* Calculate actual item transformation matrix */ if (item->xform) { - if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + if (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { /* Item has full affine */ art_affine_multiply (i2cpx, item->xform, p2cpx); } else { @@ -456,16 +455,16 @@ gnome_canvas_item_invoke_update (GnomeCanvasItem *item, double *p2cpx, ArtSVP *c child_flags &= ~GNOME_CANVAS_UPDATE_REQUESTED; - if (item->flags & GNOME_CANVAS_ITEM_NEED_UPDATE) + if (item->object.flags & GNOME_CANVAS_ITEM_NEED_UPDATE) child_flags |= GNOME_CANVAS_UPDATE_REQUESTED; - if (item->flags & GNOME_CANVAS_ITEM_NEED_AFFINE) + if (item->object.flags & GNOME_CANVAS_ITEM_NEED_AFFINE) child_flags |= GNOME_CANVAS_UPDATE_AFFINE; - if (item->flags & GNOME_CANVAS_ITEM_NEED_CLIP) + if (item->object.flags & GNOME_CANVAS_ITEM_NEED_CLIP) child_flags |= GNOME_CANVAS_UPDATE_CLIP; - if (item->flags & GNOME_CANVAS_ITEM_NEED_VIS) + if (item->object.flags & GNOME_CANVAS_ITEM_NEED_VIS) child_flags |= GNOME_CANVAS_UPDATE_VISIBILITY; if (child_flags & GCI_UPDATE_MASK) { @@ -487,7 +486,7 @@ gnome_canvas_item_invoke_point (GnomeCanvasItem *item, double x, double y, int c /* Calculate x & y in item local coordinates */ if (item->xform) { - if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + if (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { gdouble p2i[6], t; /* Item has full affine */ art_affine_invert (p2i, item->xform); @@ -590,7 +589,7 @@ gnome_canvas_item_affine_relative (GnomeCanvasItem *item, const double affine[6] /* Calculate actual item transformation matrix */ if (item->xform) { - if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + if (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { /* Item has full affine */ art_affine_multiply (i2p, affine, item->xform); } else { @@ -633,14 +632,14 @@ gnome_canvas_item_affine_absolute (GnomeCanvasItem *item, const double i2p[6]) } if (i2p) { - if (item->xform && !(item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL)) { + if (item->xform && !(item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL)) { /* We do not want to deal with translation-only affines */ g_free (item->xform); item->xform = NULL; } if (!item->xform) item->xform = g_new (gdouble, 6); memcpy (item->xform, i2p, 6 * sizeof (gdouble)); - item->flags |= GNOME_CANVAS_ITEM_AFFINE_FULL; + item->object.flags |= GNOME_CANVAS_ITEM_AFFINE_FULL; } else { if (item->xform) { g_free (item->xform); @@ -648,9 +647,9 @@ gnome_canvas_item_affine_absolute (GnomeCanvasItem *item, const double i2p[6]) } } - if (!(item->flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { + if (!(item->object.flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { /* Request update */ - item->flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; + item->object.flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; gnome_canvas_item_request_update (item); } @@ -878,8 +877,8 @@ gnome_canvas_item_show (GnomeCanvasItem *item) { g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - if (!(item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { - item->flags |= GNOME_CANVAS_ITEM_VISIBLE; + if (!(item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { + item->object.flags |= GNOME_CANVAS_ITEM_VISIBLE; gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2 + 1, item->y2 + 1); item->canvas->need_repick = TRUE; } @@ -898,8 +897,8 @@ gnome_canvas_item_hide (GnomeCanvasItem *item) { g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - if (item->flags & GNOME_CANVAS_ITEM_VISIBLE) { - item->flags &= ~GNOME_CANVAS_ITEM_VISIBLE; + if (item->object.flags & GNOME_CANVAS_ITEM_VISIBLE) { + item->object.flags &= ~GNOME_CANVAS_ITEM_VISIBLE; gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2 + 1, item->y2 + 1); item->canvas->need_repick = TRUE; } @@ -927,8 +926,6 @@ gnome_canvas_item_hide (GnomeCanvasItem *item) int gnome_canvas_item_grab (GnomeCanvasItem *item, guint event_mask, GdkCursor *cursor, guint32 etime) { - GtkLayout *layout; - GdkWindow *bin_window; int retval; g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), GDK_GRAB_NOT_VIEWABLE); @@ -937,13 +934,10 @@ gnome_canvas_item_grab (GnomeCanvasItem *item, guint event_mask, GdkCursor *curs if (item->canvas->grabbed_item) return GDK_GRAB_ALREADY_GRABBED; - if (!(item->flags & GNOME_CANVAS_ITEM_VISIBLE)) + if (!(item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) return GDK_GRAB_NOT_VIEWABLE; - layout = GTK_LAYOUT (item->canvas); - bin_window = gtk_layout_get_bin_window (layout); - - retval = gdk_pointer_grab (bin_window, + retval = gdk_pointer_grab (item->canvas->layout.bin_window, FALSE, event_mask, NULL, @@ -1001,7 +995,7 @@ gnome_canvas_item_i2w_affine (GnomeCanvasItem *item, double affine[6]) while (item) { if (item->xform != NULL) { - if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + if (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { art_affine_multiply (affine, affine, item->xform); } else { affine[4] += item->xform[0]; @@ -1159,14 +1153,8 @@ gnome_canvas_item_grab_focus (GnomeCanvasItem *item) focused_item = item->canvas->focused_item; if (focused_item) { - GtkLayout *layout; - GdkWindow *bin_window; - - layout = GTK_LAYOUT (item->canvas); - bin_window = gtk_layout_get_bin_window (layout); - ev.focus_change.type = GDK_FOCUS_CHANGE; - ev.focus_change.window = bin_window; + ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window; ev.focus_change.send_event = FALSE; ev.focus_change.in = FALSE; @@ -1177,14 +1165,8 @@ gnome_canvas_item_grab_focus (GnomeCanvasItem *item) gtk_widget_grab_focus (GTK_WIDGET (item->canvas)); if (focused_item) { - GtkLayout *layout; - GdkWindow *bin_window; - - layout = GTK_LAYOUT (item->canvas); - bin_window = gtk_layout_get_bin_window (layout); - ev.focus_change.type = GDK_FOCUS_CHANGE; - ev.focus_change.window = bin_window; + ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window; ev.focus_change.send_event = FALSE; ev.focus_change.in = TRUE; @@ -1224,7 +1206,7 @@ gnome_canvas_item_get_bounds (GnomeCanvasItem *item, double *x1, double *y1, dou /* Make the bounds relative to the item's parent coordinate system */ - if (item->xform && (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL)) { + if (item->xform && (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL)) { p1.x = p2.x = tx1; p1.y = p4.y = ty1; p3.x = p4.x = tx2; @@ -1304,10 +1286,10 @@ gnome_canvas_item_get_bounds (GnomeCanvasItem *item, double *x1, double *y1, dou void gnome_canvas_item_request_update (GnomeCanvasItem *item) { - if (item->flags & GNOME_CANVAS_ITEM_NEED_UPDATE) + if (item->object.flags & GNOME_CANVAS_ITEM_NEED_UPDATE) return; - item->flags |= GNOME_CANVAS_ITEM_NEED_UPDATE; + item->object.flags |= GNOME_CANVAS_ITEM_NEED_UPDATE; if (item->parent != NULL) { /* Recurse up the tree */ @@ -1455,12 +1437,12 @@ static double * gnome_canvas_ensure_translate (GnomeCanvasItem *item) { if (item->xform == NULL) { - item->flags &= ~GNOME_CANVAS_ITEM_AFFINE_FULL; + GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_AFFINE_FULL); item->xform = g_new (double, 2); item->xform[0] = 0.0; item->xform[1] = 0.0; return item->xform; - } else if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + } else if (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { return item->xform + 4; } else { return item->xform; @@ -1511,7 +1493,7 @@ gnome_canvas_group_get_property (GObject *gobject, guint param_id, case GROUP_PROP_X: if (item->xform == NULL) g_value_set_double (value, 0); - else if (GNOME_CANVAS_ITEM (gobject)->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) + else if (GTK_OBJECT (gobject)->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) g_value_set_double (value, item->xform[4]); else g_value_set_double (value, item->xform[0]); @@ -1520,7 +1502,7 @@ gnome_canvas_group_get_property (GObject *gobject, guint param_id, case GROUP_PROP_Y: if (item->xform == NULL) g_value_set_double (value, 0); - else if (GNOME_CANVAS_ITEM (gobject)->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) + else if (GTK_OBJECT (gobject)->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) g_value_set_double (value, item->xform[5]); else g_value_set_double (value, item->xform[1]); @@ -1599,7 +1581,7 @@ gnome_canvas_group_realize (GnomeCanvasItem *item) for (list = group->item_list; list; list = list->next) { i = list->data; - if (!(i->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(i->object.flags & GNOME_CANVAS_ITEM_REALIZED)) (* GNOME_CANVAS_ITEM_GET_CLASS (i)->realize) (i); } @@ -1619,7 +1601,7 @@ gnome_canvas_group_unrealize (GnomeCanvasItem *item) for (list = group->item_list; list; list = list->next) { i = list->data; - if (i->flags & GNOME_CANVAS_ITEM_REALIZED) + if (i->object.flags & GNOME_CANVAS_ITEM_REALIZED) (* GNOME_CANVAS_ITEM_GET_CLASS (i)->unrealize) (i); } @@ -1639,7 +1621,7 @@ gnome_canvas_group_map (GnomeCanvasItem *item) for (list = group->item_list; list; list = list->next) { i = list->data; - if (!(i->flags & GNOME_CANVAS_ITEM_MAPPED)) + if (!(i->object.flags & GNOME_CANVAS_ITEM_MAPPED)) (* GNOME_CANVAS_ITEM_GET_CLASS (i)->map) (i); } @@ -1659,7 +1641,7 @@ gnome_canvas_group_unmap (GnomeCanvasItem *item) for (list = group->item_list; list; list = list->next) { i = list->data; - if (i->flags & GNOME_CANVAS_ITEM_MAPPED) + if (i->object.flags & GNOME_CANVAS_ITEM_MAPPED) (* GNOME_CANVAS_ITEM_GET_CLASS (i)->unmap) (i); } @@ -1680,12 +1662,12 @@ gnome_canvas_group_draw (GnomeCanvasItem *item, GdkDrawable *drawable, for (list = group->item_list; list; list = list->next) { child = list->data; - if (((child->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (((child->object.flags & GNOME_CANVAS_ITEM_VISIBLE) && ((child->x1 < (x + width)) && (child->y1 < (y + height)) && (child->x2 > x) && (child->y2 > y))) - || ((child->flags & GNOME_CANVAS_ITEM_ALWAYS_REDRAW) + || ((GTK_OBJECT_FLAGS (child) & GNOME_CANVAS_ITEM_ALWAYS_REDRAW) && (child->x1 < child->canvas->redraw_x2) && (child->y1 < child->canvas->redraw_y2) && (child->x2 > child->canvas->redraw_x1) @@ -1732,7 +1714,7 @@ gnome_canvas_group_point (GnomeCanvasItem *item, double x, double y, int cx, int point_item = NULL; /* cater for incomplete item implementations */ - if ((child->flags & GNOME_CANVAS_ITEM_VISIBLE) + if ((child->object.flags & GNOME_CANVAS_ITEM_VISIBLE) && GNOME_CANVAS_ITEM_GET_CLASS (child)->point) { dist = gnome_canvas_item_invoke_point (child, gx, gy, cx, cy, &point_item); has_point = TRUE; @@ -1773,7 +1755,7 @@ gnome_canvas_group_bounds (GnomeCanvasItem *item, double *x1, double *y1, double for (list = group->item_list; list; list = list->next) { child = list->data; - if (child->flags & GNOME_CANVAS_ITEM_VISIBLE) { + if (child->object.flags & GNOME_CANVAS_ITEM_VISIBLE) { set = TRUE; gnome_canvas_item_get_bounds (child, &minx, &miny, &maxx, &maxy); break; @@ -1794,7 +1776,7 @@ gnome_canvas_group_bounds (GnomeCanvasItem *item, double *x1, double *y1, double for (; list; list = list->next) { child = list->data; - if (!(child->flags & GNOME_CANVAS_ITEM_VISIBLE)) + if (!(child->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) continue; gnome_canvas_item_get_bounds (child, &tx1, &ty1, &tx2, &ty2); @@ -1831,12 +1813,12 @@ gnome_canvas_group_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf) for (list = group->item_list; list; list = list->next) { child = list->data; - if (((child->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (((child->object.flags & GNOME_CANVAS_ITEM_VISIBLE) && ((child->x1 < buf->rect.x1) && (child->y1 < buf->rect.y1) && (child->x2 > buf->rect.x0) && (child->y2 > buf->rect.y0))) - || ((child->flags & GNOME_CANVAS_ITEM_ALWAYS_REDRAW) + || ((GTK_OBJECT_FLAGS (child) & GNOME_CANVAS_ITEM_ALWAYS_REDRAW) && (child->x1 < child->canvas->redraw_x2) && (child->y1 < child->canvas->redraw_y2) && (child->x2 > child->canvas->redraw_x1) @@ -1859,10 +1841,10 @@ group_add (GnomeCanvasGroup *group, GnomeCanvasItem *item) } else group->item_list_end = g_list_append (group->item_list_end, item)->next; - if (group->item.flags & GNOME_CANVAS_ITEM_REALIZED) + if (group->item.object.flags & GNOME_CANVAS_ITEM_REALIZED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->realize) (item); - if (group->item.flags & GNOME_CANVAS_ITEM_MAPPED) + if (group->item.object.flags & GNOME_CANVAS_ITEM_MAPPED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->map) (item); g_object_notify (G_OBJECT (item), "parent"); @@ -1879,10 +1861,10 @@ group_remove (GnomeCanvasGroup *group, GnomeCanvasItem *item) for (children = group->item_list; children; children = children->next) if (children->data == item) { - if (item->flags & GNOME_CANVAS_ITEM_MAPPED) + if (item->object.flags & GNOME_CANVAS_ITEM_MAPPED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->unmap) (item); - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) + if (item->object.flags & GNOME_CANVAS_ITEM_REALIZED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->unrealize) (item); /* Unparent the child */ @@ -2110,13 +2092,7 @@ panic_root_destroyed (GtkObject *object, gpointer data) static void gnome_canvas_init (GnomeCanvas *canvas) { - GtkLayout *layout; - guint layout_width, layout_height; - - layout = GTK_LAYOUT (canvas); - gtk_layout_get_size (layout, &layout_width, &layout_height); - - gtk_widget_set_can_focus (GTK_WIDGET (canvas), TRUE); + GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS); canvas->need_update = FALSE; canvas->need_redraw = FALSE; @@ -2125,8 +2101,8 @@ gnome_canvas_init (GnomeCanvas *canvas) canvas->scroll_x1 = 0.0; canvas->scroll_y1 = 0.0; - canvas->scroll_x2 = layout_width; - canvas->scroll_y2 = layout_height; + canvas->scroll_x2 = canvas->layout.width; + canvas->scroll_y2 = canvas->layout.height; canvas->pixels_per_unit = 1.0; @@ -2307,8 +2283,6 @@ static void gnome_canvas_realize (GtkWidget *widget) { GnomeCanvas *canvas; - GtkLayout *layout; - GdkWindow *bin_window; g_return_if_fail (GNOME_IS_CANVAS (widget)); @@ -2319,11 +2293,8 @@ gnome_canvas_realize (GtkWidget *widget) canvas = GNOME_CANVAS (widget); - layout = GTK_LAYOUT (canvas); - bin_window = gtk_layout_get_bin_window (layout); - - gdk_window_set_events (bin_window, - (gdk_window_get_events (bin_window) + gdk_window_set_events (canvas->layout.bin_window, + (gdk_window_get_events (canvas->layout.bin_window) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -2336,7 +2307,7 @@ gnome_canvas_realize (GtkWidget *widget) /* Create our own temporary pixmap gc and realize all the items */ - canvas->pixmap_gc = gdk_gc_new (bin_window); + canvas->pixmap_gc = gdk_gc_new (canvas->layout.bin_window); (* GNOME_CANVAS_ITEM_GET_CLASS (canvas->root)->realize) (canvas->root); } @@ -2370,27 +2341,14 @@ gnome_canvas_unrealize (GtkWidget *widget) static void scroll_to (GnomeCanvas *canvas, int cx, int cy) { - GtkWidget *widget; - GtkLayout *layout; - GtkAllocation allocation; - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; - guint layout_width, layout_height; int scroll_width, scroll_height; int right_limit, bottom_limit; int old_zoom_xofs, old_zoom_yofs; + int changed_x = FALSE, changed_y = FALSE; int canvas_width, canvas_height; - widget = GTK_WIDGET (canvas); - gtk_widget_get_allocation (widget, &allocation); - - layout = GTK_LAYOUT (canvas); - hadjustment = gtk_layout_get_hadjustment (layout); - vadjustment = gtk_layout_get_vadjustment (layout); - gtk_layout_get_size (layout, &layout_width, &layout_height); - - canvas_width = allocation.width; - canvas_height = allocation.height; + canvas_width = GTK_WIDGET (canvas)->allocation.width; + canvas_height = GTK_WIDGET (canvas)->allocation.height; scroll_width = floor ((canvas->scroll_x2 - canvas->scroll_x1) * canvas->pixels_per_unit + 0.5); @@ -2443,31 +2401,41 @@ scroll_to (GnomeCanvas *canvas, int cx, int cy) /* The reason is, that coverage UTA will be invalidated by offset change */ /* fixme: Strictly this is not correct - we have to remove our own idle (Lauris) */ /* More stuff - we have to mark root as needing fresh affine (Lauris) */ - if (!(canvas->root->flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { - canvas->root->flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; + if (!(canvas->root->object.flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { + canvas->root->object.flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; gnome_canvas_request_update (canvas); } gtk_widget_queue_draw (GTK_WIDGET (canvas)); } - if (hadjustment) - gtk_adjustment_set_value (hadjustment, cx); + if (canvas->layout.hadjustment && ((int) canvas->layout.hadjustment->value) != cx) { + canvas->layout.hadjustment->value = cx; + changed_x = TRUE; + } - if (vadjustment) - gtk_adjustment_set_value (vadjustment, cy); + if (canvas->layout.vadjustment && ((int) canvas->layout.vadjustment->value) != cy) { + canvas->layout.vadjustment->value = cy; + changed_y = TRUE; + } - if ((scroll_width != (int) layout_width) - || (scroll_height != (int) layout_height)) + if ((scroll_width != (int) canvas->layout.width) + || (scroll_height != (int) canvas->layout.height)) gtk_layout_set_size (GTK_LAYOUT (canvas), scroll_width, scroll_height); + + /* Signal GtkLayout that it should do a redraw. */ + + if (changed_x) + g_signal_emit_by_name (canvas->layout.hadjustment, "value_changed"); + + if (changed_y) + g_signal_emit_by_name (canvas->layout.vadjustment, "value_changed"); } /* Size allocation handler for the canvas */ static void gnome_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - GtkLayout *layout; - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; + GnomeCanvas *canvas; g_return_if_fail (GNOME_IS_CANVAS (widget)); g_return_if_fail (allocation != NULL); @@ -2475,27 +2443,22 @@ gnome_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) if (GTK_WIDGET_CLASS (canvas_parent_class)->size_allocate) (* GTK_WIDGET_CLASS (canvas_parent_class)->size_allocate) (widget, allocation); - layout = GTK_LAYOUT (widget); - hadjustment = gtk_layout_get_hadjustment (layout); - vadjustment = gtk_layout_get_vadjustment (layout); + canvas = GNOME_CANVAS (widget); /* Recenter the view, if appropriate */ - g_object_freeze_notify (G_OBJECT (hadjustment)); - g_object_freeze_notify (G_OBJECT (vadjustment)); - - gtk_adjustment_set_page_size (hadjustment, allocation->width); - gtk_adjustment_set_page_increment (hadjustment, allocation->width / 2); + canvas->layout.hadjustment->page_size = allocation->width; + canvas->layout.hadjustment->page_increment = allocation->width / 2; - gtk_adjustment_set_page_size (vadjustment, allocation->height); - gtk_adjustment_set_page_increment (vadjustment, allocation->height / 2); + canvas->layout.vadjustment->page_size = allocation->height; + canvas->layout.vadjustment->page_increment = allocation->height / 2; - scroll_to (GNOME_CANVAS (widget), - gtk_adjustment_get_value (hadjustment), - gtk_adjustment_get_value (vadjustment)); + scroll_to (canvas, + canvas->layout.hadjustment->value, + canvas->layout.vadjustment->value); - g_object_thaw_notify (G_OBJECT (hadjustment)); - g_object_thaw_notify (G_OBJECT (vadjustment)); + g_signal_emit_by_name (canvas->layout.hadjustment, "changed"); + g_signal_emit_by_name (canvas->layout.vadjustment, "changed"); } /* Emits an event for an item in the canvas, be it the current item, grabbed @@ -2718,7 +2681,7 @@ pick_current_item (GnomeCanvas *canvas, GdkEvent *event) /* find the closest item */ - if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (canvas->root->object.flags & GNOME_CANVAS_ITEM_VISIBLE) gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy, &canvas->new_current_item); else @@ -2776,8 +2739,6 @@ static gint gnome_canvas_button (GtkWidget *widget, GdkEventButton *event) { GnomeCanvas *canvas; - GtkLayout *layout; - GdkWindow *bin_window; int mask; int retval; @@ -2788,14 +2749,11 @@ gnome_canvas_button (GtkWidget *widget, GdkEventButton *event) canvas = GNOME_CANVAS (widget); - layout = GTK_LAYOUT (canvas); - bin_window = gtk_layout_get_bin_window (layout); - /* * dispatch normally regardless of the event's window if an item has * has a pointer grab in effect */ - if (!canvas->grabbed_item && event->window != bin_window) + if (!canvas->grabbed_item && event->window != canvas->layout.bin_window) return retval; switch (event->button) { @@ -2855,18 +2813,13 @@ static gint gnome_canvas_motion (GtkWidget *widget, GdkEventMotion *event) { GnomeCanvas *canvas; - GtkLayout *layout; - GdkWindow *bin_window; g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); canvas = GNOME_CANVAS (widget); - layout = GTK_LAYOUT (widget); - bin_window = gtk_layout_get_bin_window (layout); - - if (event->window != bin_window) + if (event->window != canvas->layout.bin_window) return FALSE; canvas->state = event->state; @@ -2910,18 +2863,13 @@ static gint gnome_canvas_crossing (GtkWidget *widget, GdkEventCrossing *event) { GnomeCanvas *canvas; - GtkLayout *layout; - GdkWindow *bin_window; g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); canvas = GNOME_CANVAS (widget); - layout = GTK_LAYOUT (canvas); - bin_window = gtk_layout_get_bin_window (layout); - - if (event->window != bin_window) + if (event->window != canvas->layout.bin_window) return FALSE; canvas->state = event->state; @@ -2934,11 +2882,7 @@ gnome_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event) { GnomeCanvas *canvas; - /* XXX Can't access flags directly anymore, but is it really needed? - * If so, could we call gtk_widget_send_focus_change() instead? */ -#if 0 GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); -#endif canvas = GNOME_CANVAS (widget); @@ -2954,11 +2898,7 @@ gnome_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) { GnomeCanvas *canvas; - /* XXX Can't access flags directly anymore, but is it really needed? - * If so, could we call gtk_widget_send_focus_change() instead? */ -#if 0 GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); -#endif canvas = GNOME_CANVAS (widget); @@ -2974,34 +2914,18 @@ static void gnome_canvas_paint_rect (GnomeCanvas *canvas, gint x0, gint y0, gint x1, gint y1) { GtkWidget *widget; - GtkLayout *layout; - GdkWindow *bin_window; - GtkAllocation allocation; - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; gint draw_x1, draw_y1; gint draw_x2, draw_y2; gint draw_width, draw_height; - gdouble hadjustment_value; - gdouble vadjustment_value; g_return_if_fail (!canvas->need_update); widget = GTK_WIDGET (canvas); - gtk_widget_get_allocation (widget, &allocation); - - layout = GTK_LAYOUT (canvas); - bin_window = gtk_layout_get_bin_window (layout); - hadjustment = gtk_layout_get_hadjustment (layout); - vadjustment = gtk_layout_get_vadjustment (layout); - hadjustment_value = gtk_adjustment_get_value (hadjustment); - vadjustment_value = gtk_adjustment_get_value (vadjustment); - - draw_x1 = MAX (x0, hadjustment_value - canvas->zoom_xofs); - draw_y1 = MAX (y0, vadjustment_value - canvas->zoom_yofs); - draw_x2 = MIN (draw_x1 + allocation.width, x1); - draw_y2 = MIN (draw_y1 + allocation.height, y1); + draw_x1 = MAX (x0, canvas->layout.hadjustment->value - canvas->zoom_xofs); + draw_y1 = MAX (y0, canvas->layout.vadjustment->value - canvas->zoom_yofs); + draw_x2 = MIN (draw_x1 + GTK_WIDGET (canvas)->allocation.width, x1); + draw_y2 = MIN (draw_y1 + GTK_WIDGET (canvas)->allocation.height, y1); draw_width = draw_x2 - draw_x1; draw_height = draw_y2 - draw_y1; @@ -3020,7 +2944,6 @@ gnome_canvas_paint_rect (GnomeCanvas *canvas, gint x0, gint y0, gint x1, gint y1 GnomeCanvasBuf buf; guchar *px; GdkColor *color; - GtkStyle *style; px = g_new (guchar, draw_width * 3 * draw_height); @@ -3030,27 +2953,26 @@ gnome_canvas_paint_rect (GnomeCanvas *canvas, gint x0, gint y0, gint x1, gint y1 buf.rect.y0 = draw_y1; buf.rect.x1 = draw_x2; buf.rect.y1 = draw_y2; - style = gtk_widget_get_style (widget); - color = &style->bg[GTK_STATE_NORMAL]; + color = &widget->style->bg[GTK_STATE_NORMAL]; buf.bg_color = (((color->red & 0xff00) << 8) | (color->green & 0xff00) | (color->blue >> 8)); buf.is_bg = 1; buf.is_buf = 0; g_signal_emit (G_OBJECT (canvas), canvas_signals[RENDER_BACKGROUND], 0, &buf); - if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (canvas->root->object.flags & GNOME_CANVAS_ITEM_VISIBLE) (* GNOME_CANVAS_ITEM_GET_CLASS (canvas->root)->render) (canvas->root, &buf); if (buf.is_bg) { gdk_gc_set_rgb_fg_color (canvas->pixmap_gc, color); - gdk_draw_rectangle (bin_window, + gdk_draw_rectangle (canvas->layout.bin_window, canvas->pixmap_gc, TRUE, (draw_x1 + canvas->zoom_xofs), (draw_y1 + canvas->zoom_yofs), draw_width, draw_height); } else { - gdk_draw_rgb_image_dithalign (bin_window, + gdk_draw_rgb_image_dithalign (canvas->layout.bin_window, canvas->pixmap_gc, (draw_x1 + canvas->zoom_xofs), (draw_y1 + canvas->zoom_yofs), @@ -3064,19 +2986,15 @@ gnome_canvas_paint_rect (GnomeCanvas *canvas, gint x0, gint y0, gint x1, gint y1 g_free (px); } else { GdkPixmap *pixmap; - GdkVisual *visual; - gint depth; - - visual = gtk_widget_get_visual (widget); - depth = gdk_visual_get_depth (visual); - pixmap = gdk_pixmap_new (bin_window, - draw_width, draw_height, depth); + pixmap = gdk_pixmap_new (canvas->layout.bin_window, + draw_width, draw_height, + gtk_widget_get_visual (widget)->depth); g_signal_emit (G_OBJECT (canvas), canvas_signals[DRAW_BACKGROUND], 0, pixmap, draw_x1, draw_y1, draw_width, draw_height); - if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (canvas->root->object.flags & GNOME_CANVAS_ITEM_VISIBLE) (* GNOME_CANVAS_ITEM_GET_CLASS (canvas->root)->draw) ( canvas->root, pixmap, draw_x1, draw_y1, @@ -3084,7 +3002,7 @@ gnome_canvas_paint_rect (GnomeCanvas *canvas, gint x0, gint y0, gint x1, gint y1 /* Copy the pixmap to the window and clean up */ - gdk_draw_drawable (bin_window, + gdk_draw_drawable (canvas->layout.bin_window, canvas->pixmap_gc, pixmap, 0, 0, @@ -3101,18 +3019,13 @@ static gint gnome_canvas_expose (GtkWidget *widget, GdkEventExpose *event) { GnomeCanvas *canvas; - GtkLayout *layout; - GdkWindow *bin_window; GdkRectangle *rects; gint n_rects; int i; canvas = GNOME_CANVAS (widget); - layout = GTK_LAYOUT (canvas); - bin_window = gtk_layout_get_bin_window (layout); - - if (!gtk_widget_is_drawable (widget) || (event->window != bin_window)) + if (!gtk_widget_is_drawable (widget) || (event->window != canvas->layout.bin_window)) return FALSE; #ifdef VERBOSE @@ -3155,29 +3068,10 @@ gnome_canvas_expose (GtkWidget *widget, GdkEventExpose *event) static void paint (GnomeCanvas *canvas) { - GtkWidget *widget; - GtkLayout *layout; - GdkWindow *bin_window; - GtkAllocation allocation; - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; ArtIRect *rects; gint n_rects, i; ArtIRect visible_rect; GdkRegion *region; - gdouble hadjustment_value; - gdouble vadjustment_value; - - widget = GTK_WIDGET (canvas); - gtk_widget_get_allocation (widget, &allocation); - - layout = GTK_LAYOUT (canvas); - bin_window = gtk_layout_get_bin_window (layout); - hadjustment = gtk_layout_get_hadjustment (layout); - vadjustment = gtk_layout_get_vadjustment (layout); - - hadjustment_value = gtk_adjustment_get_value (hadjustment); - vadjustment_value = gtk_adjustment_get_value (vadjustment); /* Extract big rectangles from the microtile array */ @@ -3191,10 +3085,10 @@ paint (GnomeCanvas *canvas) /* Turn those rectangles into a GdkRegion for exposing */ - visible_rect.x0 = hadjustment_value - canvas->zoom_xofs; - visible_rect.y0 = vadjustment_value - canvas->zoom_yofs; - visible_rect.x1 = visible_rect.x0 + allocation.width; - visible_rect.y1 = visible_rect.y0 + allocation.height; + visible_rect.x0 = canvas->layout.hadjustment->value - canvas->zoom_xofs; + visible_rect.y0 = canvas->layout.vadjustment->value - canvas->zoom_yofs; + visible_rect.x1 = visible_rect.x0 + GTK_WIDGET (canvas)->allocation.width; + visible_rect.y1 = visible_rect.y0 + GTK_WIDGET (canvas)->allocation.height; region = gdk_region_new (); @@ -3211,7 +3105,7 @@ paint (GnomeCanvas *canvas) gdkrect.height = clipped.y1 - clipped.y0; region = gdk_region_rectangle (&gdkrect); - gdk_window_invalidate_region (bin_window, region, FALSE); + gdk_window_invalidate_region (canvas->layout.bin_window, region, FALSE); gdk_region_destroy (region); } } @@ -3228,13 +3122,9 @@ static void gnome_canvas_draw_background (GnomeCanvas *canvas, GdkDrawable *drawable, int x, int y, int width, int height) { - GtkStyle *style; - - style = gtk_widget_get_style (GTK_WIDGET (canvas)); - /* By default, we use the style background. */ gdk_gc_set_foreground (canvas->pixmap_gc, - &style->bg[GTK_STATE_NORMAL]); + >K_WIDGET (canvas)->style->bg[GTK_STATE_NORMAL]); gdk_draw_rectangle (drawable, canvas->pixmap_gc, TRUE, @@ -3353,31 +3243,19 @@ gnome_canvas_root (GnomeCanvas *canvas) void gnome_canvas_set_scroll_region (GnomeCanvas *canvas, double x1, double y1, double x2, double y2) { - GtkLayout *layout; - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; - gdouble hadjustment_value; - gdouble vadjustment_value; double wxofs, wyofs; int xofs, yofs; g_return_if_fail (GNOME_IS_CANVAS (canvas)); - layout = GTK_LAYOUT (canvas); - hadjustment = gtk_layout_get_hadjustment (layout); - vadjustment = gtk_layout_get_vadjustment (layout); - - hadjustment_value = gtk_adjustment_get_value (hadjustment); - vadjustment_value = gtk_adjustment_get_value (vadjustment); - /* * Set the new scrolling region. If possible, do not move the visible contents of the * canvas. */ gnome_canvas_c2w (canvas, - hadjustment_value + canvas->zoom_xofs, - vadjustment_value + canvas->zoom_yofs, + GTK_LAYOUT (canvas)->hadjustment->value + canvas->zoom_xofs, + GTK_LAYOUT (canvas)->vadjustment->value + canvas->zoom_yofs, /*canvas->zoom_xofs, canvas->zoom_yofs,*/ &wxofs, &wyofs); @@ -3442,24 +3320,13 @@ gnome_canvas_get_scroll_region (GnomeCanvas *canvas, double *x1, double *y1, dou void gnome_canvas_set_center_scroll_region (GnomeCanvas *canvas, gboolean center_scroll_region) { - GtkLayout *layout; - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; - gdouble hadjustment_value; - gdouble vadjustment_value; - g_return_if_fail (GNOME_IS_CANVAS (canvas)); - layout = GTK_LAYOUT (canvas); - hadjustment = gtk_layout_get_hadjustment (layout); - vadjustment = gtk_layout_get_vadjustment (layout); - - hadjustment_value = gtk_adjustment_get_value (hadjustment); - vadjustment_value = gtk_adjustment_get_value (vadjustment); - canvas->center_scroll_region = center_scroll_region != 0; - scroll_to (canvas, hadjustment_value, vadjustment_value); + scroll_to (canvas, + canvas->layout.hadjustment->value, + canvas->layout.vadjustment->value); } /** @@ -3498,9 +3365,6 @@ gnome_canvas_get_center_scroll_region (GnomeCanvas *canvas) void gnome_canvas_set_pixels_per_unit (GnomeCanvas *canvas, double n) { - GtkLayout *layout; - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; double ax, ay; int x1, y1; int anchor_x, anchor_y; @@ -3508,30 +3372,20 @@ gnome_canvas_set_pixels_per_unit (GnomeCanvas *canvas, double n) g_return_if_fail (GNOME_IS_CANVAS (canvas)); g_return_if_fail (n > GNOME_CANVAS_EPSILON); - layout = GTK_LAYOUT (canvas); - hadjustment = gtk_layout_get_hadjustment (layout); - vadjustment = gtk_layout_get_vadjustment (layout); - if (canvas->center_scroll_region) { - GtkAllocation allocation; - - gtk_widget_get_allocation (GTK_WIDGET (canvas), &allocation); - - anchor_x = allocation.width / 2; - anchor_y = allocation.height / 2; + anchor_x = GTK_WIDGET (canvas)->allocation.width / 2; + anchor_y = GTK_WIDGET (canvas)->allocation.height / 2; } else anchor_x = anchor_y = 0; /* Find the coordinates of the anchor point in units. */ - if(hadjustment) { - gdouble value = gtk_adjustment_get_value (hadjustment); - ax = (value + anchor_x) / canvas->pixels_per_unit + canvas->scroll_x1 + canvas->zoom_xofs; + if(canvas->layout.hadjustment) { + ax = (canvas->layout.hadjustment->value + anchor_x) / canvas->pixels_per_unit + canvas->scroll_x1 + canvas->zoom_xofs; } else { ax = (0.0 + anchor_x) / canvas->pixels_per_unit + canvas->scroll_x1 + canvas->zoom_xofs; } - if(vadjustment) { - gdouble value = gtk_adjustment_get_value (vadjustment); - ay = (value + anchor_y) / canvas->pixels_per_unit + canvas->scroll_y1 + canvas->zoom_yofs; + if(canvas->layout.hadjustment) { + ay = (canvas->layout.vadjustment->value + anchor_y) / canvas->pixels_per_unit + canvas->scroll_y1 + canvas->zoom_yofs; } else { ay = (0.0 + anchor_y) / canvas->pixels_per_unit + canvas->scroll_y1 + canvas->zoom_yofs; } @@ -3544,8 +3398,8 @@ gnome_canvas_set_pixels_per_unit (GnomeCanvas *canvas, double n) scroll_to (canvas, x1, y1); - if (!(canvas->root->flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { - canvas->root->flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; + if (!(canvas->root->object.flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { + canvas->root->object.flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; gnome_canvas_request_update (canvas); } @@ -3583,22 +3437,13 @@ gnome_canvas_scroll_to (GnomeCanvas *canvas, int cx, int cy) void gnome_canvas_get_scroll_offsets (GnomeCanvas *canvas, int *cx, int *cy) { - GtkLayout *layout; - GtkAdjustment *adjustment; - g_return_if_fail (GNOME_IS_CANVAS (canvas)); - layout = GTK_LAYOUT (canvas); - - if (cx) { - adjustment = gtk_layout_get_hadjustment (layout); - *cx = (gint) gtk_adjustment_get_value (adjustment); - } + if (cx) + *cx = canvas->layout.hadjustment->value; - if (cy) { - adjustment = gtk_layout_get_vadjustment (layout); - *cy = (gint) gtk_adjustment_get_value (adjustment); - } + if (cy) + *cy = canvas->layout.vadjustment->value; } /** @@ -3795,26 +3640,10 @@ uta_union_clip (ArtUta *uta1, ArtUta *uta2, ArtIRect *clip) static inline void get_visible_region (GnomeCanvas *canvas, ArtIRect *visible) { - GtkLayout *layout; - GtkAllocation allocation; - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; - gdouble hadjustment_value; - gdouble vadjustment_value; - - gtk_widget_get_allocation (GTK_WIDGET (canvas), &allocation); - - layout = GTK_LAYOUT (canvas); - hadjustment = gtk_layout_get_hadjustment (layout); - vadjustment = gtk_layout_get_vadjustment (layout); - - hadjustment_value = gtk_adjustment_get_value (hadjustment); - vadjustment_value = gtk_adjustment_get_value (vadjustment); - - visible->x0 = hadjustment_value - canvas->zoom_xofs; - visible->y0 = vadjustment_value - canvas->zoom_yofs; - visible->x1 = visible->x0 + allocation.width; - visible->y1 = visible->y0 + allocation.height; + visible->x0 = canvas->layout.hadjustment->value - canvas->zoom_xofs; + visible->y0 = canvas->layout.vadjustment->value - canvas->zoom_yofs; + visible->x1 = visible->x0 + GTK_WIDGET (canvas)->allocation.width; + visible->y1 = visible->y0 + GTK_WIDGET (canvas)->allocation.height; } /** diff --git a/libgnomecanvas/gnome-canvas.h b/libgnomecanvas/gnome-canvas.h index 559bd9c8fb..a9c70be4f5 100644 --- a/libgnomecanvas/gnome-canvas.h +++ b/libgnomecanvas/gnome-canvas.h @@ -90,17 +90,17 @@ typedef struct _GnomeCanvasGroupClass GnomeCanvasGroupClass; */ /* Object flags for items */ -typedef enum { - GNOME_CANVAS_ITEM_REALIZED = 1 << 0, - GNOME_CANVAS_ITEM_MAPPED = 1 << 1, - GNOME_CANVAS_ITEM_ALWAYS_REDRAW = 1 << 2, - GNOME_CANVAS_ITEM_VISIBLE = 1 << 3, - GNOME_CANVAS_ITEM_NEED_UPDATE = 1 << 4, - GNOME_CANVAS_ITEM_NEED_AFFINE = 1 << 5, - GNOME_CANVAS_ITEM_NEED_CLIP = 1 << 6, - GNOME_CANVAS_ITEM_NEED_VIS = 1 << 7, - GNOME_CANVAS_ITEM_AFFINE_FULL = 1 << 8 -} GnomeCanvasItemFlags; +enum { + GNOME_CANVAS_ITEM_REALIZED = 1 << 4, + GNOME_CANVAS_ITEM_MAPPED = 1 << 5, + GNOME_CANVAS_ITEM_ALWAYS_REDRAW = 1 << 6, + GNOME_CANVAS_ITEM_VISIBLE = 1 << 7, + GNOME_CANVAS_ITEM_NEED_UPDATE = 1 << 8, + GNOME_CANVAS_ITEM_NEED_AFFINE = 1 << 9, + GNOME_CANVAS_ITEM_NEED_CLIP = 1 << 10, + GNOME_CANVAS_ITEM_NEED_VIS = 1 << 11, + GNOME_CANVAS_ITEM_AFFINE_FULL = 1 << 12 +}; /* Update flags for items */ enum { @@ -161,10 +161,6 @@ struct _GnomeCanvasItem { /* Bounding box for this item (in canvas coordinates) */ double x1, y1, x2, y2; - - /* XXX GtkObject flags are sealed now, so we have to provide - * our own. This breaks ABI compatibility with upstream. */ - GnomeCanvasItemFlags flags; }; struct _GnomeCanvasItemClass { diff --git a/widgets/misc/e-canvas-background.c b/widgets/misc/e-canvas-background.c index a44a05407a..28875725b3 100644 --- a/widgets/misc/e-canvas-background.c +++ b/widgets/misc/e-canvas-background.c @@ -266,7 +266,7 @@ ecb_set_property (GObject *object, if (color_changed) { ecb->priv->color = color; - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { + if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(item)) { get_color (ecb); if (!item->canvas->aa) { gdk_gc_set_foreground (ecb->priv->gc, &ecb->priv->color); diff --git a/widgets/misc/e-canvas-vbox.c b/widgets/misc/e-canvas-vbox.c index 5fc939939b..63b23efdf6 100644 --- a/widgets/misc/e-canvas-vbox.c +++ b/widgets/misc/e-canvas-vbox.c @@ -256,7 +256,7 @@ e_canvas_vbox_real_add_item(ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *item) e_canvas_vbox->items = g_list_append(e_canvas_vbox->items, item); g_object_weak_ref (G_OBJECT (item), e_canvas_vbox_remove_item, e_canvas_vbox); - if (GNOME_CANVAS_ITEM (e_canvas_vbox)->flags & GNOME_CANVAS_ITEM_REALIZED) { + if (GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED) { gnome_canvas_item_set(item, "width", (gdouble) e_canvas_vbox->minimum_width, NULL); @@ -270,7 +270,7 @@ e_canvas_vbox_real_add_item_start(ECanvasVbox *e_canvas_vbox, GnomeCanvasItem *i e_canvas_vbox->items = g_list_prepend(e_canvas_vbox->items, item); g_object_weak_ref (G_OBJECT (item), e_canvas_vbox_remove_item, e_canvas_vbox); - if (GNOME_CANVAS_ITEM (e_canvas_vbox)->flags & GNOME_CANVAS_ITEM_REALIZED) { + if (GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED) { gnome_canvas_item_set(item, "width", (gdouble) e_canvas_vbox->minimum_width, NULL); @@ -297,7 +297,7 @@ static void e_canvas_vbox_reflow( GnomeCanvasItem *item, gint flags ) { ECanvasVbox *e_canvas_vbox = E_CANVAS_VBOX(item); - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { + if (GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED) { gdouble old_height; gdouble running_height; diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c index 3b8d5ed57f..593c9c4530 100644 --- a/widgets/misc/e-canvas.c +++ b/widgets/misc/e-canvas.c @@ -399,7 +399,7 @@ pick_current_item (GnomeCanvas *canvas, GdkEvent *event) /* find the closest item */ - if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE) + if (canvas->root->object.flags & GNOME_CANVAS_ITEM_VISIBLE) gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy, &canvas->new_current_item); else @@ -593,11 +593,7 @@ e_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event) canvas = GNOME_CANVAS (widget); ecanvas = E_CANVAS (widget); - /* XXX Can't access flags directly anymore, but is it really needed? - * If so, could we call gtk_widget_send_focus_change() instead? */ -#if 0 GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); -#endif gtk_im_context_focus_in (ecanvas->im_context); @@ -620,11 +616,7 @@ e_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) canvas = GNOME_CANVAS (widget); ecanvas = E_CANVAS (widget); - /* XXX Can't access flags directly anymore, but is it really needed? - * If so, could we call gtk_widget_send_focus_change() instead? */ -#if 0 GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); -#endif gtk_im_context_focus_out (ecanvas->im_context); @@ -708,12 +700,12 @@ e_canvas_item_invoke_reflow (GnomeCanvasItem *item, gint flags) group = GNOME_CANVAS_GROUP (item); for (list = group->item_list; list; list = list->next) { child = GNOME_CANVAS_ITEM (list->data); - if (child->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) + if (child->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) e_canvas_item_invoke_reflow (child, flags); } } - if (item->flags & E_CANVAS_ITEM_NEEDS_REFLOW) { + if (item->object.flags & E_CANVAS_ITEM_NEEDS_REFLOW) { ECanvasItemReflowFunc func; func = (ECanvasItemReflowFunc) g_object_get_data (G_OBJECT (item), @@ -722,14 +714,14 @@ e_canvas_item_invoke_reflow (GnomeCanvasItem *item, gint flags) func (item, flags); } - item->flags &= ~E_CANVAS_ITEM_NEEDS_REFLOW; - item->flags &= ~E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; + item->object.flags &= ~E_CANVAS_ITEM_NEEDS_REFLOW; + item->object.flags &= ~E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; } static void do_reflow (ECanvas *canvas) { - if (GNOME_CANVAS(canvas)->root->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) + if (GNOME_CANVAS(canvas)->root->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) e_canvas_item_invoke_reflow (GNOME_CANVAS(canvas)->root, 0); } @@ -769,10 +761,10 @@ add_idle (ECanvas *canvas) static void e_canvas_item_descendent_needs_reflow (GnomeCanvasItem *item) { - if (item->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) + if (item->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) return; - item->flags |= E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; + item->object.flags |= E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; if (item->parent) e_canvas_item_descendent_needs_reflow(item->parent); } @@ -780,8 +772,8 @@ e_canvas_item_descendent_needs_reflow (GnomeCanvasItem *item) void e_canvas_item_request_reflow (GnomeCanvasItem *item) { - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { - item->flags |= E_CANVAS_ITEM_NEEDS_REFLOW; + if (item->object.flags & GNOME_CANVAS_ITEM_REALIZED) { + item->object.flags |= E_CANVAS_ITEM_NEEDS_REFLOW; e_canvas_item_descendent_needs_reflow(item); add_idle(E_CANVAS(item->canvas)); } diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c index 0af5dc8b98..cf8aae1aff 100644 --- a/widgets/table/e-table-group-container.c +++ b/widgets/table/e-table-group-container.c @@ -1040,7 +1040,7 @@ etgc_reflow (GnomeCanvasItem *item, gint flags) if (frozen) return; - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { + if (GTK_OBJECT_FLAGS(etgc)& GNOME_CANVAS_ITEM_REALIZED) { gdouble running_height = 0; gdouble running_width = 0; gdouble old_height; diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index 2d88258be9..381f0cd24c 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -343,15 +343,12 @@ eti_free_save_state (ETableItem *eti) static void eti_realize_cell_views ( ETableItem *eti) { - GnomeCanvasItem *item; gint i; - item = GNOME_CANVAS_ITEM (eti); - if (eti->cell_views_realized) return; - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) return; for (i = 0; i < eti->n_cells; i++) @@ -676,11 +673,7 @@ height_cache_idle(ETableItem *eti) static void free_height_cache (ETableItem *eti) { - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (eti); - - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { + if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS (eti)) { if (eti->height_cache) g_free (eti->height_cache); eti->height_cache = NULL; @@ -916,12 +909,9 @@ eti_request_region_show (ETableItem *eti, static void eti_show_cursor (ETableItem *eti, gint delay) { - GnomeCanvasItem *item; gint cursor_row; - item = GNOME_CANVAS_ITEM (eti); - - if (!((item->flags & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) + if (!((GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) return; if (eti->frozen_count > 0) { @@ -950,13 +940,17 @@ eti_show_cursor (ETableItem *eti, gint delay) static void eti_check_cursor_bounds (ETableItem *eti) { - GnomeCanvasItem *item; gint x1, y1, x2, y2; gint cursor_row; - item = GNOME_CANVAS_ITEM (eti); + if (!((GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) + return; + + if (eti->frozen_count > 0) { + return; + } - if (!((item->flags & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) + if (!((GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) return; if (eti->frozen_count > 0) { @@ -1095,9 +1089,7 @@ eti_table_model_no_change (ETableModel *table_model, ETableItem *eti) static void eti_table_model_changed (ETableModel *table_model, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1119,9 +1111,7 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti) static void eti_table_model_row_changed (ETableModel *table_model, gint row, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1139,9 +1129,7 @@ eti_table_model_row_changed (ETableModel *table_model, gint row, ETableItem *eti static void eti_table_model_cell_changed (ETableModel *table_model, gint col, gint row, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1159,9 +1147,7 @@ eti_table_model_cell_changed (ETableModel *table_model, gint col, gint row, ETab static void eti_table_model_rows_inserted (ETableModel *table_model, gint row, gint count, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1188,9 +1174,7 @@ eti_table_model_rows_inserted (ETableModel *table_model, gint row, gint count, E static void eti_table_model_rows_deleted (ETableModel *table_model, gint row, gint count, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1444,10 +1428,11 @@ eti_dispose (GObject *object) static void eti_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (object); - ETableItem *eti = E_TABLE_ITEM (object); + ETableItem *eti; gint cursor_col; + eti = E_TABLE_ITEM (object); + switch (prop_id) { case PROP_TABLE_HEADER: eti_remove_header_model (eti); @@ -1496,7 +1481,7 @@ eti_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpe if ((eti->minimum_width == eti->width && g_value_get_double(value) > eti->width) || g_value_get_double(value) < eti->width) { eti->needs_compute_width = 1; - e_canvas_item_request_reflow (item); + e_canvas_item_request_reflow (GNOME_CANVAS_ITEM(eti)); } eti->minimum_width = g_value_get_double (value); break; @@ -1510,18 +1495,18 @@ eti_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpe case PROP_UNIFORM_ROW_HEIGHT: if (eti->uniform_row_height != g_value_get_boolean (value)) { eti->uniform_row_height = g_value_get_boolean (value); - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { + if (GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) { free_height_cache(eti); eti->needs_compute_height = 1; - e_canvas_item_request_reflow (item); + e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); eti->needs_redraw = 1; - gnome_canvas_item_request_update (item); + gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti)); } } break; } eti->needs_redraw = 1; - gnome_canvas_item_request_update (item); + gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(eti)); } static void @@ -2780,9 +2765,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) static void eti_style_set (ETableItem *eti, GtkStyle *previous_style) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) return; if (eti->cell_views_realized) { @@ -3091,10 +3074,9 @@ e_table_item_get_focused_column (ETableItem *eti) static void eti_cursor_change (ESelectionModel *selection, gint row, gint col, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); gint view_row; - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) return; view_row = model_to_view_row(eti, row); @@ -3130,11 +3112,10 @@ eti_cursor_change (ESelectionModel *selection, gint row, gint col, ETableItem *e static void eti_cursor_activated (ESelectionModel *selection, gint row, gint col, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); gint view_row; gint view_col; - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) return; view_row = model_to_view_row(eti, row); @@ -3162,9 +3143,7 @@ eti_cursor_activated (ESelectionModel *selection, gint row, gint col, ETableItem static void eti_selection_change (ESelectionModel *selection, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) return; eti->needs_redraw = TRUE; @@ -3174,9 +3153,7 @@ eti_selection_change (ESelectionModel *selection, ETableItem *eti) static void eti_selection_row_change (ESelectionModel *selection, gint row, ETableItem *eti) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); - - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) return; if (!eti->needs_redraw) { diff --git a/widgets/text/e-reflow.c b/widgets/text/e-reflow.c index b35856808c..4e3f36fd19 100644 --- a/widgets/text/e-reflow.c +++ b/widgets/text/e-reflow.c @@ -730,14 +730,14 @@ e_reflow_set_property (GObject *object, guint prop_id, const GValue *value, GPar break; case PROP_MINIMUM_WIDTH: reflow->minimum_width = g_value_get_double (value); - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) + if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(object)) set_empty(reflow); e_canvas_item_request_reflow(item); break; case PROP_EMPTY_MESSAGE: g_free(reflow->empty_message); reflow->empty_message = g_strdup(g_value_get_string (value)); - if (item->flags & GNOME_CANVAS_ITEM_REALIZED) + if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(object)) set_empty(reflow); break; case PROP_MODEL: @@ -1382,7 +1382,7 @@ e_reflow_reflow( GnomeCanvasItem *item, gint flags ) gint next_column; gint i; - if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS (reflow) & GNOME_CANVAS_ITEM_REALIZED)) return; if (reflow->need_reflow_columns) { -- cgit