On Mon, 2017-07-17 at 12:32 +0300, Igor Chetverovod wrote:
> Hi all, I have a need to switch locale on the fly (without  an
> application
> UI reload).
> I  have a function which are using gkt_container_forall()  for
> marking of
> all widgets are having GObject property "label" ,  all of them get
> aditional GObject field  "msg_id" with original english text of
> property
> "label").   When user press the button "Change locale"  function
> iterates
> through all children of  the main window and reads thier marks
> "msg_id"
> added before and uses them as a parameter for get_text() to
> get  translated
> version of the label.  And it sets  localized text of every label by
> function g_object_set(). Function works good for all widgets in my
> application. But there is exclusion - GtkMenuItems widgets. Function
>  gkt_container_forall() iterates trough them only once - at the
> "marking"
> phase. In "change locale" phase it does not iterate them. It
> translates
> only top level of GtkMenuBar, but does not GtkMenuItems and
> GtkCheckMenuItems.
> 
> Fuction gtk_container_foreach () givese the same results.
> 
> Is there method to solve this issue by gtk-functions?
> 
> I am using gtk3.22.1 for Windows7.

Hi Igor,

Translating the UI on the fly is something I have wanted for many
years, and would be awesome to have real support for :)

That said, using your current 'hack' (which seems a bit dangerous as it
makes assumptions about "label" properties on widgets and their
meaning), you are just missing some special cases to traverse through
the UI.

For this case, you can probably get away with somthing like the
following inserted into your recursive widget crawling loop:

  if (GTK_IS_MENU_ITEM(widget))
     child = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget))

https://developer.gnome.org/gtk3/stable/GtkMenuItem.html#gtk-menu-item-get-submenu


Cheers,
    -Tristan

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to