added a "const gchar *textdomain" parameter so g_object_[set|get]_data()

2002-09-25  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpitemfactory.[ch] (gimp_item_factory_create_item):
	added a "const gchar *textdomain" parameter so
	g_object_[set|get]_data() hacks needed for translation are private
	stuff of GimpItemFactory. Use more qdata instead of just data,
	minor cleanup.

	* app/gui/plug-in-menus.c: pass the textdomain as paramater
	instead of g_object_setting it on the item_factory.

	* app/gui/file-open-dialog.c
	* app/gui/file-save-dialog.c
	* app/gui/menus.c: pass NULL as textdomain.
This commit is contained in:
Michael Natterer 2002-09-25 10:39:41 +00:00 committed by Michael Natterer
parent 323dc086b2
commit 80357a00c0
11 changed files with 61 additions and 24 deletions

View File

@ -1,3 +1,18 @@
2002-09-25 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpitemfactory.[ch] (gimp_item_factory_create_item):
added a "const gchar *textdomain" parameter so
g_object_[set|get]_data() hacks needed for translation are private
stuff of GimpItemFactory. Use more qdata instead of just data,
minor cleanup.
* app/gui/plug-in-menus.c: pass the textdomain as paramater
instead of g_object_setting it on the item_factory.
* app/gui/file-open-dialog.c
* app/gui/file-save-dialog.c
* app/gui/menus.c: pass NULL as textdomain.
2002-09-25 Michael Natterer <mitch@gimp.org> 2002-09-25 Michael Natterer <mitch@gimp.org>
* libgimp/Makefile.am: install gimpcompat.h * libgimp/Makefile.am: install gimpcompat.h

View File

@ -150,6 +150,7 @@ file_open_dialog_menu_init (Gimp *gimp,
gimp_item_factory_create_item (item_factory, gimp_item_factory_create_item (item_factory,
&entry, &entry,
NULL,
file_proc, 2, file_proc, 2,
TRUE, FALSE); TRUE, FALSE);

View File

@ -131,6 +131,7 @@ file_save_dialog_menu_init (Gimp *gimp,
gimp_item_factory_create_item (item_factory, gimp_item_factory_create_item (item_factory,
&entry, &entry,
NULL,
file_proc, 2, file_proc, 2,
TRUE, FALSE); TRUE, FALSE);

View File

@ -150,6 +150,7 @@ file_open_dialog_menu_init (Gimp *gimp,
gimp_item_factory_create_item (item_factory, gimp_item_factory_create_item (item_factory,
&entry, &entry,
NULL,
file_proc, 2, file_proc, 2,
TRUE, FALSE); TRUE, FALSE);

View File

@ -131,6 +131,7 @@ file_save_dialog_menu_init (Gimp *gimp,
gimp_item_factory_create_item (item_factory, gimp_item_factory_create_item (item_factory,
&entry, &entry,
NULL,
file_proc, 2, file_proc, 2,
TRUE, FALSE); TRUE, FALSE);

View File

@ -2227,8 +2227,8 @@ menus_init (Gimp *gimp)
gimp_item_factory_create_item (image_factory, gimp_item_factory_create_item (image_factory,
&entry, &entry,
tool_info, NULL,
2, tool_info, 2,
TRUE, FALSE); TRUE, FALSE);
} }
} }

View File

@ -223,11 +223,9 @@ plug_in_make_menu_entry (gpointer foo,
item_factory = item_factory =
gimp_item_factory_from_path (menu_entry->proc_def->menu_path); gimp_item_factory_from_path (menu_entry->proc_def->menu_path);
g_object_set_data (G_OBJECT (item_factory), "textdomain",
(gpointer) menu_entry->domain);
gimp_item_factory_create_item (item_factory, gimp_item_factory_create_item (item_factory,
&entry, &entry,
menu_entry->domain,
&menu_entry->proc_def->db_info, 2, &menu_entry->proc_def->db_info, 2,
TRUE, FALSE); TRUE, FALSE);
} }

View File

@ -2227,8 +2227,8 @@ menus_init (Gimp *gimp)
gimp_item_factory_create_item (image_factory, gimp_item_factory_create_item (image_factory,
&entry, &entry,
tool_info, NULL,
2, tool_info, 2,
TRUE, FALSE); TRUE, FALSE);
} }
} }

