Re: gettext and gtk_item_factory_create_items



Ayose <zubzet yahoo es> writes:

Hi people.

Can I use gettext with gtk_item_factory_create_items ?

For instance, I have this menu:

static GtkItemFactoryEntry menu_items[] = {
{ "/_File",         NULL,         NULL, 0, "<Branch>",    NULL },
{ "/File/_New",     "<control>N", NULL, 0, "<StockItem>", GTK_STOCK_NEW},
{ "/File/_Open",    "<control>O", NULL, 0, "<StockItem>", GTK_STOCK_OPEN},
{ "/File/_Save",    "<control>S", NULL, 0, "<StockItem>", GTK_STOCK_SAVE},
[...]

And then I call

      gtk_item_factory_create_items (item_factory, 
              sizeof(menu_items)/sizeof(menu_items[0]), 
              menu_items,
              NULL);

The function works well, but I want to use gettext with every menu
entry. If I type something like

#define _(s) gettext(s)

[...]

{ _("/_File"),         NULL,         NULL, 0, "<Branch>",    NULL },
{ _("/File/_New"),     "<control>N", NULL, 0, "<StockItem>", GTK_STOCK_NEW},
[...]

I get the error:

gui.c:22: initializer element is not constant
gui.c:22: (near initialization for `menu_items[0].path')
[...]


Is there some smart way for using gettext here?

void   gtk_item_factory_set_translate_func (GtkItemFactory      *ifactory,
                                            GtkTranslateFunc     func,
                                            gpointer             data,
                                            GtkDestroyNotify     notify);

What you do is mark your items with N_(), and then make your translate
func call gettext() on them.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]