[g-a-devel]AccessibleComponent for desktop objects



The attached patch causes AccessibleComponent to be implemented for SpiDesktop 
and provides implementation for AccessibleComponent_getExtents().

This is bug 101524.

OK to commit.

Padraig
Index: desktop.c
===================================================================
RCS file: /cvs/gnome/at-spi/registryd/desktop.c,v
retrieving revision 1.21
diff -u -p -r1.21 desktop.c
--- desktop.c	13 Sep 2002 13:09:02 -0000	1.21
+++ desktop.c	27 Jan 2003 10:16:31 -0000
@@ -27,6 +27,9 @@
 #include <stdio.h>
 #include <libbonobo.h>
 #include "desktop.h"
+#include <atk/atkcomponent.h>
+#include <gdk/gdkscreen.h>
+#include <gdk/gdkx.h>
 
 /* SpiDesktop signals */
 enum {
@@ -48,15 +51,97 @@ typedef struct {
 /* A pointer to our parent object class */
 static SpiAccessibleClass *parent_class;
 
+#define SPI_TYPE_ATK_DESKTOP		(spi_api_desktop_get_type ())
+
+typedef struct {
+	AtkObject parent;
+} SpiAtkDesktop;
+
+typedef struct {
+	AtkObjectClass parent;
+} SpiAtkDesktopClass;
+
+static void spi_atk_desktop_init (SpiAtkDesktop *desktop);
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void spi_atk_desktop_get_extents	 (AtkComponent    *component,
+                                          gint            *x,
+                                          gint            *y,
+                                          gint            *width,
+                                          gint            *height,
+                                          AtkCoordType    coord_type);
+
+static GType 
+spi_api_desktop_get_type ()
+{
+  static GType type = 0;
+
+  if (!type)
+    {
+      static const GTypeInfo typeInfo =
+      {
+  	sizeof (SpiAtkDesktopClass),
+  	(GBaseInitFunc) NULL,
+  	(GBaseFinalizeFunc) NULL,
+  	(GClassInitFunc) NULL,
+  	(GClassFinalizeFunc) NULL,
+  	NULL,
+  	sizeof (SpiAtkDesktop),
+  	0,
+  	(GInstanceInitFunc) spi_atk_desktop_init,
+      } ;
+      static const GInterfaceInfo atk_component_info =
+	{
+        (GInterfaceInitFunc) atk_component_interface_init,
+	(GInterfaceFinalizeFunc) NULL,
+	NULL
+      };
+
+      type = g_type_register_static (ATK_TYPE_OBJECT,
+                                     "SpiAtkDesktop", &typeInfo, 0);
+      g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
+                                   &atk_component_info);
+    }
+  return type;
+}
+
+static void 
+spi_atk_desktop_init (SpiAtkDesktop *desktop)
+{
+  atk_object_set_name (ATK_OBJECT (desktop), "main");
+}
+
 static void
-spi_desktop_init (SpiDesktop *desktop)
+atk_component_interface_init (AtkComponentIface *iface)
 {
-  spi_base_construct (SPI_BASE (desktop), g_object_new (ATK_TYPE_OBJECT, NULL));
+  g_return_if_fail (iface != NULL);
+
+  iface->get_extents = spi_atk_desktop_get_extents;
+}
+
+static void 
+spi_atk_desktop_get_extents (AtkComponent *component,
+                             gint         *x,
+                             gint	  *y,
+                             gint	  *width,
+                             gint	  *height,
+                             AtkCoordType coord_type)
+{
+  GdkDisplay *display;
+  GdkScreen *screen;
+
+  display = gdk_x11_lookup_xdisplay (GDK_DISPLAY ());
+  screen = gdk_display_get_default_screen (display);
+  *x = 0;
+  *y = 0;
+  *width = gdk_screen_get_width (screen);
+  *height = gdk_screen_get_height (screen);
+}
 
+static void
+spi_desktop_init (SpiDesktop *desktop)
+{
   desktop->applications = NULL;
   bonobo_object_set_immortal (BONOBO_OBJECT (desktop), TRUE);
-
-  atk_object_set_name (ATK_OBJECT (SPI_BASE (desktop)->gobj), "main");
 }
 
 static void
@@ -158,9 +243,14 @@ BONOBO_TYPE_FUNC_FULL (SpiDesktop,
 SpiDesktop *
 spi_desktop_new (void)
 {
-  SpiDesktop *retval = g_object_new (SPI_DESKTOP_TYPE, NULL);
+  SpiDesktop *desktop; 
+  SpiAccessible *accessible; 
+
+  accessible = spi_accessible_construct (SPI_DESKTOP_TYPE, g_object_new (SPI_TYPE_ATK_DESKTOP, NULL));
+  g_assert (SPI_IS_DESKTOP (accessible));
+  desktop = SPI_DESKTOP (accessible);
 
-  return retval;
+  return desktop;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]