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	25 Sep 2003 15:38:01 -0000
@@ -19,9 +19,12 @@
 
 #include <gtk/gtk.h>
 #include "gailimage.h"
+#include "gailintl.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);
 
@@ -38,6 +41,111 @@ static gboolean  gail_image_set_image_de
                                                 const gchar     *description);
 static void      gail_image_finalize           (GObject         *object);
                                                          
+static GQuark q_dialog_authentication;
+static GQuark q_dialog_info;
+static GQuark q_dialog_warning;
+static GQuark q_dialog_error;
+static GQuark q_dialog_question;
+static GQuark q_dnd;
+static GQuark q_dnd_multiple;
+static GQuark q_add;
+static GQuark q_apply;
+static GQuark q_bold;
+static GQuark q_cancel;
+static GQuark q_cdrom;
+static GQuark q_clear;
+static GQuark q_close;
+static GQuark q_color_picker;
+static GQuark q_convert;
+static GQuark q_copy;
+static GQuark q_cut;
+static GQuark q_delete;
+static GQuark q_execute;
+static GQuark q_find;
+static GQuark q_find_and_replace;
+static GQuark q_floppy;
+static GQuark q_goto_bottom;
+static GQuark q_goto_first;
+static GQuark q_goto_last;
+static GQuark q_goto_top;
+static GQuark q_go_back;
+static GQuark q_go_down;
+static GQuark q_go_forward;
+static GQuark q_go_up;
+static GQuark q_help;
+static GQuark q_home;
+static GQuark q_index;
+static GQuark q_italic;
+static GQuark q_jump_to;
+static GQuark q_justify_center;
+static GQuark q_justify_fill;
+static GQuark q_justify_left;
+static GQuark q_justify_right;
+static GQuark q_missing_image;
+static GQuark q_new;
+static GQuark q_no;
+static GQuark q_ok;
+static GQuark q_open;
+static GQuark q_paste;
+static GQuark q_preferences;
+static GQuark q_print;
+static GQuark q_print_preview;
+static GQuark q_properties;
+static GQuark q_quit;
+static GQuark q_redo;
+static GQuark q_refresh;
+static GQuark q_remove;
+static GQuark q_revert_to_saved;
+static GQuark q_save;
+static GQuark q_save_as;
+static GQuark q_select_color;
+static GQuark q_select_font;
+static GQuark q_sort_ascending;
+static GQuark q_sort_descending;
+static GQuark q_spell_check;
+static GQuark q_stop;
+static GQuark q_strikethrough;
+static GQuark q_undelete;
+static GQuark q_underline;
+static GQuark q_yes;
+static GQuark q_zoom_100;
+static GQuark q_zoom_fit;
+static GQuark q_zoom_in;
+static GQuark q_zoom_out;
+
+static GQuark q_timer;
+static GQuark q_timer_stop;
+static GQuark q_trash;
+static GQuark q_trash_full;
+static GQuark q_scores;
+static GQuark q_about;
+static GQuark q_blank;
+static GQuark q_volume;
+static GQuark q_midi;
+static GQuark q_mic;
+static GQuark q_line_in;
+static GQuark q_mail;
+static GQuark q_mail_rcv;
+static GQuark q_mail_snd;
+static GQuark q_mail_rpl;
+static GQuark q_mail_fwd;
+static GQuark q_mail_new;
+static GQuark q_attach;
+static GQuark q_book_red;
+static GQuark q_book_green;
+static GQuark q_book_blue;
+static GQuark q_book_yellow;
+static GQuark q_book_open;
+static GQuark q_multiple_file;
+static GQuark q_not;
+static GQuark q_table_borders;
+static GQuark q_table_fill;
+static GQuark q_text_indent;
+static GQuark q_text_unindent;
+static GQuark q_text_bulleted_list;
+static GQuark q_text_numbered_list;
+static GQuark q_authentication;
+
 static gpointer parent_class = NULL;
 
 GType
