Do not dist gir_DATA
[platform/upstream/atk.git] / atk / atkhypertext.c
index 7135aae..c9b123a 100755 (executable)
@@ -1,5 +1,5 @@
 /* ATK - The Accessibility Toolkit for GTK+
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 #include "atkhypertext.h"
 
-struct _AtkHypertextIfaceClass
-{
-  GObjectClass parent;
+enum {
+  LINK_SELECTED,
+  LAST_SIGNAL
 };
 
-typedef struct _AtkHypertextIfaceClass AtkHypertextIfaceClass;
-
-static void atk_hypertext_interface_init (AtkHypertextIfaceClass *klass);
+static void atk_hypertext_base_init (AtkHypertextIface *class);
 
-static gpointer parent_class = NULL;
+static guint atk_hypertext_signals[LAST_SIGNAL] = { 0 };
 
 
 GType
-atk_hypertext_get_type ()
+atk_hypertext_get_type (void)
 {
   static GType type = 0;
 
@@ -40,9 +38,9 @@ atk_hypertext_get_type ()
     static const GTypeInfo tinfo =
     {
       sizeof (AtkHypertextIface),
-      (GBaseInitFunc) NULL,
+      (GBaseInitFunc) atk_hypertext_base_init,
       (GBaseFinalizeFunc) NULL,
-      (GInterfaceInitFunc) atk_hypertext_interface_init,
+
     };
 
     type = g_type_register_static (G_TYPE_INTERFACE, "AtkHypertext", &tinfo, 0);
@@ -52,9 +50,24 @@ atk_hypertext_get_type ()
 }
 
 static void
-atk_hypertext_interface_init (AtkHypertextIfaceClass *klass)
+atk_hypertext_base_init (AtkHypertextIface *class)
 {
-  parent_class = g_type_class_ref (ATK_TYPE_HYPERTEXT);
+  static gboolean initialized = FALSE;
+
+  if (!initialized)
+    {
+      atk_hypertext_signals[LINK_SELECTED] =
+        g_signal_new ("link_selected",
+                      ATK_TYPE_HYPERTEXT,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET (AtkHypertextIface, link_selected),
+                      (GSignalAccumulator) NULL, NULL,
+                      g_cclosure_marshal_VOID__INT,
+                      G_TYPE_NONE,
+                      1, G_TYPE_INT);
+
+      initialized = TRUE;
+    }
 }
 
 /**
@@ -68,15 +81,17 @@ atk_hypertext_interface_init (AtkHypertextIfaceClass *klass)
  * Returns: the link in this hypertext document at
  * index @link_index
  **/
-AtkHyperLink* 
+AtkHyperlink* 
 atk_hypertext_get_link (AtkHypertext  *hypertext,
                         gint          link_index)
 {
   AtkHypertextIface *iface;
 
-  g_return_val_if_fail (hypertext != NULL, NULL);
   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), NULL);
 
+  if (link_index < 0)
+    return NULL;
+
   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
 
   if (iface->get_link)
@@ -98,7 +113,6 @@ atk_hypertext_get_n_links (AtkHypertext  *hypertext)
 {
   AtkHypertextIface *iface;
 
-  g_return_val_if_fail (hypertext != NULL, 0);
   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), 0);
 
   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
@@ -115,10 +129,10 @@ atk_hypertext_get_n_links (AtkHypertext  *hypertext)
  * @char_index: a character index
  *
  * Gets the index into the array of hyperlinks that is associated with
- * the character specified by @cahr_index, or -1 if there is no hyperlink
- * associated with this character.
+ * the character specified by @char_index.
  *
- * Returns: an index into the array of hyperlinks in @hypertext
+ * Returns: an index into the array of hyperlinks in @hypertext,
+ * or -1 if there is no hyperlink associated with this character.
  **/
 gint 
 atk_hypertext_get_link_index (AtkHypertext  *hypertext,
@@ -126,9 +140,11 @@ atk_hypertext_get_link_index (AtkHypertext  *hypertext,
 {
   AtkHypertextIface *iface;
 
-  g_return_val_if_fail (hypertext != NULL, -1);
   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), -1);
 
+  if (char_index < 0)
+    return -1;
+
   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
 
   if (iface->get_link_index)