Commit Graph

1061 Commits

Author SHA1 Message Date
Benjamin Otte
27c9352df3 widget: Replace reset_style() calls
... with finer grained _gtk_widget_invalidate_style_context() calls.
2012-04-17 08:59:10 +02:00
Benjamin Otte
969daec353 widget: Don't go via path when resetting style
Instead, invalidate the path when the style context changes. And
invalidate the style context directly.
2012-04-17 08:59:09 +02:00
Benjamin Otte
d589566f40 widget: Add _gtk_widget_invalidate_style_context()
This is supposed to replace gtk_widget_reset_style().
2012-04-17 08:59:09 +02:00
Benjamin Otte
48a8ca8bbe widget: Merge function into only caller 2012-04-17 08:59:09 +02:00
Benjamin Otte
257d961a01 widget: Clear broken widget path in constructor
... where it belongs instead of fiddling with it in get_path().
2012-04-17 08:59:09 +02:00
Benjamin Otte
7f511f2b33 widget: Don't set widget path on style context
Instead, make the style context use the widget's path. Saves a bunch of
memory.
2012-04-17 08:59:09 +02:00
Benjamin Otte
e5ab48ac59 stylecontext: Notify widget directly of changes
This way, we don't need to g_signal_connect(), which saves a bunch of
memory and performance.
2012-04-17 08:59:08 +02:00
Benjamin Otte
1aa4a196dc stylecontext: Add setter for widget
... and actually set the widget on the style context. Note that this
function does not take a reference on the widget, which is a very good
reason to keep it private.
2012-04-17 08:59:08 +02:00
Matthias Clasen
050cba6a31 Fix malformed doc comments
Most of these are forgotten :'s and similar details
which gtk-doc now warns about.
2012-04-12 21:12:16 -04:00
Benjamin Otte
1ca8098543 widget: Create style context using regular API 2012-04-07 13:01:25 +02:00
Benjamin Otte
5d57981184 widget: Set up signals after initializing style context
Otherwise, signals would be emitted on semi set up style context which
would then cause crashes when the signal handlers tried to use them.

https://bugzilla.gnome.org/show_bug.cgi?id=662023
2012-03-09 13:23:05 +01:00
Chun-wei Fan
4e5a8b822d gtkwidget.c: Use G_VA_COPY instead of va_copy()
va_copy() is not universally available, and we already have a G_VA_COPY
macro that emulates the behaviour of va_copy() when it's not available, or
simply calls va_copy() if it's there
2012-03-08 18:56:32 +08:00
Alexander Larsson
2422c44f8e Add custom va_marshallers in some places
This is a slight performance optimization in the common case.
2012-03-05 12:39:09 +01:00
Carlos Garcia Campos
9f4bfff1b0 gtk: Add a way to do event capture
This patch adds a capture phase to GTK+'s event propagation
model. Events are first propagated from the toplevel (or the
grab widget, if a grab is in place) down to the target widget
 and then back up. The second phase is using the existing
::event signal, the new capture phase is using a private
API instead of a public signal for now.

This mechanism can be used in many places where we currently
have to prevent child widgets from getting events by putting
an input-only window over them. It will also be used to implement
kinetic scrolling in subsequent patches.

http://bugzilla.gnome.org/show_bug.cgi?id=641836

We automatically request more motion events in behalf of
the original widget if it listens to motion hints. So
the capturing widget doesn't need to handle such
implementation details.

