/ghex-3.5.2/src/factory.c

# · C · 65 lines · 28 code · 10 blank · 27 comment · 2 complexity · 034152de3a15349f80d248d4acd6bd05 MD5 · raw file

  1. /* Copyright 2002 Sun Microsystems Inc.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. */
  18. #include "factory.h"
  19. static gboolean is_gail_loaded (GType derived_type);
  20. void
  21. setup_factory (void)
  22. {
  23. AtkRegistry* default_registry;
  24. GType derived_type;
  25. /*
  26. * set up the factory only if GAIL is loaded.
  27. */
  28. derived_type = g_type_parent (GTK_TYPE_HEX);
  29. if (is_gail_loaded (derived_type))
  30. {
  31. /* create the factory */
  32. default_registry = atk_get_default_registry();
  33. atk_registry_set_factory_type (default_registry,
  34. GTK_TYPE_HEX,
  35. ACCESSIBLE_TYPE_GTK_HEX_FACTORY);
  36. }
  37. }
  38. /*
  39. * This function checks if GAIL is loaded or not,
  40. * given the parent type.
  41. * It should be called from the application only
  42. * after gnome_program_init() is called.
  43. */
  44. static gboolean
  45. is_gail_loaded (GType derived_type)
  46. {
  47. AtkObjectFactory *factory;
  48. GType derived_atk_type;
  49. factory = atk_registry_get_factory (atk_get_default_registry(),
  50. derived_type);
  51. derived_atk_type = atk_object_factory_get_accessible_type (factory);
  52. if (g_type_is_a (derived_atk_type, GTK_TYPE_ACCESSIBLE))
  53. return TRUE;
  54. return FALSE;
  55. }