Merge branch 'master' of ssh://alexl@git.gnome.org/git/gtk+

This commit is contained in:
Alexander Larsson 2009-04-07 19:29:19 +02:00
commit 4ecd6a0f89
14 changed files with 2948 additions and 3723 deletions

View File

@ -285,6 +285,7 @@ using #GtkBuilder.
some attribute value.
@GTK_BUILDER_ERROR_VERSION_MISMATCH: The input file requires a newer version
of GTK+.
@GTK_BUILDER_ERROR_DUPLICATE_ID: An object id occurred twice.
<!-- ##### FUNCTION gtk_builder_new ##### -->
<para>

View File

@ -49,7 +49,7 @@ internal child "accessible" of a <structname>GtkWidget</structname>.
</object>
<object class="GtkButton" id="button1">
<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"/>
</accessibility>
<child internal-child="accessible">

View File

@ -229,7 +229,7 @@ gdk_display_get_name (GdkDisplay *display)
DWORD session_id;
char *display_name;
static const char *display_name_cache = NULL;
typedef BOOL (* PFN_ProcessIdToSessionId) (DWORD, DWORD *);
typedef BOOL (WINAPI *PFN_ProcessIdToSessionId) (DWORD, DWORD *);
PFN_ProcessIdToSessionId processIdToSessionId;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);

View File

@ -257,6 +257,8 @@ class GtkBuilderConverter(object):
for node in objects:
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
# Convert Gazpachos UI tag

View File

@ -1329,7 +1329,14 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
g_value_take_boxed (value, vector);
}
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;
}
break;
case G_TYPE_OBJECT:
if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF))

View File

@ -52,7 +52,8 @@ typedef enum
GTK_BUILDER_ERROR_INVALID_TAG,
GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
GTK_BUILDER_ERROR_INVALID_VALUE,
GTK_BUILDER_ERROR_VERSION_MISMATCH
GTK_BUILDER_ERROR_VERSION_MISMATCH,
GTK_BUILDER_ERROR_DUPLICATE_ID
} GtkBuilderError;
GQuark gtk_builder_error_quark (void);

View File

@ -298,7 +298,8 @@ is_requested_object (const gchar *object,
}
static void
parse_object (ParserData *data,
parse_object (GMarkupParseContext *context,
ParserData *data,
const gchar *element_name,
const gchar **names,
const gchar **values,
@ -310,6 +311,7 @@ parse_object (ParserData *data,
gchar *object_class = NULL;
gchar *object_id = NULL;
gchar *constructor = NULL;
gint line, line2;
child_info = state_peek_info (data, ChildInfo);
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]);
if (!object_class)
{
g_markup_parse_context_get_position (context, &line, NULL);
g_set_error (error, GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION,
_("Invalid type function: `%s'"),
values[i]);
_("Invalid type function on line %d: '%s'"),
line, values[i]);
return;
}
}
@ -389,6 +392,19 @@ parse_object (ParserData *data,
if (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
@ -848,7 +864,7 @@ start_element (GMarkupParseContext *context,
if (strcmp (element_name, "requires") == 0)
parse_requires (data, element_name, names, values, error);
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)
{
/* If outside a requested object, simply ignore this tag */
@ -1145,6 +1161,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
data->builder = builder;
data->filename = filename;
data->domain = g_strdup (domain);
data->object_ids = g_hash_table_new (g_str_hash, g_str_equal);
data->requested_objects = NULL;
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_free (data->requested_objects);
g_free (data->domain);
g_hash_table_destroy (data->object_ids);
g_markup_parse_context_free (data->ctx);
g_free (data);

View File

@ -101,6 +101,8 @@ typedef struct {
gboolean inside_requested_object;
gint requested_object_level;
gint cur_object_level;
GHashTable *object_ids;
} ParserData;
typedef GType (*GTypeGetFunc) (void);

View File

@ -1538,6 +1538,12 @@ gtk_expander_set_label (GtkExpander *expander,
* 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.
*
* 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
* by the widget and must not be modified or freed.
*

View File

@ -228,10 +228,9 @@ void gtk_item_factory_create_menu_entries (guint n_entries,
void gtk_item_factories_path_delete (const gchar *ifactory_path,
const gchar *path);
#endif /* !GTK_DISABLE_DEPRECATED */
G_END_DECLS
#endif /* !GTK_DISABLE_DEPRECATED */
#endif /* __GTK_ITEM_FACTORY_H__ */

View File

@ -9466,12 +9466,16 @@ gtk_widget_buildable_set_buildable_property (GtkBuildable *buildable,
g_object_set_property (G_OBJECT (buildable), name, value);
}
typedef struct {
typedef struct
{
gchar *action_name;
gchar *description;
GString *description;
gchar *context;
gboolean translatable;
} AtkActionData;
typedef struct {
typedef struct
{
gchar *target;
gchar *type;
} AtkRelationData;
@ -9480,7 +9484,8 @@ static void
free_action (AtkActionData *data, gpointer user_data)
{
g_free (data->action_name);
g_free (data->description);
g_string_free (data->description, TRUE);
g_free (data->context);
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,
NULL);
}
}
typedef struct {
typedef struct
{
GSList *actions;
GSList *relations;
} AccessibilitySubParserData;
@ -9624,14 +9629,27 @@ accessibility_start_element (GMarkupParseContext *context,
{
gchar *action_name = NULL;
gchar *description = NULL;
gchar *context = NULL;
gboolean translatable = FALSE;
AtkActionData *action;
for (i = 0; names[i]; i++)
{
if (strcmp (names[i], "action_name") == 0)
action_name = g_strdup (values[i]);
action_name = values[i];
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
{
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>",
"<input>",
line_number, char_number, names[i], "action");
g_free (action_name);
g_free (description);
return;
}
}
if (!action_name || !description)
if (!action_name)
{
g_markup_parse_context_get_position (context,
&line_number,
@ -9660,15 +9676,15 @@ accessibility_start_element (GMarkupParseContext *context,
"%s:%d:%d <%s> requires attribute \"%s\"",
"<input>",
line_number, char_number, "action",
description ? "action_name" : "description");
g_free (action_name);
g_free (description);
"action_name");
return;
}
action = g_slice_new (AtkActionData);
action->action_name = action_name;
action->description = description;
action->action_name = g_strdup (action_name);
action->description = g_string_new (description);
action->context = g_strdup (context);
action->translatable = translatable;
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);
}
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 =
{
accessibility_start_element,
NULL,
accessibility_text,
};
typedef struct {
typedef struct
{
GObject *object;
guint key;
guint modifiers;
@ -9833,8 +9869,18 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
break;
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);
@ -9846,7 +9892,6 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
a11y_data->relations);
g_slice_free (AccessibilitySubParserData, a11y_data);
}
}

View File

@ -44,10 +44,18 @@ builder_new_from_string (const gchar *buffer,
const gchar *domain)
{
GtkBuilder *builder;
GError *error = NULL;
builder = gtk_builder_new ();
if (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;
}
@ -1580,6 +1588,7 @@ test_widget (void)
" <object class=\"GtkButton\" id=\"button1\">"
" <accessibility>"
" <action action_name=\"click\" description=\"Sliff\"/>"
" <action action_name=\"clack\" translatable=\"yes\">Sniff</action>"
" </accessibility>"
" </object>"
" </child>"

4361
po/el.po

File diff suppressed because it is too large Load Diff

2080
po/fr.po

File diff suppressed because it is too large Load Diff