We are not making event capture part of the public API for 3.4,
which is why there is no ::captured-event signal.
2012-03-01 16:25:21 -05:00
Matthias Clasen
6c257040a5 gtk: translate unhandled touch events to button events
We don't want to fallback for 'random' touch sequences, since
that could lead to all kinds of pairedness and other violations.
Since the X server already tells us what touch events it would
have used for emulating pointer events, we just use that information
here.
2012-03-01 16:25:21 -05:00
Matthias Clasen
680872815b gtk: Add a separate ::touch-event signal 2012-03-01 16:25:20 -05:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Javier Jardón
392fdff8e5 docs: GtkWidget's "state-flags-changed" is a signal not a property 2012-02-15 13:43:58 +00:00
Murray Cumming
a0b4ab109d Documentation: Correct references to properties.
These should use :, not ::, though signals would use ::.
See
http://developer.gnome.org/gtk-doc-manual/unstable/documenting_syntax.html.en
and
http://developer.gnome.org/gtk-doc-manual/unstable/documenting_symbols.html.en
2012-02-15 11:43:33 +01:00
Andrea Cimitan
4a18fe7ef2 Introduce gtk_window_get/set_attached_to()
gtk_window_get/set_attached_to() is a new API that allows for windows to
be attached to a GtkWidget.
The attachment is a logical binding between the toplevel window and the
widget that generated it; this kind of information is currently used to
propagate style information from the widget to the window, but is also
useful e.g. for accessibility.

https://bugzilla.gnome.org/show_bug.cgi?id=666103
2012-01-12 14:03:00 -05:00
Rui Matos
e9adaabc5e Rename 'window-unfocused' to 'backdrop'
'window-unfocused' is too long and mentions "focus" which is historically
loaded with the meaning "input focus".

