From f1ddcbac7cc196b5d20565a5a0d2e8fb7f14e560 Mon Sep 17 00:00:00 2001 From: Padraig O'Briain Date: Thu, 9 Aug 2001 10:58:07 +0000 Subject: [PATCH] atk/atkaction.c, atk/atkcomponent.c Remove all instances of * atk/atkaction.c, atk/atkcomponent.c Remove all instances of g_return_if_fail (foo != NULL); that are immediately before a g_return_if_fail (ATK_IS_FOO (foo)); since the second check catches the NULL. * atk/atkcomponent.c Add functions atk_component_real_contains(), atk_component_real_get_position(), atkcomponent_real_get_size() as default implementations for atk_component_contains(), atk_component_get_position(), atk_component_get_size() --- ChangeLog | 13 +++++++ atk/atkaction.c | 6 --- atk/atkcomponent.c | 96 +++++++++++++++++++++++++++++++++++++++++------ docs/tmpl/atk-unused.sgml | 10 +++++ docs/tmpl/atkimage.sgml | 13 +------ 5 files changed, 109 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d066f4..d51b2cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,17 @@ +2001-08-09 Padraig O'Briain + + * atk/atkaction.c, atk/atkcomponent.c + Remove all instances of g_return_if_fail (foo != NULL); that are + immediately before a g_return_if_fail (ATK_IS_FOO (foo)); + since the second check catches the NULL. + * atk/atkcomponent.c + Add functions atk_component_real_contains(), + atk_component_real_get_position(), atkcomponent_real_get_size() + as default implementations for atk_component_contains(), + atk_component_get_position(), atk_component_get_size() + 2001-08-07 Brian Cameron + * atk/atkimage.[ch] docs/atk-sections.txt docs/tmpl/atkimage.sgml Updated AtkImage get_position to get_image_position diff --git a/atk/atkaction.c b/atk/atkaction.c index ed6d5d2..071396e 100755 --- a/atk/atkaction.c +++ b/atk/atkaction.c @@ -52,7 +52,6 @@ atk_action_do_action (AtkAction *obj, { AtkActionIface *iface; - g_return_if_fail (obj != NULL); g_return_if_fail (ATK_IS_ACTION (obj)); iface = ATK_ACTION_GET_IFACE (obj); @@ -77,7 +76,6 @@ atk_action_get_n_actions (AtkAction *obj) { AtkActionIface *iface; - g_return_val_if_fail (obj != NULL, 0); g_return_val_if_fail (ATK_IS_ACTION (obj), 0); iface = ATK_ACTION_GET_IFACE (obj); @@ -104,7 +102,6 @@ atk_action_get_description (AtkAction *obj, { AtkActionIface *iface; - g_return_val_if_fail (obj != NULL, NULL); g_return_val_if_fail (ATK_IS_ACTION (obj), NULL); iface = ATK_ACTION_GET_IFACE (obj); @@ -131,7 +128,6 @@ atk_action_get_name (AtkAction *obj, { AtkActionIface *iface; - g_return_val_if_fail (obj != NULL, NULL); g_return_val_if_fail (ATK_IS_ACTION (obj), NULL); iface = ATK_ACTION_GET_IFACE (obj); @@ -159,7 +155,6 @@ atk_action_get_keybinding (AtkAction *obj, { AtkActionIface *iface; - g_return_val_if_fail (obj != NULL, NULL); g_return_val_if_fail (ATK_IS_ACTION (obj), NULL); iface = ATK_ACTION_GET_IFACE (obj); @@ -187,7 +182,6 @@ atk_action_set_description (AtkAction *obj, { AtkActionIface *iface; - g_return_val_if_fail (obj != NULL, FALSE); g_return_val_if_fail (ATK_IS_ACTION (obj), FALSE); iface = ATK_ACTION_GET_IFACE (obj); diff --git a/atk/atkcomponent.c b/atk/atkcomponent.c index d68013f..a5cd1be 100755 --- a/atk/atkcomponent.c +++ b/atk/atkcomponent.c @@ -20,11 +20,25 @@ #include "atkcomponent.h" +static gboolean atk_component_real_contains (AtkComponent *component, + gint x, + gint y, + AtkCoordType coord_type); + static AtkObject* atk_component_real_get_accessible_at_point (AtkComponent *component, gint x, gint y, AtkCoordType coord_type); +static void atk_component_real_get_position (AtkComponent *component, + gint *x, + gint *y, + AtkCoordType coord_type); + +static void atk_component_real_get_size (AtkComponent *component, + gint *width, + gint *height); + GType atk_component_get_type () { @@ -60,7 +74,6 @@ atk_component_add_focus_handler (AtkComponent *component, AtkFocusHandler handler) { AtkComponentIface *iface = NULL; - g_return_val_if_fail (component != NULL, 0); g_return_val_if_fail (ATK_IS_COMPONENT (component), 0); iface = ATK_COMPONENT_GET_IFACE (component); @@ -114,7 +127,6 @@ atk_component_contains (AtkComponent *component, AtkCoordType coord_type) { AtkComponentIface *iface = NULL; - g_return_val_if_fail (component != NULL, FALSE); g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE); iface = ATK_COMPONENT_GET_IFACE (component); @@ -122,7 +134,12 @@ atk_component_contains (AtkComponent *component, if (iface->contains) return (iface->contains) (component, x, y, coord_type); else - return FALSE; + { + /* + * if this method is not overridden use the default implementation. + */ + return atk_component_real_contains (component, x, y, coord_type); + } } /** @@ -145,7 +162,6 @@ atk_component_get_accessible_at_point (AtkComponent *component, AtkCoordType coord_type) { AtkComponentIface *iface = NULL; - g_return_val_if_fail (component != NULL, NULL); g_return_val_if_fail (ATK_IS_COMPONENT (component), NULL); iface = ATK_COMPONENT_GET_IFACE (component); @@ -215,6 +231,13 @@ atk_component_get_position (AtkComponent *component, if (iface->get_position) (iface->get_position) (component, x, y, coord_type); + else + { + /* + * if this method is not overridden use the default implementation. + */ + atk_component_real_get_position (component, x, y, coord_type); + } } /** @@ -227,8 +250,8 @@ atk_component_get_position (AtkComponent *component, **/ void atk_component_get_size (AtkComponent *component, - gint *x, - gint *y) + gint *width, + gint *height) { AtkComponentIface *iface = NULL; g_return_if_fail (ATK_IS_COMPONENT (component)); @@ -236,7 +259,14 @@ atk_component_get_size (AtkComponent *component, iface = ATK_COMPONENT_GET_IFACE (component); if (iface->get_size) - (iface->get_size) (component, x, y); + (iface->get_size) (component, width, height); + else + { + /* + * if this method is not overridden use the default implementation. + */ + atk_component_real_get_size (component, width, height); + } } /** @@ -251,7 +281,6 @@ gboolean atk_component_grab_focus (AtkComponent *component) { AtkComponentIface *iface = NULL; - g_return_val_if_fail (component != NULL, FALSE); g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE); iface = ATK_COMPONENT_GET_IFACE (component); @@ -285,7 +314,6 @@ atk_component_set_extents (AtkComponent *component, AtkCoordType coord_type) { AtkComponentIface *iface = NULL; - g_return_val_if_fail (component != NULL, FALSE); g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE); iface = ATK_COMPONENT_GET_IFACE (component); @@ -315,7 +343,6 @@ atk_component_set_position (AtkComponent *component, AtkCoordType coord_type) { AtkComponentIface *iface = NULL; - g_return_val_if_fail (component != NULL, FALSE); g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE); iface = ATK_COMPONENT_GET_IFACE (component); @@ -342,7 +369,6 @@ atk_component_set_size (AtkComponent *component, gint y) { AtkComponentIface *iface = NULL; - g_return_val_if_fail (component != NULL, FALSE); g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE); iface = ATK_COMPONENT_GET_IFACE (component); @@ -353,6 +379,27 @@ atk_component_set_size (AtkComponent *component, return FALSE; } +static gboolean +atk_component_real_contains (AtkComponent *component, + gint x, + gint y, + AtkCoordType coord_type) +{ + gint real_x, real_y, width, height; + + real_x = real_y = width = height = 0; + + atk_component_get_extents (component, &real_x, &real_y, &width, &height, coord_type); + + if ((x >= real_x) && + (x < real_x + width) && + (y >= real_y) && + (y < real_y + height)) + return TRUE; + else + return FALSE; +} + static AtkObject* atk_component_real_get_accessible_at_point (AtkComponent *component, gint x, @@ -386,3 +433,30 @@ atk_component_real_get_accessible_at_point (AtkComponent *component, } return NULL; } + +static void +atk_component_real_get_position (AtkComponent *component, + gint *x, + gint *y, + AtkCoordType coord_type) +{ + gint width, height; + + atk_component_get_extents (component, x, y, &width, &height, coord_type); +} + +static void +atk_component_real_get_size (AtkComponent *component, + gint *width, + gint *height) +{ + gint x, y; + AtkCoordType coord_type; + + /* + * Pick one coordinate type; it does not matter for size + */ + coord_type = ATK_XY_WINDOW; + + atk_component_get_extents (component, &x, &y, width, height, coord_type); +} diff --git a/docs/tmpl/atk-unused.sgml b/docs/tmpl/atk-unused.sgml index 880b955..01542b3 100644 --- a/docs/tmpl/atk-unused.sgml +++ b/docs/tmpl/atk-unused.sgml @@ -81,6 +81,16 @@ atk @image: @Returns: + + + + + +@image: +@x: +@y: +@coord_type: + diff --git a/docs/tmpl/atkimage.sgml b/docs/tmpl/atkimage.sgml index 4a0bb76..92735e0 100644 --- a/docs/tmpl/atkimage.sgml +++ b/docs/tmpl/atkimage.sgml @@ -28,22 +28,11 @@ an assistive technology to get descriptive information about images. @parent: -@get_image_position: +@get_position: @get_image_description: @get_image_size: @set_image_description: - - - - - -@image: -@x: -@y: -@coord_type: - - -- 2.7.4