Merge branch 'master' of ssh://alexl@git.gnome.org/git/gtk+
This commit is contained in:
@ -285,6 +285,7 @@ using #GtkBuilder.
|
|||||||
some attribute value.
|
some attribute value.
|
||||||
@GTK_BUILDER_ERROR_VERSION_MISMATCH: The input file requires a newer version
|
@GTK_BUILDER_ERROR_VERSION_MISMATCH: The input file requires a newer version
|
||||||
of GTK+.
|
of GTK+.
|
||||||
|
@GTK_BUILDER_ERROR_DUPLICATE_ID: An object id occurred twice.
|
||||||
|
|
||||||
<!-- ##### FUNCTION gtk_builder_new ##### -->
|
<!-- ##### FUNCTION gtk_builder_new ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
@ -49,7 +49,7 @@ internal child "accessible" of a <structname>GtkWidget</structname>.
|
|||||||
</object>
|
</object>
|
||||||
<object class="GtkButton" id="button1">
|
<object class="GtkButton" id="button1">
|
||||||
<accessibility>
|
<accessibility>
|
||||||
<action action_name="click" description="Click the button."/>
|
<action action_name="click" translatable="yes">Click the button.</action>
|
||||||
<relation target="label1" type="labelled-by"/>
|
<relation target="label1" type="labelled-by"/>
|
||||||
</accessibility>
|
</accessibility>
|
||||||
<child internal-child="accessible">
|
<child internal-child="accessible">
|
||||||
|
@ -229,7 +229,7 @@ gdk_display_get_name (GdkDisplay *display)
|
|||||||
DWORD session_id;
|
DWORD session_id;
|
||||||
char *display_name;
|
char *display_name;
|
||||||
static const char *display_name_cache = NULL;
|
static const char *display_name_cache = NULL;
|
||||||
typedef BOOL (* PFN_ProcessIdToSessionId) (DWORD, DWORD *);
|
typedef BOOL (WINAPI *PFN_ProcessIdToSessionId) (DWORD, DWORD *);
|
||||||
PFN_ProcessIdToSessionId processIdToSessionId;
|
PFN_ProcessIdToSessionId processIdToSessionId;
|
||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||||
|
@ -257,6 +257,8 @@ class GtkBuilderConverter(object):
|
|||||||
|
|
||||||
for node in objects:
|
for node in objects:
|
||||||
self._convert(node.getAttribute("class"), node)
|
self._convert(node.getAttribute("class"), node)
|
||||||
|
if self._get_object(node.getAttribute('id')) is not None:
|
||||||
|
print "WARNING: duplicate id \"" + node.getAttribute('id') + "\""
|
||||||
self.objects[node.getAttribute('id')] = node
|
self.objects[node.getAttribute('id')] = node
|
||||||
|
|
||||||
# Convert Gazpachos UI tag
|
# Convert Gazpachos UI tag
|
||||||
|
@ -1329,7 +1329,14 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
|||||||
g_value_take_boxed (value, vector);
|
g_value_take_boxed (value, vector);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
g_set_error (error,
|
||||||
|
GTK_BUILDER_ERROR,
|
||||||
|
GTK_BUILDER_ERROR_INVALID_VALUE,
|
||||||
|
"Could not parse '%s' as a %s",
|
||||||
|
string, G_VALUE_TYPE_NAME (value));
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case G_TYPE_OBJECT:
|
case G_TYPE_OBJECT:
|
||||||
if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF))
|
if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF))
|
||||||
|
@ -52,7 +52,8 @@ typedef enum
|
|||||||
GTK_BUILDER_ERROR_INVALID_TAG,
|
GTK_BUILDER_ERROR_INVALID_TAG,
|
||||||
GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
|
GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
|
||||||
GTK_BUILDER_ERROR_INVALID_VALUE,
|
GTK_BUILDER_ERROR_INVALID_VALUE,
|
||||||
GTK_BUILDER_ERROR_VERSION_MISMATCH
|
GTK_BUILDER_ERROR_VERSION_MISMATCH,
|
||||||
|
GTK_BUILDER_ERROR_DUPLICATE_ID
|
||||||
} GtkBuilderError;
|
} GtkBuilderError;
|
||||||
|
|
||||||
GQuark gtk_builder_error_quark (void);
|
GQuark gtk_builder_error_quark (void);
|
||||||
|
@ -298,7 +298,8 @@ is_requested_object (const gchar *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_object (ParserData *data,
|
parse_object (GMarkupParseContext *context,
|
||||||
|
ParserData *data,
|
||||||
const gchar *element_name,
|
const gchar *element_name,
|
||||||
const gchar **names,
|
const gchar **names,
|
||||||
const gchar **values,
|
const gchar **values,
|
||||||
@ -310,6 +311,7 @@ parse_object (ParserData *data,
|
|||||||
gchar *object_class = NULL;
|
gchar *object_class = NULL;
|
||||||
gchar *object_id = NULL;
|
gchar *object_id = NULL;
|
||||||
gchar *constructor = NULL;
|
gchar *constructor = NULL;
|
||||||
|
gint line, line2;
|
||||||
|
|
||||||
child_info = state_peek_info (data, ChildInfo);
|
child_info = state_peek_info (data, ChildInfo);
|
||||||
if (child_info && strcmp (child_info->tag.name, "object") == 0)
|
if (child_info && strcmp (child_info->tag.name, "object") == 0)
|
||||||
@ -335,10 +337,11 @@ parse_object (ParserData *data,
|
|||||||
object_class = _get_type_by_symbol (values[i]);
|
object_class = _get_type_by_symbol (values[i]);
|
||||||
if (!object_class)
|
if (!object_class)
|
||||||
{
|
{
|
||||||
|
g_markup_parse_context_get_position (context, &line, NULL);
|
||||||
g_set_error (error, GTK_BUILDER_ERROR,
|
g_set_error (error, GTK_BUILDER_ERROR,
|
||||||
GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION,
|
GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION,
|
||||||
_("Invalid type function: `%s'"),
|
_("Invalid type function on line %d: '%s'"),
|
||||||
values[i]);
|
line, values[i]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,6 +392,19 @@ parse_object (ParserData *data,
|
|||||||
|
|
||||||
if (child_info)
|
if (child_info)
|
||||||
object_info->parent = (CommonInfo*)child_info;
|
object_info->parent = (CommonInfo*)child_info;
|
||||||
|
|
||||||
|
g_markup_parse_context_get_position (context, &line, NULL);
|
||||||
|
line2 = GPOINTER_TO_INT (g_hash_table_lookup (data->object_ids, object_id));
|
||||||
|
if (line2 != 0)
|
||||||
|
{
|
||||||
|
g_set_error (error, GTK_BUILDER_ERROR,
|
||||||
|
GTK_BUILDER_ERROR_DUPLICATE_ID,
|
||||||
|
_("Duplicate object id '%s' on line %d (previously on line %d)"),
|
||||||
|
object_id, line, line2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_hash_table_insert (data->object_ids, object_id, GINT_TO_POINTER (line));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -848,7 +864,7 @@ start_element (GMarkupParseContext *context,
|
|||||||
if (strcmp (element_name, "requires") == 0)
|
if (strcmp (element_name, "requires") == 0)
|
||||||
parse_requires (data, element_name, names, values, error);
|
parse_requires (data, element_name, names, values, error);
|
||||||
else if (strcmp (element_name, "object") == 0)
|
else if (strcmp (element_name, "object") == 0)
|
||||||
parse_object (data, element_name, names, values, error);
|
parse_object (context, data, element_name, names, values, error);
|
||||||
else if (data->requested_objects && !data->inside_requested_object)
|
else if (data->requested_objects && !data->inside_requested_object)
|
||||||
{
|
{
|
||||||
/* If outside a requested object, simply ignore this tag */
|
/* If outside a requested object, simply ignore this tag */
|
||||||
@ -1145,6 +1161,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
|
|||||||
data->builder = builder;
|
data->builder = builder;
|
||||||
data->filename = filename;
|
data->filename = filename;
|
||||||
data->domain = g_strdup (domain);
|
data->domain = g_strdup (domain);
|
||||||
|
data->object_ids = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
data->requested_objects = NULL;
|
data->requested_objects = NULL;
|
||||||
if (requested_objs)
|
if (requested_objs)
|
||||||
@ -1204,6 +1221,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
|
|||||||
g_slist_foreach (data->requested_objects, (GFunc) g_free, NULL);
|
g_slist_foreach (data->requested_objects, (GFunc) g_free, NULL);
|
||||||
g_slist_free (data->requested_objects);
|
g_slist_free (data->requested_objects);
|
||||||
g_free (data->domain);
|
g_free (data->domain);
|
||||||
|
g_hash_table_destroy (data->object_ids);
|
||||||
g_markup_parse_context_free (data->ctx);
|
g_markup_parse_context_free (data->ctx);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ typedef struct {
|
|||||||
gboolean inside_requested_object;
|
gboolean inside_requested_object;
|
||||||
gint requested_object_level;
|
gint requested_object_level;
|
||||||
gint cur_object_level;
|
gint cur_object_level;
|
||||||
|
|
||||||
|
GHashTable *object_ids;
|
||||||
} ParserData;
|
} ParserData;
|
||||||
|
|
||||||
typedef GType (*GTypeGetFunc) (void);
|
typedef GType (*GTypeGetFunc) (void);
|
||||||
|
@ -1538,6 +1538,12 @@ gtk_expander_set_label (GtkExpander *expander,
|
|||||||
* return value will be %NULL. This will be the case if you create an
|
* return value will be %NULL. This will be the case if you create an
|
||||||
* empty button with gtk_button_new() to use as a container.
|
* empty button with gtk_button_new() to use as a container.
|
||||||
*
|
*
|
||||||
|
* Note that this function behaved differently in versions prior to
|
||||||
|
* 2.14 and used to return the label text stripped of embedded
|
||||||
|
* underlines indicating mnemonics and Pango markup. This problem can
|
||||||
|
* be avoided by fetching the label text directly from the label
|
||||||
|
* widget.
|
||||||
|
*
|
||||||
* Return value: The text of the label widget. This string is owned
|
* Return value: The text of the label widget. This string is owned
|
||||||
* by the widget and must not be modified or freed.
|
* by the widget and must not be modified or freed.
|
||||||
*
|
*
|
||||||
|
@ -228,10 +228,9 @@ void gtk_item_factory_create_menu_entries (guint n_entries,
|
|||||||
void gtk_item_factories_path_delete (const gchar *ifactory_path,
|
void gtk_item_factories_path_delete (const gchar *ifactory_path,
|
||||||
const gchar *path);
|
const gchar *path);
|
||||||
|
|
||||||
#endif /* !GTK_DISABLE_DEPRECATED */
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* !GTK_DISABLE_DEPRECATED */
|
||||||
|
|
||||||
#endif /* __GTK_ITEM_FACTORY_H__ */
|
#endif /* __GTK_ITEM_FACTORY_H__ */
|
||||||
|
|
||||||
|
@ -9466,12 +9466,16 @@ gtk_widget_buildable_set_buildable_property (GtkBuildable *buildable,
|
|||||||
g_object_set_property (G_OBJECT (buildable), name, value);
|
g_object_set_property (G_OBJECT (buildable), name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
gchar *action_name;
|
gchar *action_name;
|
||||||
gchar *description;
|
GString *description;
|
||||||
|
gchar *context;
|
||||||
|
gboolean translatable;
|
||||||
} AtkActionData;
|
} AtkActionData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
gchar *target;
|
gchar *target;
|
||||||
gchar *type;
|
gchar *type;
|
||||||
} AtkRelationData;
|
} AtkRelationData;
|
||||||
@ -9480,7 +9484,8 @@ static void
|
|||||||
free_action (AtkActionData *data, gpointer user_data)
|
free_action (AtkActionData *data, gpointer user_data)
|
||||||
{
|
{
|
||||||
g_free (data->action_name);
|
g_free (data->action_name);
|
||||||
g_free (data->description);
|
g_string_free (data->description, TRUE);
|
||||||
|
g_free (data->context);
|
||||||
g_slice_free (AtkActionData, data);
|
g_slice_free (AtkActionData, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9548,10 +9553,10 @@ gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
|
|||||||
g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
|
g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
GSList *actions;
|
GSList *actions;
|
||||||
GSList *relations;
|
GSList *relations;
|
||||||
} AccessibilitySubParserData;
|
} AccessibilitySubParserData;
|
||||||
@ -9624,14 +9629,27 @@ accessibility_start_element (GMarkupParseContext *context,
|
|||||||
{
|
{
|
||||||
gchar *action_name = NULL;
|
gchar *action_name = NULL;
|
||||||
gchar *description = NULL;
|
gchar *description = NULL;
|
||||||
|
gchar *context = NULL;
|
||||||
|
gboolean translatable = FALSE;
|
||||||
AtkActionData *action;
|
AtkActionData *action;
|
||||||
|
|
||||||
for (i = 0; names[i]; i++)
|
for (i = 0; names[i]; i++)
|
||||||
{
|
{
|
||||||
if (strcmp (names[i], "action_name") == 0)
|
if (strcmp (names[i], "action_name") == 0)
|
||||||
action_name = g_strdup (values[i]);
|
action_name = values[i];
|
||||||
else if (strcmp (names[i], "description") == 0)
|
else if (strcmp (names[i], "description") == 0)
|
||||||
description = g_strdup (values[i]);
|
description = values[i];
|
||||||
|
else if (strcmp (names[i], "translatable") == 0)
|
||||||
|
{
|
||||||
|
if (!_gtk_builder_boolean_from_string (values[i], &translatable, error))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (strcmp (names[i], "comments") == 0)
|
||||||
|
{
|
||||||
|
/* do nothing, comments are for translators */
|
||||||
|
}
|
||||||
|
else if (strcmp (names[i], "context") == 0)
|
||||||
|
context = values[i];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_markup_parse_context_get_position (context,
|
g_markup_parse_context_get_position (context,
|
||||||
@ -9643,13 +9661,11 @@ accessibility_start_element (GMarkupParseContext *context,
|
|||||||
"%s:%d:%d '%s' is not a valid attribute of <%s>",
|
"%s:%d:%d '%s' is not a valid attribute of <%s>",
|
||||||
"<input>",
|
"<input>",
|
||||||
line_number, char_number, names[i], "action");
|
line_number, char_number, names[i], "action");
|
||||||
g_free (action_name);
|
|
||||||
g_free (description);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!action_name || !description)
|
if (!action_name)
|
||||||
{
|
{
|
||||||
g_markup_parse_context_get_position (context,
|
g_markup_parse_context_get_position (context,
|
||||||
&line_number,
|
&line_number,
|
||||||
@ -9660,15 +9676,15 @@ accessibility_start_element (GMarkupParseContext *context,
|
|||||||
"%s:%d:%d <%s> requires attribute \"%s\"",
|
"%s:%d:%d <%s> requires attribute \"%s\"",
|
||||||
"<input>",
|
"<input>",
|
||||||
line_number, char_number, "action",
|
line_number, char_number, "action",
|
||||||
description ? "action_name" : "description");
|
"action_name");
|
||||||
g_free (action_name);
|
|
||||||
g_free (description);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
action = g_slice_new (AtkActionData);
|
action = g_slice_new (AtkActionData);
|
||||||
action->action_name = action_name;
|
action->action_name = g_strdup (action_name);
|
||||||
action->description = description;
|
action->description = g_string_new (description);
|
||||||
|
action->context = g_strdup (context);
|
||||||
|
action->translatable = translatable;
|
||||||
|
|
||||||
data->actions = g_slist_prepend (data->actions, action);
|
data->actions = g_slist_prepend (data->actions, action);
|
||||||
}
|
}
|
||||||
@ -9678,12 +9694,32 @@ accessibility_start_element (GMarkupParseContext *context,
|
|||||||
g_warning ("Unsupported tag for GtkWidget: %s\n", element_name);
|
g_warning ("Unsupported tag for GtkWidget: %s\n", element_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
accessibility_text (GMarkupParseContext *context,
|
||||||
|
const gchar *text,
|
||||||
|
gsize text_len,
|
||||||
|
gpointer user_data,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
|
||||||
|
|
||||||
|
if (strcmp (g_markup_parse_context_get_element (context), "action") == 0)
|
||||||
|
{
|
||||||
|
AtkActionData *action = data->actions->data;
|
||||||
|
|
||||||
|
g_string_append_len (action->description, text, text_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const GMarkupParser accessibility_parser =
|
static const GMarkupParser accessibility_parser =
|
||||||
{
|
{
|
||||||
accessibility_start_element,
|
accessibility_start_element,
|
||||||
|
NULL,
|
||||||
|
accessibility_text,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
GObject *object;
|
GObject *object;
|
||||||
guint key;
|
guint key;
|
||||||
guint modifiers;
|
guint modifiers;
|
||||||
@ -9833,8 +9869,18 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (i < n_actions)
|
if (i < n_actions)
|
||||||
atk_action_set_description (action, i,
|
{
|
||||||
action_data->description);
|
gchar *description;
|
||||||
|
|
||||||
|
if (action_data->translatable && action_data->description->len)
|
||||||
|
description = _gtk_builder_parser_translate (gtk_builder_get_translation_domain (builder),
|
||||||
|
action_data->context,
|
||||||
|
action_data->description->str);
|
||||||
|
else
|
||||||
|
description = action_data->description->str;
|
||||||
|
|
||||||
|
atk_action_set_description (action, i, description);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
|
g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
|
||||||
@ -9846,7 +9892,6 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
|
|||||||
a11y_data->relations);
|
a11y_data->relations);
|
||||||
|
|
||||||
g_slice_free (AccessibilitySubParserData, a11y_data);
|
g_slice_free (AccessibilitySubParserData, a11y_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,18 @@ builder_new_from_string (const gchar *buffer,
|
|||||||
const gchar *domain)
|
const gchar *domain)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
builder = gtk_builder_new ();
|
builder = gtk_builder_new ();
|
||||||
if (domain)
|
if (domain)
|
||||||
gtk_builder_set_translation_domain (builder, domain);
|
gtk_builder_set_translation_domain (builder, domain);
|
||||||
gtk_builder_add_from_string (builder, buffer, length, NULL);
|
gtk_builder_add_from_string (builder, buffer, length, &error);
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
g_print ("ERROR: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1580,6 +1588,7 @@ test_widget (void)
|
|||||||
" <object class=\"GtkButton\" id=\"button1\">"
|
" <object class=\"GtkButton\" id=\"button1\">"
|
||||||
" <accessibility>"
|
" <accessibility>"
|
||||||
" <action action_name=\"click\" description=\"Sliff\"/>"
|
" <action action_name=\"click\" description=\"Sliff\"/>"
|
||||||
|
" <action action_name=\"clack\" translatable=\"yes\">Sniff</action>"
|
||||||
" </accessibility>"
|
" </accessibility>"
|
||||||
" </object>"
|
" </object>"
|
||||||
" </child>"
|
" </child>"
|
||||||
|
Reference in New Issue
Block a user