'backdrop' isn't generally used in GUI speak and still conveys the state the
widgets in an unfocused or background toplevel window are in.
2012-01-09 18:38:00 +01:00
Benjamin Otte
0ac519e8a1 widget: Set parent style context 2012-01-09 18:37:50 +01:00
Javier Jardón
d005b01319 gtk/*: Use g_list_free_full() convenience function 2012-01-05 04:22:43 +01:00
Benjamin Otte
8a83f0c2d1 widget: Print a g_warning() when a cairo_t is invalid
Only print the warning on internal code, so we aren't too verbose.
2011-12-23 00:15:59 +01:00
Rui Matos
cc8012eb32 widget: Set style flags on the style context when the flags are set
This will allow us to simplify most draw methods by not having to explicitly
set the style flags on the context.
2011-12-19 19:21:15 +00:00
Rui Matos
eecbdb6f57 widget: Always propagate state flags to all children
https://bugzilla.gnome.org/show_bug.cgi?id=666126
2011-12-19 19:21:15 +00:00
Matthias Clasen
2398d7e900 Introduce gtkaccelmapprivate.h
Move internal accel map API there and update all users.
Also, add an internal function to create an accel path for
an action and parameter, and use it in gtkapplication.c and
gtkmodelmenuitem.c instead of duplicating that code.
2011-12-19 12:51:11 -05:00
Benjamin Otte
0c1f2f2fc1 widget: Set widget in accessible's constructor
No need to add t manually later.
2011-12-19 16:17:13 +01:00
Benjamin Otte
03a63def24 widget: Unref accessible 2011-12-19 16:17:13 +01:00
Benjamin Otte
e042462674 widget: Unset self from accessible 2011-12-19 16:17:13 +01:00
Benjamin Otte
23b5f9c066 widget: Unset widget on accessibles 2011-12-19 16:17:13 +01:00
Rui Matos
9d6da33ff5 widget: Flip the sensitive flag even if the state doesn't change
Even if we can't change our sensitivity because the parent is insensitive we
should still flip the sensitive flag. Otherwise, with and insensitive parent,

child.set_sensitive(True)
...
parent.set_sensitive(True)

would result in child still being insensitive.

https://bugzilla.gnome.org/show_bug.cgi?id=666392
2011-12-17 11:48:01 +00:00
Benjamin Otte
94f00eb04d widget: Don't change sensitive state with insensitve parent
This way child.set_sensitive(True) with an insensitive parent doesn't
cause child to become sensitive.
2011-12-16 04:50:11 +01:00
Rui Matos
1235dc320b widget: Synthesize crossing only if sensitivity changed while propagating state 2011-12-14 17:03:44 +00:00
Alexander Larsson
10b5ec20f2 Fix set_focus_child handling during focus changes
In many cases we used to set focus_child to NULL all the way up
to the top and then to the right value, even if there was
a common ancestor, meaning these see a temporary NULL value for
focus_child. Only when the new focus widgets direct parent was
in the previous ancestor list did we stop early.

This fixes that by always stopping propagation when reaching
the common ancestor.
2011-12-14 00:26:40 +01:00
Rui Matos
7a6babfd02 widget: Unset window-unfocused in gtk_widget_unparent()
Widgets without a parent aren't inside a toplevel window so we must remove
window-unfocused as it doesn't make sense outside a toplevel.

https://bugzilla.gnome.org/show_bug.cgi?id=661428
2011-12-07 22:41:58 +00:00
Benjamin Otte
4259a27cf5 widget: Update Pango context on state change
The layout depends on the state flags, so it must be updated when they
change.
2011-12-05 18:27:05 +01:00
Matthias Clasen
7814718152 Drop uses of @returns syntax 2011-11-21 13:12:58 -05:00
Murray Cumming
43dd705308 Fix tiny docs typo. 2011-11-18 11:30:07 +01:00
Benjamin Otte
0b716e77ea widget: Add _gtk_widget_peek_accessible()
This function returns the accessible if it already exists. This way we
can call functions on the accessible from the widget itself instead of
having to rely on signals.
2011-11-16 04:39:23 +01:00
Benjamin Otte
fd93e08a7c widget: Don't use deprecated symbols
Not even in deprecated functions!
2011-11-08 21:14:06 +01:00
Benjamin Otte
d41732b729 widget: Deprecate gtk_widget_get_pointer () 2011-11-08 21:14:06 +01:00
Rui Matos
70f87b8bd5 gtk: Add a GTK_STATE_FLAG_WINDOW_UNFOCUSED widget state flag
This allows themes to style widgets differently according to whether the
toplevel window they are in is presented as focused.

https://bugzilla.gnome.org/show_bug.cgi?id=661428
2011-11-08 19:33:22 +00:00
Matthias Clasen
2de4405c32 Move deprecated gtkwidget style api to gtkstyle 2011-11-02 08:10:42 -04:00
Matthias Clasen
df1e2cd128 Fix more test breakage 2011-10-25 07:38:36 -04:00
Benjamin Otte
b195c7dbb2 a11y: Hack around infinite loops in parent setting
This is kind of a hack to get rid of infinite loops that occur when
child accessibles try to set their parent upon creation but the parent
accessible creates its children in the initialize vfunc. Because in that
case, the parent will not have an accessible set when the child tries to
access it, because it is still initializing itself. Which will cause a
new accessible to be created.

https://bugzilla.gnome.org/show_bug.cgi?id=660687
2011-10-25 07:38:36 -04:00
Michael Natterer
5c4f2ef0c1 gtk: move _gtk_modules_has_mixed_deps() to gtkmodlesprivate.h
and remove gtkmainprivate.h completely.
2011-10-23 13:57:07 +02:00
Michael Natterer
4a7a67339a Bug 659602 - Provide an abstraction for the platform's use of modifier keys
Add enum GdkModifierIntent which identifies use cases for modifier masks
and GdkKeyMap::get_modifier_mask(). Add a default implementation which returns
what is currently hardcoded all over GTK+, and an implementation in the
quartz backend. Also add gtk_widget_get_modifier_mask() which simplifies
things by doing widget->display->keymap->get_modifier_mask().
2011-09-27 09:56:25 +02:00
Matthias Clasen
5ff8fe6971 Documentation fixes
Mostly making sure that return values and varargs don't loose
their docs.
2011-09-25 21:04:49 -04:00
Matthias Clasen
a233022934 Disable underallocation warnings in non-debug builds
It doesn't look like we have much traction of actually fixing
these, and there is very real cost to not being able to distcheck.
2011-08-30 11:28:52 -04:00
Jürg Billeter
c7bcef426b widget: Add transfer annotation for gtk_widget_set_window
gtk_widget_set_window does not add any reference to the window and
unrealize will destroy it.
2011-08-11 12:35:46 +02:00
Matthias Clasen
2ba9c4b4a7 Make focus rectangles optional
This commit introduces a new setting, gtk-visible-focus, backed
by the Gtk/VisibleFocus X setting. Its three values control how
focus rectangles are displayed.

'always' is equivalent to the traditional GTK+ behaviour of always
rendering focus rectangles.

'never' does what it says, and is intended for keyboardless
situations, e.g. tablets.

'automatic' hides focus rectangles initially, until the user
interacts with the keyboard, at which point focus rectangles
become visible.

https://bugzilla.gnome.org/show_bug.cgi?id=649567
2011-08-10 16:34:20 +02:00
Matthias Clasen
2983f3fc14 Update gtk_widget_get_accessible() docs
Don't mention GTK_MODULES for loading a11y implementations
anymore.
2011-07-23 21:28:29 -04:00
Benjamin Otte
9c81336830 widget: Reset the accessible role when a new accessible type is set
We want the role to be kept in the accessible object. Using
gtk_widget_class_set_accessible_role() is only meant as a quick
workaround to requiring subclassing of the accessibles in the quite
common case where a subclass does not change the accessible
implementation at all and only has a different role.
2011-07-18 18:30:50 +02:00
Benjamin Otte
b17ad131ea API: Add gtk_widget_class_set_accessible_role()
Easy access to modifying the roles of subclasses, as this is a thing
that commonly changes for various subclasses.
2011-07-18 18:30:49 +02:00
Matthias Clasen
d8c00cd537 Revert "Add a getter for the accessible type of a widget class"
This reverts commit 9a212b3120.
2011-07-14 19:28:07 -04:00
Matthias Clasen
9a212b3120 Add a getter for the accessible type of a widget class
This will be necessary to port out-of-tree a11y implementations
from the atk object factory approach to this new way of doing
things.
2011-07-13 23:02:25 -04:00
Matthias Clasen
775ccf39e7 Initial conversion of GailWidget to GtkWidgetAccessible 2011-07-05 16:09:57 -04:00
Benjamin Otte
4227a63f48 widget: Use g_type_add_class_private()
It turns out that that funciton does indeed exist and my rant was just
outdated. Shame on me.
2011-07-05 16:08:01 -04:00
Benjamin Otte
ebf8bf0000 API: Add gtk_widget_class_set_accessible_type()
The function is supposed to bypass the ATK registry. For 2 reasons:
1) We get rid of a lot of boilerplate madness.
2) The registry allows creating multiple accessibles per widget and we
   don't.

The old code for registries is still there.
2011-07-05 16:07:57 -04:00
Benjamin Otte
9ebcd66d43 widget: Add a GtkWidgetClassPrivate
As long as glib doesn't provide class privates, we'll have to ship our
own...
2011-07-05 16:07:57 -04:00
Matthias Clasen
f1a9c3efff Remove unused includes
Nothing is using gtkrc.h functionality any more.
2011-06-16 23:33:43 -04:00
Benjamin Otte
76f2aa737b docs: Add Since tag to GtkWidget::draw 2011-06-13 18:29:07 +02:00
Javier Jardón
bf0d8402f5 gtk: Use const instead G_CONST_RETURN 2011-06-10 13:07:54 +01:00
Javier Jardón
7b0d77def5 gtkcontainer: Move private functions to private header
https://bugzilla.gnome.org/show_bug.cgi?id=651707
2011-06-06 12:10:29 +01:00
Benjamin Otte
c6285387e3 widget: Update the font at the right place
Doing it unconditionally is not useful when the subclasses actually
using them can only ever do it in the style_updated signal. So do it in
the style_updated handler instead.
2011-06-04 21:18:09 +02:00
Benjamin Otte
a6daba5e78 API: Change semantics of gtk_container_get_child_path()
Include the child widget path in the returned path now. This allows
customizing the path of the current widgets - like adding flags to child
widgets (and maybe siblings in the future).
2011-06-02 02:03:50 +02:00
Benjamin Otte
b0616c8225 API: Add gtk_widget_path_append_for_widget()
Includes a bunch of header shuffling so we can use GtkWidget* in
gtkwidgetpath.h
2011-06-02 02:03:50 +02:00
Javier Jardón
fb9e4c2c37 all: avoid boxed structs copying where possible (and 2)
Use the GtkStyleContext accessors for boxed properties where possible,
to reduce allocations.
2011-05-31 19:18:11 +02:00
John Stowers
21761ce5fc Add missing gtk_widget_override_* annotations
https://bugzilla.gnome.org/show_bug.cgi?id=649779
2011-05-09 23:09:26 +12:00
Matthias Clasen
deb271d355 Add gtk_container_child_notify
This is a variant of gtk_widget_child_notify() that takes an
explicit container, instead of relying on widget->parent to
be the correct container to use.
2011-05-06 14:29:14 -04:00
Matthias Clasen
cf588d7404 GtkWidget: avoid an unused variable warning 2011-05-01 10:02:58 -04:00
Benjamin Otte
5b1ca9dfa8 widget: Allow underallocation for scrollables
Also document this fact.
2011-04-28 22:21:45 +02:00
Benjamin Otte
7e2eed8c1b widget: Update underallocation warning
Also print the parent widget. As the parent's size_allocate
implementation is usually the culprit for this warning happening, it
makes sense to print it.
2011-04-28 22:21:45 +02:00
Benjamin Otte
92f9892cca widget: Warn when allocation for gtk_widget_size_allocate() is too small
Widgets may not be underallocated, it is the responsibility of the
caller to ensure this never happens.
2011-04-28 05:13:30 +02:00
Benjamin Otte
9bb145a677 widget: Add hack to make label mnemonics work again
Mnemonics for characters that go beyond the baseline (q, y, g) were not
being shown, because they are drawn outside of the label's allocated
size.
This patch just disables the clip-to-size for labels, so that the label
can draw outsize of its allocation. In most cases, that works around
this bug.

https://bugzilla.gnome.org/show_bug.cgi?id=648570
2011-04-26 14:15:34 +02:00
Benjamin Otte
10fd53970c docs: Strictify the docs for gtk_cairo_should_draw_window()
We don't actually enforce the docs, but we will in the future. (in fact,
I only added this because widgets were doing stupid things.)
2011-04-19 22:18:18 +02:00
Benjamin Otte
b5dc24fd28 widget: Make gtk_widget_get_aux_info() private 2011-04-19 22:18:18 +02:00
David King
e279210522 widget: add Since tags for margin accessors 2011-04-18 08:22:54 +02:00
Benjamin Otte
71e9606e16 docs: Fix wrong description for query-tooltip
Coordinates are not relative to widget->window
2011-04-16 22:31:24 +02:00
Matthias Clasen
304989291d GtkWidgetPrivate: Improve struct packing 2011-04-12 12:50:30 -04:00
Benjamin Otte
0bfc95faa3 widget: Propagate the right states to the widget when setting the parent 2011-03-30 16:40:06 +02:00
Benjamin Otte
1e43965350 widget: Get rid of parent_sensitive flag
Instead rely on state_flags & GTK_STATE_FLAG_INSENSITIVE to tell us if a
widget is sensitive.
This has the huge benefit that the way the widget is actually rendered
corresponds to the return value of gtk_widget_is_sensitive().

As a side effect, we do not ever allow unsetting the
GTK_STATE_FLAG_INSENSITIVE for a widget the is set to not be sensitive
(via gtk_widget_set_sensitive()). This way we stop propagation of making
stuff sensitive at insensitive widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=642918
2011-03-30 16:40:06 +02:00
Matthias Clasen
b2f872112a Make GtkWidget::halign RTL-save
This commit makes GTK_ALIGN_START/_END pay attention to
the text direction when used in horizontal context.

This is how similar parameters in GtkMisc and GtkAlignment work,
and is generally expected of GTK+ positioning parameters. And this
is new GTK+ 3 api, so it is basically still unused at this point.

If explicit right/left turn out to be needed at some point, we
can expand the enumeration with new values.
2011-03-30 10:34:02 -04:00
Benjamin Otte
179cec87c8 widget: Only reemit style-set signal after gtk_widget_get_style()
If the widget does not care about the compat code, just ignore it.
2011-03-27 03:44:19 +02:00
Benjamin Otte
9d3465412e widget: Don't invalidate style context in its invalidate callback 2011-03-27 03:39:43 +02:00
Benjamin Otte
bb879b6954 widget: Update path unconditionally in gtk_widget_reset_style()
Also, don't set the new path twice on the style context.
2011-03-27 01:53:04 +01:00
Benjamin Otte
d7ca207133 widget: Don't duplicate style context updates
The screen changes are done in do_screen_change(), the widget path is
updated in gtk_widget_reset_style().
2011-03-27 01:52:16 +01:00
Benjamin Otte
fb65806c8c widget: Call the non-deprecated function
Both functions are identical, just that one isn't deprecated.
2011-03-27 01:51:20 +01:00
Benjamin Otte
fafee4e276 widget: Emit initial style-set signal in the same situations as GTK2
This ensures that widgets that aren't ported and rely on the style-set
signal being emitted work as well as before. They should not rely on
style-set being emitted however.

Note that this function is a no-op if the initial style has been set
already and is very cheap if it has not been set yet. It only becomes
relevant if the resulting style actually gets used.

https://bugzilla.gnome.org/show_bug.cgi?id=639584
2011-03-27 00:48:26 +01:00
Benjamin Otte
af8a6a7abd widget: Create the widget's style lazily
That way we don't have to update the style's colors all the time on
theme changes when the widget is not actually using GtkStyle.
2011-03-27 00:48:26 +01:00
Benjamin Otte
1891b790b3 widget: Don't call gtk_style_attach() and gtk_style_detach() anymore 2011-03-27 00:48:26 +01:00
Benjamin Otte
080ae55e87 docs: Make clear that gtk_widget_set_style() does not do anything 2011-03-27 00:48:26 +01:00
Benjamin Otte
29444cc30e widget: Use a priv variable 2011-03-27 00:48:26 +01:00
Benjamin Otte
2bb64c868c widget: Widgets always have a style, so no need to check for NULL 2011-03-27 00:48:26 +01:00
Benjamin Otte
963c0905f2 widget: Reshuffle code for style context getter
The intention of this patch is to make the code clearer, shorter and
most of all to avoid recreating the widget path and setting it path
twice on the style context when the style context was recreated.
2011-03-27 00:48:25 +01:00
Benjamin Otte
757087e9b4 widget: Don't create the style context if not necessary
If all we want to do is update the context's screen, we don't need to
create it if it doesn't exist yet.
2011-03-27 00:48:25 +01:00
Benjamin Otte
0cdebc8bd5 Revert "Ensure GtkWidget::style-updated is emitted before first size negociation"
This reverts commit b7f772eb93.

The commit just poked around things and added lots of workarounds
instead of actually fixing the bug it set out to fix.

See https://bugzilla.gnome.org/show_bug.cgi?id=639584 for details.
2011-03-26 23:52:28 +01:00
Benjamin Otte
8ce533265e gtk: Reset children styles when changing name
Changing the name of a widget does not just change the current widget's
path, but also the path of all its children.
2011-03-26 23:51:51 +01:00
Tristan Van Berkom
38b5c8cf45 Cache heights-for-range-of-widths instead of height for every width.
This patch optimizes window resizes by assuming that if a widget
has the same height at a width of 50 as with a width of 150, the
height for width 100 will also be the same.

The patch also further optimizes the cache allocator, now there
are 2 pointer arrays of up to a maximum of 5 requests, the arrays
will only be allocated if a request is ever made in that orientation
and the array will be sparse until each request is made (i.e. if a
label can only wrap to 3 lines, there will only be 3 out of a
possible 5 SizeRequest structures allocated to cache it).
2011-03-25 18:42:08 +09:00