View File

@ -223,11 +223,9 @@ plug_in_make_menu_entry (gpointer foo,
item_factory = item_factory =
gimp_item_factory_from_path (menu_entry->proc_def->menu_path); gimp_item_factory_from_path (menu_entry->proc_def->menu_path);
g_object_set_data (G_OBJECT (item_factory), "textdomain",
(gpointer) menu_entry->domain);
gimp_item_factory_create_item (item_factory, gimp_item_factory_create_item (item_factory,
&entry, &entry,
menu_entry->domain,
&menu_entry->proc_def->db_info, 2, &menu_entry->proc_def->db_info, 2,
TRUE, FALSE); TRUE, FALSE);
} }

View File

@ -52,7 +52,8 @@ static void gimp_item_factory_init (GimpItemFactory *factory
static void gimp_item_factory_finalize (GObject *object); static void gimp_item_factory_finalize (GObject *object);
static void gimp_item_factory_create_branches (GimpItemFactory *factory, static void gimp_item_factory_create_branches (GimpItemFactory *factory,
GimpItemFactoryEntry *entry); GimpItemFactoryEntry *entry,
const gchar *textdomain);
static void gimp_item_factory_item_realize (GtkWidget *widget, static void gimp_item_factory_item_realize (GtkWidget *widget,
gpointer data); gpointer data);
static gboolean gimp_item_factory_item_key_press (GtkWidget *widget, static gboolean gimp_item_factory_item_key_press (GtkWidget *widget,
@ -238,6 +239,7 @@ gimp_item_factory_from_path (const gchar *path)
void void
gimp_item_factory_create_item (GimpItemFactory *item_factory, gimp_item_factory_create_item (GimpItemFactory *item_factory,
GimpItemFactoryEntry *entry, GimpItemFactoryEntry *entry,
const gchar *textdomain,
gpointer callback_data, gpointer callback_data,
guint callback_type, guint callback_type,
gboolean create_tearoff, gboolean create_tearoff,
@ -252,7 +254,7 @@ gimp_item_factory_create_item (GimpItemFactory *item_factory,
{ {
if (! gimprc.disable_tearoff_menus && create_tearoff) if (! gimprc.disable_tearoff_menus && create_tearoff)
{ {
gimp_item_factory_create_branches (item_factory, entry); gimp_item_factory_create_branches (item_factory, entry, textdomain);
} }
} }
else if (gimprc.disable_tearoff_menus || ! create_tearoff) else if (gimprc.disable_tearoff_menus || ! create_tearoff)
@ -272,11 +274,18 @@ gimp_item_factory_create_item (GimpItemFactory *item_factory,
entry->entry.callback_action = (guint) quark; entry->entry.callback_action = (guint) quark;
} }
if (textdomain)
g_object_set_data (G_OBJECT (item_factory), "textdomain",
(gpointer) textdomain);
gtk_item_factory_create_item (GTK_ITEM_FACTORY (item_factory), gtk_item_factory_create_item (GTK_ITEM_FACTORY (item_factory),
(GtkItemFactoryEntry *) entry, (GtkItemFactoryEntry *) entry,
callback_data, callback_data,
callback_type); callback_type);
if (textdomain)
g_object_set_data (G_OBJECT (item_factory), "textdomain", NULL);
menu_item = gtk_item_factory_get_item (GTK_ITEM_FACTORY (item_factory), menu_item = gtk_item_factory_get_item (GTK_ITEM_FACTORY (item_factory),
((GtkItemFactoryEntry *) entry)->path); ((GtkItemFactoryEntry *) entry)->path);
@ -314,6 +323,7 @@ gimp_item_factory_create_items (GimpItemFactory *item_factory,
{ {
gimp_item_factory_create_item (item_factory, gimp_item_factory_create_item (item_factory,
entries + i, entries + i,
NULL,
callback_data, callback_data,
callback_type, callback_type,
create_tearoff, create_tearoff,
@ -681,7 +691,8 @@ gimp_item_factory_tearoff_callback (GtkWidget *widget,
static void static void
gimp_item_factory_create_branches (GimpItemFactory *factory, gimp_item_factory_create_branches (GimpItemFactory *factory,
GimpItemFactoryEntry *entry) GimpItemFactoryEntry *entry,
const gchar *textdomain)
{ {
GString *tearoff_path; GString *tearoff_path;
gint factory_length; gint factory_length;
@ -718,6 +729,7 @@ gimp_item_factory_create_branches (GimpItemFactory *factory,
gimp_item_factory_create_item (factory, gimp_item_factory_create_item (factory,
&branch_entry, &branch_entry,
textdomain,
NULL, 2, TRUE, FALSE); NULL, 2, TRUE, FALSE);
g_object_set_data (G_OBJECT (factory), "complete", NULL); g_object_set_data (G_OBJECT (factory), "complete", NULL);
@ -738,6 +750,7 @@ gimp_item_factory_create_branches (GimpItemFactory *factory,
gimp_item_factory_create_item (factory, gimp_item_factory_create_item (factory,
&tearoff_entry, &tearoff_entry,
textdomain,
NULL, 2, TRUE, FALSE); NULL, 2, TRUE, FALSE);
} }
@ -753,16 +766,22 @@ gimp_item_factory_item_realize (GtkWidget *widget,
{ {
if (GTK_IS_MENU_SHELL (widget->parent)) if (GTK_IS_MENU_SHELL (widget->parent))
{ {
if (! g_object_get_data (G_OBJECT (widget->parent), static GQuark quark_key_press_connected = 0;
"menus_key_press_connected"))
if (! quark_key_press_connected)
quark_key_press_connected =
g_quark_from_static_string ("gimp-menu-item-key-press-connected");
if (! GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget->parent),
quark_key_press_connected)))
{ {
g_signal_connect (G_OBJECT (widget->parent), "key_press_event", g_signal_connect (G_OBJECT (widget->parent), "key_press_event",
G_CALLBACK (gimp_item_factory_item_key_press), G_CALLBACK (gimp_item_factory_item_key_press),
data); data);
g_object_set_data (G_OBJECT (widget->parent), g_object_set_qdata (G_OBJECT (widget->parent),
"menus_key_press_connected", quark_key_press_connected,
(gpointer) TRUE); GINT_TO_POINTER (TRUE));
} }
} }
} }
@ -787,6 +806,9 @@ gimp_item_factory_item_key_press (GtkWidget *widget,
{ {
help_page = (gchar *) g_object_get_data (G_OBJECT (active_menu_item), help_page = (gchar *) g_object_get_data (G_OBJECT (active_menu_item),
"help_page"); "help_page");
if (help_page && ! *help_page)
help_page = NULL;
} }
/* For any key except F1, continue with the standard /* For any key except F1, continue with the standard
@ -796,8 +818,8 @@ gimp_item_factory_item_key_press (GtkWidget *widget,
if (kevent->keyval != GDK_F1) if (kevent->keyval != GDK_F1)
{ {
if (help_page && if (help_page &&
*help_page && (item_factory ==
item_factory == (GtkItemFactory *) gimp_item_factory_from_path ("<Toolbox>") && (GtkItemFactory *) gimp_item_factory_from_path ("<Toolbox>")) &&
(strcmp (help_page, "help/dialogs/help.html") == 0 || (strcmp (help_page, "help/dialogs/help.html") == 0 ||
strcmp (help_page, "help/context_help.html") == 0)) strcmp (help_page, "help/context_help.html") == 0))
{ {
@ -814,8 +836,7 @@ gimp_item_factory_item_key_press (GtkWidget *widget,
factory_path = (gchar *) g_object_get_data (G_OBJECT (item_factory), factory_path = (gchar *) g_object_get_data (G_OBJECT (item_factory),
"factory_path"); "factory_path");
if (! help_page || if (! help_page)
! *help_page)
help_page = "index.html"; help_page = "index.html";
if (factory_path && help_page) if (factory_path && help_page)

View File

@ -83,6 +83,7 @@ GimpItemFactory * gimp_item_factory_from_path (const gchar *path);
void gimp_item_factory_create_item (GimpItemFactory *factory, void gimp_item_factory_create_item (GimpItemFactory *factory,
GimpItemFactoryEntry *entry, GimpItemFactoryEntry *entry,
const gchar *textdomain,
gpointer callback_data, gpointer callback_data,
guint callback_type, guint callback_type,
gboolean create_tearoff, gboolean create_tearoff,