[cairo-commit] goocanvas/src Makefile.am, 1.7, 1.8 goocanvasatk.c, NONE, 1.1 goocanvasatk.h, NONE, 1.1 goocanvasgroupview.c, 1.10, 1.11 goocanvasgroupview.h, 1.2, 1.3 goocanvasitemview.c, 1.6, 1.7 goocanvasitemview.h, 1.6, 1.7 goocanvasitemviewsimple.c, 1.2, 1.3 goocanvasitemviewsimple.h, 1.1, 1.2 goocanvasview.c, 1.13, 1.14 goocanvasview.h, 1.6, 1.7

Damon Chaplin commit at pdx.freedesktop.org
Tue Apr 18 08:43:09 PDT 2006


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv25504/src

Modified Files:
	Makefile.am goocanvasgroupview.c goocanvasgroupview.h 
	goocanvasitemview.c goocanvasitemview.h 
	goocanvasitemviewsimple.c goocanvasitemviewsimple.h 
	goocanvasview.c goocanvasview.h 
Added Files:
	goocanvasatk.c goocanvasatk.h 
Log Message:
2006-04-18  Damon Chaplin  <damon at gnome.org>

	* src/goocanvasview.c (goo_canvas_view_get_model): new function.
	(goo_canvas_view_adjustment_value_changed): emit "visible_data_changed"
	on accessible object.
	(goo_canvas_view_init): initialize default bounds, and create default
	adjustments.

	* src/goocanvasitemview.[hc]: added new is_visible() method, and
	"can-focus" property, and convenience find_child() function.

	* src/goocanvasitemviewsimple.c: implemented "can-focus" property
	and "is_visible" method.

	* src/goocanvasgroupview.c: implemented "can-focus" property and
	"is_visible" method, and used same flags field as
	GooCanvasItemViewSimple.

	* src/goocanvasatk.[c]: new files to support accessibility. Most of
	the code has been copied from foocanvas & libgnomecanvas, with slight
	changes to handler our model/view split.

	* src/goocanvasitemviewsimple.c (goo_canvas_item_view_simple_finalize):
	chain up to parent's finalize method.



Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/goocanvas/src/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Makefile.am	16 Apr 2006 13:20:05 -0000	1.7
+++ Makefile.am	18 Apr 2006 15:43:07 -0000	1.8
@@ -42,6 +42,8 @@
 
 libgoocanvas_la_SOURCES =			\
 	goocanvasmarshal.list			\
+	goocanvasatk.h				\
+	goocanvasatk.c				\
 	goocanvasellipse.c			\
 	goocanvasellipseview.c			\
 	goocanvasgroup.c			\

--- NEW FILE: goocanvasatk.c ---
/*
 * GooCanvas. Copyright (C) 2005-6 Damon Chaplin.
 * Released under the GNU LGPL license. See COPYING for details.
 *
 * goocanvasatk.c - the accessibility code.
 */
#include <config.h>
#include <math.h>
#include <gtk/gtk.h>
#include "goocanvas.h"


/*
 * GooCanvasItemViewAccessible.
 */

typedef AtkGObjectAccessible      GooCanvasItemViewAccessible;
typedef AtkGObjectAccessibleClass GooCanvasItemViewAccessibleClass;

#define GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), goo_canvas_item_view_accessible_get_type ()))

static void goo_canvas_item_view_accessible_component_interface_init (AtkComponentIface *iface);
static gint goo_canvas_item_view_accessible_get_index_in_parent (AtkObject *accessible);

G_DEFINE_TYPE_WITH_CODE (GooCanvasItemViewAccessible,
			 goo_canvas_item_view_accessible,
			 ATK_TYPE_GOBJECT_ACCESSIBLE,
			 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, goo_canvas_item_view_accessible_component_interface_init));


/* Returns the extents of the item view, in pixels relative to the main
   canvas window. */
static void
goo_canvas_item_view_accessible_get_item_extents (GooCanvasItemView *view,
						  GdkRectangle      *rect)
{
  GooCanvasView *canvas_view;
  GooCanvasBounds *bounds;

  canvas_view = goo_canvas_item_view_get_canvas_view (view);
  if (!canvas_view)
    {
      rect->x = rect->y = rect->width = rect->height = 0;
      return;
    }

  /* Get the bounds in device units. */
  bounds = goo_canvas_item_view_get_bounds  (view);

  /* Convert to pixels within the entire canvas. */
  goo_canvas_view_convert_to_pixels (canvas_view, &bounds->x1, &bounds->y1);
  goo_canvas_view_convert_to_pixels (canvas_view, &bounds->x2, &bounds->y2);

  /* Convert to pixels within the visible window. */
  bounds->x1 -= canvas_view->hadjustment->value;
  bounds->y1 -= canvas_view->vadjustment->value;
  bounds->x2 -= canvas_view->hadjustment->value;
  bounds->y2 -= canvas_view->vadjustment->value;

  /* Round up or down to integers. */
  rect->x = floor (bounds->x1);
  rect->y = floor (bounds->y1);
  rect->width = ceil (bounds->x1) - rect->x;
  rect->height = ceil (bounds->y1) - rect->y;
}


/* This returns TRUE if the given rectangle intersects the canvas window.
   The rectangle should be in pixels relative to the main canvas window. */
static gboolean
goo_canvas_item_view_accessible_is_item_in_window (GooCanvasItemView *view,
						   GdkRectangle      *rect)
{
  GtkWidget *widget;

  widget = (GtkWidget*) goo_canvas_item_view_get_canvas_view (view);
  if (!widget)
    return FALSE;

  if (rect->x + rect->width < 0 || rect->x > widget->allocation.width
      || rect->y + rect->height < 0 || rect->y > widget->allocation.height)
    return FALSE;

  return TRUE;
}


