From 7331de667a3f6e9dd3e5f719ac744e70b3ab8ef8 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 8 Oct 2019 16:43:19 -0300 Subject: [PATCH] Adding i18n support on the new toolbar. --- src/widgets/toolbar/core.c | 36 +++++++++++++++++------------------- src/widgets/toolbar/private.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/widgets/toolbar/toolbar.cbp | 1 + 3 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 src/widgets/toolbar/private.h diff --git a/src/widgets/toolbar/core.c b/src/widgets/toolbar/core.c index 2a35647..e4e31e5 100644 --- a/src/widgets/toolbar/core.c +++ b/src/widgets/toolbar/core.c @@ -27,9 +27,7 @@ * */ - #include - #include - #include + #include "private.h" static gboolean popup_context_menu(GtkToolbar *toolbar, gint x, gint y, gint button_number); static void finalize(GObject *object); @@ -103,24 +101,24 @@ } itens[] = { { - .label = "Default" + .label = N_( "Default" ) }, { - .label = "Small", + .label = N_( "Small" ), .icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR }, { - .label = "Large", + .label = N_( "Large" ), .icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR }, }; size_t ix; - GtkWidget * item = gtk_menu_item_new_with_mnemonic("Icon _size"); + GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("Icon _size") ); gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); GtkWidget * submenu = gtk_menu_new(); @@ -128,7 +126,7 @@ for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { - item = gtk_menu_item_new_with_mnemonic(itens[ix].label); + item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); if(ix > 0) g_object_set_data(G_OBJECT(item),"icon_size", (gpointer) &itens[ix].icon_size); @@ -149,28 +147,28 @@ } itens[] = { { - .label = "Default" + .label = N_( "Default" ) }, { - .label = "Icons only", + .label = N_( "Icons only" ), .style = GTK_TOOLBAR_ICONS }, { - .label = "Text only", + .label = N_( "Text only" ), .style = GTK_TOOLBAR_TEXT }, { - .label = "Icons & text", + .label = N_( "Icons & text" ), .style = GTK_TOOLBAR_BOTH }, }; size_t ix; - GtkWidget * item = gtk_menu_item_new_with_mnemonic("S_tyle"); + GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("S_tyle") ); gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); GtkWidget * submenu = gtk_menu_new(); @@ -178,7 +176,7 @@ for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { - item = gtk_menu_item_new_with_mnemonic(itens[ix].label); + item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); if(ix > 0) g_object_set_data(G_OBJECT(item),"toolbar_style", (gpointer) &itens[ix].style); @@ -215,29 +213,29 @@ g_return_val_if_fail(GTK_IS_TOOLBAR(toolbar),NULL); if(!action) { - g_message("Invalid action identifier"); + g_message(_("Invalid action identifier")); return NULL; } if(!action->icon) { - g_message("Action \"%s\" doesn't have an icon", action->name); + g_message(_("Action \"%s\" doesn't have an icon"), action->name); return NULL; } if(!action->label) { - g_message("Action \"%s\" doesn't have a label", action->name); + g_message(_("Action \"%s\" doesn't have a label"), action->name); return NULL; } debug("Action: %s icon: %s", action->name, action->icon); - GtkToolItem * item = gtk_tool_button_new(gtk_image_new_from_icon_name(action->icon,GTK_ICON_SIZE_LARGE_TOOLBAR),action->label); + GtkToolItem * item = gtk_tool_button_new(gtk_image_new_from_icon_name(action->icon,GTK_ICON_SIZE_LARGE_TOOLBAR),gettext(action->label)); gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item),TRUE); gtk_widget_set_name(GTK_WIDGET(item), action->name); if(action->summary) - gtk_tool_item_set_tooltip_text(item,action->summary); + gtk_tool_item_set_tooltip_text(item,gettext(action->summary)); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); diff --git a/src/widgets/toolbar/private.h b/src/widgets/toolbar/private.h new file mode 100644 index 0000000..f73c20c --- /dev/null +++ b/src/widgets/toolbar/private.h @@ -0,0 +1,47 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +#ifndef PRIVATE_H_INCLUDED + + #define PRIVATE_H_INCLUDED + + #include + + #ifndef GETTEXT_PACKAGE + #define GETTEXT_PACKAGE PACKAGE_NAME + #endif + + #include + #include + #include + + #include + #include + +#endif // PRIVATE_H_INCLUDED diff --git a/src/widgets/toolbar/toolbar.cbp b/src/widgets/toolbar/toolbar.cbp index 5df87bc..f9d0801 100644 --- a/src/widgets/toolbar/toolbar.cbp +++ b/src/widgets/toolbar/toolbar.cbp @@ -42,6 +42,7 @@ + -- libgit2 0.21.2