From 8b2ba203b1a537a2ad9509008f7221ac3253b2ad Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sun, 8 Jan 2006 14:01:14 +0000 Subject: [PATCH] src/gnome-utils/gnc-main-window.c: Add gnc workaround function for errorneous gtk_action_group_set_translation_domain. Fixes the statusbar-tooltip error mentioned on 2006-01-07. Filed in gtk as bug#326200. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12295 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 7 ++++ src/gnome-utils/gnc-embedded-window.c | 2 +- src/gnome-utils/gnc-main-window.c | 36 +++++++++++++++++++-- src/gnome-utils/gnc-main-window.h | 22 +++++++++++++ src/gnome-utils/gnc-plugin-menu-additions.c | 2 +- src/gnome-utils/gnc-plugin-page.c | 2 +- 6 files changed, 66 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f92c4db9d..7984654273 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-01-08 Christian Stimming + + * src/gnome-utils/gnc-main-window.c: Add gnc workaround function + for errorneous gtk_action_group_set_translation_domain. Fixes the + statusbar-tooltip error mentioned on 2006-01-07. Filed in gtk as + bug#326200. + 2006-01-07 David Hampton * src/report/standard-reports/account-summary.scm: Copy the table diff --git a/src/gnome-utils/gnc-embedded-window.c b/src/gnome-utils/gnc-embedded-window.c index 279d0f555e..db087fec3e 100644 --- a/src/gnome-utils/gnc-embedded-window.c +++ b/src/gnome-utils/gnc-embedded-window.c @@ -369,7 +369,7 @@ gnc_embedded_window_new (const gchar *action_group_name, /* Create menu and toolbar information */ priv->action_group = gtk_action_group_new (action_group_name); - gtk_action_group_set_translation_domain(priv->action_group, GETTEXT_PACKAGE); + gnc_gtk_action_group_set_translation_domain(priv->action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (priv->action_group, action_entries, n_action_entries, user_data); gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0); diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c index 621c780672..528f31e0d6 100644 --- a/src/gnome-utils/gnc-main-window.c +++ b/src/gnome-utils/gnc-main-window.c @@ -2158,7 +2158,7 @@ gnc_main_window_merge_actions (GncMainWindow *window, priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); entry = g_new0 (MergedActionEntry, 1); entry->action_group = gtk_action_group_new (group_name); - gtk_action_group_set_translation_domain (entry->action_group, GETTEXT_PACKAGE); + gnc_gtk_action_group_set_translation_domain (entry->action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (entry->action_group, actions, n_actions, data); gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0); entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error); @@ -2466,7 +2466,7 @@ gnc_main_window_setup_window (GncMainWindow *window) /* Create menu and toolbar information */ priv->action_group = gtk_action_group_new ("MainWindowActions"); - gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE); + gnc_gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (priv->action_group, gnc_menu_actions, gnc_menu_n_actions, window); gtk_action_group_add_toggle_actions (priv->action_group, @@ -3270,5 +3270,37 @@ gnc_main_window_button_press_cb (GtkWidget *whatever, } +/* CS: Code copied from gtk/gtkactiongroup.c */ +static gchar * +dgettext_swapped (const gchar *msgid, + const gchar *domainname) +{ + /* CS: Pass this through dgettext if and only if msgid is + nonempty. */ + return (msgid && *msgid) ? dgettext (domainname, msgid) : (gchar*) msgid; +} + +/* + * This is copied into GnuCash from Gtk in order to fix problems when + * empty msgids were passed through gettext(). + * + * See http://bugzilla.gnome.org/show_bug.cgi?id=326200 . If that bug + * is fixed in the gtk that we can rely open, then + * gnc_gtk_action_group_set_translation_domain can be replaced by + * gtk_action_group_set_translation_domain again. + */ +void +gnc_gtk_action_group_set_translation_domain (GtkActionGroup *action_group, + const gchar *domain) +{ + g_return_if_fail (GTK_IS_ACTION_GROUP (action_group)); + + gtk_action_group_set_translate_func (action_group, + (GtkTranslateFunc)dgettext_swapped, + g_strdup (domain), + g_free); +} +/* CS: End of code copied from gtk/gtkactiongroup.c */ + /** @} */ /** @} */ diff --git a/src/gnome-utils/gnc-main-window.h b/src/gnome-utils/gnc-main-window.h index a40b8d53cc..1ec58e55f3 100644 --- a/src/gnome-utils/gnc-main-window.h +++ b/src/gnome-utils/gnc-main-window.h @@ -273,6 +273,28 @@ void gnc_main_window_set_progressbar_window( GncMainWindow *window ); gboolean gnc_main_window_button_press_cb (GtkWidget *whatever, GdkEventButton *event, GncPluginPage *page); + +/** + * gnc_gtk_action_group_set_translation_domain: + * @action_group: a #GtkActionGroup + * @domain: the translation domain to use for dgettext() calls + * + * Sets the translation domain and uses dgettext() for translating the + * @label and @tooltip of #GtkActionEntrys added by + * gtk_action_group_add_actions(). + * + * This is copied from gtk's gtk_action_group_set_translation_domain() + * into GnuCash in order to fix problems when empty msgids were passed + * through gettext(). + * + * See http://bugzilla.gnome.org/show_bug.cgi?id=326200 . If that bug + * is fixed in the gtk that we can rely open, then + * gnc_gtk_action_group_set_translation_domain can be replaced by + * gtk_action_group_set_translation_domain again. + **/ +void +gnc_gtk_action_group_set_translation_domain (GtkActionGroup *action_group, + const gchar *domain); G_END_DECLS #endif /* __GNC_MAIN_WINDOW_H */ diff --git a/src/gnome-utils/gnc-plugin-menu-additions.c b/src/gnome-utils/gnc-plugin-menu-additions.c index a6cd2533b3..fd8b1c0d4e 100644 --- a/src/gnome-utils/gnc-plugin-menu-additions.c +++ b/src/gnome-utils/gnc-plugin-menu-additions.c @@ -438,7 +438,7 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, per_window.window = window; per_window.ui_manager = window->ui_merge; per_window.group = gtk_action_group_new ("MenuAdditions" ); - gtk_action_group_set_translation_domain (per_window.group, GETTEXT_PACKAGE); + gnc_gtk_action_group_set_translation_domain (per_window.group, GETTEXT_PACKAGE); per_window.merge_id = gtk_ui_manager_new_merge_id(window->ui_merge); gtk_ui_manager_insert_action_group(window->ui_merge, per_window.group, 0); diff --git a/src/gnome-utils/gnc-plugin-page.c b/src/gnome-utils/gnc-plugin-page.c index 3a92750d83..608b019660 100644 --- a/src/gnome-utils/gnc-plugin-page.c +++ b/src/gnome-utils/gnc-plugin-page.c @@ -913,7 +913,7 @@ gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_nam priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); group = gtk_action_group_new(group_name); - gtk_action_group_set_translation_domain(group, GETTEXT_PACKAGE); + gnc_gtk_action_group_set_translation_domain(group, GETTEXT_PACKAGE); priv->action_group = group; return group; }