forked from AuroraMiddleware/gtk
Make gtk_builder_get_translation_domain() useful for subparsers.
* gtk/gtkbuilderparser.c: Make gtk_builder_get_translation_domain() useful for subparsers. * gtk/gtkcontainer.c: Make the child property parser support translatable child properties. svn path=/trunk/; revision=21855
This commit is contained in:
parent
2afd463b26
commit
70675377c0
10
ChangeLog
10
ChangeLog
@ -1,3 +1,11 @@
|
|||||||
|
2008-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkbuilderparser.c: Make gtk_builder_get_translation_domain()
|
||||||
|
useful for subparsers.
|
||||||
|
|
||||||
|
* gtk/gtkcontainer.c: Make the child property parser support
|
||||||
|
translatable child properties.
|
||||||
|
|
||||||
2008-12-07 Matthias Clasen <mclasen@redhat.com>
|
2008-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
Bug 554274 – Add default hook for GtkLinkButton
|
Bug 554274 – Add default hook for GtkLinkButton
|
||||||
@ -8,7 +16,7 @@
|
|||||||
2008-12-07 Matthias Clasen <mclasen@redhat.com>
|
2008-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
Bug 559325 – documentation for gdk_display_get_window_at_pointer()
|
Bug 559325 – documentation for gdk_display_get_window_at_pointer()
|
||||||
is wrong
|
: is wrong
|
||||||
|
|
||||||
* gdk/gdkdisplay.c (gdk_display_get_window_at_pointer): Correct
|
* gdk/gdkdisplay.c (gdk_display_get_window_at_pointer): Correct
|
||||||
the documentation. Patch by Paul Davis
|
the documentation. Patch by Paul Davis
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2008-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/tmpl/gtkcontainer.sgml: Document translatable child
|
||||||
|
properties in GtkBuilder
|
||||||
|
|
||||||
2008-11-29 Baptiste Mille-Mathias <baptiste.millemathias@gmail.com>
|
2008-11-29 Baptiste Mille-Mathias <baptiste.millemathias@gmail.com>
|
||||||
|
|
||||||
* docs/reference/gtk/images/accel-label.png:
|
* docs/reference/gtk/images/accel-label.png:
|
||||||
|
@ -125,6 +125,11 @@ child properties for the child.
|
|||||||
</object>
|
</object>
|
||||||
]]></programlisting>
|
]]></programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
<para>
|
||||||
|
Since 2.16, child properties can also be marked as translatable using
|
||||||
|
the same "translatable", "comments" and "context" attributes that are used
|
||||||
|
for regular properties.
|
||||||
|
</para>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
|
|
||||||
<!-- ##### SECTION See_Also ##### -->
|
<!-- ##### SECTION See_Also ##### -->
|
||||||
|
@ -634,9 +634,24 @@ parse_interface (ParserData *data,
|
|||||||
{
|
{
|
||||||
if (strcmp (names[i], "domain") == 0)
|
if (strcmp (names[i], "domain") == 0)
|
||||||
{
|
{
|
||||||
g_free (data->domain);
|
|
||||||
data->domain = g_strdup (values[i]);
|
if (data->domain)
|
||||||
break;
|
{
|
||||||
|
if (strcmp (data->domain, values[i]) == 0)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
g_warning ("%s: interface domain '%s' overrides "
|
||||||
|
"programically set domain '%s'",
|
||||||
|
data->filename,
|
||||||
|
values[i],
|
||||||
|
data->domain
|
||||||
|
);
|
||||||
|
|
||||||
|
g_free (data->domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
data->domain = g_strdup (values[i]);
|
||||||
|
gtk_builder_set_translation_domain (data->builder, data->domain);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
error_invalid_attribute (data, "interface", names[i], error);
|
error_invalid_attribute (data, "interface", names[i], error);
|
||||||
@ -1116,13 +1131,21 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
|
|||||||
gchar **requested_objs,
|
gchar **requested_objs,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
const gchar* domain;
|
||||||
ParserData *data;
|
ParserData *data;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
|
/* Store the original domain so that interface domain attribute can be
|
||||||
|
* applied for the builder and the original domain can be restored after
|
||||||
|
* parsing has finished. This allows subparsers to translate elements with
|
||||||
|
* gtk_builder_get_translation_domain() without breaking the ABI or API
|
||||||
|
*/
|
||||||
|
domain = gtk_builder_get_translation_domain (builder);
|
||||||
|
|
||||||
data = g_new0 (ParserData, 1);
|
data = g_new0 (ParserData, 1);
|
||||||
data->builder = builder;
|
data->builder = builder;
|
||||||
data->filename = filename;
|
data->filename = filename;
|
||||||
data->domain = g_strdup (gtk_builder_get_translation_domain (builder));
|
data->domain = g_strdup (domain);
|
||||||
|
|
||||||
data->requested_objects = NULL;
|
data->requested_objects = NULL;
|
||||||
if (requested_objs)
|
if (requested_objs)
|
||||||
@ -1184,4 +1207,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
|
|||||||
g_free (data->domain);
|
g_free (data->domain);
|
||||||
g_markup_parse_context_free (data->ctx);
|
g_markup_parse_context_free (data->ctx);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
|
|
||||||
|
/* restore the original domain */
|
||||||
|
gtk_builder_set_translation_domain (builder, domain);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "gtkcontainer.h"
|
#include "gtkcontainer.h"
|
||||||
#include "gtkbuildable.h"
|
#include "gtkbuildable.h"
|
||||||
|
#include "gtkbuilderprivate.h"
|
||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
@ -361,6 +362,8 @@ typedef struct {
|
|||||||
GtkContainer *container;
|
GtkContainer *container;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
gchar *child_prop_name;
|
gchar *child_prop_name;
|
||||||
|
gchar *context;
|
||||||
|
gboolean translatable
|
||||||
} PackingPropertiesData;
|
} PackingPropertiesData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -379,6 +382,20 @@ attributes_start_element (GMarkupParseContext *context,
|
|||||||
for (i = 0; names[i]; i++)
|
for (i = 0; names[i]; i++)
|
||||||
if (strcmp (names[i], "name") == 0)
|
if (strcmp (names[i], "name") == 0)
|
||||||
parser_data->child_prop_name = g_strdup (values[i]);
|
parser_data->child_prop_name = g_strdup (values[i]);
|
||||||
|
else if (strcmp (names[i], "translatable") == 0)
|
||||||
|
{
|
||||||
|
if (!_gtk_builder_boolean_from_string (values[1],
|
||||||
|
&parser_data->translatable,
|
||||||
|
error))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (strcmp (names[i], "comments") == 0)
|
||||||
|
; /* for translators */
|
||||||
|
else if (strcmp (names[i], "context") == 0)
|
||||||
|
parser_data->context = g_strdup (values[1]);
|
||||||
|
else
|
||||||
|
g_warning ("Unsupported attribute for GtkContainer Child "
|
||||||
|
"property: %s\n", names[i]);
|
||||||
}
|
}
|
||||||
else if (strcmp (element_name, "packing") == 0)
|
else if (strcmp (element_name, "packing") == 0)
|
||||||
return;
|
return;
|
||||||
@ -394,18 +411,37 @@ attributes_text_element (GMarkupParseContext *context,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
PackingPropertiesData *parser_data = (PackingPropertiesData*)user_data;
|
PackingPropertiesData *parser_data = (PackingPropertiesData*)user_data;
|
||||||
|
const gchar* value;
|
||||||
|
|
||||||
if (!parser_data->child_prop_name)
|
if (!parser_data->child_prop_name)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (parser_data->translatable && text_len)
|
||||||
|
{
|
||||||
|
const gchar* domain;
|
||||||
|
domain = gtk_builder_get_translation_domain (parser_data->builder);
|
||||||
|
|
||||||
|
value = _gtk_builder_parser_translate (domain,
|
||||||
|
parser_data->context,
|
||||||
|
text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = g_strdup (text);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_container_buildable_set_child_property (parser_data->container,
|
gtk_container_buildable_set_child_property (parser_data->container,
|
||||||
parser_data->builder,
|
parser_data->builder,
|
||||||
parser_data->child,
|
parser_data->child,
|
||||||
parser_data->child_prop_name,
|
parser_data->child_prop_name,
|
||||||
text);
|
value);
|
||||||
|
|
||||||
g_free (parser_data->child_prop_name);
|
g_free (parser_data->child_prop_name);
|
||||||
|
g_free (parser_data->context);
|
||||||
|
g_free (value);
|
||||||
parser_data->child_prop_name = NULL;
|
parser_data->child_prop_name = NULL;
|
||||||
|
parser_data->context = NULL;
|
||||||
|
parser_data->translatable = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const GMarkupParser attributes_parser =
|
static const GMarkupParser attributes_parser =
|
||||||
|
Loading…
Reference in New Issue
Block a user