JP, Good question! I reviewed the code agian and made a new patch for gal. It mainly moves the register code to a11y part and call it only when a11y is enabled. Please note the patch also removed two useless files under gal/a11y and a useless funcition in gal-a11y-e-table.c. Thanks! Harry JP Rosevear wrote: On Thu, 2005-01-27 at 11:50 +0800, Harry Lu wrote:Hi, JPR, This patch can fix the invalid cast warning you mentioned in irc. Please review it. Thanks! HarryWell, this fixes the warning, but why is the atk_get_root guard not needed for other atk_object_set_name_calls? -JP |
Index: ChangeLog =================================================================== RCS file: /cvs/gnome/gal/ChangeLog,v retrieving revision 1.906 diff -u -r1.906 ChangeLog --- ChangeLog 27 Jan 2005 05:23:02 -0000 1.906 +++ ChangeLog 27 Jan 2005 08:09:37 -0000 @@ -1,3 +1,24 @@ +2005-01-27 Harry Lu <harry lu sun com> + + Some code clean work. + + * gal/a11y/e-table/gal-a11y-e-table-click-to-add.c: + (gal_a11y_e_table_click_to_add_init): new function to + register type only when a11y is enabled. + * gal/a11y/e-table/gal-a11y-e-table-click-to-add.h: + * gal/a11y/e-table/gal-a11y-e-table-item.c: + (gal_a11y_e_table_item_init): ditto. + * gal/a11y/e-table/gal-a11y-e-table.c: (gal_a11y_e_table_init): ditto. + * gal/a11y/e-table/gal-a11y-e-table.h: + * gal/a11y/e-table/gal-a11y-e-tree.c: (gal_a11y_e_tree_init): ditto. + * gal/a11y/e-table/gal-a11y-e-tree.h: + * gal/a11y/e-text/gal-a11y-e-text.c: (gal_a11y_e_text_init): ditto. + * gal/a11y/e-text/gal-a11y-e-text.h: + * gal/a11y/factory.c: useless file removed. + * gal/a11y/init.c: useless file removed. + * gal/e-text/e-text.c: (e_text_class_init): move a11y registry + call to a11y code. + 2005-01-27 Li Yuan <li yuan sun com> * gal/a11y/e-table/Makefile.am: Index: gal/a11y/factory.c =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/factory.c,v retrieving revision 1.1 diff -u -r1.1 factory.c --- gal/a11y/factory.c 30 Nov 2002 07:54:14 -0000 1.1 +++ gal/a11y/factory.c 27 Jan 2005 08:09:39 -0000 @@ -1,63 +0,0 @@ -#include <atk/atkobjectfactory.h> - -#include "gtkhtml.h" -#include "factory.h" -#include "object.h" - -static GType -gtk_html_a11y_factory_get_accessible_type (void) -{ - return G_TYPE_GTK_HTML_A11Y; -} - -static AtkObject* -gtk_html_a11y_factory_create_accessible (GObject *obj) -{ - GtkWidget *widget; - AtkObject *accessible; - - g_return_val_if_fail (GTK_IS_WIDGET (obj), NULL); - - widget = GTK_WIDGET (obj); - - accessible = gtk_html_a11y_new (widget); - - return accessible; -} - -static void -gtk_html_a11y_factory_class_init (AtkObjectFactoryClass *klass) -{ - klass->create_accessible = gtk_html_a11y_factory_create_accessible; - klass->get_accessible_type = gtk_html_a11y_factory_get_accessible_type; -} - -static GType -gtk_html_a11y_factory_get_type (void) -{ - static GType t = 0; - - if (!t) { - static const GTypeInfo tinfo = { - sizeof (AtkObjectFactoryClass), - NULL, NULL, (GClassInitFunc) gtk_html_a11y_factory_class_init, - NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL - }; - - t = g_type_register_static (ATK_TYPE_OBJECT_FACTORY, "GtkHTMLA11YNFactory", &tinfo, 0); - } - return t; -} - -static int accessibility_initialized = FALSE; - -void -gtk_html_accessibility_init (void) -{ - if (accessibility_initialized) - return; - - atk_registry_set_factory_type (atk_get_default_registry (), GTK_TYPE_HTML, gtk_html_a11y_factory_get_type ()); - - accessibility_initialized = TRUE; -} Index: gal/a11y/init.c =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/init.c,v retrieving revision 1.1 diff -u -r1.1 init.c --- gal/a11y/init.c 30 Nov 2002 07:54:14 -0000 1.1 +++ gal/a11y/init.c 27 Jan 2005 08:09:39 -0000 @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Christopher James Lahey <clahey ximian com> - * - * Copyright (C) 2002 Ximian, Inc. - */ - -#include <config.h> - -#include "e-table/gal-a11y-e-table-factory.h" -#include "e-table/gal-a11y-e-cell-text.h" -#include "e-table/gal-a11y-e-cell-registry.h" - -#include "e-text/gal-a11y-e-text-factory.h" -#include <gal/e-text/e-text.h> - -#include <gal/e-table/e-table.h> -#include <gal/e-table/e-cell-text.h> -#include <atk/atkregistry.h> - -/* Static functions */ - -static gboolean initialized = FALSE; - -extern void gnome_accessibility_module_init (void); -extern void gnome_accessibility_module_shutdown (void); - -void -gal_a11y_init () -{ - if (initialized) - return; - atk_registry_set_factory_type (atk_get_default_registry (), - E_TABLE_TYPE, - gal_a11y_e_table_factory_get_type ()); - atk_registry_set_factory_type (atk_get_default_registry (), - E_TYPE_TEXT, - gal_a11y_e_text_factory_get_type ()); - - gal_a11y_e_cell_registry_add_cell_type (NULL, - E_CELL_TEXT_TYPE, - gal_a11y_e_cell_text_new); - initialized = TRUE; -} - -void -gnome_accessibility_module_init () -{ - gal_a11y_init(); -} - -void -gnome_accessibility_module_shutdown () -{ - if (!initialized) - return; - atk_registry_set_factory_type (atk_get_default_registry (), - E_TABLE_TYPE, - 0); - - initialized = FALSE; -} - -int -gtk_module_init (gint *argc, char** argv[]) -{ - gal_a11y_init (); - - return 0; -} Index: gal/a11y/e-table/gal-a11y-e-table-click-to-add.c =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table-click-to-add.c,v retrieving revision 1.3 diff -u -r1.3 gal-a11y-e-table-click-to-add.c --- gal/a11y/e-table/gal-a11y-e-table-click-to-add.c 27 Jan 2005 05:24:18 -0000 1.3 +++ gal/a11y/e-table/gal-a11y-e-table-click-to-add.c 27 Jan 2005 08:09:43 -0000 @@ -8,6 +8,7 @@ #include <config.h> #include "gal-a11y-util.h" #include "gal-a11y-e-table-click-to-add.h" +#include "gal-a11y-e-table-click-to-add-factory.h" #include <gal/e-table/e-table-group.h> #include <gal/e-table/e-table-group-leaf.h> #include <gal/e-table/e-table-click-to-add.h> @@ -313,3 +314,14 @@ return ATK_OBJECT (a11y); } + +void +gal_a11y_e_table_click_to_add_init (void) +{ + if (atk_get_root ()) + atk_registry_set_factory_type (atk_get_default_registry (), + E_TABLE_CLICK_TO_ADD_TYPE, + gal_a11y_e_table_click_to_add_factory_get_type ()); + +} + Index: gal/a11y/e-table/gal-a11y-e-table-click-to-add.h =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table-click-to-add.h,v retrieving revision 1.1 diff -u -r1.1 gal-a11y-e-table-click-to-add.h --- gal/a11y/e-table/gal-a11y-e-table-click-to-add.h 17 Dec 2003 02:35:20 -0000 1.1 +++ gal/a11y/e-table/gal-a11y-e-table-click-to-add.h 27 Jan 2005 08:09:44 -0000 @@ -32,4 +32,5 @@ GType gal_a11y_e_table_click_to_add_get_type (void); AtkObject *gal_a11y_e_table_click_to_add_new (GObject *widget); +void gal_a11y_e_table_click_to_add_init (void); #endif /* ! __GAL_A11Y_E_TABLE_CLICK_TO_ADD_H__ */ Index: gal/a11y/e-table/gal-a11y-e-table-item.c =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table-item.c,v retrieving revision 1.15 diff -u -r1.15 gal-a11y-e-table-item.c --- gal/a11y/e-table/gal-a11y-e-table-item.c 27 Jan 2005 05:24:18 -0000 1.15 +++ gal/a11y/e-table/gal-a11y-e-table-item.c 27 Jan 2005 08:09:53 -0000 @@ -1302,7 +1302,9 @@ void gal_a11y_e_table_item_init (void) { - atk_registry_set_factory_type (atk_get_default_registry (), - E_TABLE_ITEM_TYPE, - gal_a11y_e_table_item_factory_get_type ()); + if (atk_get_root ()) + atk_registry_set_factory_type (atk_get_default_registry (), + E_TABLE_ITEM_TYPE, + gal_a11y_e_table_item_factory_get_type ()); } + Index: gal/a11y/e-table/gal-a11y-e-table.c =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table.c,v retrieving revision 1.4 diff -u -r1.4 gal-a11y-e-table.c --- gal/a11y/e-table/gal-a11y-e-table.c 27 Jan 2005 05:24:18 -0000 1.4 +++ gal/a11y/e-table/gal-a11y-e-table.c 27 Jan 2005 08:10:02 -0000 @@ -8,6 +8,7 @@ #include <config.h> #include "gal-a11y-e-table.h" +#include "gal-a11y-e-table-factory.h" #include "gal-a11y-e-table-item.h" #include "gal-a11y-util.h" #include <gal/e-table/e-table.h> @@ -64,19 +65,6 @@ return a11y; } -static ETableItem * -find_table_item (ETable *table) -{ - if (e_table_model_row_count(table->model) < 1) - return NULL; - else { - if (table->group) - return find_first_table_item (table->group); - } - - return NULL; -} - static gboolean init_child_item (GalA11yETable *a11y) { @@ -292,3 +280,14 @@ return ATK_OBJECT (a11y); } + +void +gal_a11y_e_table_init (void) +{ + if (atk_get_root ()) + atk_registry_set_factory_type (atk_get_default_registry (), + E_TABLE_TYPE, + gal_a11y_e_table_factory_get_type ()); + +} + Index: gal/a11y/e-table/gal-a11y-e-table.h =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table.h,v retrieving revision 1.1 diff -u -r1.1 gal-a11y-e-table.h --- gal/a11y/e-table/gal-a11y-e-table.h 30 Nov 2002 07:54:15 -0000 1.1 +++ gal/a11y/e-table/gal-a11y-e-table.h 27 Jan 2005 08:10:02 -0000 @@ -40,4 +40,6 @@ GType gal_a11y_e_table_get_type (void); AtkObject *gal_a11y_e_table_new (GObject *table); +void gal_a11y_e_table_init (void); + #endif /* ! __GAL_A11Y_E_TABLE_H__ */ Index: gal/a11y/e-table/gal-a11y-e-tree.c =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-tree.c,v retrieving revision 1.5 diff -u -r1.5 gal-a11y-e-tree.c --- gal/a11y/e-table/gal-a11y-e-tree.c 27 Jan 2005 05:24:18 -0000 1.5 +++ gal/a11y/e-table/gal-a11y-e-tree.c 27 Jan 2005 08:10:03 -0000 @@ -6,6 +6,7 @@ #include <config.h> #include "gal-a11y-e-tree.h" +#include "gal-a11y-e-tree-factory.h" #include "gal-a11y-util.h" #include "gal-a11y-e-table-item.h" #include <gal/e-table/e-tree.h> @@ -162,3 +163,14 @@ return ATK_OBJECT (a11y); } + +void +gal_a11y_e_tree_init (void) +{ + if (atk_get_root ()) + atk_registry_set_factory_type (atk_get_default_registry (), + E_TREE_TYPE, + gal_a11y_e_tree_factory_get_type ()); + +} + Index: gal/a11y/e-table/gal-a11y-e-tree.h =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-tree.h,v retrieving revision 1.1 diff -u -r1.1 gal-a11y-e-tree.h --- gal/a11y/e-table/gal-a11y-e-tree.h 11 Oct 2003 02:59:24 -0000 1.1 +++ gal/a11y/e-table/gal-a11y-e-tree.h 27 Jan 2005 08:10:03 -0000 @@ -38,4 +38,6 @@ GType gal_a11y_e_tree_get_type (void); AtkObject *gal_a11y_e_tree_new (GObject *tree); +void gal_a11y_e_tree_init (void); + #endif /* ! __GAL_A11Y_E_TREE_H__ */ Index: gal/a11y/e-text/gal-a11y-e-text.c =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-text/gal-a11y-e-text.c,v retrieving revision 1.7 diff -u -r1.7 gal-a11y-e-text.c --- gal/a11y/e-text/gal-a11y-e-text.c 10 Jun 2004 17:00:57 -0000 1.7 +++ gal/a11y/e-text/gal-a11y-e-text.c 27 Jan 2005 08:10:15 -0000 @@ -9,6 +9,7 @@ #include <config.h> #include <string.h> #include "gal-a11y-e-text.h" +#include "gal-a11y-e-text-factory.h" #include "gal-a11y-util.h" #include <atk/atkobject.h> #include <atk/atktable.h> @@ -1119,3 +1120,14 @@ return type; } + +void +gal_a11y_e_text_init (void) +{ + if (atk_get_root ()) + atk_registry_set_factory_type (atk_get_default_registry (), + E_TYPE_TEXT, + gal_a11y_e_text_factory_get_type ()); + +} + Index: gal/a11y/e-text/gal-a11y-e-text.h =================================================================== RCS file: /cvs/gnome/gal/gal/a11y/e-text/gal-a11y-e-text.h,v retrieving revision 1.1 diff -u -r1.1 gal-a11y-e-text.h --- gal/a11y/e-text/gal-a11y-e-text.h 30 Nov 2002 07:54:16 -0000 1.1 +++ gal/a11y/e-text/gal-a11y-e-text.h 27 Jan 2005 08:10:15 -0000 @@ -37,4 +37,6 @@ /* Standard Glib function */ GType gal_a11y_e_text_get_type (void); +void gal_a11y_e_text_init (void); + #endif /* ! __GAL_A11Y_E_TEXT_H__ */ Index: gal/e-table/ChangeLog =================================================================== RCS file: /cvs/gnome/gal/gal/e-table/ChangeLog,v retrieving revision 1.945 diff -u -r1.945 ChangeLog --- gal/e-table/ChangeLog 27 Jan 2005 05:16:18 -0000 1.945 +++ gal/e-table/ChangeLog 27 Jan 2005 08:12:13 -0000 @@ -1,3 +1,12 @@ +2005-01-27 Harry Lu <harry lu sun com> + + Some code clean work. + + * e-table-click-to-add.c: (etcta_class_init): move a11y registry + call to a11y code. + * e-table.c: (e_table_class_init): ditto. + * e-tree.c: (e_tree_class_init): ditto. + 2005-01-27 Li Yuan <li yuan sun com> * e-cell-combo.c: (e_cell_combo_init), (e_cell_combo_do_popup), Index: gal/e-table/e-table-click-to-add.c =================================================================== RCS file: /cvs/gnome/gal/gal/e-table/e-table-click-to-add.c,v retrieving revision 1.40 diff -u -r1.40 e-table-click-to-add.c --- gal/e-table/e-table-click-to-add.c 27 Jan 2005 05:16:18 -0000 1.40 +++ gal/e-table/e-table-click-to-add.c 27 Jan 2005 08:12:18 -0000 @@ -41,7 +41,7 @@ #include "gal/util/e-util.h" #include "gal/util/e-i18n.h" #include "gal/util/e-marshal.h" -#include "gal/a11y/e-table/gal-a11y-e-table-click-to-add-factory.h" +#include "gal/a11y/e-table/gal-a11y-e-table-click-to-add.h" enum { CURSOR_CHANGE, @@ -544,11 +544,7 @@ e_marshal_NONE__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_STYLE); - - atk_registry_set_factory_type (atk_get_default_registry (), - E_TABLE_CLICK_TO_ADD_TYPE, - gal_a11y_e_table_click_to_add_factory_get_type ()); - + gal_a11y_e_table_click_to_add_init (); } static void Index: gal/e-table/e-table.c =================================================================== RCS file: /cvs/gnome/gal/gal/e-table/e-table.c,v retrieving revision 1.233 diff -u -r1.233 e-table.c --- gal/e-table/e-table.c 27 Jan 2005 05:16:19 -0000 1.233 +++ gal/e-table/e-table.c 27 Jan 2005 08:13:05 -0000 @@ -56,7 +56,7 @@ #include "e-table-utils.h" #include <atk/atk.h> -#include "gal/a11y/e-table/gal-a11y-e-table-factory.h" +#include "gal/a11y/e-table/gal-a11y-e-table.h" #define COLUMN_HEADER_HEIGHT 16 @@ -3343,10 +3343,7 @@ E_TABLE_MODEL_TYPE, G_PARAM_READABLE)); - atk_registry_set_factory_type (atk_get_default_registry (), - E_TABLE_TYPE, - gal_a11y_e_table_factory_get_type ()); - + gal_a11y_e_table_init (); } E_MAKE_TYPE(e_table, "ETable", ETable, e_table_class_init, e_table_init, PARENT_TYPE) Index: gal/e-table/e-tree.c =================================================================== RCS file: /cvs/gnome/gal/gal/e-table/e-tree.c,v retrieving revision 1.109 diff -u -r1.109 e-tree.c --- gal/e-table/e-tree.c 10 Jun 2004 15:29:15 -0000 1.109 +++ gal/e-table/e-tree.c 27 Jan 2005 08:13:25 -0000 @@ -54,7 +54,7 @@ #include "e-tree.h" #include "gal/util/e-marshal.h" -#include "gal/a11y/e-table/gal-a11y-e-tree-factory.h" +#include "gal/a11y/e-table/gal-a11y-e-tree.h" #define COLUMN_HEADER_HEIGHT 16 @@ -3318,10 +3318,7 @@ 10, G_PARAM_READABLE)); - atk_registry_set_factory_type (atk_get_default_registry (), - E_TREE_TYPE, - gal_a11y_e_tree_factory_get_type ()); - + gal_a11y_e_tree_init (); } E_MAKE_TYPE(e_tree, "ETree", ETree, e_tree_class_init, e_tree_init, PARENT_TYPE) Index: gal/e-text/e-text.c =================================================================== RCS file: /cvs/gnome/gal/gal/e-text/e-text.c,v retrieving revision 1.159 diff -u -r1.159 e-text.c --- gal/e-text/e-text.c 22 Jan 2005 03:44:36 -0000 1.159 +++ gal/e-text/e-text.c 27 Jan 2005 08:14:11 -0000 @@ -68,7 +68,7 @@ #include <libart_lgpl/art_rgb_bitmap_affine.h> #include <atk/atk.h> -#include "gal/a11y/e-text/gal-a11y-e-text-factory.h" +#include "gal/a11y/e-text/gal-a11y-e-text.h" #define PARENT_TYPE (gnome_canvas_item_get_type()) @@ -3700,10 +3700,7 @@ if (!clipboard_atom) clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); - atk_registry_set_factory_type (atk_get_default_registry (), - E_TYPE_TEXT, - gal_a11y_e_text_factory_get_type ()); - + gal_a11y_e_text_init (); } /* Object initialization function for the text item */