Commit 4f74b453 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Implemented new "context" i18n metadata.


	* gladeui/glade-property.[ch], gladeui/glade-command.[ch], 
	gladeui/glade-editor-property.c: Implemented new "context" i18n
	metadata.

	* gladeui/glade-widget.c: Fixed to hide non-window widgets in glade_widget_hide()


svn path=/trunk/; revision=1967
parent 54ddfac5
2008-09-30 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-property.[ch], gladeui/glade-command.[ch],
gladeui/glade-editor-property.c: Implemented new "context" i18n
metadata.
* gladeui/glade-widget.c: Fixed to hide non-window widgets in glade_widget_hide()
2008-09-29 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/glade-column-types.[ch]: Exported glade_column_list_copy/free()
* plugins/gtk+/glade-model-data.[ch], plugins/gtk+/Makefile.am: Added model data
pspec, editor not compĺete yet...
pspec, editor not complete yet...
* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Implemented new pspec as
list/treestore's "data" property with load/save support.
......@@ -13,6 +20,12 @@
* gladeui/glade-utils.[ch]: Added glade_utils_liststore_from_enum_type()
* gladeui/glade-widget.c: glade_widget_rebuild() updates prop_refs now
* gladeui/glade-property-class.c, gladeui/glade-xml-utils.h, gladeui/glade-property.c:
now you can set construct-only on virtual properties, they will rebuild the object
and give you a chance to sync (you MUST handle set_property in a construct-only case)
2008-09-29 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* plugins/gtk+/glade-column-types.[ch]: added missing files.
......
......@@ -12,7 +12,8 @@ Add versioning metadata for libglade unsupported properties and widgets.
Sort objects from widgets in the inspector widget.
Make popup work in workspace with no-window widgets
Take care of external object property references (sync them) at rebuild time
Remove deleted widgets from the workspace
Take care of external object property references (sync them) at glade_widget_rebuild time
Liststore/Treestore data is not translatable
store data needs improvement and cant be released as is (cant even have spaces in data, needs real new structure).
......
......@@ -1073,7 +1073,6 @@ glade_command_remove (GList *widgets)
CommandData *cdata;
GtkWidget *placeholder;
GList *list, *l;
gchar *desc;
g_return_if_fail (widgets != NULL);
......@@ -1098,13 +1097,10 @@ glade_command_remove (GList *widgets)
GLADE_COMMAND (me)->description = g_strdup ("dummy");
if (g_list_length (widgets) == 1)
desc = g_strdup_printf (_("Remove %s"),
GLADE_WIDGET (widgets->data)->name);
glade_command_push_group (_("Remove %s"),
GLADE_WIDGET (widgets->data)->name);
else
desc = g_strdup_printf (_("Remove multiple"));
glade_command_push_group (desc);
g_free (desc);
glade_command_push_group (_("Remove multiple"));
for (list = widgets; list && list->data; list = list->next)
{
......@@ -1956,9 +1952,11 @@ typedef struct {
GladeProperty *property;
gboolean translatable;
gboolean has_context;
gchar *context;
gchar *comment;
gboolean old_translatable;
gboolean old_has_context;
gchar *old_context;
gchar *old_comment;
} GladeCommandSetI18n;
......@@ -1976,6 +1974,7 @@ glade_command_set_i18n_execute(GladeCommand *cmd)
GladeCommandSetI18n *me = (GladeCommandSetI18n *)cmd;
gboolean temp_translatable;
gboolean temp_has_context;
gchar *temp_context;
gchar *temp_comment;
/* sanity check */
......@@ -1985,17 +1984,21 @@ glade_command_set_i18n_execute(GladeCommand *cmd)
/* set the new values in the property */
glade_property_i18n_set_translatable(me->property, me->translatable);
glade_property_i18n_set_has_context(me->property, me->has_context);
glade_property_i18n_set_context(me->property, me->context);
glade_property_i18n_set_comment(me->property, me->comment);
/* swap the current values with the old values to prepare for undo */
temp_translatable = me->translatable;
temp_has_context = me->has_context;
temp_context = me->context;
temp_comment = me->comment;
me->translatable = me->old_translatable;
me->has_context = me->old_has_context;
me->context = me->old_context;
me->comment = me->old_comment;
me->old_translatable = temp_translatable;
me->old_has_context = temp_has_context;
me->old_context = temp_context;
me->old_comment = temp_comment;
return TRUE;
......@@ -2015,7 +2018,9 @@ glade_command_set_i18n_finalize(GObject *obj)
g_return_if_fail(GLADE_IS_COMMAND_SET_I18N(obj));
me = GLADE_COMMAND_SET_I18N(obj);
g_free (me->context);
g_free (me->comment);
g_free (me->old_context);
g_free (me->old_comment);
glade_command_finalize(obj);
......@@ -2052,8 +2057,11 @@ glade_command_set_i18n_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd
/* adjust this command to contain, as its old values, the other command's current values */
this->old_translatable = other->old_translatable;
this->old_has_context = other->old_has_context;
g_free (this->old_context);
g_free (this->old_comment);
this->old_context = other->old_context;
this->old_comment = other->old_comment;
other->old_context = NULL;
other->old_comment = NULL;
glade_app_update_ui ();
......@@ -2064,12 +2072,17 @@ glade_command_set_i18n_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd
* @property: a #GladeProperty
* @translatable: a #gboolean
* @has_context: a #gboolean
* @context: a #const gchar *
* @comment: a #const gchar *
*
* Sets the i18n data on the property.
*/
void
glade_command_set_i18n (GladeProperty *property, gboolean translatable, gboolean has_context, const gchar *comment)
glade_command_set_i18n (GladeProperty *property,
gboolean translatable,
gboolean has_context,
const gchar *context,
const gchar *comment)
{
GladeCommandSetI18n *me;
......@@ -2077,9 +2090,11 @@ glade_command_set_i18n (GladeProperty *property, gboolean translatable, gboolean
/* check that something changed before continuing with the command */
if (translatable == property->i18n_translatable &&
has_context == property->i18n_has_context &&
((comment == NULL && property->i18n_comment == NULL) ||
(comment && property->i18n_comment && !strcmp(property->i18n_comment, comment))))
has_context == property->i18n_has_context &&
/* XXX add context string shit herex */
((comment == NULL && property->i18n_comment == NULL) ||
(comment && property->i18n_comment && !strcmp(property->i18n_comment, comment))))
return;
/* load up the command */
......@@ -2087,9 +2102,11 @@ glade_command_set_i18n (GladeProperty *property, gboolean translatable, gboolean
me->property = property;
me->translatable = translatable;
me->has_context = has_context;
me->context = g_strdup(context);
me->comment = g_strdup(comment);
me->old_translatable = property->i18n_translatable;
me->old_has_context = property->i18n_has_context;
me->old_context = g_strdup(property->i18n_context);
me->old_comment = g_strdup(property->i18n_comment);
GLADE_COMMAND(me)->description = g_strdup_printf(_("Setting i18n metadata"));;
......@@ -2228,11 +2245,13 @@ glade_command_convert_cleanup (GladeProject *project,
GladeProjectFormat fmt)
{
GladeWidget *widget;
const GList *objects;
const GList *objects, *list;
objects = glade_project_get_objects (project);
for (objects = glade_project_get_objects (project); objects; objects = objects->next)
for (list = objects; list; list = list->next)
{
widget = glade_widget_get_from_gobject (objects->data);
widget = glade_widget_get_from_gobject (list->data);
/* If libglade-only widget going in builder format ... */
if ((fmt == GLADE_PROJECT_FORMAT_GTKBUILDER &&
......@@ -2280,11 +2299,9 @@ glade_command_set_project_format (GladeProject *project,
if (glade_project_get_format (project) != fmt)
{
gchar *prj_name = glade_project_get_name (project);
gchar *desc = g_strdup_printf (_("Converting %s to %s format"),
prj_name,
fmt == GLADE_PROJECT_FORMAT_LIBGLADE ? "libglade" : "Gtk+ Builder");
glade_command_push_group (desc);
g_free (desc);
glade_command_push_group (_("Converting %s to %s format"),
prj_name,
fmt == GLADE_PROJECT_FORMAT_LIBGLADE ? "libglade" : "Gtk+ Builder");
g_free (prj_name);
/* load up the command */
......@@ -2305,14 +2322,13 @@ glade_command_set_project_format (GladeProject *project,
catalog = glade_app_get_catalog (cat_name);
glade_catalog_convert_project (catalog, project, fmt);
glade_command_convert_cleanup (project, fmt);
g_free (cat_name);
}
g_list_free (req_libs);
}
glade_command_convert_cleanup (project, fmt);
/* execute the command and push it on the stack if successful
* this sets the actual format
......
......@@ -149,9 +149,10 @@ void glade_command_change_signal (GladeWidget *glade_widget,
/************************ set i18n ******************************/
void glade_command_set_i18n (GladeProperty *property,
gboolean translatable,
gboolean has_context,
const gchar *comment);
gboolean translatable,
gboolean has_context,
const gchar *context,
const gchar *comment);
G_END_DECLS
......
......@@ -1662,25 +1662,43 @@ glade_eprop_text_buffer_changed (GtkTextBuffer *buffer,
g_free (text);
}
static void
glade_eprop_text_show_i18n_dialog (GtkWidget *entry,
GladeEditorProperty *eprop)
/**
* glade_editor_property_show_i18n_dialog:
* @parent: The parent widget for the dialog.
* @fmt: the #GladeProjectFormat
* @text: A read/write pointer to the text property
* @context: A read/write pointer to the translation context
* @comment: A read/write pointer to the translator comment
* @has_context: A read/write pointer to the context setting (libglade only)
* @translatable: A read/write pointer to the translatable setting]
*
* Runs a dialog and updates the provided values.
*
* Returns: %TRUE if OK was selected.
*/
gboolean
glade_editor_property_show_i18n_dialog (GtkWidget *parent,
GladeProjectFormat fmt,
gchar **text,
gchar **context,
gchar **comment,
gboolean *has_context,
gboolean *translatable)
{
GtkWidget *dialog;
GtkWidget *vbox, *hbox;
GtkWidget *label;
GtkWidget *sw;
GtkWidget *alignment;
GtkWidget *text_view, *comment_view;
GtkTextBuffer *text_buffer, *comment_buffer;
GtkWidget *text_view, *comment_view, *context_view;
GtkTextBuffer *text_buffer, *comment_buffer, *context_buffer = NULL;
GtkWidget *translatable_button, *context_button;
const gchar *text;
gint res;
gchar *str;
GParamSpec *pspec;
g_return_val_if_fail (text && context && comment && translatable && has_context, FALSE);
dialog = gtk_dialog_new_with_buttons (_("Edit Text"),
GTK_WINDOW (gtk_widget_get_toplevel (entry)),
parent ? GTK_WINDOW (gtk_widget_get_toplevel (parent)) : NULL,
GTK_DIALOG_MODAL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
......@@ -1730,11 +1748,10 @@ glade_eprop_text_show_i18n_dialog (GtkWidget *entry,
text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
text = g_value_get_string (eprop->property->value);
if (text)
if (*text)
{
gtk_text_buffer_set_text (text_buffer,
text,
*text,
-1);
}
......@@ -1744,37 +1761,68 @@ glade_eprop_text_show_i18n_dialog (GtkWidget *entry,
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
/* Translatable */
translatable_button = gtk_check_button_new_with_mnemonic (_("T_ranslatable"));
gtk_widget_show (translatable_button);
gtk_box_pack_start (GTK_BOX (hbox), translatable_button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (translatable_button),
glade_property_i18n_get_translatable (eprop->property));
/* Add a cute tooltip */
if ((pspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (eprop->property),
"i18n-translatable")) != NULL)
gtk_widget_set_tooltip_text (translatable_button,
g_param_spec_get_blurb (pspec));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (translatable_button), *translatable);
gtk_widget_set_tooltip_text (translatable_button,
_("Whether this property is translatable or not"));
/* Has Context */
context_button = gtk_check_button_new_with_mnemonic (_("_Has context prefix"));
gtk_widget_show (context_button);
gtk_box_pack_start (GTK_BOX (hbox), context_button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (context_button),
glade_property_i18n_get_has_context (eprop->property));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (context_button), *has_context);
gtk_widget_set_tooltip_text (context_button,
_("Whether or not the translatable string has a context prefix"));
if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE)
gtk_widget_show (context_button);
/* Add a cute tooltip */
if ((pspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (eprop->property),
"i18n-has-context")) != NULL)
gtk_widget_set_tooltip_text (context_button,
g_param_spec_get_blurb (pspec));
/* Context. */
if (fmt != GLADE_PROJECT_FORMAT_LIBGLADE)
{
alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 0, 0);
gtk_widget_show (alignment);
label = gtk_label_new_with_mnemonic (_("Conte_xt for translation:"));
gtk_widget_show (label);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_container_add (GTK_CONTAINER (alignment), label);
gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
gtk_widget_set_tooltip_text (alignment,
"XXX Some explanation about translation context please ???");
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (sw);
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
context_view = gtk_text_view_new ();
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (context_view), GTK_WRAP_WORD);
gtk_widget_show (context_view);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), context_view);
gtk_container_add (GTK_CONTAINER (sw), context_view);
context_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (context_view));
if (*context)
{
gtk_text_buffer_set_text (context_buffer,
*context,
-1);
}
}
/* Comments. */
alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 0, 0);
gtk_widget_show (alignment);
/* Comments. */
label = gtk_label_new_with_mnemonic (_("Co_mments for translators:"));
gtk_widget_show (label);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
......@@ -1798,47 +1846,90 @@ glade_eprop_text_show_i18n_dialog (GtkWidget *entry,
comment_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (comment_view));
text = glade_property_i18n_get_comment (eprop->property);
if (text)
if (*comment)
{
gtk_text_buffer_set_text (comment_buffer,
text,
*comment,
-1);
}
res = gtk_dialog_run (GTK_DIALOG (dialog));
if (res == GTK_RESPONSE_OK) {
GtkTextIter start, end;
gboolean translatable, has_context;
g_free ((gpointer)*text);
g_free ((gpointer)*context);
g_free ((gpointer)*comment);
/* get the new values for translatable, has_context, and comment */
translatable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (translatable_button));
has_context = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (context_button));
*translatable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (translatable_button));
*has_context = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (context_button));
/* Comment */
gtk_text_buffer_get_bounds (comment_buffer, &start, &end);
str = gtk_text_buffer_get_text (comment_buffer, &start, &end, TRUE);
if (str[0] == '\0')
*comment = gtk_text_buffer_get_text (comment_buffer, &start, &end, TRUE);
if (*comment[0] == '\0')
{
g_free (str);
str = NULL;
g_free (*comment);
*comment = NULL;
}
/* set the new i18n data via a glade command so it can be undone */
glade_command_set_i18n (eprop->property, translatable, has_context, str);
g_free (str);
/* Text */
gtk_text_buffer_get_bounds (text_buffer, &start, &end);
str = gtk_text_buffer_get_text (text_buffer, &start, &end, TRUE);
/* set the new text */
glade_eprop_text_changed_common (eprop, str, eprop->use_command);
g_free (str);
*text = gtk_text_buffer_get_text (text_buffer, &start, &end, TRUE);
if (*text[0] == '\0')
{
g_free (*text);
*text = NULL;
}
/* Context */
if (fmt != GLADE_PROJECT_FORMAT_LIBGLADE)
{
gtk_text_buffer_get_bounds (context_buffer, &start, &end);
*context = gtk_text_buffer_get_text (context_buffer, &start, &end, TRUE);
if (*context[0] == '\0')
{
g_free (*context);
*context = NULL;
}
}
gtk_widget_destroy (dialog);
return TRUE;
}
gtk_widget_destroy (dialog);
return FALSE;
}
static void
glade_eprop_text_show_i18n_dialog (GtkWidget *entry,
GladeEditorProperty *eprop)
{
GladeProject *project;
GladeProjectFormat fmt;
gchar *text = g_value_dup_string (eprop->property->value);
gchar *context = g_strdup (glade_property_i18n_get_context (eprop->property));
gchar *comment = g_strdup (glade_property_i18n_get_comment (eprop->property));
gboolean translatable = glade_property_i18n_get_translatable (eprop->property);
gboolean has_context = glade_property_i18n_get_has_context (eprop->property);
project = eprop->property->widget->project;
fmt = glade_project_get_format (project);
if (glade_editor_property_show_i18n_dialog (entry, fmt, &text, &context, &comment,
&has_context, &translatable))
{
glade_command_set_i18n (eprop->property, translatable, has_context, context, comment);
glade_eprop_text_changed_common (eprop, text, eprop->use_command);
glade_editor_property_load (eprop, eprop->property);
g_free (text);
g_free (context);
g_free (comment);
}
}
static GtkWidget *
......@@ -2754,15 +2845,13 @@ glade_eprop_object_show_dialog (GtkWidget *dialog_button,
{
if ((old_ref = glade_widget_get_parentless_widget_ref (new_widget)))
{
gchar *desc = g_strdup_printf (_("Setting %s of %s to %s"),
eprop->property->klass->name,
eprop->property->widget->name,
new_widget->name);
glade_command_push_group (desc);
glade_command_push_group (_("Setting %s of %s to %s"),
eprop->property->klass->name,
eprop->property->widget->name,
new_widget->name);
glade_command_set_property (old_ref, NULL);
glade_editor_property_commit (eprop, value);
glade_command_pop_group ();
g_free (desc);
}
else
glade_editor_property_commit (eprop, value);
......@@ -2780,14 +2869,13 @@ glade_eprop_object_show_dialog (GtkWidget *dialog_button,
{
GValue *value;
GladeWidget *new_widget;
/* translators: Creating 'a widget' for 'a property' of 'a widget' */
gchar *desc = g_strdup_printf (_("Creating %s for %s of %s"),
create_adaptor->name,
eprop->property->klass->name,
eprop->property->widget->name);
glade_command_push_group (desc);
g_free (desc);
/* translators: Creating 'a widget' for 'a property' of 'a widget' */
glade_command_push_group (_("Creating %s for %s of %s"),
create_adaptor->name,
eprop->property->klass->name,
eprop->property->widget->name);
/* Dont bother if the user canceled the widget */
if ((new_widget = glade_command_create (create_adaptor, NULL, NULL, project)) != NULL)
{
......
......@@ -157,6 +157,13 @@ void glade_editor_property_commit (GladeEditorProperty *
void glade_editor_property_commit_no_callback (GladeEditorProperty *eprop,
GValue *value);
gboolean glade_editor_property_show_i18n_dialog (GtkWidget *parent,
GladeProjectFormat fmt,
gchar **text,
gchar **context,
gchar **comment,
gboolean *has_context,
gboolean *translatable);
/* Generic eprops */
#define GLADE_TYPE_EPROP_NUMERIC (glade_eprop_numeric_get_type())
......
......@@ -1511,6 +1511,7 @@ glade_property_class_update_from_node (GladeXmlNode *node,
if ((child = glade_xml_search_child (node, GLADE_TAG_PARAMETERS)) != NULL)
klass->parameters = glade_parameter_list_new_from_node (klass->parameters, child);
klass->construct_only = glade_xml_get_property_boolean (node, GLADE_TAG_CONSTRUCT_ONLY, klass->construct_only);
klass->translatable = glade_xml_get_property_boolean (node, GLADE_TAG_TRANSLATABLE, klass->translatable);
klass->common = glade_xml_get_property_boolean (node, GLADE_TAG_COMMON, klass->common);
klass->optional = glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL, klass->optional);
......
......@@ -72,6 +72,7 @@ enum
PROP_SENSITIVE,
PROP_I18N_TRANSLATABLE,
PROP_I18N_HAS_CONTEXT,
PROP_I18N_CONTEXT,
PROP_I18N_COMMENT,
PROP_STATE
};
......@@ -91,6 +92,7 @@ glade_property_dup_impl (GladeProperty *template_prop, GladeWidget *widget)
"class", template_prop->klass,
"i18n-translatable", template_prop->i18n_translatable,
"i18n-has-context", template_prop->i18n_has_context,
"i18n-context", template_prop->i18n_context,
"i18n-comment", template_prop->i18n_comment,
NULL);
property->widget = widget;
......@@ -334,19 +336,32 @@ glade_property_sync_impl (GladeProperty *property)
property->enabled == FALSE ||
/* explicit "never sync" flag */
property->klass->ignore ||
/* avoid recursion */
property->syncing ||
/* recursion guards */
property->syncing >= property->sync_tolerance ||
/* No widget owns this property yet */
property->widget == NULL)
return;
property->syncing = TRUE;
property->syncing++;
/* In the case of construct_only, the widget instance must be rebuilt
* to apply the property
*/
if (property->klass->construct_only)
if (property->klass->construct_only && property->syncing == 1)
{
/* Virtual properties can be construct only, in which
* case they are allowed to trigger a rebuild, and in
* the process are allowed to get "synced" after the
* instance is rebuilt.
*/
if (property->klass->virt)
property->sync_tolerance++;
glade_widget_rebuild (property->widget);
if (property->klass->virt)
property->sync_tolerance--;
}
else if (property->klass->packing)
glade_widget_child_set_property (glade_widget_get_parent (property->widget),
property->widget,
......@@ -357,7 +372,7 @@ glade_property_sync_impl (GladeProperty *property)
property->klass->id,
property->value);
property->syncing = FALSE;
property->syncing--;
}
static void
......@@ -409,6 +424,9 @@ glade_property_set_real_property (GObject *object,
case PROP_I18N_HAS_CONTEXT:
glade_property_i18n_set_has_context (property, g_value_get_boolean (value));
break;
case PROP_I18N_CONTEXT:
glade_property_i18n_set_context (property, g_value_get_string (value));
break;
case PROP_I18N_COMMENT:
glade_property_i18n_set_comment (property, g_value_get_string (value));
break;
......@@ -443,6 +461,9 @@ glade_property_get_real_property (GObject *object,
case PROP_I18N_HAS_CONTEXT:
g_value_set_boolean (value, glade_property_i18n_get_has_context (property));
break;
case PROP_I18N_CONTEXT:
g_value_set_string (value, glade_property_i18n_get_context (property));
break;
case PROP_I18N_COMMENT:
g_value_set_string (value, glade_property_i18n_get_comment (property));
break;
......@@ -479,6 +500,7 @@ glade_property_init (GladeProperty *property)
property->i18n_translatable = TRUE;
property->i18n_has_context = FALSE;
property->i18n_comment = NULL;
property->sync_tolerance = 1;
}
static void
......@@ -527,6 +549,13 @@ glade_property_klass_init (GladePropertyKlass *prop_class)
_("This gives backends control to set property sensitivity"),
TRUE, G_PARAM_READWRITE));
g_object_class_install_property
(object_class, PROP_I18N_CONTEXT,
g_param_spec_string
("i18n-context", _("Context"),
_("Context for translation"),
NULL, G_PARAM_READWRITE));
g_object_class_install_property
(object_class, PROP_I18N_COMMENT,
g_param_spec_string
......@@ -1076,23 +1105,32 @@ glade_property_read (GladeProperty *property,
if (property)
{
gint translatable, has_context;
gchar *comment;
gchar *comment = NULL, *context = NULL;
translatable = glade_xml_get_property_boolean
(prop, GLADE_TAG_TRANSLATABLE, FALSE);
has_context = glade_xml_get_property_boolean
(prop, GLADE_TAG_HAS_CONTEXT, FALSE);
comment = glade_xml_get_property_string
(prop, GLADE_TAG_COMMENT);
glade_property_i18n_set_translatable
(property, translatable);
glade_property_i18n_set_has_context
(property, has_context);
glade_property_i18n_set_comment
(property, comment);
if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE)
has_context = glade_xml_get_property_boolean
(prop, GLADE_TAG_HAS_CONTEXT, FALSE);
else
context = glade_xml_get_property_string
(prop, GLADE_TAG_CONTEXT);
glade_property_i18n_set_translatable (property, translatable);
glade_property_i18n_set_comment (property, comment);
if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE)
glade_property_i18n_set_has_context
(property, has_context);
else
glade_property_i18n_set_context
(property, context);
g_free (comment);
g_free (context);
}
g_free (value);
......@@ -1209,18 +1247,21 @@ glade_property_write (GladeProperty *property,
GLADE_TAG_TRANSLATABLE,
GLADE_XML_TAG_I18N_TRUE);
if (property->i18n_has_context)
if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE && property->i18n_has_context)
glade_xml_node_set_property_string (prop_node,
GLADE_TAG_HAS_CONTEXT,
GLADE_XML_TAG_I18N_TRUE);
if (fmt == GLADE_PROJECT_FORMAT_GTKBUILDER && property->i18n_context)
glade_xml_node_set_property_string (prop_node,
GLADE_TAG_CONTEXT,
property->i18n_context);