diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-01-14 01:50:49 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-06-15 00:55:49 +0800 |
commit | fd8b55edaa88906b588aa07d9eadcacd34a7a774 (patch) | |
tree | 14fe95f503fefe738465ff4a734671afec0efb57 | |
parent | e8a1662875e3e957d96d4f60cb8b5664ee4f74b3 (diff) | |
download | gsoc2013-evolution-fd8b55edaa88906b588aa07d9eadcacd34a7a774.tar gsoc2013-evolution-fd8b55edaa88906b588aa07d9eadcacd34a7a774.tar.gz gsoc2013-evolution-fd8b55edaa88906b588aa07d9eadcacd34a7a774.tar.bz2 gsoc2013-evolution-fd8b55edaa88906b588aa07d9eadcacd34a7a774.tar.lz gsoc2013-evolution-fd8b55edaa88906b588aa07d9eadcacd34a7a774.tar.xz gsoc2013-evolution-fd8b55edaa88906b588aa07d9eadcacd34a7a774.tar.zst gsoc2013-evolution-fd8b55edaa88906b588aa07d9eadcacd34a7a774.zip |
Fix all remaining GTK3 issues.
Work around the issue of GnomeCanvasItem amending its own flags to
GtkObject::flags (which is sealed) by giving it its own flags field.
This breaks libgnomecanvas ABI and API, but I see no other way.
-rw-r--r-- | addressbook/gui/widgets/e-minicard-label.c | 4 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 14 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 30 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 10 | ||||
-rw-r--r-- | calendar/gui/ea-week-view.c | 2 | ||||
-rw-r--r-- | e-util/gtk-compat.h | 1 | ||||
-rw-r--r-- | libgnomecanvas/gailcanvas.c | 10 | ||||
-rw-r--r-- | libgnomecanvas/gailcanvasitem.c | 8 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-line.c | 6 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-rich-text.c | 29 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-shape.c | 17 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-text.c | 17 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas.c | 451 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas.h | 26 | ||||
-rw-r--r-- | widgets/misc/e-canvas-background.c | 2 | ||||
-rw-r--r-- | widgets/misc/e-canvas-vbox.c | 6 | ||||
-rw-r--r-- | widgets/misc/e-canvas.c | 28 | ||||
-rw-r--r-- | widgets/table/e-table-group-container.c | 2 | ||||
-rw-r--r-- | widgets/table/e-table-item.c | 79 | ||||
-rw-r--r-- | widgets/text/e-reflow.c | 6 |
20 files changed, 508 insertions, 240 deletions
diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c index 0eb166bcf3..5c1eba1f43 100644 --- a/addressbook/gui/widgets/e-minicard-label.c +++ b/addressbook/gui/widgets/e-minicard-label.c @@ -414,7 +414,9 @@ e_minicard_label_resize_children(EMinicardLabel *e_minicard_label) static void set_colors (EMinicardLabel *label) { - if ((GTK_OBJECT_FLAGS (label) & GNOME_CANVAS_ITEM_REALIZED)) { + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (label); + + if ((item->flags & 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 213d600746..92a415b88f 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 (GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED) + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) e_canvas_item_request_reflow(item); } break; @@ -467,7 +467,9 @@ e_minicard_finalize (GObject *object) static void e_minicard_style_set (EMinicard *minicard, GtkStyle *previous_style) { - if ((GTK_OBJECT_FLAGS( minicard ) & GNOME_CANVAS_ITEM_REALIZED)) + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (minicard); + + if ((item->flags & GNOME_CANVAS_ITEM_REALIZED)) set_selected (minicard, minicard->selected); } @@ -910,9 +912,12 @@ 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 (!(GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED)) + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) return; + if (e_minicard->contact) { EContactField field; GList *list; @@ -1012,7 +1017,8 @@ static void e_minicard_reflow(GnomeCanvasItem *item, gint flags) { EMinicard *e_minicard = E_MINICARD(item); - if (GTK_OBJECT_FLAGS (e_minicard) & GNOME_CANVAS_ITEM_REALIZED) { + + if (item->flags & 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 010f5bdb32..de4b9b3b68 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -1931,7 +1931,11 @@ 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); @@ -1950,7 +1954,11 @@ 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); @@ -7100,10 +7108,8 @@ 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->object.flags - & GNOME_CANVAS_ITEM_VISIBLE) { - e_day_view_update_main_canvas_drag (day_view, row, - day); + } else if (day_view->drag_item->flags & GNOME_CANVAS_ITEM_VISIBLE) { + e_day_view_update_main_canvas_drag (day_view, row, day); } } @@ -7511,8 +7517,7 @@ 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->object.flags - & GNOME_CANVAS_ITEM_VISIBLE)) + && (day_view->drag_long_event_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) return; day_view->drag_last_day = day; @@ -7539,7 +7544,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->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_long_event_rect_item->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); } @@ -7547,8 +7552,7 @@ 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->object.flags - & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_long_event_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { const gchar *summary; if (event && is_comp_data_valid (event)) { @@ -7629,7 +7633,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->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) + && (day_view->drag_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) return; day_view->drag_last_day = day; @@ -7700,12 +7704,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->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_bar_item->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->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_rect_item->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); } @@ -7713,7 +7717,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->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { + if (!(day_view->drag_item->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 accafd9ac2..db6d861c28 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -1363,7 +1363,11 @@ 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); @@ -1381,7 +1385,11 @@ 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); @@ -4676,7 +4684,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]->object.flags & GNOME_CANVAS_ITEM_VISIBLE; + return week_view->jump_buttons[day]->flags & GNOME_CANVAS_ITEM_VISIBLE; return FALSE; } diff --git a/calendar/gui/ea-week-view.c b/calendar/gui/ea-week-view.c index fcbae83cb7..19028cf189 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]->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (week_view->jump_buttons[i]->flags & GNOME_CANVAS_ITEM_VISIBLE) ++count; } diff --git a/e-util/gtk-compat.h b/e-util/gtk-compat.h index 2b96d9c4b2..6b93eed320 100644 --- a/e-util/gtk-compat.h +++ b/e-util/gtk-compat.h @@ -14,6 +14,7 @@ #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 4ec0b67de3..02abd10deb 100644 --- a/libgnomecanvas/gailcanvas.c +++ b/libgnomecanvas/gailcanvas.c @@ -29,6 +29,8 @@ #include "gailcanvasitemfactory.h" #include "gailcanvaswidgetfactory.h" +#include <e-util/gtk-compat.h> + static void gail_canvas_class_init (GailCanvasClass *klass); static void gail_canvas_real_initialize (AtkObject *obj, gpointer data); @@ -180,13 +182,13 @@ gail_canvas_real_initialize (AtkObject *obj, canvas = GNOME_CANVAS (data); - adj = canvas->layout.hadjustment; + adj = gtk_layout_get_hadjustment (GTK_LAYOUT (canvas)); g_signal_connect (adj, "value_changed", G_CALLBACK (adjustment_changed), canvas); - adj = canvas->layout.vadjustment; + adj = gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)); g_signal_connect (adj, "value_changed", G_CALLBACK (adjustment_changed), @@ -206,7 +208,7 @@ gail_canvas_get_n_children (AtkObject* obj) g_return_val_if_fail (GAIL_IS_CANVAS (obj), 0); accessible = GTK_ACCESSIBLE (obj); - widget = accessible->widget; + widget = gtk_accessible_get_widget (accessible); if (widget == NULL) /* State is defunct */ return 0; @@ -235,7 +237,7 @@ gail_canvas_ref_child (AtkObject *obj, g_return_val_if_fail (GAIL_IS_CANVAS (obj), NULL); accessible = GTK_ACCESSIBLE (obj); - widget = accessible->widget; + widget = gtk_accessible_get_widget (accessible); if (widget == NULL) /* State is defunct */ return NULL; diff --git a/libgnomecanvas/gailcanvasitem.c b/libgnomecanvas/gailcanvasitem.c index f059e1909c..5ae7c8bee3 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->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (item->flags & GNOME_CANVAS_ITEM_VISIBLE) { atk_state_set_add_state (state_set, ATK_STATE_VISIBLE); if (is_item_on_screen (item)) @@ -482,14 +482,16 @@ is_item_in_window (GnomeCanvasItem *item, gint height) { GtkWidget *widget; + GdkWindow *window; gboolean retval; widget = GTK_WIDGET (item->canvas); - if (widget->window) + window = gtk_widget_get_window (widget); + if (window) { int window_width, window_height; - gdk_window_get_geometry (widget->window, NULL, NULL, + gdk_window_get_geometry (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 48cafb71c7..fa7c74ccc1 100644 --- a/libgnomecanvas/gnome-canvas-line.c +++ b/libgnomecanvas/gnome-canvas-line.c @@ -1096,14 +1096,18 @@ 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); - line->gc = gdk_gc_new (item->canvas->layout.bin_window); + layout = GTK_LAYOUT (item->canvas); + bin_window = gtk_layout_get_bin_window (layout); + line->gc = gdk_gc_new (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 2a50f2ed4d..db0e52fde1 100644 --- a/libgnomecanvas/gnome-canvas-rich-text.c +++ b/libgnomecanvas/gnome-canvas-rich-text.c @@ -1522,8 +1522,14 @@ gnome_canvas_rich_text_event(GnomeCanvasItem *item, GdkEvent *event) return gnome_canvas_rich_text_button_release_event( item, (GdkEventButton *) event); case GDK_FOCUS_CHANGE: - if (((GdkEventFocus *) event)->window != - item->canvas->layout.bin_window) + { + GtkLayout *layout; + GdkWindow *bin_window; + + layout = GTK_LAYOUT (item->canvas); + bin_window = gtk_layout_get_bin_window (layout); + + if (((GdkEventFocus *) event)->window != bin_window) return FALSE; if (((GdkEventFocus *) event)->in) @@ -1532,6 +1538,7 @@ gnome_canvas_rich_text_event(GnomeCanvasItem *item, GdkEvent *event) else return gnome_canvas_rich_text_focus_out_event( item, (GdkEventFocus *) event); + } default: return FALSE; } @@ -1705,8 +1712,13 @@ 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", @@ -1919,7 +1931,7 @@ gnome_canvas_rich_text_ensure_layout(GnomeCanvasRichText *text) style = gtk_text_attributes_new(); gnome_canvas_rich_text_set_attributes_from_style( - text, style, canvas->style); + text, style, gtk_widget_get_style (canvas)); style->pixels_above_lines = text->_priv->pixels_above_lines; style->pixels_below_lines = text->_priv->pixels_below_lines; @@ -2120,6 +2132,8 @@ 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; @@ -2145,13 +2159,16 @@ 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, - GTK_WIDGET(item->canvas), + widget, drawable, - GTK_WIDGET (item->canvas)->style->text_gc[GTK_STATE_NORMAL], + 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 79d8124525..b951cbc014 100644 --- a/libgnomecanvas/gnome-canvas-shape.c +++ b/libgnomecanvas/gnome-canvas-shape.c @@ -648,12 +648,18 @@ gnome_canvas_shape_realize (GnomeCanvasItem *item) (* parent_class->realize) (item); if (!item->canvas->aa) { + GtkLayout *layout; + GdkWindow *bin_window; + gcbp_ensure_gdk (shape); - g_assert(item->canvas->layout.bin_window != NULL); + layout = GTK_LAYOUT (item->canvas); + bin_window = gtk_layout_get_bin_window (layout); + + g_assert (bin_window != NULL); - 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); + shape->priv->gdk->fill_gc = gdk_gc_new (bin_window); + shape->priv->gdk->outline_gc = gdk_gc_new (bin_window); } } @@ -1428,10 +1434,11 @@ gcbp_ensure_mask (GnomeCanvasShape * shape, gint width, gint height) if ((width > ctx->width) || (height > ctx->height)) { /* Ctx is too small */ - + GtkWidget *widget; GdkWindow * window; - window = ((GtkWidget *) (((GnomeCanvasItem *) shape)->canvas))->window; + widget = GTK_WIDGET (GNOME_CANVAS_ITEM (shape)->canvas); + window = gtk_widget_get_window (widget); 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 81cc357e41..c7e58aef0d 100644 --- a/libgnomecanvas/gnome-canvas-text.c +++ b/libgnomecanvas/gnome-canvas-text.c @@ -1307,9 +1307,13 @@ gnome_canvas_text_get_property (GObject *object, static void gnome_canvas_text_apply_font_desc (GnomeCanvasText *text) { - PangoFontDescription *font_desc = - pango_font_description_copy ( - GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas)->style->font_desc); + 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); if (text->font_desc) pango_font_description_merge (font_desc, text->font_desc, TRUE); @@ -1423,6 +1427,8 @@ 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); @@ -1430,7 +1436,10 @@ gnome_canvas_text_realize (GnomeCanvasItem *item) if (parent_class->realize) (* parent_class->realize) (item); - text->gc = gdk_gc_new (item->canvas->layout.bin_window); + layout = GTK_LAYOUT (item->canvas); + bin_window = gtk_layout_get_bin_window (layout); + + text->gc = gdk_gc_new (bin_window); } /* Unrealize handler for the text item */ diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c index 5345a59200..3241283719 100644 --- a/libgnomecanvas/gnome-canvas.c +++ b/libgnomecanvas/gnome-canvas.c @@ -91,6 +91,7 @@ #include "gnome-canvas-marshal.h" #include "gnome-canvas-marshal.c" +#include <e-util/gtk-compat.h> /* We must run our idle update handler *before* GDK wants to redraw. */ #define CANVAS_IDLE_PRIORITY (GDK_PRIORITY_REDRAW - 5) @@ -168,7 +169,7 @@ gnome_canvas_item_get_type (void) static void gnome_canvas_item_init (GnomeCanvasItem *item) { - item->object.flags |= GNOME_CANVAS_ITEM_VISIBLE; + item->flags |= GNOME_CANVAS_ITEM_VISIBLE; } /** @@ -300,7 +301,7 @@ gnome_canvas_item_construct (GnomeCanvasItem *item, GnomeCanvasGroup *parent, static void redraw_if_visible (GnomeCanvasItem *item) { - if (item->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (item->flags & GNOME_CANVAS_ITEM_VISIBLE) gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2 + 1, item->y2 + 1); } @@ -339,10 +340,10 @@ gnome_canvas_item_dispose (GObject *object) /* Normal destroy stuff */ - if (item->object.flags & GNOME_CANVAS_ITEM_MAPPED) + if (item->flags & GNOME_CANVAS_ITEM_MAPPED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->unmap) (item); - if (item->object.flags & GNOME_CANVAS_ITEM_REALIZED) + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->unrealize) (item); if (item->parent) @@ -361,7 +362,7 @@ gnome_canvas_item_dispose (GObject *object) static void gnome_canvas_item_realize (GnomeCanvasItem *item) { - GTK_OBJECT_SET_FLAGS (item, GNOME_CANVAS_ITEM_REALIZED); + item->flags |= GNOME_CANVAS_ITEM_REALIZED; gnome_canvas_item_request_update (item); } @@ -370,31 +371,31 @@ gnome_canvas_item_realize (GnomeCanvasItem *item) static void gnome_canvas_item_unrealize (GnomeCanvasItem *item) { - GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_REALIZED); + item->flags &= ~GNOME_CANVAS_ITEM_REALIZED; } /* Map handler for canvas items */ static void gnome_canvas_item_map (GnomeCanvasItem *item) { - GTK_OBJECT_SET_FLAGS (item, GNOME_CANVAS_ITEM_MAPPED); + item->flags |= GNOME_CANVAS_ITEM_MAPPED; } /* Unmap handler for canvas items */ static void gnome_canvas_item_unmap (GnomeCanvasItem *item) { - GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_MAPPED); + item->flags &= ~GNOME_CANVAS_ITEM_MAPPED; } /* Update handler for canvas items */ static void gnome_canvas_item_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) { - 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); + 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; } #define noHACKISH_AFFINE @@ -423,13 +424,13 @@ gnome_canvas_item_invoke_update (GnomeCanvasItem *item, double *p2cpx, ArtSVP *c #endif child_flags = flags; - if (!(item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) + if (!(item->flags & GNOME_CANVAS_ITEM_VISIBLE)) child_flags &= ~GNOME_CANVAS_UPDATE_IS_VISIBLE; /* Calculate actual item transformation matrix */ if (item->xform) { - if (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { /* Item has full affine */ art_affine_multiply (i2cpx, item->xform, p2cpx); } else { @@ -455,16 +456,16 @@ gnome_canvas_item_invoke_update (GnomeCanvasItem *item, double *p2cpx, ArtSVP *c child_flags &= ~GNOME_CANVAS_UPDATE_REQUESTED; - if (item->object.flags & GNOME_CANVAS_ITEM_NEED_UPDATE) + if (item->flags & GNOME_CANVAS_ITEM_NEED_UPDATE) child_flags |= GNOME_CANVAS_UPDATE_REQUESTED; - if (item->object.flags & GNOME_CANVAS_ITEM_NEED_AFFINE) + if (item->flags & GNOME_CANVAS_ITEM_NEED_AFFINE) child_flags |= GNOME_CANVAS_UPDATE_AFFINE; - if (item->object.flags & GNOME_CANVAS_ITEM_NEED_CLIP) + if (item->flags & GNOME_CANVAS_ITEM_NEED_CLIP) child_flags |= GNOME_CANVAS_UPDATE_CLIP; - if (item->object.flags & GNOME_CANVAS_ITEM_NEED_VIS) + if (item->flags & GNOME_CANVAS_ITEM_NEED_VIS) child_flags |= GNOME_CANVAS_UPDATE_VISIBILITY; if (child_flags & GCI_UPDATE_MASK) { @@ -486,7 +487,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->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { gdouble p2i[6], t; /* Item has full affine */ art_affine_invert (p2i, item->xform); @@ -589,7 +590,7 @@ gnome_canvas_item_affine_relative (GnomeCanvasItem *item, const double affine[6] /* Calculate actual item transformation matrix */ if (item->xform) { - if (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { /* Item has full affine */ art_affine_multiply (i2p, affine, item->xform); } else { @@ -632,14 +633,14 @@ gnome_canvas_item_affine_absolute (GnomeCanvasItem *item, const double i2p[6]) } if (i2p) { - if (item->xform && !(item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL)) { + if (item->xform && !(item->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->object.flags |= GNOME_CANVAS_ITEM_AFFINE_FULL; + item->flags |= GNOME_CANVAS_ITEM_AFFINE_FULL; } else { if (item->xform) { g_free (item->xform); @@ -647,9 +648,9 @@ gnome_canvas_item_affine_absolute (GnomeCanvasItem *item, const double i2p[6]) } } - if (!(item->object.flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { + if (!(item->flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { /* Request update */ - item->object.flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; + item->flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; gnome_canvas_item_request_update (item); } @@ -877,8 +878,8 @@ gnome_canvas_item_show (GnomeCanvasItem *item) { g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - if (!(item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - item->object.flags |= GNOME_CANVAS_ITEM_VISIBLE; + if (!(item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { + item->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; } @@ -897,8 +898,8 @@ gnome_canvas_item_hide (GnomeCanvasItem *item) { g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - if (item->object.flags & GNOME_CANVAS_ITEM_VISIBLE) { - item->object.flags &= ~GNOME_CANVAS_ITEM_VISIBLE; + if (item->flags & GNOME_CANVAS_ITEM_VISIBLE) { + item->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; } @@ -926,6 +927,8 @@ 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); @@ -934,10 +937,13 @@ gnome_canvas_item_grab (GnomeCanvasItem *item, guint event_mask, GdkCursor *curs if (item->canvas->grabbed_item) return GDK_GRAB_ALREADY_GRABBED; - if (!(item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) + if (!(item->flags & GNOME_CANVAS_ITEM_VISIBLE)) return GDK_GRAB_NOT_VIEWABLE; - retval = gdk_pointer_grab (item->canvas->layout.bin_window, + layout = GTK_LAYOUT (item->canvas); + bin_window = gtk_layout_get_bin_window (layout); + + retval = gdk_pointer_grab (bin_window, FALSE, event_mask, NULL, @@ -995,7 +1001,7 @@ gnome_canvas_item_i2w_affine (GnomeCanvasItem *item, double affine[6]) while (item) { if (item->xform != NULL) { - if (item->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { art_affine_multiply (affine, affine, item->xform); } else { affine[4] += item->xform[0]; @@ -1153,8 +1159,14 @@ 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 = GTK_LAYOUT (item->canvas)->bin_window; + ev.focus_change.window = bin_window; ev.focus_change.send_event = FALSE; ev.focus_change.in = FALSE; @@ -1165,8 +1177,14 @@ 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 = GTK_LAYOUT (item->canvas)->bin_window; + ev.focus_change.window = bin_window; ev.focus_change.send_event = FALSE; ev.focus_change.in = TRUE; @@ -1206,7 +1224,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->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL)) { + if (item->xform && (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL)) { p1.x = p2.x = tx1; p1.y = p4.y = ty1; p3.x = p4.x = tx2; @@ -1286,10 +1304,10 @@ gnome_canvas_item_get_bounds (GnomeCanvasItem *item, double *x1, double *y1, dou void gnome_canvas_item_request_update (GnomeCanvasItem *item) { - if (item->object.flags & GNOME_CANVAS_ITEM_NEED_UPDATE) + if (item->flags & GNOME_CANVAS_ITEM_NEED_UPDATE) return; - item->object.flags |= GNOME_CANVAS_ITEM_NEED_UPDATE; + item->flags |= GNOME_CANVAS_ITEM_NEED_UPDATE; if (item->parent != NULL) { /* Recurse up the tree */ @@ -1437,12 +1455,12 @@ static double * gnome_canvas_ensure_translate (GnomeCanvasItem *item) { if (item->xform == NULL) { - GTK_OBJECT_UNSET_FLAGS (item, GNOME_CANVAS_ITEM_AFFINE_FULL); + item->flags &= ~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->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { + } else if (item->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { return item->xform + 4; } else { return item->xform; @@ -1493,7 +1511,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 (GTK_OBJECT (gobject)->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) + else if (GNOME_CANVAS_ITEM (gobject)->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) g_value_set_double (value, item->xform[4]); else g_value_set_double (value, item->xform[0]); @@ -1502,7 +1520,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 (GTK_OBJECT (gobject)->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) + else if (GNOME_CANVAS_ITEM (gobject)->flags & GNOME_CANVAS_ITEM_AFFINE_FULL) g_value_set_double (value, item->xform[5]); else g_value_set_double (value, item->xform[1]); @@ -1581,7 +1599,7 @@ gnome_canvas_group_realize (GnomeCanvasItem *item) for (list = group->item_list; list; list = list->next) { i = list->data; - if (!(i->object.flags & GNOME_CANVAS_ITEM_REALIZED)) + if (!(i->flags & GNOME_CANVAS_ITEM_REALIZED)) (* GNOME_CANVAS_ITEM_GET_CLASS (i)->realize) (i); } @@ -1601,7 +1619,7 @@ gnome_canvas_group_unrealize (GnomeCanvasItem *item) for (list = group->item_list; list; list = list->next) { i = list->data; - if (i->object.flags & GNOME_CANVAS_ITEM_REALIZED) + if (i->flags & GNOME_CANVAS_ITEM_REALIZED) (* GNOME_CANVAS_ITEM_GET_CLASS (i)->unrealize) (i); } @@ -1621,7 +1639,7 @@ gnome_canvas_group_map (GnomeCanvasItem *item) for (list = group->item_list; list; list = list->next) { i = list->data; - if (!(i->object.flags & GNOME_CANVAS_ITEM_MAPPED)) + if (!(i->flags & GNOME_CANVAS_ITEM_MAPPED)) (* GNOME_CANVAS_ITEM_GET_CLASS (i)->map) (i); } @@ -1641,7 +1659,7 @@ gnome_canvas_group_unmap (GnomeCanvasItem *item) for (list = group->item_list; list; list = list->next) { i = list->data; - if (i->object.flags & GNOME_CANVAS_ITEM_MAPPED) + if (i->flags & GNOME_CANVAS_ITEM_MAPPED) (* GNOME_CANVAS_ITEM_GET_CLASS (i)->unmap) (i); } @@ -1662,12 +1680,12 @@ gnome_canvas_group_draw (GnomeCanvasItem *item, GdkDrawable *drawable, for (list = group->item_list; list; list = list->next) { child = list->data; - if (((child->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (((child->flags & GNOME_CANVAS_ITEM_VISIBLE) && ((child->x1 < (x + width)) && (child->y1 < (y + height)) && (child->x2 > x) && (child->y2 > y))) - || ((GTK_OBJECT_FLAGS (child) & GNOME_CANVAS_ITEM_ALWAYS_REDRAW) + || ((child->flags & GNOME_CANVAS_ITEM_ALWAYS_REDRAW) && (child->x1 < child->canvas->redraw_x2) && (child->y1 < child->canvas->redraw_y2) && (child->x2 > child->canvas->redraw_x1) @@ -1714,7 +1732,7 @@ gnome_canvas_group_point (GnomeCanvasItem *item, double x, double y, int cx, int point_item = NULL; /* cater for incomplete item implementations */ - if ((child->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if ((child->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; @@ -1755,7 +1773,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->object.flags & GNOME_CANVAS_ITEM_VISIBLE) { + if (child->flags & GNOME_CANVAS_ITEM_VISIBLE) { set = TRUE; gnome_canvas_item_get_bounds (child, &minx, &miny, &maxx, &maxy); break; @@ -1776,7 +1794,7 @@ gnome_canvas_group_bounds (GnomeCanvasItem *item, double *x1, double *y1, double for (; list; list = list->next) { child = list->data; - if (!(child->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) + if (!(child->flags & GNOME_CANVAS_ITEM_VISIBLE)) continue; gnome_canvas_item_get_bounds (child, &tx1, &ty1, &tx2, &ty2); @@ -1813,12 +1831,12 @@ gnome_canvas_group_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf) for (list = group->item_list; list; list = list->next) { child = list->data; - if (((child->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (((child->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))) - || ((GTK_OBJECT_FLAGS (child) & GNOME_CANVAS_ITEM_ALWAYS_REDRAW) + || ((child->flags & GNOME_CANVAS_ITEM_ALWAYS_REDRAW) && (child->x1 < child->canvas->redraw_x2) && (child->y1 < child->canvas->redraw_y2) && (child->x2 > child->canvas->redraw_x1) @@ -1841,10 +1859,10 @@ group_add (GnomeCanvasGroup *group, GnomeCanvasItem *item) } else group->item_list_end = g_list_append (group->item_list_end, item)->next; - if (group->item.object.flags & GNOME_CANVAS_ITEM_REALIZED) + if (group->item.flags & GNOME_CANVAS_ITEM_REALIZED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->realize) (item); - if (group->item.object.flags & GNOME_CANVAS_ITEM_MAPPED) + if (group->item.flags & GNOME_CANVAS_ITEM_MAPPED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->map) (item); g_object_notify (G_OBJECT (item), "parent"); @@ -1861,10 +1879,10 @@ group_remove (GnomeCanvasGroup *group, GnomeCanvasItem *item) for (children = group->item_list; children; children = children->next) if (children->data == item) { - if (item->object.flags & GNOME_CANVAS_ITEM_MAPPED) + if (item->flags & GNOME_CANVAS_ITEM_MAPPED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->unmap) (item); - if (item->object.flags & GNOME_CANVAS_ITEM_REALIZED) + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) (* GNOME_CANVAS_ITEM_GET_CLASS (item)->unrealize) (item); /* Unparent the child */ @@ -2092,7 +2110,13 @@ panic_root_destroyed (GtkObject *object, gpointer data) static void gnome_canvas_init (GnomeCanvas *canvas) { - GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS); + 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); canvas->need_update = FALSE; canvas->need_redraw = FALSE; @@ -2101,8 +2125,8 @@ gnome_canvas_init (GnomeCanvas *canvas) canvas->scroll_x1 = 0.0; canvas->scroll_y1 = 0.0; - canvas->scroll_x2 = canvas->layout.width; - canvas->scroll_y2 = canvas->layout.height; + canvas->scroll_x2 = layout_width; + canvas->scroll_y2 = layout_height; canvas->pixels_per_unit = 1.0; @@ -2283,6 +2307,8 @@ static void gnome_canvas_realize (GtkWidget *widget) { GnomeCanvas *canvas; + GtkLayout *layout; + GdkWindow *bin_window; g_return_if_fail (GNOME_IS_CANVAS (widget)); @@ -2293,8 +2319,11 @@ gnome_canvas_realize (GtkWidget *widget) canvas = GNOME_CANVAS (widget); - gdk_window_set_events (canvas->layout.bin_window, - (gdk_window_get_events (canvas->layout.bin_window) + 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_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -2307,7 +2336,7 @@ gnome_canvas_realize (GtkWidget *widget) /* Create our own temporary pixmap gc and realize all the items */ - canvas->pixmap_gc = gdk_gc_new (canvas->layout.bin_window); + canvas->pixmap_gc = gdk_gc_new (bin_window); (* GNOME_CANVAS_ITEM_GET_CLASS (canvas->root)->realize) (canvas->root); } @@ -2341,14 +2370,27 @@ 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; - canvas_width = GTK_WIDGET (canvas)->allocation.width; - canvas_height = GTK_WIDGET (canvas)->allocation.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; scroll_width = floor ((canvas->scroll_x2 - canvas->scroll_x1) * canvas->pixels_per_unit + 0.5); @@ -2401,41 +2443,31 @@ 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->object.flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { - canvas->root->object.flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; + if (!(canvas->root->flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { + canvas->root->flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; gnome_canvas_request_update (canvas); } gtk_widget_queue_draw (GTK_WIDGET (canvas)); } - if (canvas->layout.hadjustment && ((int) canvas->layout.hadjustment->value) != cx) { - canvas->layout.hadjustment->value = cx; - changed_x = TRUE; - } + if (hadjustment) + gtk_adjustment_set_value (hadjustment, cx); - if (canvas->layout.vadjustment && ((int) canvas->layout.vadjustment->value) != cy) { - canvas->layout.vadjustment->value = cy; - changed_y = TRUE; - } + if (vadjustment) + gtk_adjustment_set_value (vadjustment, cy); - if ((scroll_width != (int) canvas->layout.width) - || (scroll_height != (int) canvas->layout.height)) + if ((scroll_width != (int) layout_width) + || (scroll_height != (int) 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) { - GnomeCanvas *canvas; + GtkLayout *layout; + GtkAdjustment *hadjustment; + GtkAdjustment *vadjustment; g_return_if_fail (GNOME_IS_CANVAS (widget)); g_return_if_fail (allocation != NULL); @@ -2443,22 +2475,27 @@ 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); - canvas = GNOME_CANVAS (widget); + layout = GTK_LAYOUT (widget); + hadjustment = gtk_layout_get_hadjustment (layout); + vadjustment = gtk_layout_get_vadjustment (layout); /* Recenter the view, if appropriate */ - canvas->layout.hadjustment->page_size = allocation->width; - canvas->layout.hadjustment->page_increment = allocation->width / 2; + 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.vadjustment->page_size = allocation->height; - canvas->layout.vadjustment->page_increment = allocation->height / 2; + gtk_adjustment_set_page_size (vadjustment, allocation->height); + gtk_adjustment_set_page_increment (vadjustment, allocation->height / 2); - scroll_to (canvas, - canvas->layout.hadjustment->value, - canvas->layout.vadjustment->value); + scroll_to (GNOME_CANVAS (widget), + gtk_adjustment_get_value (hadjustment), + gtk_adjustment_get_value (vadjustment)); - g_signal_emit_by_name (canvas->layout.hadjustment, "changed"); - g_signal_emit_by_name (canvas->layout.vadjustment, "changed"); + g_object_thaw_notify (G_OBJECT (hadjustment)); + g_object_thaw_notify (G_OBJECT (vadjustment)); } /* Emits an event for an item in the canvas, be it the current item, grabbed @@ -2681,7 +2718,7 @@ pick_current_item (GnomeCanvas *canvas, GdkEvent *event) /* find the closest item */ - if (canvas->root->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE) gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy, &canvas->new_current_item); else @@ -2739,6 +2776,8 @@ static gint gnome_canvas_button (GtkWidget *widget, GdkEventButton *event) { GnomeCanvas *canvas; + GtkLayout *layout; + GdkWindow *bin_window; int mask; int retval; @@ -2749,11 +2788,14 @@ 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 != canvas->layout.bin_window) + if (!canvas->grabbed_item && event->window != bin_window) return retval; switch (event->button) { @@ -2813,13 +2855,18 @@ 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); - if (event->window != canvas->layout.bin_window) + layout = GTK_LAYOUT (widget); + bin_window = gtk_layout_get_bin_window (layout); + + if (event->window != bin_window) return FALSE; canvas->state = event->state; @@ -2863,13 +2910,18 @@ 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); - if (event->window != canvas->layout.bin_window) + layout = GTK_LAYOUT (canvas); + bin_window = gtk_layout_get_bin_window (layout); + + if (event->window != bin_window) return FALSE; canvas->state = event->state; @@ -2882,7 +2934,11 @@ 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); @@ -2898,7 +2954,11 @@ 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); @@ -2914,18 +2974,34 @@ 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); - 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); + 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_width = draw_x2 - draw_x1; draw_height = draw_y2 - draw_y1; @@ -2944,6 +3020,7 @@ 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); @@ -2953,26 +3030,27 @@ 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; - color = &widget->style->bg[GTK_STATE_NORMAL]; + style = gtk_widget_get_style (widget); + color = &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->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (canvas->root->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 (canvas->layout.bin_window, + gdk_draw_rectangle (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 (canvas->layout.bin_window, + gdk_draw_rgb_image_dithalign (bin_window, canvas->pixmap_gc, (draw_x1 + canvas->zoom_xofs), (draw_y1 + canvas->zoom_yofs), @@ -2986,15 +3064,19 @@ 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 (canvas->layout.bin_window, - draw_width, draw_height, - gtk_widget_get_visual (widget)->depth); + pixmap = gdk_pixmap_new (bin_window, + draw_width, draw_height, depth); g_signal_emit (G_OBJECT (canvas), canvas_signals[DRAW_BACKGROUND], 0, pixmap, draw_x1, draw_y1, draw_width, draw_height); - if (canvas->root->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE) (* GNOME_CANVAS_ITEM_GET_CLASS (canvas->root)->draw) ( canvas->root, pixmap, draw_x1, draw_y1, @@ -3002,7 +3084,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 (canvas->layout.bin_window, + gdk_draw_drawable (bin_window, canvas->pixmap_gc, pixmap, 0, 0, @@ -3019,13 +3101,18 @@ 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); - if (!gtk_widget_is_drawable (widget) || (event->window != canvas->layout.bin_window)) + layout = GTK_LAYOUT (canvas); + bin_window = gtk_layout_get_bin_window (layout); + + if (!gtk_widget_is_drawable (widget) || (event->window != bin_window)) return FALSE; #ifdef VERBOSE @@ -3068,10 +3155,29 @@ 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 */ @@ -3085,10 +3191,10 @@ paint (GnomeCanvas *canvas) /* Turn those rectangles into a GdkRegion for exposing */ - 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; + 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; region = gdk_region_new (); @@ -3105,7 +3211,7 @@ paint (GnomeCanvas *canvas) gdkrect.height = clipped.y1 - clipped.y0; region = gdk_region_rectangle (&gdkrect); - gdk_window_invalidate_region (canvas->layout.bin_window, region, FALSE); + gdk_window_invalidate_region (bin_window, region, FALSE); gdk_region_destroy (region); } } @@ -3122,9 +3228,13 @@ 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, - >K_WIDGET (canvas)->style->bg[GTK_STATE_NORMAL]); + &style->bg[GTK_STATE_NORMAL]); gdk_draw_rectangle (drawable, canvas->pixmap_gc, TRUE, @@ -3243,19 +3353,31 @@ 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, - GTK_LAYOUT (canvas)->hadjustment->value + canvas->zoom_xofs, - GTK_LAYOUT (canvas)->vadjustment->value + canvas->zoom_yofs, + hadjustment_value + canvas->zoom_xofs, + vadjustment_value + canvas->zoom_yofs, /*canvas->zoom_xofs, canvas->zoom_yofs,*/ &wxofs, &wyofs); @@ -3320,13 +3442,24 @@ 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, - canvas->layout.hadjustment->value, - canvas->layout.vadjustment->value); + scroll_to (canvas, hadjustment_value, vadjustment_value); } /** @@ -3365,6 +3498,9 @@ 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; @@ -3372,20 +3508,30 @@ 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) { - anchor_x = GTK_WIDGET (canvas)->allocation.width / 2; - anchor_y = GTK_WIDGET (canvas)->allocation.height / 2; + GtkAllocation allocation; + + gtk_widget_get_allocation (GTK_WIDGET (canvas), &allocation); + + anchor_x = allocation.width / 2; + anchor_y = allocation.height / 2; } else anchor_x = anchor_y = 0; /* Find the coordinates of the anchor point in units. */ - if(canvas->layout.hadjustment) { - ax = (canvas->layout.hadjustment->value + anchor_x) / canvas->pixels_per_unit + canvas->scroll_x1 + canvas->zoom_xofs; + if(hadjustment) { + gdouble value = gtk_adjustment_get_value (hadjustment); + ax = (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(canvas->layout.hadjustment) { - ay = (canvas->layout.vadjustment->value + anchor_y) / canvas->pixels_per_unit + canvas->scroll_y1 + canvas->zoom_yofs; + if(vadjustment) { + gdouble value = gtk_adjustment_get_value (vadjustment); + ay = (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; } @@ -3398,8 +3544,8 @@ gnome_canvas_set_pixels_per_unit (GnomeCanvas *canvas, double n) scroll_to (canvas, x1, y1); - if (!(canvas->root->object.flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { - canvas->root->object.flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; + if (!(canvas->root->flags & GNOME_CANVAS_ITEM_NEED_AFFINE)) { + canvas->root->flags |= GNOME_CANVAS_ITEM_NEED_AFFINE; gnome_canvas_request_update (canvas); } @@ -3437,13 +3583,22 @@ 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)); - if (cx) - *cx = canvas->layout.hadjustment->value; + layout = GTK_LAYOUT (canvas); - if (cy) - *cy = canvas->layout.vadjustment->value; + if (cx) { + adjustment = gtk_layout_get_hadjustment (layout); + *cx = (gint) gtk_adjustment_get_value (adjustment); + } + + if (cy) { + adjustment = gtk_layout_get_vadjustment (layout); + *cy = (gint) gtk_adjustment_get_value (adjustment); + } } /** @@ -3640,10 +3795,26 @@ uta_union_clip (ArtUta *uta1, ArtUta *uta2, ArtIRect *clip) static inline void get_visible_region (GnomeCanvas *canvas, ArtIRect *visible) { - 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; + 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; } /** diff --git a/libgnomecanvas/gnome-canvas.h b/libgnomecanvas/gnome-canvas.h index a9c70be4f5..559bd9c8fb 100644 --- a/libgnomecanvas/gnome-canvas.h +++ b/libgnomecanvas/gnome-canvas.h @@ -90,17 +90,17 @@ typedef struct _GnomeCanvasGroupClass GnomeCanvasGroupClass; */ /* Object flags for items */ -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 -}; +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; /* Update flags for items */ enum { @@ -161,6 +161,10 @@ 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 28875725b3..a44a05407a 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 (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(item)) { + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { 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 63b23efdf6..5fc939939b 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 (GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED) { + if (GNOME_CANVAS_ITEM (e_canvas_vbox)->flags & 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 (GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED) { + if (GNOME_CANVAS_ITEM (e_canvas_vbox)->flags & 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 (GTK_OBJECT_FLAGS( e_canvas_vbox ) & GNOME_CANVAS_ITEM_REALIZED) { + if (item->flags & 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 593c9c4530..3b8d5ed57f 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->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE) gnome_canvas_item_invoke_point (canvas->root, x, y, cx, cy, &canvas->new_current_item); else @@ -593,7 +593,11 @@ 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); @@ -616,7 +620,11 @@ 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); @@ -700,12 +708,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->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) + if (child->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) e_canvas_item_invoke_reflow (child, flags); } } - if (item->object.flags & E_CANVAS_ITEM_NEEDS_REFLOW) { + if (item->flags & E_CANVAS_ITEM_NEEDS_REFLOW) { ECanvasItemReflowFunc func; func = (ECanvasItemReflowFunc) g_object_get_data (G_OBJECT (item), @@ -714,14 +722,14 @@ e_canvas_item_invoke_reflow (GnomeCanvasItem *item, gint flags) func (item, flags); } - item->object.flags &= ~E_CANVAS_ITEM_NEEDS_REFLOW; - item->object.flags &= ~E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; + item->flags &= ~E_CANVAS_ITEM_NEEDS_REFLOW; + item->flags &= ~E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; } static void do_reflow (ECanvas *canvas) { - if (GNOME_CANVAS(canvas)->root->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) + if (GNOME_CANVAS(canvas)->root->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) e_canvas_item_invoke_reflow (GNOME_CANVAS(canvas)->root, 0); } @@ -761,10 +769,10 @@ add_idle (ECanvas *canvas) static void e_canvas_item_descendent_needs_reflow (GnomeCanvasItem *item) { - if (item->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) + if (item->flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW) return; - item->object.flags |= E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; + item->flags |= E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW; if (item->parent) e_canvas_item_descendent_needs_reflow(item->parent); } @@ -772,8 +780,8 @@ e_canvas_item_descendent_needs_reflow (GnomeCanvasItem *item) void e_canvas_item_request_reflow (GnomeCanvasItem *item) { - if (item->object.flags & GNOME_CANVAS_ITEM_REALIZED) { - item->object.flags |= E_CANVAS_ITEM_NEEDS_REFLOW; + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { + item->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 cf8aae1aff..0af5dc8b98 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 (GTK_OBJECT_FLAGS(etgc)& GNOME_CANVAS_ITEM_REALIZED) { + if (item->flags & 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 381f0cd24c..2d88258be9 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -343,12 +343,15 @@ 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 (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) return; for (i = 0; i < eti->n_cells; i++) @@ -673,7 +676,11 @@ height_cache_idle(ETableItem *eti) static void free_height_cache (ETableItem *eti) { - if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS (eti)) { + GnomeCanvasItem *item; + + item = GNOME_CANVAS_ITEM (eti); + + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { if (eti->height_cache) g_free (eti->height_cache); eti->height_cache = NULL; @@ -909,9 +916,12 @@ eti_request_region_show (ETableItem *eti, static void eti_show_cursor (ETableItem *eti, gint delay) { + GnomeCanvasItem *item; gint cursor_row; - if (!((GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) + item = GNOME_CANVAS_ITEM (eti); + + if (!((item->flags & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) return; if (eti->frozen_count > 0) { @@ -940,17 +950,13 @@ 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; - if (!((GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) - return; - - if (eti->frozen_count > 0) { - return; - } + item = GNOME_CANVAS_ITEM (eti); - if (!((GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) + if (!((item->flags & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) return; if (eti->frozen_count > 0) { @@ -1089,7 +1095,9 @@ eti_table_model_no_change (ETableModel *table_model, ETableItem *eti) static void eti_table_model_changed (ETableModel *table_model, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1111,7 +1119,9 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti) static void eti_table_model_row_changed (ETableModel *table_model, gint row, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1129,7 +1139,9 @@ 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) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1147,7 +1159,9 @@ 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) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1174,7 +1188,9 @@ 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) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) { eti_unfreeze (eti); return; } @@ -1428,11 +1444,10 @@ eti_dispose (GObject *object) static void eti_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - ETableItem *eti; + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (object); + ETableItem *eti = E_TABLE_ITEM (object); gint cursor_col; - eti = E_TABLE_ITEM (object); - switch (prop_id) { case PROP_TABLE_HEADER: eti_remove_header_model (eti); @@ -1481,7 +1496,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 (GNOME_CANVAS_ITEM(eti)); + e_canvas_item_request_reflow (item); } eti->minimum_width = g_value_get_double (value); break; @@ -1495,18 +1510,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 (GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) { + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) { free_height_cache(eti); eti->needs_compute_height = 1; - e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); + e_canvas_item_request_reflow (item); eti->needs_redraw = 1; - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti)); + gnome_canvas_item_request_update (item); } } break; } eti->needs_redraw = 1; - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(eti)); + gnome_canvas_item_request_update (item); } static void @@ -2765,7 +2780,9 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) static void eti_style_set (ETableItem *eti, GtkStyle *previous_style) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) return; if (eti->cell_views_realized) { @@ -3074,9 +3091,10 @@ 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 (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) return; view_row = model_to_view_row(eti, row); @@ -3112,10 +3130,11 @@ 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 (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) return; view_row = model_to_view_row(eti, row); @@ -3143,7 +3162,9 @@ eti_cursor_activated (ESelectionModel *selection, gint row, gint col, ETableItem static void eti_selection_change (ESelectionModel *selection, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) return; eti->needs_redraw = TRUE; @@ -3153,7 +3174,9 @@ eti_selection_change (ESelectionModel *selection, ETableItem *eti) static void eti_selection_row_change (ESelectionModel *selection, gint row, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); + + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) return; if (!eti->needs_redraw) { diff --git a/widgets/text/e-reflow.c b/widgets/text/e-reflow.c index 4e3f36fd19..b35856808c 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 (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(object)) + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) 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 (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(object)) + if (item->flags & GNOME_CANVAS_ITEM_REALIZED) set_empty(reflow); break; case PROP_MODEL: @@ -1382,7 +1382,7 @@ e_reflow_reflow( GnomeCanvasItem *item, gint flags ) gint next_column; gint i; - if (!(GTK_OBJECT_FLAGS (reflow) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(item->flags & GNOME_CANVAS_ITEM_REALIZED)) return; if (reflow->need_reflow_columns) { |