@@ -82,10 +190,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 +220,369 @@ gail_image_new (GtkWidget *widget)
   accessible->role = ATK_ROLE_ICON;
 
   return accessible;
+}
+
+static void
+init_strings (void)
+{
+  q_dialog_authentication = g_quark_from_static_string ("gtk-dialog-authentication");
+  q_dialog_info = g_quark_from_static_string ("gtk-dialog-info");
+  q_dialog_warning = g_quark_from_static_string ("gtk-dialog-warning");
+  q_dialog_question = g_quark_from_static_string ("gtk-dialog-question");
+  q_dialog_question = g_quark_from_static_string ("gtk-dialog-question");
+  q_dnd = g_quark_from_static_string ("gtk-dialog-dnd");
+  q_dnd_multiple = g_quark_from_static_string ("gtk-dialog-dnd-multiple");
+  q_add = g_quark_from_static_string ("gtk-dialog-add");
+  q_apply = g_quark_from_static_string ("gtk-dialog-apply");
+  q_bold = g_quark_from_static_string ("gtk-dialog-bold");
+  q_cancel = g_quark_from_static_string ("gtk-dialog-cancel");
+  q_cdrom = g_quark_from_static_string ("gtk-dialog-cdrom");
+  q_clear = g_quark_from_static_string ("gtk-dialog-clear");
+  q_close = g_quark_from_static_string ("gtk-dialog-close");
+  q_color_picker = g_quark_from_static_string ("gtk-dialog-color-picker");
+  q_convert = g_quark_from_static_string ("gtk-dialog-convert");
+  q_copy = g_quark_from_static_string ("gtk-dialog-copy");
+  q_cut = g_quark_from_static_string ("gtk-dialog-cut");
+  q_delete = g_quark_from_static_string ("gtk-dialog-delete");
+  q_execute = g_quark_from_static_string ("gtk-dialog-execute");
+  q_find = g_quark_from_static_string ("gtk-dialog-find");
+  q_find_and_replace = g_quark_from_static_string ("gtk-dialog-find-and-replace");
+  q_goto_bottom = g_quark_from_static_string ("gtk-goto-bottom");
+  q_goto_first = g_quark_from_static_string ("gtk-goto-first");
+  q_goto_last = g_quark_from_static_string ("gtk-goto-last");
+  q_goto_top = g_quark_from_static_string ("gtk-goto-top");
+  q_go_back = g_quark_from_static_string ("gtk-go-back");
+  q_go_down = g_quark_from_static_string ("gtk-go-down");
+  q_go_forward = g_quark_from_static_string ("gtk-go-forward");
+  q_go_up = g_quark_from_static_string ("gtk-go-up");
+  q_help = g_quark_from_static_string ("gtk-help");
+  q_home = g_quark_from_static_string ("gtk-home");
+  q_index = g_quark_from_static_string ("gtk-index");
+  q_italic = g_quark_from_static_string ("gtk-italic");
+  q_jump_to = g_quark_from_static_string ("gtk-jump-to");
+  q_justify_center = g_quark_from_static_string ("gtk-justify-center");
+  q_justify_fill = g_quark_from_static_string ("gtk-justify-fill");
+  q_justify_left = g_quark_from_static_string ("gtk-justify-left");
+  q_justify_right = g_quark_from_static_string ("gtk-justify-right");
+  q_missing_image = g_quark_from_static_string ("gtk-missing-image");
+  q_new = g_quark_from_static_string ("gtk-new");
+  q_no = g_quark_from_static_string ("gtk-no");
+  q_ok = g_quark_from_static_string ("gtk-ok");
+  q_open = g_quark_from_static_string ("gtk-open");
+  q_paste = g_quark_from_static_string ("gtk-paste");
+  q_preferences = g_quark_from_static_string ("gtk-preferences");
+  q_print = g_quark_from_static_string ("gtk-print");
+  q_print_preview = g_quark_from_static_string ("gtk-print-preview");
+  q_quit = g_quark_from_static_string ("gtk-quit");
+  q_redo = g_quark_from_static_string ("gtk-redo");
+  q_refresh = g_quark_from_static_string ("gtk-refresh");
+  q_remove = g_quark_from_static_string ("gtk-remove");
+  q_revert_to_saved = g_quark_from_static_string ("gtk-revert-to-saved");
+  q_save = g_quark_from_static_string ("gtk-save");
+  q_save_as = g_quark_from_static_string ("gtk-save-as");
+  q_select_color = g_quark_from_static_string ("gtk-select-color");
+  q_select_font = g_quark_from_static_string ("gtk-select-font");
+  q_sort_ascending = g_quark_from_static_string ("gtk-sort-ascending");
+  q_sort_descending = g_quark_from_static_string ("gtk-sort-descending");
+  q_spell_check = g_quark_from_static_string ("gtk-spell-check");
+  q_stop = g_quark_from_static_string ("gtk-stop");
+  q_strikethrough = g_quark_from_static_string ("gtk-strikethrough");
+  q_undelete = g_quark_from_static_string ("gtk-undelete");
+  q_underline = g_quark_from_static_string ("gtk-underline");
+  q_yes = g_quark_from_static_string ("gtk-yes");
+  q_zoom_100 = g_quark_from_static_string ("gtk-zoom-100");
+  q_zoom_fit = g_quark_from_static_string ("gtk-zoom-fit");
+  q_zoom_in = g_quark_from_static_string ("gtk-zoom-in");
+  q_zoom_out = g_quark_from_static_string ("gtk-zoom-out");
+
+  q_timer = g_quark_from_static_string ("gnome-stock-timer");
+  q_timer_stop = g_quark_from_static_string ("gnome-stock-timer-stop");
+  q_trash = g_quark_from_static_string ("gnome-stock-trash");
+  q_trash_full = g_quark_from_static_string ("gnome-stock-trash-full");
+  q_scores = g_quark_from_static_string ("gnome-stock-scores");
+  q_about = g_quark_from_static_string ("gnome-stock-about");
+  q_blank = g_quark_from_static_string ("gnome-stock-blank");
+  q_volume = g_quark_from_static_string ("gnome-stock-volume");
+  q_midi = g_quark_from_static_string ("gnome-stock-midi");
+  q_mic = g_quark_from_static_string ("gnome-stock-mic");
+  q_line_in = g_quark_from_static_string ("gnome-stock-line-in");
+  q_mail = g_quark_from_static_string ("gnome-stock-mail");
+  q_mail_rcv = g_quark_from_static_string ("gnome-stock-mail-rcv");
+  q_mail_snd = g_quark_from_static_string ("gnome-stock-mail-snd");
+  q_mail_rpl = g_quark_from_static_string ("gnome-stock-mail-rpl");
+  q_mail_fwd = g_quark_from_static_string ("gnome-stock-mail-fwd");
+  q_mail_new = g_quark_from_static_string ("gnome-stock-mail-new");
+  q_attach = g_quark_from_static_string ("gnome-stock-attach");
+  q_book_red = g_quark_from_static_string ("gnome-stock-book-red");
+  q_book_green = g_quark_from_static_string ("gnome-stock-book-green");
+  q_book_blue = g_quark_from_static_string ("gnome-stock-book-blue");
+  q_book_yellow = g_quark_from_static_string ("gnome-stock-book-yellow");
+  q_book_open = g_quark_from_static_string ("gnome-stock-book-open");
+  q_multiple_file = g_quark_from_static_string ("gnome-stock-multiple-file");
+  q_no = g_quark_from_static_string ("gnome-stock-no");
+  q_table_borders = g_quark_from_static_string ("gnome-stock-table-borders");
+  q_table_fill = g_quark_from_static_string ("gnome-stock-table-fill");
+  q_text_indent = g_quark_from_static_string ("gnome-stock-text-indent");
+  q_text_unindent = g_quark_from_static_string ("gnome-stock-text-unindent");
+  q_text_bulleted_list = g_quark_from_static_string ("gnome-stock-text-bulleted-list");
+  q_text_numbered_list = g_quark_from_static_string ("gnome-stock-text-numbered-list");
+  q_authentication = g_quark_from_static_string ("gnome-stock-authentication");
+}
+
+static G_CONST_RETURN gchar*
+get_localized_name (const gchar *str)
+{
+  GQuark str_q;
+  G_CONST_RETURN gchar *name;
+  static gboolean gettext_initialized = FALSE;
+
+  if (!gettext_initialized)
+    {
+      init_strings ();
+      gettext_initialized = TRUE;
+#ifdef ENABLE_NLS
+      bindtextdomain (GETTEXT_PACKAGE, GAILLOCALEDIR);
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+      bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+#endif
+    }
+
+  str_q = g_quark_try_string (str);
+  if (str_q == q_dialog_authentication)
+    name = _("dialog-authentication");
+  else if (str_q == q_dialog_info)
+    name = _("dialog-info");
+  else if (str_q == q_dialog_warning)
+    name = _("dialog-warning");
+  else if (str_q == q_dialog_error)
+    name = _("dialog-error");
+  else if (str_q == q_dialog_error)
+    name = _("dialog-question");
+  else if (str_q == q_dnd)
+    name = _("dnd");
+  else if (str_q == q_dnd_multiple)
+    name = _("dnd-multiple");
+  else if (str_q == q_add)
+    name = _("add");
+  else if (str_q == q_apply)
+    name = _("apply");
+  else if (str_q == q_bold)
+    name = _("bold");
+  else if (str_q == q_cancel)
+    name = _("cancel");
+  else if (str_q == q_cdrom)
+    name = _("cdrom");
+  else if (str_q == q_clear)
+    name = _("clear");
+  else if (str_q == q_close)
+    name = _("close");
+  else if (str_q == q_color_picker)
+    name = _("color-picker");
+  else if (str_q == q_convert)
+    name = _("convert");
+  else if (str_q == q_copy)
+    name = _("copy");
+  else if (str_q == q_cut)
+    name = _("cut");
+  else if (str_q == q_delete)
+    name = _("delete");
+  else if (str_q == q_execute)
+    name = _("execute");
+  else if (str_q == q_execute)
+    name = _("execute");
+  else if (str_q == q_find)
+    name = _("find");
+  else if (str_q == q_find_and_replace)
+    name = _("find-and-replace");
+  else if (str_q == q_floppy)
+    name = _("floppy");
+  else if (str_q == q_goto_bottom)
+    name = _("goto-bottom");
+  else if (str_q == q_goto_first)
+    name = _("goto-first");
+  else if (str_q == q_goto_last)
+    name = _("goto-last");
+  else if (str_q == q_goto_top)
+    name = _("goto-top");
+  else if (str_q == q_go_back)
+    name = _("go-back");
+  else if (str_q == q_go_down)
+    name = _("go-down");
+  else if (str_q == q_go_forward)
+    name = _("go-forward");
+  else if (str_q == q_go_up)
+    name = _("go-up");
+  else if (str_q == q_help)
+    name = _("help");
+  else if (str_q == q_home)
+    name = _("home");
+  else if (str_q == q_index)
+    name = _("index");
+  else if (str_q == q_italic)
+    name = _("italic");
+  else if (str_q == q_jump_to)
+    name = _("jump-to");
+  else if (str_q == q_justify_center)
+    name = _("justify-center");
+  else if (str_q == q_justify_fill)
+    name = _("justify-fill");
+  else if (str_q == q_justify_left)
+    name = _("justify-left");
+  else if (str_q == q_justify_right)
+    name = _("justify-right");
+  else if (str_q == q_missing_image)
+    name = _("missing-image");
+  else if (str_q == q_new)
+    name = _("new");
+  else if (str_q == q_no)
+    name = _("no");
+  else if (str_q == q_ok)
+    name = _("ok");
+  else if (str_q == q_open)
+    name = _("open");
+  else if (str_q == q_paste)
+    name = _("paste");
+  else if (str_q == q_preferences)
+    name = _("preferences");
+  else if (str_q == q_print)
+    name = _("print");
+  else if (str_q == q_print_preview)
+    name = _("print-preview");
+  else if (str_q == q_quit)
+    name = _("quit");
+  else if (str_q == q_redo)
+    name = _("redo");
+  else if (str_q == q_refresh)
+    name = _("refresh");
+  else if (str_q == q_remove)
+    name = _("remove");
+  else if (str_q == q_revert_to_saved)
+    name = _("revert-to-saved");
+  else if (str_q == q_save)
+    name = _("save");
+  else if (str_q == q_save_as)
+    name = _("save_as");
+  else if (str_q == q_select_color)
+    name = _("select-color");
+  else if (str_q == q_select_font)
+    name = _("select-font");
+  else if (str_q == q_sort_ascending)
+    name = _("sort-ascending");
+  else if (str_q == q_sort_descending)
+    name = _("sort-descending");
+  else if (str_q == q_spell_check)
+    name = _("spell-check");
+  else if (str_q == q_stop)
+    name = _("stop");
+  else if (str_q == q_strikethrough)
+    name = _("strikethrough");
+  else if (str_q == q_undelete)
+    name = _("undelete");
+  else if (str_q == q_underline)
+    name = _("underline");
+  else if (str_q == q_yes)
+    name = _("yes");
+  else if (str_q == q_zoom_100)
+    name = _("zoom-100");
+  else if (str_q == q_zoom_fit)
+    name = _("zoom-fit");
+  else if (str_q == q_zoom_in)
+    name = _("zoom-in");
+  else if (str_q == q_zoom_out)
+    name = _("zoom-out");
+  else if (str_q == q_timer)
+    name = _("timer");
+  else if (str_q == q_timer_stop)
+    name = _("timer-stop");
+  else if (str_q == q_trash)
+    name = _("trash");
+  else if (str_q == q_trash_full)
+    name = _("trash-full");
+  else if (str_q == q_scores)
+    name = _("scores");
+  else if (str_q == q_about)
+    name = _("about");
+  else if (str_q == q_blank)
+    name = _("blank");
+  else if (str_q == q_volume)
+    name = _("volume");
+  else if (str_q == q_midi)
+    name = _("midi");
+  else if (str_q == q_mic)
+    name = _("mic");
+  else if (str_q == q_line_in)
+    name = _("line-in");
+  else if (str_q == q_mail)
+    name = _("mail");
+  else if (str_q == q_mail_rcv)
+    name = _("mail-receive");
+  else if (str_q == q_mail_snd)
+    name = _("mail-send");
+  else if (str_q == q_mail_rpl)
+    name = _("mail-reply");
+  else if (str_q == q_mail_fwd)
+    name = _("mail-forward");
+  else if (str_q == q_attach)
+    name = _("attach");
+  else if (str_q == q_book_red)
+    name = _("book-red");
+  else if (str_q == q_book_green)
+    name = _("book-green");
+  else if (str_q == q_book_blue)
+    name = _("book-blue");
+  else if (str_q == q_book_yellow)
+    name = _("book-yellow");
+  else if (str_q == q_book_open)
+    name = _("book-open");
+  else if (str_q == q_multiple_file)
+    name = _("multiple-file");
+  else if (str_q == q_not)
+    name = _("not");
+  else if (str_q == q_table_borders)
+    name = _("table-borders");
+  else if (str_q == q_table_fill)
+    name = _("table-fill");
+  else if (str_q == q_text_indent)
+    name = _("text-indent");
+  else if (str_q == q_text_unindent)
+    name = _("text-unindent");
+  else if (str_q == q_text_bulleted_list)
+    name = _("text-bulleted-list");
+  else if (str_q == q_text_numbered_list)
+    name = _("text-numbered-list");
+  else if (str_q == q_authentication)
+    name = _("authentication");
+  else 
+    name = str;
+
+  return name;
+}
+
+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)
+        return get_localized_name (image->data.stock.stock_id); 
+      else return NULL;
+    }
 }
 
 static void
