Commit Graph

129 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
69293db804 builderparser: Only allocate subparser stack when needed
Out of the 3.3k possibly_finish_subparser calls when opening the
widget-factory, only 300 need one.
2021-01-17 04:39:26 +01:00
Timm Bäder
071ea6b559 builderparser: Use GPtrArray for stack 2021-01-05 08:53:11 +01:00
Matthias Clasen
e4be785c6c builder: Be a bit more strict about requires
Check that the major version matches (without this, the
requires check is really toothless), but allow 3.99 to
match 4.0.
2020-11-10 19:18:26 -05:00
Arnaud Bonatti
db6d7dccd8 Drop “gtk+” plus sign in GtkBuilder <requires>. 2020-11-07 16:16:55 +01:00
Sophie Herold
cd0bef9390 Add some missing nullable return annotations 2020-10-17 15:32:36 +02:00
Florian Müllner
2715b3ec31 buildable: Make vfunc accessor functions private
With the exception of gtk_buildable_get_id(), those are only used
to construct objects from XML descriptions, which is functionality
internal to GTK.

The API is therefore unlikely to be missed, and keeping it internal
means they can no longer unintentionally shadow object methods in
bindings with less namespacing; for example it's currently ambiguous
whether `infoBar.add_child()` refers to gtk_info_bar_add_child() or
gtk_buildable_add_child().

https://gitlab.gnome.org/GNOME/gtk/-/issues/3191
2020-09-26 02:16:57 +02:00
Matthias Clasen
125ed52ccb Merge branch 'new-sysprof' into 'master'
Port profiling to sysprof-collector api

See merge request GNOME/gtk!2457
2020-08-21 23:58:09 +00:00
Matthias Clasen
d4e069a629 Port tracing to the sysprof collector api
Use the new sysprof collector api to do tracing.
2020-08-21 10:55:01 -04:00
Björn Daase
6315cd977c *: Fix spelling mistakes found by codespell 2020-08-21 15:29:34 +02: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
713a6676ff builder: Allow text content in <lookup>
<lookup>foo</lookup>
is now short for
  <lookup>
    <constant>foo</constant>
  </lookup>
ie it looks up the object with the given name so it can then do a
property lookup with it.

This is the most common operation, so it's a nice shortcut.
2020-05-30 19:26:44 -04:00
Benjamin Otte
448a88e4f5 builder: Allow <constant> without a type
A constant without a type is assumed to be an object. This is the most
common case and allows
  <constant>foo</constant>
without requiring updates to the type whenever the foo object changes.
2020-05-30 19:26:44 -04:00
Benjamin Otte
ed22af50bc builder: Make <lookup> type optional
If no type is set, use the type of the expression.
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
e356d59a92 build: Add -Wnull-dereference
Sprinkle various g_assert() around the code where gcc cannot figure out
on its own that a variable is not NULL and too much refactoring would be
needed to make it do that.

Also fix usage of g_assert_nonnull(x) to use g_assert(x) because the
first is not marked as G_GNUC_NORETURN because of course GTester
supports not aborting on aborts.
2020-03-05 08:14:37 +01:00
Alexander Larsson
e134eef505 builder: Don't add profiler marks for short parses
There are a lot of thes (since we're recursing), so don't spew the
output with uninteresting ones.
2020-02-12 12:42:29 +01:00
Alexander Larsson
2890cd849f profiler: Add _end_mark() version of _add_mark()
These don't take a duration, instead they call g_get_monotonic_time() to
and subtract the start time for it.

Almost all our calls are like this, and this makes the callsites clearer
and avoids inlining the clock call into the call site.
2020-02-12 11:25:34 +01:00
Alexander Larsson
cc643df88b Convert all profiler times from nsec to usec
usec is the scale of the monotonic timer which is where we get almost
all the times from. The only actual source of nsec is the opengl
GPU time (but who knows what the actual resulution of that is).

Changing this to usec allows us to get rid of " * 1000" in a *lot* of
places all over the codebase, which are ugly and confusing.
2020-02-12 10:44:17 +01:00
Matthias Clasen
cb60c1b83d builder: Add profiler marks for parsing
This is useful to understand what ui files take
long to load.
2020-01-30 10:04:38 +01:00
Benjamin Otte
5015730212 builder: Turn last dlsym() function into a scope API
Looking up a get_type function by its name is now also part of
GtkBuilderScope.
2019-12-12 19:39:36 +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
33bd8f322c builder: Improve error message 2019-12-03 18:12:25 +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
Rico Tzschichholz
97231ca231 gtk: Fix some g-i annotation warnings 2019-09-15 17:57:28 +02:00
Rico Tzschichholz
67bd28eaaf gtk: Fix parameter annotations for gtk_buildable_parse_context_get_position 2019-09-15 17:57:28 +02: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
Mohammed Sadiq
c1bb699151 builderparser: Allow bind-source without bind-property
This allow users to bind same property of two objects with only
specifing “name” and “bind-source” in UI file.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2080
2019-08-10 19:01:36 +05:30
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
Debarshi Ray
60cee7339f GtkBuilder: Enforce "class" as a mandatory attribute for <object>
https://bugzilla.gnome.org/show_bug.cgi?id=786931
2017-09-25 15:26:34 +02:00
Debarshi Ray
fd9aec27fc GtkBuilder: Prefer "type-func" over "class" when looking for the GType
https://bugzilla.gnome.org/show_bug.cgi?id=786932
2017-08-29 15:41:01 +02: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
c392f41bb2 builderparser: Shuffle if-statements around once more
The previous reordering broke the builderparser test case.
2017-01-08 13:07:12 +01:00
Timm Bäder
212f8a6c7b builderparser: Order string comparisons after frequency
The typical UI file has a lot more <property> tags than it has
<requested> or <interface> tags, etc. so order the string comparisons
according to this expected case.
2016-10-31 19:29:36 +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
Timm Bäder
f415a8bc84 builderparser: stack-allocate ParserData
No reason for it to be heap-allocated, it won't survive this function
call anyway.
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
2ee7fb1818 Don't use g_print for debug output
The g_print documentation explicitly says not to do this, since
g_print is meant to be redirected by applications. Instead use
g_message for logging that can be triggered via GTK_DEBUG.
2016-02-28 21:40:23 -05:00
Matthias Clasen
eec75ee9d6 Cosmetic changes
Line up struct-filling code with the order in the declaration.
2015-10-20 06:14:57 -04:00