Commit Graph

60 Commits

Author SHA1 Message Date
Timm Bäder
cb41b96a9e builderparser: Save finalizers in a GPtrArray
We get up to 370 of these when starting the widget-factory.
2021-01-17 04:39:26 +01:00
Timm Bäder
de6cd4f0d2 builder: Use a GPtrArray when parsing signals 2021-01-17 04:39:26 +01:00
Timm Bäder
aec2fb939f builderparser: Keep properties in a GPtrArray 2021-01-17 04:39:26 +01:00
Timm Bäder
21b6c8b5d8 builder: Remove unused typedef 2021-01-05 08:53:13 +01:00
Timm Bäder
41fb6f6a8e builder: Remove unused function prototype 2021-01-05 08:53:13 +01:00
Timm Bäder
071ea6b559 builderparser: Use GPtrArray for stack 2021-01-05 08:53:11 +01:00
Matthias Clasen
e050a2661c builder: Expot _gtk_builder_boolean_from_string privately
When specifying accessible properties in ui files, it
is better to accept the same syntax for booleans as
elsewhere, so lets reuse this function.
2020-10-25 12:19:21 -04:00
Timm Bäder
c5909d4dc4 gtkbuilder: Remove pointless function prototype 2020-10-14 15:06:12 -04:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Benjamin Otte
b43c8ae646 expression: Allow passing a this object to bind()
This gives a bit more control over the arguments passed to expressions.
2020-05-30 19:26:46 -04:00
Benjamin Otte
934bfc8887 builder: Add <binding> tag
The tag contains an expression that it then gtk_expression_bind()s to
the object it is contained in.
2020-05-30 19:26:44 -04:00
Benjamin Otte
fde75aa9f6 builder: Add support for parsing expressions 2020-05-30 17:47:47 -04:00
Timm Bäder
7789d0e23f builder: Make object names a const array
We don't take ownership.
2020-03-07 15:30:38 +01:00
Benjamin Otte
512c4c13a6 builder: Add gtk_builder_lookup_object()
... and use it. This function looks up an object like
gtk_builder_get_object() but generates an error on failure.

Unlike the evil function _gtk_builder_lookup_object() which also
generates an error but hides it for later lookup.

Use this to avoid continuing applying properties when an error was
encountered.
2019-12-12 19:12:11 +01:00
Benjamin Otte
420169d5cd builder: Improve signal connecting
- Propagate the error back to the parser, so we get a proper GError
  instead of a g_warning().
- Connect closures by id, don't construct a name from the ids so that
  glib can take it apart again.
2019-11-22 17:42:31 +01:00
Benjamin Otte
80acc8f296 builder: Carry the module as part of the GtkBuilder object
This way, we don't open the module in every place we want to look up
functions.
2019-11-22 07:46:18 +01:00
Alexander Larsson
ff23397701 GtkBuilder: Add support for precompiling builder xml 2019-09-10 12:08:20 -04:00
Alexander Larsson
96b37f4eb8 Use the new GtkBuildableParser type in GtkBuildable interfaces 2019-09-10 12:08:20 -04:00
Alexander Larsson
135cea76fb GtkBuildableParser: Add a wrapper for GMarkupParser
This currenly just wraps GMarkupParser, but the plan is to expose this
instead of GMarkup in the GtkBuildable interfaces, allowing us to
replace the parser with something that handles pre-parsed input
instead.

Note that we duplicate some of the features of GMarkup to implement
the APIs rather then call down to GMarkup, as we need to support these
in the pre-parsed case anyway.
2019-09-10 12:07:15 -04:00
Matthias Clasen
54e7a94d70 builder: Fix signedness issues in apis
Whenever we take a length argument that can
be -1 for 'nul-terminated', it should be
gssize, not gsize.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1555
2019-05-01 03:21:29 +00:00
Matthias Clasen
ed3b9669b3 builder: Allow specifying objects inline
In addition to <property name="foo">bar</property> referring
to an object with ID bar, we now also parse
<property name="foo"><object>...
to specify a property 'inline'.
2019-02-08 00:09:44 -05:00
Timm Bäder
0333602809 builderparser: Remove pointless TagType struct 2017-03-21 19:04:58 +01:00
Timm Bäder
de56947e86 gtkbuilder: Remove unused struct 2017-01-30 18:11:00 +01:00
Timm Bäder
938598032c builderparser: Save tag type instead of tag name
So we can save a few string comparisons
2016-10-31 19:29:36 +01:00
Timm Bäder
e3a3a66370 builderparser: Don't needlessly copy requested object names 2016-10-31 19:29:36 +01:00
Matthias Clasen
9c0e4c174a builder: Allow 'primary' as a modifier value
Support aliases for flags values in GtkBuilder, and use this
to support the special value 'primary' for GdkModifierType
values.