static gboolean
goo_canvas_item_view_accessible_is_item_on_screen (GooCanvasItemView *view)
{
  GdkRectangle rect;

  goo_canvas_item_view_accessible_get_item_extents (view, &rect);
  return goo_canvas_item_view_accessible_is_item_in_window (view, &rect);
}



static void
goo_canvas_item_view_accessible_get_extents (AtkComponent *component,
					     gint         *x,
					     gint         *y,
					     gint         *width,
					     gint         *height,
					     AtkCoordType coord_type)
{
  GooCanvasItemView *item_view;
  GooCanvasView *canvas_view;
  GObject *object;
  gint window_x, window_y;
  gint toplevel_x, toplevel_y;
  GdkRectangle rect;
  GdkWindow *window;

  g_return_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (component));

  *x = *y = G_MININT;

  object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (component));
  if (!object)
    return;

  item_view = GOO_CANVAS_ITEM_VIEW (object);

  canvas_view = goo_canvas_item_view_get_canvas_view (item_view);
  if (!canvas_view || !GTK_WIDGET (canvas_view)->window)
    return;

  goo_canvas_item_view_accessible_get_item_extents (item_view, &rect);
  *width = rect.width;
  *height = rect.height;

  if (!goo_canvas_item_view_accessible_is_item_in_window (item_view, &rect))
    return;

  gdk_window_get_origin (GTK_WIDGET (canvas_view)->window,
			 &window_x, &window_y);
  *x = rect.x + window_x;
  *y = rect.y + window_y;

  if (coord_type == ATK_XY_WINDOW)
    {
      window = gdk_window_get_toplevel (GTK_WIDGET (canvas_view)->window);
      gdk_window_get_origin (window, &toplevel_x, &toplevel_y);
      *x -= toplevel_x;
      *y -= toplevel_y;
    }
}


static gint
goo_canvas_item_view_accessible_get_mdi_zorder (AtkComponent *component)
{
  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (component), -1);

  return goo_canvas_item_view_accessible_get_index_in_parent (ATK_OBJECT (component));
}


static guint
goo_canvas_item_view_accessible_add_focus_handler (AtkComponent    *component,
						   AtkFocusHandler  handler)
{
  GSignalMatchType match_type;
  GClosure *closure;
  guint signal_id;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (component), 0);

  match_type = G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC;
  signal_id = g_signal_lookup ("focus-event", ATK_TYPE_OBJECT);

  /* If the handler has already been added just return. */
  if (g_signal_handler_find (component, match_type, signal_id, 0, NULL,
			     (gpointer) handler, NULL))
    return 0;

  closure = g_cclosure_new (G_CALLBACK (handler), NULL, (GClosureNotify) NULL);
  return g_signal_connect_closure_by_id (component, signal_id, 0, closure,
					 FALSE);
}


static void
goo_canvas_item_view_accessible_remove_focus_handler (AtkComponent *component,
						      guint         handler_id)
{
  g_return_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (component));

  g_signal_handler_disconnect (ATK_OBJECT (component), handler_id);
}


static gboolean
goo_canvas_item_view_accessible_grab_focus (AtkComponent    *component)
{
  GooCanvasItemView *item_view;
  GooCanvasView *canvas_view;
  GtkWidget *toplevel;
  GObject *object;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (component), FALSE);

  object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (component));
  if (!object)
    return FALSE;

  item_view = GOO_CANVAS_ITEM_VIEW (object);

  canvas_view = goo_canvas_item_view_get_canvas_view (item_view);
  if (!canvas_view)
    return FALSE;

  goo_canvas_view_grab_focus (canvas_view, item_view);

  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (canvas_view));
  if (GTK_WIDGET_TOPLEVEL (toplevel))
    gtk_window_present (GTK_WINDOW (toplevel));

  return TRUE;
}


static void
goo_canvas_item_view_accessible_component_interface_init (AtkComponentIface *iface)
{
  iface->get_extents          = goo_canvas_item_view_accessible_get_extents;
  iface->get_mdi_zorder       = goo_canvas_item_view_accessible_get_mdi_zorder;
  iface->add_focus_handler    = goo_canvas_item_view_accessible_add_focus_handler;
  iface->remove_focus_handler = goo_canvas_item_view_accessible_remove_focus_handler;
  iface->grab_focus           = goo_canvas_item_view_accessible_grab_focus;
}


static void
goo_canvas_item_view_accessible_initialize (AtkObject *object,
					    gpointer   data)
{
  if (ATK_OBJECT_CLASS (goo_canvas_item_view_accessible_parent_class)->initialize)
    ATK_OBJECT_CLASS (goo_canvas_item_view_accessible_parent_class)->initialize (object, data);

  /* FIXME: Maybe this should be ATK_LAYER_CANVAS. */
  g_object_set_data (G_OBJECT (object), "atk-component-layer",
		     GINT_TO_POINTER (ATK_LAYER_MDI));
}


static AtkObject*
goo_canvas_item_view_accessible_get_parent (AtkObject *accessible)
{
  GooCanvasItemView *item_view, *parent_view;
  GooCanvasView *canvas_view;
  GObject *object;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (accessible), NULL);

  if (accessible->accessible_parent)
    return accessible->accessible_parent;

  object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
  if (object == NULL)
    return NULL;

  item_view = GOO_CANVAS_ITEM_VIEW (object);
  parent_view = goo_canvas_item_view_get_parent_view (item_view);

  if (parent_view)
    return atk_gobject_accessible_for_object (G_OBJECT (parent_view));

  canvas_view = goo_canvas_item_view_get_canvas_view (item_view);
  if (canvas_view)
    return gtk_widget_get_accessible (GTK_WIDGET (canvas_view));

  return NULL;
}


