X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libspi%2Fselection.c;h=538a8c2e593c6f531e14181dd4b5657943a80c18;hb=68b558bcef701bc71b1b7e53f68935f9c632fcdb;hp=bf33ecf5379f66b98ee5662310e735adee6d8430;hpb=7ff7c0d0b863f7346f21e03b6d170e8c7c6f9878;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/libspi/selection.c b/libspi/selection.c index bf33ecf..538a8c2 100644 --- a/libspi/selection.c +++ b/libspi/selection.c @@ -20,247 +20,169 @@ * Boston, MA 02111-1307, USA. */ -/* - * component.c : bonobo wrapper for accessible component implementation - * - */ -#include -#include +/* selection.c : implements the Selection interface */ +#include #include +#include +#include -/* - * This pulls the CORBA definitions for the "Accessibility::Accessible" server - */ -#include -#include "accessible.h" - -/* - * This pulls the definition of the selection bonobo object - */ -#include "selection.h" - -/* - * Static function declarations - */ - -static void -selection_class_init (SelectionClass *klass); -static void -selection_init (Selection *selection); -static void -selection_finalize (GObject *obj); -static CORBA_long -impl__get_nSelectedChildren (PortableServer_Servant _servant, - CORBA_Environment * ev); -static Accessibility_Accessible -impl_getSelectedChild (PortableServer_Servant _servant, - const CORBA_long selectedChildIndex, - CORBA_Environment * ev); -static CORBA_boolean -impl_selectChild (PortableServer_Servant _servant, - const CORBA_long childIndex, - CORBA_Environment * ev); -static CORBA_boolean -impl_deselectSelectedChild (PortableServer_Servant _servant, - const CORBA_long selectedChildIndex, - CORBA_Environment * ev); -static CORBA_boolean -impl_isChildSelected (PortableServer_Servant _servant, - const CORBA_long childIndex, - CORBA_Environment * ev); -static void -impl_selectAll (PortableServer_Servant _servant, - CORBA_Environment * ev); -static void -impl_clearSelection (PortableServer_Servant _servant, - CORBA_Environment * ev); - - -static GObjectClass *parent_class; -GType -selection_get_type (void) +SpiSelection * +spi_selection_interface_new (AtkObject *obj) { - static GType type = 0; - - if (!type) { - static const GTypeInfo tinfo = { - sizeof (SelectionClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) selection_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class data */ - sizeof (Selection), - 0, /* n preallocs */ - (GInstanceInitFunc) selection_init, - NULL /* value table */ - }; - - /* - * Bonobo_type_unique auto-generates a load of - * CORBA structures for us. All derived types must - * use bonobo_type_unique. - */ - type = bonobo_type_unique ( - BONOBO_OBJECT_TYPE, - POA_Accessibility_Selection__init, - NULL, - G_STRUCT_OFFSET (SelectionClass, epv), - &tinfo, - "AccessibleSelection"); - } - - return type; -} - -static void -selection_class_init (SelectionClass *klass) -{ - GObjectClass * object_class = (GObjectClass *) klass; - POA_Accessibility_Selection__epv *epv = &klass->epv; - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = selection_finalize; + SpiSelection *new_selection = g_object_new (SPI_SELECTION_TYPE, NULL); + spi_base_construct (SPI_BASE (new_selection), obj); - /* Initialize epv table */ - - epv->_get_nSelectedChildren = impl__get_nSelectedChildren; - epv->getSelectedChild = impl_getSelectedChild; - epv->selectChild = impl_selectChild; - epv->deselectSelectedChild = impl_deselectSelectedChild; - epv->isChildSelected = impl_isChildSelected; - epv->selectAll = impl_selectAll; - epv->clearSelection = impl_clearSelection; + return new_selection; } -static void -selection_init (Selection *selection) -{ -} -static void -selection_finalize (GObject *obj) +static AtkSelection * +get_selection_from_servant (PortableServer_Servant servant) { - Selection *selection = SELECTION (obj); - g_object_unref (selection->atko); - selection->atko = NULL; - parent_class->finalize (obj); -} + SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant)); -Selection * -selection_interface_new (AtkObject *obj) -{ - Selection *new_selection = - SELECTION(g_object_new (SELECTION_TYPE, NULL)); - new_selection->atko = obj; - g_object_ref (obj); - return new_selection; -} + if (!object) + { + return NULL; + } + return ATK_SELECTION (object->atko); +} static CORBA_long -impl__get_nSelectedChildren (PortableServer_Servant _servant, - CORBA_Environment * ev) +impl__get_nSelectedChildren (PortableServer_Servant servant, + CORBA_Environment *ev) { - BonoboObject *obj = bonobo_object_from_servant (_servant); - Selection *selection; -#ifdef SPI_DEBUG - fprintf (stderr, "calling impl__get_nSelectedChildren\n"); -#endif - g_return_val_if_fail (IS_SELECTION (obj), 0); - selection = SELECTION (obj); - g_return_val_if_fail (ATK_IS_SELECTION (selection->atko), 0); - return (CORBA_long) - atk_selection_get_selection_count (ATK_SELECTION(selection->atko)); + AtkSelection *selection = get_selection_from_servant (servant); + + g_return_val_if_fail (selection != NULL, 0); + + return (CORBA_long) atk_selection_get_selection_count (selection); } static Accessibility_Accessible -impl_getSelectedChild (PortableServer_Servant _servant, - const CORBA_long selectedChildIndex, - CORBA_Environment * ev) +impl_getSelectedChild (PortableServer_Servant servant, + const CORBA_long selectedChildIndex, + CORBA_Environment *ev) { - BonoboObject *obj = bonobo_object_from_servant (_servant); - Selection - *selection; - AtkObject *atk_object; - Accessibility_Accessible rv; + AtkObject *atk_object; + AtkSelection *selection = get_selection_from_servant (servant); + + g_return_val_if_fail (selection != NULL, CORBA_OBJECT_NIL); + #ifdef SPI_DEBUG fprintf (stderr, "calling impl_getSelectedChild\n"); #endif - g_return_val_if_fail (IS_SELECTION (obj), 0); - selection = SELECTION (obj); - g_return_val_if_fail (ATK_IS_SELECTION (selection->atko), 0); - atk_object = atk_selection_ref_selection (ATK_SELECTION (selection->atko), + atk_object = atk_selection_ref_selection (selection, (gint) selectedChildIndex); - g_return_val_if_fail (ATK_IS_OBJECT (atk_object), NULL); + + g_return_val_if_fail (ATK_IS_OBJECT (atk_object), CORBA_OBJECT_NIL); + #ifdef SPI_DEBUG - fprintf (stderr, "child type is %s\n", g_type_name (G_OBJECT_TYPE (atk_object))); + fprintf (stderr, "child type is %s\n", + g_type_name (G_OBJECT_TYPE (atk_object))); #endif - rv = bonobo_object_corba_objref (bonobo_object (accessible_new (atk_object))); - g_object_unref (atk_object); - return CORBA_Object_duplicate (rv, ev); -} + return spi_accessible_new_return (atk_object, TRUE, ev); +} static CORBA_boolean -impl_selectChild (PortableServer_Servant _servant, - const CORBA_long childIndex, - CORBA_Environment * ev) +impl_selectChild (PortableServer_Servant servant, + const CORBA_long childIndex, + CORBA_Environment *ev) { - Selection *selection = SELECTION (bonobo_object_from_servant (_servant)); - return (CORBA_boolean) - atk_selection_add_selection (ATK_SELECTION(selection->atko), (gint) childIndex); -} + AtkSelection *selection = get_selection_from_servant (servant); + g_return_val_if_fail (selection != NULL, FALSE); + return (CORBA_boolean) + atk_selection_add_selection (selection, (gint) childIndex); +} static CORBA_boolean -impl_deselectSelectedChild (PortableServer_Servant _servant, - const CORBA_long selectedChildIndex, - CORBA_Environment * ev) +impl_deselectSelectedChild (PortableServer_Servant servant, + const CORBA_long selectedChildIndex, + CORBA_Environment *ev) { - Selection *selection = SELECTION (bonobo_object_from_servant (_servant)); + AtkSelection *selection = get_selection_from_servant (servant); + + g_return_val_if_fail (selection != NULL, FALSE); + return (CORBA_boolean) - atk_selection_remove_selection (ATK_SELECTION(selection->atko), (gint) selectedChildIndex); + atk_selection_remove_selection (selection, (gint) selectedChildIndex); } - static CORBA_boolean -impl_isChildSelected (PortableServer_Servant _servant, - const CORBA_long childIndex, - CORBA_Environment * ev) +impl_isChildSelected (PortableServer_Servant servant, + const CORBA_long childIndex, + CORBA_Environment *ev) { - Selection *selection = SELECTION (bonobo_object_from_servant (_servant)); + AtkSelection *selection = get_selection_from_servant (servant); + + g_return_val_if_fail (selection != NULL, FALSE); + return (CORBA_boolean) - atk_selection_is_child_selected (ATK_SELECTION(selection->atko), (gint) childIndex); + atk_selection_is_child_selected (selection, (gint) childIndex); } +static void +impl_selectAll (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + AtkSelection *selection = get_selection_from_servant (servant); + + g_return_if_fail (selection != NULL); + + atk_selection_select_all_selection (selection); +} + static void -impl_selectAll (PortableServer_Servant _servant, - CORBA_Environment * ev) +impl_clearSelection (PortableServer_Servant servant, + CORBA_Environment *ev) { - Selection *selection = SELECTION (bonobo_object_from_servant (_servant)); - atk_selection_select_all_selection (ATK_SELECTION(selection->atko)); + AtkSelection *selection = get_selection_from_servant (servant); + + g_return_if_fail (selection != NULL); + + atk_selection_clear_selection (selection); } +static void +spi_selection_class_init (SpiSelectionClass *klass) +{ + POA_Accessibility_Selection__epv *epv = &klass->epv; -static void -impl_clearSelection (PortableServer_Servant _servant, - CORBA_Environment * ev) + /* Initialize epv table */ + + epv->_get_nSelectedChildren = impl__get_nSelectedChildren; + epv->getSelectedChild = impl_getSelectedChild; + epv->selectChild = impl_selectChild; + epv->deselectSelectedChild = impl_deselectSelectedChild; + epv->isChildSelected = impl_isChildSelected; + epv->selectAll = impl_selectAll; + epv->clearSelection = impl_clearSelection; +} + + +static void +spi_selection_init (SpiSelection *selection) { - Selection *selection = SELECTION (bonobo_object_from_servant (_servant)); - atk_selection_clear_selection (ATK_SELECTION(selection->atko)); } + +BONOBO_TYPE_FUNC_FULL (SpiSelection, + Accessibility_Selection, + SPI_TYPE_BASE, + spi_selection);