https://bugzilla.gnome.org/show_bug.cgi?id=699891
2016-03-05 23:44:03 -05:00
Matthias Clasen
c2a9202a66 Move gtk_builder_extend_with_template to public header
We export the symbol, so we should not hide it in private
headers.
2015-11-08 19:21:45 -05:00
Matthias Clasen
019078364e builder: Avoid some unnecessary overhead
Only get the class once per object, not once per property.
And don't canonicalize the property name, g_object_class_find_property
does that already.
2015-10-20 06:14:57 -04:00
Matthias Clasen
20079a9960 builder: Minor refactoring
Keep the GString in PropertyInfo around, instead of throwing it
away and just keeping the char*.
2015-09-07 12:25:29 -04:00
Matthias Clasen
569d5ad763 GtkBuilder: Export the template parsing entry point
This will let gtk-builder-tool validate templates.
2015-04-30 06:19:10 -04:00
Matthias Clasen
d58500b318 GtkBuilder: Report more lookup failures as GError
Report failures to lookup objects for property values
and bindings via GError too, and provide location information
while doing so.

https://bugzilla.gnome.org/show_bug.cgi?id=748234
2015-04-29 15:19:31 -04:00
Matthias Clasen
fc83c8ac76 GtkBuilder: Add new convenience API
Add a convenience function that is like gtk_builder_get_object()
but stashes away a GError if a lookup fails. To make the error
message informative, the function takes a line/column pair.

Doing things this way is necessary because the custom_tag_end,
custom_finished, and parser_finished vfuncs don't take a
GError parameter, despite being called from a place where
we can report a GError back.
2015-04-27 22:54:25 -04:00
Matthias Clasen
c8446f43fd GtkBuilder: Introduce some private helpers
Add functions that help reporting errors from builder
subparsers consistently.
2015-04-27 01:15:21 -04:00
Juan Pablo Ugarte
49fa04212b GtkBuilder: improved parsing error report for invalid properties and signals.
Added GTK_BUILDER_ERROR_INVALID_PROPERTY and GTK_BUILDER_ERROR_INVALID_SIGNAL
error codes

ObjectInfo: Use a GType instead of a char * for the class name.
PropertyInfo: Use a GParamSpec instead of a char * for the property name.
SignalInfo: Use signal id and detail quark instead of a detailed signal name string.

This not only save us a few malloc in each case but lets us simplify the code
and report unknown properties and signals as a parsing error instead of just
printing a warning.
2014-05-01 17:59:53 -03:00
Juan Pablo Ugarte
887fc60cce Added bindings support to GtkBuilder by introducing 3 new <property> attributes "bind-source" to specify the source object of the binding "bind-property" to specify the source property and "bind-flags" to specify the binding flags (optional)
Binding an object sensitive property with a check button active property will look like this:

<object class="GtkButton" id="button">
  <property name="sensitive" bind-source="checkbutton" bind-property="active"/>
</object>

This is based on the original work done by Denis Washington for his GSoC project

This closes Bug 654417 "[GSoC] Add <binding> element to GtkBuilder syntax"
2014-04-18 18:59:14 -03:00
Matthias Clasen
df455db2e3 GtkBuilder: Make IDs optional
One requirement of .ui files is that each object must have an ID,
even if it is never referred to or directly loaded from the code.
This makes editing .ui files much more onerous than it has to be,
due to the frequent need to invent new IDs, while avoiding
clashes.

This commit makes IDs optional in the XML. They only need to
be provided for objects which are referred to or explictly loaded
from the code. Since GtkBuilder needs IDs for its own internal
accounting, we create IDs of the form ___object_N___ if not
specified in the XML.

https://bugzilla.gnome.org/show_bug.cgi?id=712553
2013-11-18 06:00:02 -05:00
Matthias Clasen
e9f182e37a Fix a few memory leaks wrt to translations
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=699016
The fix here is slightly different. We make
_gtk_builder_parser_translate return a const char * instead of
a dup'ed string, and fix up the callers.
2013-04-28 21:43:49 -04:00
Tristan Van Berkom
b7da0d21f8 GtkBuilder: Add private _gtk_builder_extend_with_template()
This adds the definition of the <template> tag with some documentation
on the variant of the format.

_gtk_builder_extend_with_template() is to be used while GtkContainer
builds from composite templates. A couple of error codes are also added
to handle a few new possible failure cases.

DTD Files gtkbuilder.rnc and gtkbuilder.rng have been updated to include
the new <template> tag and it's attributes.
2013-04-08 21:19:27 +09:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Ryan Lortie
eed307713b GtkBuilder: change format of menus
Change the format of GtkBuilder <menu> to be more in-line with the style
of the rest of GtkBuilder so that we can do translation in a consistent
way.

The format is now substantially more difficult to hand-write, but tools
should be along soon.

There is an xslt program attached to the bug to help you convert your
existing .ui files from the old format to the new one.