static gint
goo_canvas_item_view_accessible_get_index_in_parent (AtkObject *accessible)
{
  GooCanvasItemView *item_view, *parent_view;
  GooCanvasView *canvas_view;
  GObject *object;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (accessible), -1);

  if (accessible->accessible_parent)
    {
      gint n_children, i;
      gboolean found = FALSE;

      n_children = atk_object_get_n_accessible_children (accessible->accessible_parent);
      for (i = 0; i < n_children; i++)
        {
          AtkObject *child;

          child = atk_object_ref_accessible_child (accessible->accessible_parent, i);
          if (child == accessible)
            found = TRUE;

          g_object_unref (child);
          if (found)
            return i;
        }
      return -1;
    }

  object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
  if (object == NULL)
    return -1;

  item_view = GOO_CANVAS_ITEM_VIEW (object);
  parent_view = goo_canvas_item_view_get_parent_view (item_view);

  if (parent_view)
    return goo_canvas_item_view_find_child (parent_view, item_view);

  canvas_view = goo_canvas_item_view_get_canvas_view (item_view);
  if (canvas_view)
    return 0;

  return -1;
}


static gint
goo_canvas_item_view_accessible_get_n_children (AtkObject *accessible)
{
  GooCanvasItemView *item_view;
  GObject *object;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (accessible), -1);

  object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
  if (object == NULL)
    return -1;

  item_view = GOO_CANVAS_ITEM_VIEW (object);

  return goo_canvas_item_view_get_n_children (item_view);
}


static AtkObject*
goo_canvas_item_view_accessible_ref_child (AtkObject *accessible,
					   gint       child_num)
{
  GooCanvasItemView *item_view, *child_view;
  GObject *object;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (accessible), NULL);

  object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
  if (object == NULL)
    return NULL;

  item_view = GOO_CANVAS_ITEM_VIEW (object);

  child_view = goo_canvas_item_view_get_child (item_view, child_num);
  if (child_view)
    return g_object_ref (child_view);

  return NULL;
}


static AtkStateSet*
goo_canvas_item_view_accessible_ref_state_set (AtkObject *accessible)
{
  GooCanvasItemView *item_view;
  GooCanvasView *canvas_view;
  AtkStateSet *state_set;
  GObject *object;
  gboolean can_focus = FALSE;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW_ACCESSIBLE (accessible), NULL);

  state_set = ATK_OBJECT_CLASS (goo_canvas_item_view_accessible_parent_class)->ref_state_set (accessible);

  object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
  if (!object)
    {
      atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
      return state_set;
    }

  item_view = GOO_CANVAS_ITEM_VIEW (object);

  canvas_view = goo_canvas_item_view_get_canvas_view (item_view);
  if (!canvas_view)
    return state_set;

  if (goo_canvas_item_view_is_visible (item_view, canvas_view->scale))
    {
      atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);

      if (goo_canvas_item_view_accessible_is_item_on_screen (item_view))
	atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
    }

  g_object_get (item_view, "can-focus", &can_focus, NULL);

  if (GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (canvas_view)) && can_focus)
    {
      atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);

      if (GTK_WIDGET_HAS_FOCUS (canvas_view)
	  && canvas_view->focused_item_view == item_view)
	atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
    }

  return state_set;
}


static void
goo_canvas_item_view_accessible_class_init (GooCanvasItemViewAccessibleClass *klass)
{
  AtkObjectClass *aklass = (AtkObjectClass*) klass;

  aklass->initialize          = goo_canvas_item_view_accessible_initialize;
  aklass->get_parent          = goo_canvas_item_view_accessible_get_parent;
  aklass->get_index_in_parent = goo_canvas_item_view_accessible_get_index_in_parent;
  aklass->get_n_children      = goo_canvas_item_view_accessible_get_n_children;
  aklass->ref_child           = goo_canvas_item_view_accessible_ref_child;
  aklass->ref_state_set       = goo_canvas_item_view_accessible_ref_state_set;
}


static void
goo_canvas_item_view_accessible_init (GooCanvasItemViewAccessible *accessible)
{
}


static AtkObject *
goo_canvas_item_view_accessible_new (GObject *object)
{
  AtkObject *accessible;

  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_VIEW (object), NULL);

  accessible = g_object_new (goo_canvas_item_view_accessible_get_type (),
			     NULL);
  atk_object_initialize (accessible, object);

  return accessible;
}


/*
 * GooCanvasItemViewAccessibleFactory.
 */

typedef AtkObjectFactory      GooCanvasItemViewAccessibleFactory;
typedef AtkObjectFactoryClass GooCanvasItemViewAccessibleFactoryClass;

G_DEFINE_TYPE (GooCanvasItemViewAccessibleFactory,
	       goo_canvas_item_view_accessible_factory,
	       ATK_TYPE_OBJECT_FACTORY);

static void
goo_canvas_item_view_accessible_factory_class_init (GooCanvasItemViewAccessibleFactoryClass *klass)
{
  klass->create_accessible   = goo_canvas_item_view_accessible_new;
  klass->get_accessible_type = goo_canvas_item_view_accessible_get_type;
}

static void
goo_canvas_item_view_accessible_factory_init (GooCanvasItemViewAccessibleFactory *factory)
{
}



/*
 * GooCanvasViewAccessible.
 */

static gpointer accessible_parent_class = NULL;


static void
goo_canvas_view_accessible_initialize (AtkObject *object, 
				       gpointer   data)
{
  if (ATK_OBJECT_CLASS (accessible_parent_class)->initialize) 
    ATK_OBJECT_CLASS (accessible_parent_class)->initialize (object, data);

  /* FIXME: Maybe this should be ATK_ROLE_CANVAS. */
  object->role = ATK_ROLE_LAYERED_PANE;
}


