GNOME Bugzilla – Bug 504246
use the stock item's label in gailimage
Last modified: 2007-12-20 00:47:09 UTC
(There's no 'gail' component yet, filing in 'general'.) gailimage.c has its own table of strings to use for stock images, but the strings are identical to the stock item's label except they're all-lowercase and without mnemonics. I think we should remove that, and just use the stock item label, stripping the mnemonic like we do in the toolbar code (I don't think the lowercase matters?).
Yes, please.
Created attachment 101190 [details] [review] proposed patch Turns out not all labels were /exactly/ the same as the stock item label: Stock item "gtk-dialog-info" gailimage.c "dialog information" transformed stock label "information" Stock item "gtk-dialog-warning" gailimage.c "dialog warning" transformed stock label "warning" Stock item "gtk-dialog-error" gailimage.c "dialog error" transformed stock label "error" Stock item "gtk-dialog-question" gailimage.c "dialog question" transformed stock label "question" Stock item "gtk-cdrom" gailimage.c "cdrom" transformed stock label "cd-rom" Stock item "gtk-goto-bottom" gailimage.c "go to bottom" transformed stock label "bottom" Stock item "gtk-goto-first" gailimage.c "go to first" transformed stock label "first" Stock item "gtk-goto-last" gailimage.c "go to last" transformed stock label "last" Stock item "gtk-goto-top" gailimage.c "go to top" transformed stock label "top" Stock item "gtk-go-back" gailimage.c "go back" transformed stock label "back" Stock item "gtk-go-down" gailimage.c "go down" transformed stock label "down" Stock item "gtk-go-forward" gailimage.c "go forward" transformed stock label "forward" Stock item "gtk-go-up" gailimage.c "go up" transformed stock label "up" Stock item "gtk-justify-center" gailimage.c "justify center" transformed stock label "center" Stock item "gtk-justify-fill" gailimage.c "justify fill" transformed stock label "fill" Stock item "gtk-justify-left" gailimage.c "justify left" transformed stock label "left" Stock item "gtk-justify-right" gailimage.c "justify right" transformed stock label "right" Stock item "gtk-revert-to-saved" gailimage.c "revert to saved" transformed stock label "revert" Stock item "gtk-select-color" gailimage.c "select color" transformed stock label "color" Stock item "gtk-select-font" gailimage.c "select font" transformed stock label "font" Stock item "gtk-sort-ascending" gailimage.c "sort ascending" transformed stock label "ascending" Stock item "gtk-sort-descending" gailimage.c "sort descending" transformed stock label "descending" Stock item "gtk-zoom-100" gailimage.c "zoom 100 percent" transformed stock label "normal size" Stock item "gtk-zoom-fit" gailimage.c "zoom fit" transformed stock label "best fit" And there were a few stock IDs present in the gailimage table which gtk_stock_lookup doesn't find: Stock item "gtk-dnd" not found Stock item "gtk-dnd-multiple" not found Stock item "gtk-color-picker" not found Stock item "gtk-missing-image" not found [+ many of the "gnome-*" stock icons] I think I still prefer this patch, since it will also work with the stock items that programmes define themselves.
The one problem is that atk_object_get_name returns |const char*| while I have a to-be-freed string when I take the stock item's label and transform it. Setting it back with atk_object_set_name works, but then the image doesn't change name when the stock ID changes...
instead of calling atk_object_set_name, you could keep the modified string in private, and update it when the stock id changes.
Alternatively, intern the string
Created attachment 101213 [details] [review] updated patch
so, this stores the name in the accessible, but still reconstructs it every time ? that seems a bit wasteful. i guess with a bit more work, we could return the stored name instead.
Yes, I only store it because I need to return a const string, so I always reconstruct it to get the up-to-date string (stock ID change). The alternative would be to listen to notify::stock and update the string there... I wasn't sure the minor speedup of atk_object_get_name is worth a signal connection.
Yeah, lets not worry about that for now.
* modules/other/gail/Makefile.am: * modules/other/gail/gailimage.c: (gail_image_class_init), (gail_image_init), (elide_underscores), (gail_image_get_name), (atk_image_interface_init), (gail_image_finalize): * modules/other/gail/gailimage.h: R modules/other/gail/gailintl.h: * po/POTFILES.skip: Use the stock item's label as the name of the accessible in gailimage.c. Bug #504246.