https://bugzilla.gnome.org/show_bug.cgi?id=668696
2012-01-25 19:42:19 -05:00
Alexander Larsson
c72a76c754 Add resource support for GtkBuilder
There are new calls to load ui files from resources, and
you can now read pixbufs by using relative paths in a ui
file read from a resource, or by using absolute resource:/// uris.
2012-01-16 13:59:58 +01:00
Matthias Clasen
5562d0a57a Forgotten file 2011-12-19 12:51:12 -05:00
Matthias Clasen
1ddaf01aed Quick-and-dirty GtkBuilder integration
This makes GtkBuilder accept a GMenuMarkup tree at the toplevel
(ie with <menu id='foo'> being a child of <interface>) and the resulting
GMenu object can be obtained via gtk_builder_get_object (builder, "foo").
2011-12-19 12:45:50 -05:00
Matthias Clasen
1a312bfa3e Improve GtkBuilder error reporting
Make GtkBuilder report an error when it encounters a duplicate id,
instead of segfaulting later on
2009-04-06 20:13:35 -04:00
Paolo Borelli
6ee8be8899 Bug 447998 - GtkBuilder does not support building parts of the xml tree
2008-07-15  Paolo Borelli  <pborelli@katamail.com>

	Bug 447998 - GtkBuilder does not support building parts of the xml tree

	* gtk/gtkbuilder.c:
	* gtk/gtkbuilder.h:
	* gtk/gtkbuilderprivate.h:
	* gtk/gtkbuilderparser.c:
	* gtk/gtk.symbols:
	Add two new functions that allow cherry picking and construct
	objects from a ui description file or string.

	* gtk/tests/builder.c: tests for the above.


svn path=/trunk/; revision=20845
2008-07-16 15:36:53 +00:00
Michael Natterer
77e99003a8 gtk/gtkaction.h gtk/gtkbuildable.h gtk/gtkbuilderprivate.h
2008-06-23  Michael Natterer  <mitch@imendio.com>

	* gtk/gtkaction.h
	* gtk/gtkbuildable.h
	* gtk/gtkbuilderprivate.h
	* gtk/gtkcelllayout.h
	* gtk/gtkentrycompletion.h
	* gtk/gtkfilechoosersettings.h
	* gtk/gtkfilesystem.h
	* gtk/gtkfilesystemmodel.h
	* gtk/gtkicontheme.h
	* gtk/gtklinkbutton.h
	* gtk/gtkpagesetup.h
	* gtk/gtkpapersize.h
	* gtk/gtkprintcontext.h
	* gtk/gtkprintoperation.h
	* gtk/gtkprintoperationpreview.h
	* gtk/gtkprintsettings.h
	* gtk/gtkrecentchooserprivate.h
	* gtk/gtkrecentmanager.h
	* gtk/gtksearchengine.h
	* gtk/gtktexttag.h
	* gtk/gtktreeselection.h
	* gtk/gtktreeviewcolumn.h
	* gtk/gtkuimanager.h: remove redundant inclusion of <glib.h> and
	<glib-object.h>. There is no point in relying on them being pulled
	in by other headers in some places and placing them explicitly in
	other places, so choose the "as little includes as possible"
	approach and get rid of them.


svn path=/trunk/; revision=20675
2008-06-23 14:07:19 +00:00
Tristan Van Berkom
7b0ef2095a Added support for parsing required toolkit versions (so that ui
* gtk/gtkbuilderprivate.h, gtk/gtkbuilder.h, gtk/gtkbuilderparser.c:
	Added support for parsing required toolkit versions (so that ui descriptions
	can target specific versions of the backend widget libraries) bug 527612.

	* gtk/docs/reference/gtk/tmpl/gtkbuilder.sgml: Added documentation
	for the added xml tags to the ui description.


svn path=/trunk/; revision=20152
2008-05-25 15:12:39 +00:00
Michael Natterer
57fa18345f gdk/gdkspawn.h gtk/gtkbuilderprivate.h gtk/gtkfilechoosersettings.c
2008-03-14  Michael Natterer  <mitch@imendio.com>

	* gdk/gdkspawn.h
	* gtk/gtkbuilderprivate.h
	* gtk/gtkfilechoosersettings.c
	* gtk/gtksearchenginesimple.c
	* gtk/tests/liststore.c
	* gtk/tests/treestore.c: remove single-file includes of GLib
	headers or replace them by <glib.h> where needed.


svn path=/trunk/; revision=19877
2008-03-14 20:38:58 +00:00
Johan Dahlin
424cc287f1 - Treat enums like enums and not values - Avoid invalid free, in case of
2008-03-07  Johan Dahlin  <johan@gnome.org>

    * gtk/gtkbuilder.c:
    * gtk/gtkbuilderparser.c:
    * gtk/gtkbuilderprivate.h:
    * gtk/gtkiconfactory.c:
    * tests/buildertest.c:
    - Treat enums like enums and not values
    - Avoid invalid free, in case of more than two sources
    - Add better error messages
    - Add much improved tests
    (#520979, Christian Persch)


svn path=/trunk/; revision=19732
2008-03-07 20:03:35 +00:00