static gint
goo_canvas_view_accessible_get_n_children (AtkObject *object)
{
  GtkAccessible *accessible;
  GtkWidget *widget;
  GooCanvasView *canvas_view;
  GooCanvasModel *model;
  GooCanvasItem *root;

  accessible = GTK_ACCESSIBLE (object);
  widget = accessible->widget;

  /* Check if widget still exists. */
  if (widget == NULL)
    return 0;

  g_return_val_if_fail (GOO_IS_CANVAS_VIEW (widget), 0);

  canvas_view = GOO_CANVAS_VIEW (widget);

  model = goo_canvas_view_get_model (canvas_view);
  if (!model)
    return 0;

  root = goo_canvas_model_get_root_item (model);
  if (!root)
    return 0;

  return 1;
}

static AtkObject*
goo_canvas_view_accessible_ref_child (AtkObject *object,
				      gint       child_num)
{
  GtkAccessible *accessible;
  GtkWidget *widget;
  GooCanvasView *canvas_view;
  GooCanvasModel *model;
  GooCanvasItem *root;
  AtkObject *atk_object;

  /* Canvas only has one child, so return NULL if index is non zero */
  if (child_num != 0)
    return NULL;

  accessible = GTK_ACCESSIBLE (object);
  widget = accessible->widget;

  /* Check if widget still exists. */
  if (widget == NULL)
    return NULL;

  canvas_view = GOO_CANVAS_VIEW (widget);
  model = goo_canvas_view_get_model (canvas_view);
  if (!model)
    return NULL;

  root = goo_canvas_model_get_root_item (model);
  if (!root)
    return NULL;

  atk_object = atk_gobject_accessible_for_object (G_OBJECT (root));
  g_object_ref (atk_object);

  return atk_object;
}



static void
goo_canvas_view_accessible_class_init (AtkObjectClass *klass)
{
  accessible_parent_class = g_type_class_peek_parent (klass);

  klass->initialize     = goo_canvas_view_accessible_initialize;
  klass->get_n_children = goo_canvas_view_accessible_get_n_children;
  klass->ref_child      = goo_canvas_view_accessible_ref_child;
}


static GType
goo_canvas_view_accessible_get_type (void)
{
  static GType g_define_type_id = 0;

  if (G_UNLIKELY (g_define_type_id == 0))
    {
      AtkObjectFactory *factory;
      GType parent_atk_type;
      GTypeQuery query;
      GTypeInfo tinfo = { 0 };

      /* Gail doesn't declare its classes publicly, so we have to do a query
	 to find the size of the class and instances. */
      factory = atk_registry_get_factory (atk_get_default_registry (),
					  GTK_TYPE_WIDGET);
      if (!factory)
	return G_TYPE_INVALID;

      parent_atk_type = atk_object_factory_get_accessible_type (factory);
      if (!parent_atk_type)
	return G_TYPE_INVALID;

      g_type_query (parent_atk_type, &query);
      tinfo.class_init = (GClassInitFunc) goo_canvas_view_accessible_class_init;
      tinfo.class_size = query.class_size;
      tinfo.instance_size = query.instance_size;
      g_define_type_id = g_type_register_static (parent_atk_type,
						 "GooCanvasViewAccessible",
						 &tinfo, 0);
    }

  return g_define_type_id;
}


static AtkObject *
goo_canvas_view_accessible_new (GObject *object)
{
  AtkObject *accessible;

  g_return_val_if_fail (GOO_IS_CANVAS_VIEW (object), NULL);

  accessible = g_object_new (goo_canvas_view_accessible_get_type (), NULL);
  atk_object_initialize (accessible, object);

  return accessible;
}


/*
 * GooCanvasViewAccessibleFactory.
 */

typedef AtkObjectFactory      GooCanvasViewAccessibleFactory;
typedef AtkObjectFactoryClass GooCanvasViewAccessibleFactoryClass;

G_DEFINE_TYPE (GooCanvasViewAccessibleFactory,
	       goo_canvas_view_accessible_factory,
	       ATK_TYPE_OBJECT_FACTORY);

static void
goo_canvas_view_accessible_factory_class_init (GooCanvasViewAccessibleFactoryClass *klass)
{
  klass->create_accessible   = goo_canvas_view_accessible_new;
  klass->get_accessible_type = goo_canvas_view_accessible_get_type;
}

static void
goo_canvas_view_accessible_factory_init (GooCanvasViewAccessibleFactory *factory)
{
}

--- NEW FILE: goocanvasatk.h ---
/*
 * GooCanvas. Copyright (C) 2005 Damon Chaplin.
 * Released under the GNU LGPL license. See COPYING for details.
 *
 * goocanvasatk.h - the accessibility code.
 */
#ifndef __GOO_CANVAS_ATK_H__
#define __GOO_CANVAS_ATK_H__

#include <gtk/gtk.h>


G_BEGIN_DECLS

GType    goo_canvas_view_accessible_factory_get_type  (void) G_GNUC_CONST;
GType    goo_canvas_item_view_accessible_factory_get_type  (void) G_GNUC_CONST;


G_END_DECLS

#endif /* __GOO_CANVAS_ATK_H__ */

Index: goocanvasgroupview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroupview.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- goocanvasgroupview.c	16 Apr 2006 22:29:44 -0000	1.10
+++ goocanvasgroupview.c	18 Apr 2006 15:43:07 -0000	1.11
@@ -31,10 +31,26 @@
 #include "goocanvasgroup.h"
 #include "goocanvasview.h"
 #include "goocanvasutils.h"
+#include "goocanvasatk.h"
+
+
+enum {
+  PROP_0,
+
+  PROP_CAN_FOCUS
+};
 
 
 static void canvas_item_view_interface_init (GooCanvasItemViewIface *iface);
 static void goo_canvas_group_view_finalize  (GObject              *object);
