aboutsummaryrefslogtreecommitdiffstats
path: root/libgnomecanvas
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-06-15 09:38:53 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-06-15 09:38:53 +0800
commita55021bcef7eb082b48e56aac361bd35a3a77b64 (patch)
tree9bcf1c1bbf522c87beac5d199b258f8aa24c7d7e /libgnomecanvas
parentead63f16b2269325c1e4080b3dce8818bbafe189 (diff)
downloadgsoc2013-evolution-a55021bcef7eb082b48e56aac361bd35a3a77b64.tar
gsoc2013-evolution-a55021bcef7eb082b48e56aac361bd35a3a77b64.tar.gz
gsoc2013-evolution-a55021bcef7eb082b48e56aac361bd35a3a77b64.tar.bz2
gsoc2013-evolution-a55021bcef7eb082b48e56aac361bd35a3a77b64.tar.lz
gsoc2013-evolution-a55021bcef7eb082b48e56aac361bd35a3a77b64.tar.xz
gsoc2013-evolution-a55021bcef7eb082b48e56aac361bd35a3a77b64.tar.zst
gsoc2013-evolution-a55021bcef7eb082b48e56aac361bd35a3a77b64.zip
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.
Diffstat (limited to 'libgnomecanvas')
-rw-r--r--libgnomecanvas/gailcanvas.c10
-rw-r--r--libgnomecanvas/gailcanvasitem.c8
-rw-r--r--libgnomecanvas/gnome-canvas-line.c6
-rw-r--r--libgnomecanvas/gnome-canvas-rich-text.c29
-rw-r--r--libgnomecanvas/gnome-canvas-shape.c17
-rw-r--r--libgnomecanvas/gnome-canvas-text.c17
-rw-r--r--libgnomecanvas/gnome-canvas.c451
-rw-r--r--libgnomecanvas/gnome-canvas.h26
8 files changed, 174 insertions, 390 deletions
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 <e-util/gtk-compat.h>
-
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 <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)
@@ -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]);
+ &GTK_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 {