X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=registryd%2Fdesktop.c;h=4d278dc4b8f9a6f1796f4ae10251780e152e606e;hb=345cb4da5a1c04d511fab3c6c287a9f0bcd3dad8;hp=305f7d721d80e7ec0791b951d54db2131ca6b266;hpb=42bec7927aea61be20b65fbfa155a74e3e8b4e3e;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/registryd/desktop.c b/registryd/desktop.c index 305f7d7..4d278dc 100644 --- a/registryd/desktop.c +++ b/registryd/desktop.c @@ -2,7 +2,8 @@ * AT-SPI - Assistive Technology Service Provider Interface * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) * - * Copyright 2001 Sun Microsystems Inc., Ximian Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc., Ximian Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -26,6 +27,18 @@ #include #include #include "desktop.h" +#include +#include +#include + +/* SpiDesktop signals */ +enum { + APPLICATION_ADDED, + APPLICATION_REMOVED, +LAST_SIGNAL +}; +static guint spi_desktop_signals[LAST_SIGNAL]; + /* Our parent Gtk object type */ #define PARENT_TYPE SPI_ACCESSIBLE_TYPE @@ -38,14 +51,104 @@ typedef struct { /* A pointer to our parent object class */ static SpiAccessibleClass *parent_class; +#define SPI_TYPE_ATK_DESKTOP (spi_atk_desktop_get_type ()) +#define SPI_ATK_DESKTOP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_TYPE_ATK_DESKTOP, SpiAtkDesktop)) +#define SPI_IS_ATK_DESKTOP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_TYPE_ATK_DESKTOP)) + +typedef struct { + AtkObject parent; + + GdkScreen *screen; +} 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_atk_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) +{ + GdkDisplay *display; + + atk_object_set_name (ATK_OBJECT (desktop), "main"); + display = gdk_x11_lookup_xdisplay (GDK_DISPLAY ()); + desktop->screen = gdk_display_get_default_screen (display); +} + static void -spi_desktop_init (SpiDesktop *desktop) +atk_component_interface_init (AtkComponentIface *iface) { - spi_base_construct_default (SPI_BASE (desktop)); + g_return_if_fail (iface != NULL); - desktop->applications = 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) +{ + SpiAtkDesktop *desktop; + + g_return_if_fail (SPI_IS_ATK_DESKTOP (component)); + desktop = SPI_ATK_DESKTOP (component); + *x = 0; + *y = 0; + *width = gdk_screen_get_width (desktop->screen); + *height = gdk_screen_get_height (desktop->screen); +} - atk_object_set_name (ATK_OBJECT(SPI_BASE (desktop)->gobj), "main"); +static void +spi_desktop_init (SpiDesktop *desktop) +{ + desktop->applications = NULL; + bonobo_object_set_immortal (BONOBO_OBJECT (desktop), TRUE); } static void @@ -55,7 +158,8 @@ spi_desktop_dispose (GObject *object) while (desktop->applications) { - Application *app = (Application *) desktop->applications; + Application *app = desktop->applications->data; + g_assert (app->ref != CORBA_OBJECT_NIL); spi_desktop_remove_application (desktop, app->ref); } @@ -116,6 +220,24 @@ spi_desktop_class_init (SpiDesktopClass *klass) parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE); + spi_desktop_signals[APPLICATION_ADDED] = + g_signal_new ("application_added", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (SpiDesktopClass, application_added), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, + 1, G_TYPE_UINT); + spi_desktop_signals[APPLICATION_REMOVED] = + g_signal_new ("application_removed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (SpiDesktopClass, application_removed), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, + 1, G_TYPE_UINT); epv->_get_childCount = impl_desktop_get_child_count; epv->getChildAtIndex = impl_desktop_get_child_at_index; } @@ -128,9 +250,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 @@ -165,7 +292,12 @@ spi_desktop_add_application (SpiDesktop *desktop, desktop->applications = g_list_append (desktop->applications, app); - ORBit_small_listen_for_broken (app->ref, G_CALLBACK (abnormal_application_termination), app); + ORBit_small_listen_for_broken ( + app->ref, G_CALLBACK (abnormal_application_termination), app); + + g_signal_emit (G_OBJECT (desktop), + spi_desktop_signals[APPLICATION_ADDED], 0, + g_list_index (desktop->applications, app)); } CORBA_exception_free (&ev); @@ -175,13 +307,16 @@ void spi_desktop_remove_application (SpiDesktop *desktop, const Accessibility_Application app_ref) { + guint idx; GList *l; CORBA_Environment ev; + g_return_if_fail (app_ref != CORBA_OBJECT_NIL); g_return_if_fail (SPI_IS_DESKTOP (desktop)); CORBA_exception_init (&ev); + idx = 0; for (l = desktop->applications; l; l = l->next) { Application *app = (Application *) l->data; @@ -190,6 +325,7 @@ spi_desktop_remove_application (SpiDesktop *desktop, { break; } + idx++; } CORBA_exception_free (&ev); @@ -203,5 +339,7 @@ spi_desktop_remove_application (SpiDesktop *desktop, ORBit_small_unlisten_for_broken (app->ref, G_CALLBACK (abnormal_application_termination)); bonobo_object_release_unref (app->ref, NULL); g_free (app); + + g_signal_emit (G_OBJECT (desktop), spi_desktop_signals[APPLICATION_REMOVED], 0, idx); } }