+static void goo_canvas_group_view_get_property (GObject              *object,
+						guint                 prop_id,
+						GValue               *value,
+						GParamSpec           *pspec);
+static void goo_canvas_group_view_set_property (GObject              *object,
+						guint                 prop_id,
+						const GValue         *value,
+						GParamSpec           *pspec);
 static void add_child_views_recursively     (GooCanvasGroupView   *group_view);
 static void connect_group_signals           (GooCanvasGroupView   *group_view);
 static void on_group_changed                (GooCanvasGroup       *group,
@@ -53,6 +69,16 @@
   GObjectClass *gobject_class = (GObjectClass*) klass;
 
   gobject_class->finalize = goo_canvas_group_view_finalize;
+
+  gobject_class->get_property = goo_canvas_group_view_get_property;
+  gobject_class->set_property = goo_canvas_group_view_set_property;
+
+  atk_registry_set_factory_type (atk_get_default_registry (),
+				 GOO_TYPE_CANVAS_GROUP_VIEW,
+				 goo_canvas_item_view_accessible_factory_get_type ());
+
+  g_object_class_override_property (gobject_class, PROP_CAN_FOCUS,
+				    "can-focus");
 }
 
 
@@ -60,6 +86,9 @@
 goo_canvas_group_view_init (GooCanvasGroupView *group_view)
 {
   group_view->item_views = g_ptr_array_sized_new (8);
+
+  group_view->flags = GOO_CANVAS_ITEM_VIEW_NEED_UPDATE
+    | GOO_CANVAS_ITEM_VIEW_NEED_ENTIRE_SUBTREE_UPDATE;
 }
 
 
@@ -91,9 +120,6 @@
   add_child_views_recursively (group_view);
   connect_group_signals (group_view);
 
-  group_view->need_update = TRUE;
-  group_view->need_entire_subtree_update = TRUE;
-
   g_signal_connect (group, "changed", G_CALLBACK (on_group_changed),
 		    group_view);
 
@@ -126,6 +152,50 @@
 
 
 static void
