GNOME Bugzilla – Bug 509153
Menu items don't get translated when using GtkBuilder
Last modified: 2008-01-21 16:11:30 UTC
Please describe the problem: In a application of mine I've used Glade to generate the GUI. Now with GTK 2.12, I've decided to switch to GtkBuilder. First of all, I've run the 'gtk-builder-convert' script which is bundled with GTK to transform the Glade file to a GtkBuilder file. In the original glade file there is a GtkMenuBar containing some GtkMenuItem's. All the labels of the GtkMenuItem's are marked with the 'translatable="yes"' property. Now with GtkBuilder, the GtkMenuBar and the GtkMenuItem's are transformed into a GtkUIManager containing GtkAction's. However, when I start my program using the GtkBuilder, the menu items don't get translated, while they were translated just fine when using Glade. Here is a snippet from my Glade file: <widget class="GtkMenuBar" id="menubar1"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <child> <widget class="GtkMenuItem" id="menuitem1"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">_File</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="menu1"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <child> <widget class="GtkImageMenuItem" id="imagemenuitem5"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">gtk-quit</property> <property name="use_underline">True</property> <property name="use_stock">True</property> <signal name="activate" handler="on_btnQuit_clicked"/> </widget> </child> </widget> </child> </widget> </child> <child> <widget class="GtkMenuItem" id="menuitem2"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">Debug</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="menu2"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <child> <widget class="GtkMenuItem" id="menuitem3"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">Show debug window</property> <property name="use_underline">True</property> <signal name="activate" handler="on_btnShowDebug_clicked"/> </widget> </child> </widget> </child> </widget> </child> </widget> Which gets translated to the GtkBuilder format: <object class="GtkUIManager" id="uimanager1"> <child> <object class="GtkActionGroup" id="actiongroup1"> <child> <object class="GtkAction" id="menuitem1"> <property name="name">menuitem1</property> <property name="label">_File</property> </object> </child> <child> <object class="GtkAction" id="imagemenuitem5"> <property name="stock_id">gtk-quit</property> <property name="name">imagemenuitem5</property> <signal handler="on_btnQuit_clicked" name="activate"/> </object> </child> <child> <object class="GtkAction" id="menuitem2"> <property name="name">menuitem2</property> <property name="label">Debug</property> </object> </child> <child> <object class="GtkAction" id="menuitem3"> <property name="name">menuitem3</property> <property name="label">Show debug window</property> <signal handler="on_btnShowDebug_clicked" name="activate"/> </object> </child> </object> </child> <ui> <menubar name="menubar1"> <menu action="menuitem1"> <menuitem action="imagemenuitem5"/> </menu> <menu action="menuitem2"> <menuitem action="menuitem3"/> </menu> </menubar> </ui> </object> Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
A bug in the script, context and translatable needs to be picked up when converting menuitems to actions.
Committed to trunk and gtk-2-12 branch: 2008-01-18 Johan Dahlin <johan@gnome.org> * gtk/gtk-builder-convert (get_property_node): New method (GtkBuilderConverter._create_object): Conditionally take a node as a property value, so don't lose translate/context attributes if they are set. (GtkBuilderConverter._add_action_from_menuitem): Send in Node as property values instead of strings. (#509153, Erik van Pienbroek)
*** Bug 510979 has been marked as a duplicate of this bug. ***