Index: gailimage.c
===================================================================
RCS file: /cvs/gnome/gail/gail/gailimage.c,v
retrieving revision 1.18
diff -u -p -r1.18 gailimage.c
--- gailimage.c	13 May 2002 14:00:47 -0000	1.18
+++ gailimage.c	24 Sep 2003 09:03:03 -0000
@@ -17,11 +17,15 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <strings.h>
+
 #include <gtk/gtk.h>
 #include "gailimage.h"
 
 static void      gail_image_class_init         (GailImageClass *klass);
 static void      gail_image_object_init        (GailImage      *image);
+static G_CONST_RETURN gchar* gail_image_get_name  (AtkObject     *accessible);
+
 
 static void      atk_image_interface_init      (AtkImageIface  *iface);
 
@@ -82,10 +86,12 @@ static void
 gail_image_class_init (GailImageClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  AtkObjectClass  *class = ATK_OBJECT_CLASS (klass);
 
   parent_class = g_type_class_peek_parent (klass);
 
   gobject_class->finalize = gail_image_finalize;
+  class->get_name = gail_image_get_name;
 }
 
 static void
@@ -110,6 +116,39 @@ gail_image_new (GtkWidget *widget)
   accessible->role = ATK_ROLE_ICON;
 
   return accessible;
+}
+
+static G_CONST_RETURN gchar*
+gail_image_get_name (AtkObject *accessible)
+{
+  if (accessible->name)
+    return accessible->name;
+  else
+    {
+      GtkWidget* widget = GTK_ACCESSIBLE (accessible)->widget;
+      GtkImage *image;
+
+      if (widget == NULL)
+        /*
+         * State is defunct
+         */
+        return NULL;
+
+      g_return_val_if_fail (GTK_IS_IMAGE (widget), NULL);
+      image = GTK_IMAGE (widget);
+
+      if (image->storage_type == GTK_IMAGE_STOCK &&
+          image->data.stock.stock_id)
+        {
+          if (!strncmp (image->data.stock.stock_id, "gtk-", 4))
+            return image->data.stock.stock_id + 4; 
+          else if (!strncmp (image->data.stock.stock_id, "gnome-stock-", 12))
+            return image->data.stock.stock_id + 12; 
+          else
+            return image->data.stock.stock_id;
+        }
+      else return NULL;
+    }
 }
 
 static void