+goo_canvas_group_view_get_property (GObject              *object,
+				    guint                 prop_id,
+				    GValue               *value,
+				    GParamSpec           *pspec)
+{
+  GooCanvasGroupView *group_view = (GooCanvasGroupView*) object;
+
+  switch (prop_id)
+    {
+    case PROP_CAN_FOCUS:
+      g_value_set_boolean (value,
+			   group_view->flags & GOO_CANVAS_ITEM_VIEW_CAN_FOCUS);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+goo_canvas_group_view_set_property (GObject              *object,
+				    guint                 prop_id,
+				    const GValue         *value,
+				    GParamSpec           *pspec)
+{
+  GooCanvasGroupView *group_view = (GooCanvasGroupView*) object;
+
+  switch (prop_id)
+    {
+    case PROP_CAN_FOCUS:
+      if (g_value_get_boolean (value))
+	group_view->flags |= GOO_CANVAS_ITEM_VIEW_CAN_FOCUS;
+      else
+	group_view->flags &= ~GOO_CANVAS_ITEM_VIEW_CAN_FOCUS;
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
 on_child_item_added (GooCanvasGroup     *group,
 		     gint                position,
 		     GooCanvasGroupView *group_view)
@@ -248,9 +318,10 @@
 {
   GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
 
-  if (!group_view->need_update)
+  if (!(group_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE))
     {
-      group_view->need_update = TRUE;
+      group_view->flags |= GOO_CANVAS_ITEM_VIEW_NEED_UPDATE;
+
       if (group_view->parent_view)
 	goo_canvas_item_view_request_update (group_view->parent_view);
       else
@@ -268,13 +339,13 @@
   GooCanvasBounds *bounds = &group_view->bounds, *child_bounds;
   gint i;
 
-  if (entire_tree || group_view->need_update)
+  if (entire_tree || (group_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE))
     {
-      if (group_view->need_entire_subtree_update)
+      if (group_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_ENTIRE_SUBTREE_UPDATE)
 	entire_tree = TRUE;
 
-      group_view->need_update = FALSE;
-      group_view->need_entire_subtree_update = FALSE;
+      group_view->flags &= ~GOO_CANVAS_ITEM_VIEW_NEED_UPDATE;
+      group_view->flags &= ~GOO_CANVAS_ITEM_VIEW_NEED_ENTIRE_SUBTREE_UPDATE;
 
       bounds->x1 = bounds->y1 = bounds->x2 = bounds->y2 = 0.0;
 
@@ -343,7 +414,7 @@
 {
   GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
 
-  if (group_view->need_update)
+  if (group_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE)
     goo_canvas_item_view_ensure_updated (view);
 
   return &group_view->bounds;
@@ -366,7 +437,7 @@
   gboolean visible = parent_visible;
   int i;
 
-  if (group_view->need_update)
+  if (group_view->flags & GOO_CANVAS_ITEM_VIEW_NEED_UPDATE)
     goo_canvas_item_view_ensure_updated (view);
 
   if (group->visibility == GOO_CANVAS_ITEM_INVISIBLE
@@ -409,6 +480,25 @@
 }
 
 
+static gboolean
+goo_canvas_group_view_is_visible  (GooCanvasItemView   *view,
+				   gdouble              scale)
+{
+  GooCanvasGroupView *group_view = (GooCanvasGroupView*) view;
+  GooCanvasGroup *group = group_view->group;
+
+  if (group->visibility == GOO_CANVAS_ITEM_INVISIBLE
+      || (group->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
+	  && scale < group->visibility_threshold))
+    return FALSE;
+
+  if (group_view->parent_view)
+    return goo_canvas_item_view_is_visible (group_view->parent_view, scale);
+
+  return TRUE;
+}
+
+
 static void
 goo_canvas_group_view_paint (GooCanvasItemView *view,
 			     cairo_t           *cr,
@@ -459,6 +549,7 @@
   iface->get_item        = goo_canvas_group_view_get_item;
   iface->get_bounds      = goo_canvas_group_view_get_bounds;
   iface->get_item_at     = goo_canvas_group_view_get_item_at;
+  iface->is_visible      = goo_canvas_group_view_is_visible;
   iface->update          = goo_canvas_group_view_update;
   iface->paint           = goo_canvas_group_view_paint;
 }
@@ -469,6 +560,6 @@
 				 gboolean            recompute_bounds,
 				 GooCanvasGroupView *view)
 {
-  view->need_entire_subtree_update = TRUE;
+  view->flags |= GOO_CANVAS_ITEM_VIEW_NEED_ENTIRE_SUBTREE_UPDATE;
   goo_canvas_group_view_request_update ((GooCanvasItemView*) view);
 }

Index: goocanvasgroupview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroupview.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasgroupview.h	13 Apr 2006 17:07:44 -0000	1.2
+++ goocanvasgroupview.h	18 Apr 2006 15:43:07 -0000	1.3
@@ -8,7 +8,7 @@
 #define __GOO_CANVAS_GROUP_VIEW_H__
 
 #include <gtk/gtk.h>
-#include "goocanvasitemview.h"
+#include "goocanvasitemviewsimple.h"
 #include "goocanvasgroup.h"
 
 G_BEGIN_DECLS
@@ -50,11 +50,8 @@
   /* The bounds of the group. */
   GooCanvasBounds bounds;
 
-  /* This is TRUE if some descendant of this group needs an update. */
-  guint need_update                : 1;
-
-  /* This is TRUE if we need to update all descendants of this group. */
-  guint need_entire_subtree_update : 1;
+  /* A few flags. */
+  GooCanvasItemViewFlags flags;
 };
 
 struct _GooCanvasGroupViewClass

Index: goocanvasitemview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemview.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- goocanvasitemview.c	14 Apr 2006 16:59:04 -0000	1.6
+++ goocanvasitemview.c	18 Apr 2006 15:43:07 -0000	1.7
@@ -14,6 +14,7 @@
  * and contains methods for operating on item views.
  */
 #include <config.h>
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "goocanvasitemview.h"
 #include "goocanvasview.h"
@@ -69,13 +70,13 @@
 
 
 static void
-goo_canvas_item_view_base_init (gpointer g_class)
+goo_canvas_item_view_base_init (gpointer g_iface)
 {
   static gboolean initialized = FALSE;
   
   if (!initialized)
     {
-      GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
+      GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
 
       /* Mouse events. */
 
@@ -275,6 +276,14 @@
 		      GOO_TYPE_CANVAS_ITEM_VIEW,
 		      GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
 
+
+      g_object_interface_install_property (g_iface,
+					   g_param_spec_boolean ("can-focus",
+								 _("Can Focus"),
+								 _("If the item can take the keyboard focus"),
+								 FALSE,
+								 G_PARAM_READWRITE));
+
       initialized = TRUE;
     }
 }
@@ -364,6 +373,34 @@
 
 
 /**
+ * goo_canvas_item_view_find_child:
+ * @view: a #GooCanvasItemView.
+ * @child: a child view.
+ * 
+ * Gets the index of the child item view, counting from 0.
+ * 
+ * Returns: the index of the given child item view.
+ **/
+gint
+goo_canvas_item_view_find_child      (GooCanvasItemView *view,
+				      GooCanvasItemView *child)
+{
+  GooCanvasItemView *item;
+  int n_children, i;
+
+  /* Find the current position of item and above. */
+  n_children = goo_canvas_item_view_get_n_children (view);
+  for (i = 0; i < n_children; i++)
+    {
+      item = goo_canvas_item_view_get_child (view, i);
+      if (child == item)
+	return i;
+    }
+  return -1;
+}
+
+
+/**
  * goo_canvas_item_view_request_update:
  * @view: a #GooCanvasItemView.
  * 
@@ -483,6 +520,28 @@
 
 
 /**
+ * goo_canvas_item_view_is_visible:
+ * @view: a #GooCanvasItemView.
+ * @scale: the scale setting.
+ * 
+ * Checks if the item is visible at the given scale setting.
+ *
+ * This entails checking the item's own visibility setting, as well as those
+ * of its ancestors.
+ * 
+ * Returns: %TRUE if the item is visible.
+ **/
+gboolean
+goo_canvas_item_view_is_visible  (GooCanvasItemView   *view,
+				  gdouble              scale)
+{
+  GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
+
+  return iface->is_visible (view, scale);
+}
+
+
+/**
  * goo_canvas_item_view_ensure_updated:
  * @view: a #GooCanvasItemView.
  * 

Index: goocanvasitemview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemview.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- goocanvasitemview.h	14 Apr 2006 16:59:04 -0000	1.6
+++ goocanvasitemview.h	18 Apr 2006 15:43:07 -0000	1.7
@@ -65,6 +65,8 @@
 					     gboolean             is_pointer_event,
 					     gboolean             parent_visible,
 					     gdouble              scale);
+  gboolean             (* is_visible)	    (GooCanvasItemView   *view,
+					     gdouble              scale);
   GooCanvasBounds*     (* update)           (GooCanvasItemView   *view,
 					     gboolean             entire_tree,
 					     cairo_t             *cr);
@@ -110,6 +112,8 @@
 gint               goo_canvas_item_view_get_n_children  (GooCanvasItemView *view);
 GooCanvasItemView* goo_canvas_item_view_get_child       (GooCanvasItemView *view,
 							 gint               child_num);
+gint               goo_canvas_item_view_find_child      (GooCanvasItemView *view,
+							 GooCanvasItemView *child);
 
 
 /*
@@ -130,6 +134,8 @@
 						     gboolean            is_pointer_event,
 						     gboolean            parent_visible,
 						     gdouble             scale);
+gboolean           goo_canvas_item_view_is_visible  (GooCanvasItemView   *view,
+						     gdouble              scale);
 void               goo_canvas_item_view_request_update (GooCanvasItemView *view);
 void		   goo_canvas_item_view_ensure_updated (GooCanvasItemView *view);
 GooCanvasBounds*   goo_canvas_item_view_update      (GooCanvasItemView  *view,

Index: goocanvasitemviewsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemviewsimple.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- goocanvasitemviewsimple.c	16 Apr 2006 22:29:44 -0000	1.2
+++ goocanvasitemviewsimple.c	18 Apr 2006 15:43:07 -0000	1.3
@@ -22,10 +22,26 @@
 #include <gtk/gtk.h>
 #include "goocanvasitemviewsimple.h"
 #include "goocanvasview.h"
+#include "goocanvasatk.h"
+
+
+enum {
+  PROP_0,
+
+  PROP_CAN_FOCUS
+};
 
 
 static void canvas_item_view_interface_init  (GooCanvasItemViewIface *iface);
 static void goo_canvas_item_view_simple_finalize (GObject *object);
+static void goo_canvas_item_view_simple_get_property (GObject              *object,
+						      guint                 prop_id,
+						      GValue               *value,
+						      GParamSpec           *pspec);
+static void goo_canvas_item_view_simple_set_property (GObject              *object,
+						      guint                 prop_id,
+						      const GValue         *value,
+						      GParamSpec           *pspec);
 
 G_DEFINE_TYPE_WITH_CODE (GooCanvasItemViewSimple, goo_canvas_item_view_simple,
 			 G_TYPE_OBJECT,
@@ -39,6 +55,16 @@
   GObjectClass *gobject_class = (GObjectClass*) klass;
 
   gobject_class->finalize = goo_canvas_item_view_simple_finalize;
+
+  gobject_class->get_property = goo_canvas_item_view_simple_get_property;
+  gobject_class->set_property = goo_canvas_item_view_simple_set_property;
+
+  atk_registry_set_factory_type (atk_get_default_registry (),
+				 GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE,
+				 goo_canvas_item_view_accessible_factory_get_type ());
+
+  g_object_class_override_property (gobject_class, PROP_CAN_FOCUS,
+				    "can-focus");
 }
 
 
@@ -60,6 +86,52 @@
   /* Unref the item. */
   g_object_unref (simple_view->item);
   simple_view->item = NULL;
+
+  G_OBJECT_CLASS (goo_canvas_item_view_simple_parent_class)->finalize (object);
+}
+
+
+static void
+goo_canvas_item_view_simple_get_property (GObject              *object,
+					  guint                 prop_id,
+					  GValue               *value,
+					  GParamSpec           *pspec)
+{
+  GooCanvasItemViewSimple *view = (GooCanvasItemViewSimple*) object;
+
+  switch (prop_id)
+    {
+    case PROP_CAN_FOCUS:
+      g_value_set_boolean (value,
+			   view->flags & GOO_CANVAS_ITEM_VIEW_CAN_FOCUS);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+goo_canvas_item_view_simple_set_property (GObject              *object,
+					  guint                 prop_id,
+					  const GValue         *value,
+					  GParamSpec           *pspec)
+{
+  GooCanvasItemViewSimple *view = (GooCanvasItemViewSimple*) object;
+
+  switch (prop_id)
+    {
+    case PROP_CAN_FOCUS:
+      if (g_value_get_boolean (value))
+	view->flags |= GOO_CANVAS_ITEM_VIEW_CAN_FOCUS;
+      else
+	view->flags &= ~GOO_CANVAS_ITEM_VIEW_CAN_FOCUS;
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
 }
 
 
@@ -152,6 +224,25 @@
 }
 
 
+static gboolean
+goo_canvas_item_view_simple_is_visible  (GooCanvasItemView   *view,
+					 gdouble              scale)
+{
+  GooCanvasItemViewSimple *simple_view = (GooCanvasItemViewSimple*) view;
+  GooCanvasItemSimple *simple = simple_view->item;
+
+  if (simple->visibility == GOO_CANVAS_ITEM_INVISIBLE
+      || (simple->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
+	  && scale < simple->visibility_threshold))
+    return FALSE;
+
+  if (simple_view->parent_view)
+    return goo_canvas_item_view_is_visible (simple_view->parent_view, scale);
+
+  return FALSE;
+}
+
+
 static GooCanvasBounds*
 goo_canvas_item_view_simple_update  (GooCanvasItemView  *view,
 				     gboolean            entire_tree,
@@ -227,6 +318,7 @@
   iface->get_item        = goo_canvas_item_view_simple_get_item;
   iface->get_bounds      = goo_canvas_item_view_simple_get_bounds;
   iface->get_item_at     = goo_canvas_item_view_simple_get_item_at;
+  iface->is_visible      = goo_canvas_item_view_simple_is_visible;
   iface->update          = goo_canvas_item_view_simple_update;
   iface->paint           = goo_canvas_item_view_simple_paint;
 }

Index: goocanvasitemviewsimple.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemviewsimple.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- goocanvasitemviewsimple.h	16 Apr 2006 13:20:05 -0000	1.1
+++ goocanvasitemviewsimple.h	18 Apr 2006 15:43:07 -0000	1.2
@@ -17,7 +17,13 @@
 typedef enum
 {
   /* If the view needs to recompute its bounds and redraw. */
-  GOO_CANVAS_ITEM_VIEW_NEED_UPDATE = 1 << 0
+  GOO_CANVAS_ITEM_VIEW_NEED_UPDATE		  = 1 << 0,
+
+  /* If all descendants need to be updated.. */
+  GOO_CANVAS_ITEM_VIEW_NEED_ENTIRE_SUBTREE_UPDATE = 1 << 1,
+
+  /* If the view can take the keyboard focus. */
+  GOO_CANVAS_ITEM_VIEW_CAN_FOCUS		  = 1 << 2
 } GooCanvasItemViewFlags;
 
 #define GOO_TYPE_CANVAS_ITEM_VIEW_SIMPLE            (goo_canvas_item_view_simple_get_type ())
@@ -49,7 +55,7 @@
   /* The bounds of the item, relative to the entire canvas. */
   GooCanvasBounds bounds;
 
-  /* This is TRUE if we need to recompute our bounds & repaint. */
+  /* A few flags. */
   GooCanvasItemViewFlags flags;
 };
 

Index: goocanvasview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- goocanvasview.c	16 Apr 2006 22:29:44 -0000	1.13
+++ goocanvasview.c	18 Apr 2006 15:43:07 -0000	1.14
@@ -122,6 +122,7 @@
  */
 #include <config.h>
 #include <gtk/gtk.h>
+#include "goocanvasatk.h"
 #include "goocanvasview.h"
 #include "goocanvasitemview.h"
 #include "goocanvasgroupview.h"
@@ -205,6 +206,10 @@
 
   klass->set_scroll_adjustments      = goo_canvas_view_set_adjustments;
 
+  atk_registry_set_factory_type (atk_get_default_registry (),
+				 GOO_TYPE_CANVAS_VIEW,
+				 goo_canvas_view_accessible_factory_get_type ());
+
   /**
    * GooCanvasView::set-scroll-adjustments
    * @hadjustment: the horizontal adjustment.
@@ -257,6 +262,20 @@
   canvas_view->need_update = TRUE;
   canvas_view->crossing_event.type = GDK_LEAVE_NOTIFY;
   canvas_view->anchor = GTK_ANCHOR_NORTH_WEST;
+
+  /* Set the default bounds to a reasonable size. */
+  canvas_view->bounds.x1 = 0.0;
+  canvas_view->bounds.y1 = 0.0;
+  canvas_view->bounds.x2 = 1000.0;
+  canvas_view->bounds.y2 = 1000.0;
+
+  /* Create our own adjustments, in case we aren't inserted into a scrolled
+     window. The accessibility code needs these. */
+  canvas_view->hadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+  canvas_view->vadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+
+  g_object_ref_sink (canvas_view->hadjustment);
+  g_object_ref_sink (canvas_view->vadjustment);
 }
 
 
@@ -295,11 +314,31 @@
   set_item_view_pointer (&view->focused_item_view, NULL);
   set_item_view_pointer (&view->keyboard_grab_item_view, NULL);
 
+  g_object_unref (view->hadjustment);
+  g_object_unref (view->vadjustment);
+
   G_OBJECT_CLASS (goo_canvas_view_parent_class)->finalize (object);
 }
 
 
 /**
+ * goo_canvas_view_get_model:
+ * @view: a #GooCanvasView.
+ * 
+ * Gets the model being displayed in the canvas.
+ * 
+ * Returns: the #GooCanvasModel being displayed.
+ **/
+GooCanvasModel*
+goo_canvas_view_get_model    (GooCanvasView     *view)
+{
+  g_return_val_if_fail (GOO_IS_CANVAS_VIEW (view), NULL);
+
+  return view->model;
+}
+
+
+/**
  * goo_canvas_view_set_model:
  * @view: a #GooCanvasView.
  * @model: a #GooCanvasModel.
@@ -315,6 +354,8 @@
 {
   GooCanvasItem *root_item;
 
+  g_return_if_fail (GOO_IS_CANVAS_VIEW (view));
+
   if (view->model == model)
     return;
 
@@ -686,6 +727,8 @@
 goo_canvas_view_adjustment_value_changed (GtkAdjustment *adjustment,
 					  GooCanvasView *view)
 {
+  AtkObject *accessible;
+
   if (!view->freeze_count && GTK_WIDGET_REALIZED (view))
     {
       gdk_window_move (view->canvas_window,
@@ -696,12 +739,16 @@
 	 updates here for smoother scrolling. */
       if (adjustment)
 	gdk_window_process_updates (view->canvas_window, TRUE);
+
+      /* Notify any accessibility modules that the view has changed. */
+      accessible = gtk_widget_get_accessible (GTK_WIDGET (view));
+      g_signal_emit_by_name (accessible, "visible_data_changed");
     }
 }
 
 
-/* Sets either or both adjustments, or leaves the current adjustment if hadj
-   or vadj is NULL. */
+/* Sets either or both adjustments, If hadj or vadj is NULL a new adjustment
+   is created. */
 static void           
 goo_canvas_view_set_adjustments (GooCanvasView *view,
 				 GtkAdjustment *hadj,
@@ -715,6 +762,7 @@
     g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
   else if (view->hadjustment)
     hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+
   if (vadj)
     g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
   else if (view->vadjustment)

Index: goocanvasview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- goocanvasview.h	14 Apr 2006 18:52:28 -0000	1.6
+++ goocanvasview.h	18 Apr 2006 15:43:07 -0000	1.7
@@ -123,6 +123,7 @@
 GType         goo_canvas_view_get_type       (void) G_GNUC_CONST;
 GtkWidget*    goo_canvas_view_new            (void);
 
+GooCanvasModel* goo_canvas_view_get_model    (GooCanvasView     *view);
 void          goo_canvas_view_set_model	     (GooCanvasView     *view,
 					      GooCanvasModel    *model);
 



More information about the cairo-commit mailing list