Exit early in gtk_style_context_update_cache codepaths
If lookup->missing is empty we don't need to continue looking.
We short circuit in several places as this can happen
after iteratively makeign lookup->missing smaller.
We need to use the allocated codepath if *any* argument is
allocated, not if one arg is not allocated.
This bug caused unnecessary calls to _gtk_bitmask_is_allocated,
as well as return completely wrong result if both bitmask are
allocated.
What is this bin doing with all these crazy deltas? Company does:
<Company> that can safely be removed
<Company> in general, code that isn't obvious can either be understood
<Company> with a bit of thinking or it can be removed
<Company> if in doubt, go for the 2nd of those :)
Most GtkBin subclasses override this strange garbage anyway, so it's
not like this code is ever *run*, per se. Just make it proxy directly
to the child, and hope nothing goes wrong.
gtkbin: Complete more of a base implementation for GtkBin subclasses
Implement get_preferred_width, get_preferred_height, and size_allocate.
This allows GtkBin subclasses to be quick and easy, without the
author doing the subclassing to have to do much work.
Benjamin Otte [Thu, 8 Nov 2012 22:15:19 +0000 (23:15 +0100)]
label: Fix another sizing corner case causing segfaults
If the "wider" label is the smaller one, use the wider size for both
cases. This can happen when ellipsizing a single character, which is
often smaller than the ellipsizing glpyph(s).
Benjamin Otte [Thu, 8 Nov 2012 15:17:00 +0000 (16:17 +0100)]
symboliccolor: Change the print output
Functions should not have a space before the opening parenthesis. So
change output like
alpha (@color, 0.5)
to
alpha(@color, 0.5)
and do the same for "shade" and "mix".
Benjamin Otte [Tue, 6 Nov 2012 19:50:09 +0000 (20:50 +0100)]
Disable deprecation checks for all libraries we depend on on stable branches.
This is so newer versions of those libraries don't cause more warnings
with a stable GTK version.
We don't ever want to turn off deprecation warnings for master however,
because that's where we get rid of deprecated API we use.
Note that only glib allows use to easily do this, so nothing is done for
Pango, gdk-pixbuf or Cairo here.
Benjamin Otte [Mon, 5 Nov 2012 17:55:27 +0000 (18:55 +0100)]
label: Handle crazy corner cases
With ellipsizing, the ellipsized text can have a smaller height than the
non-ellipsized text. So the wider text is also higher. Example:
.<big>TEXT</big>
will ellipsize to the small text.
Paolo Borelli [Sun, 4 Nov 2012 15:46:35 +0000 (16:46 +0100)]
gtkmenubutton: remove weak pointer when needed
We must make sure to remove the weak pointer when disposing the widget
or when resetting the align widget otherwise glib will try to nullify
invalid memory.
Benjamin Otte [Sun, 4 Nov 2012 14:47:03 +0000 (15:47 +0100)]
sizegroup: Construct the set of sizegroup peers as a hash table
This way we don't need a marker on GtkWidgetParivate that needs to be
unset later, so we have all our data in the same place and can avoid
problems with reentrancy and shenanigans like that.
Benjamin Otte [Sat, 3 Nov 2012 17:52:28 +0000 (18:52 +0100)]
sizerequest: Move optimization
With size groups now doing hfw, doing the optimization for CONSTANT_SIZE
was done too early. Size groups need to know that it's a hfw request, so
the other widgets in the size group get the correct behavior.
Benjamin Otte [Fri, 2 Nov 2012 20:49:32 +0000 (21:49 +0100)]
label: Fix ellipsize and wrap being set
The label code assumed that Pango treats this as "wrap to as much space
as possible and then ellipsize all the lines", but for Pango, ellipsize
takes precedence over wrap. So do the same thing in GtkLabel.
Also updated is the reftest that checked this behavior.
Benjamin Otte [Fri, 2 Nov 2012 20:38:16 +0000 (21:38 +0100)]
reftests: Improve reftest performance
Get rid of all the event boxes in this test. Event boxes need GDK
windows which cost a lot of performance when running the test and they
clip the label output.
Getting rid of the clipping also shows 2 bugs in this test that weren't
visible before. Those will be fixed in a followup patch.
Benjamin Otte [Thu, 1 Nov 2012 23:50:54 +0000 (00:50 +0100)]
sizerequest: Cache sizes without size groups
We compute on-demand for size groups anyway, so we can (in theory, this
patch doesn't do that yet) get around costly cache blowing when
invalidating single widgets of a size group this way.
Benjamin Otte [Thu, 1 Nov 2012 23:44:30 +0000 (00:44 +0100)]
sizegroups: Use is_visible() instead of get_mapped() for visibility
The current approach of using gtk_widget_get_mapped() is broken:
The usual steps taken when showing a window are:
(1) request the sizes
(2) allocate the sizes
(3) show the window in the allocated size
Showing the window with a random size between steps (1) and (2) would of
course
result in extra work and potential flickering when the widgets get
resized to
their proper sizes.
However, as GtkSizeGroup::ignore-hidden uses gtk_widget_get_mapped() to
determine visibility for a widget, the following will happen:
(1) the widget will request a 0 size
(2) the widget will be allocated a 0 size
(3) the widget will be too small when it is shown
gtk_widget_get_visible() however is set in advance. Note that toggling
visibility also causes a gtk-widget_queue_resize() call already so we
take care of changes in here automatically.
Benjamin Otte [Thu, 1 Nov 2012 23:12:48 +0000 (00:12 +0100)]
sizegroup: Check ignore_hidden flag when adding groups
Instead of only checking the ignore_hidden flag when getting the
preferred sizes, respect it already when constructing the list of
widgets. This way, widgets don't queue resizes for groups they're
ignored in anyway.
Benjamin Otte [Thu, 1 Nov 2012 23:06:02 +0000 (00:06 +0100)]
sizegroup: Use for loops
For loops to loop over lists look nicer and actually do the right thing
with "break" and "continue" statements. So they are vastly preferred to
while loops.
Benjamin Otte [Thu, 1 Nov 2012 22:41:38 +0000 (23:41 +0100)]
sizegroup: Don't cache the sizes anymore
This simplifies code and because sizes are cached by the widgets
themselves, it's not a large performance problem (unless people use huge
amounts of widgets in a single size group, but who does that?
bgo#687196 - Fix model corruption during file removal
The main problem is that we were emitting the row-deleted signal for the model in the middle
of the process that actually deletes the row from the model (remove the row from the array,
update the model->file_lookup hash table, etc.). In the model's caller, one of the row-deleted
callbacks was requesting an iter, which caused the model to revalidate itself - but it did
this while it was in an inconsistent state. This led to an assertion failure later when the
model resorted itself.
The fix in remove_file() is like this:
* The filteredness/visibility of the deleted node is not updated. The
node will simply be gone; we don't need to update those values at
all.
* We invalidate just the node that is being deleted.
* The model->file_lookup hash table is not completely nuked; instead,
we carefully adjust its indices.
* The row-deleted signal is only emitted at the very end, when
deletion is complete and the model is consistent.
Many thanks to William Hua for doing the detective work on this bug!
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
Cosimo Cecchi [Sun, 28 Oct 2012 19:01:30 +0000 (15:01 -0400)]
icon-theme: support loading symbolic GFileIcons from generic URIs
Right now we support loading and recoloring symbolic GFileIcons, but
only if the underlying GFile has a local path. This breaks when the
GFileIcon is loaded from a GResource, which is a reasonable option for an
application that wants to ship a custom symbolic icon.
This patch changes GtkIconInfo to store a GFile together with the file
path, and changes the symbolic icon lookup code to use the GFile URI,
which transparently makes the code work also for GResources.
Benjamin Otte [Fri, 26 Oct 2012 23:39:30 +0000 (01:39 +0200)]
themingbackground: Restructure code some more
Move variable initialization outside the first code with side effects.
This allows adding some more early returns, including one for code that
used to trigger g_return_if_fail() in certain corner cases.
Benjamin Otte [Fri, 26 Oct 2012 21:33:40 +0000 (23:33 +0200)]
stylecontext: Don't use bg image in gtk_style_context_set_background()
Old code tried to use the "background-image" proeprty for setting the
default image background. While this used to work in the early days of
GTK3, today it is grossly misleading as the backgronud image may be
resized, repositioned and semi-translucent which causes very weird
artifacts when rendering.
Benjamin Otte [Wed, 19 Sep 2012 14:41:19 +0000 (16:41 +0200)]
settings: Use _gtk_css_provider_load_named()
This way we create one provider per settings object instead of stuffing
it into a global unchanging never-deleting hash table.
Also, we now reload the theme when instructed instead of keeping the old
loaded (and possibly stale) data forever.
Benjamin Otte [Wed, 19 Sep 2012 14:30:27 +0000 (16:30 +0200)]
cssprovider: Move fallback code into _gtk_css_provider_load_named()
This makes sure the full theme loading logic resides in one function and
isn't scattered around.
As a side-effect, the hash table kept by gtk_css_provider_get_named()
will now be populated with fallback themes. This will not be a problem
after the next commit though.
Benjamin Otte [Wed, 19 Sep 2012 14:07:39 +0000 (16:07 +0200)]
cssprovider: Split out theme loading function
Split maintaining the global themes hash table and the theme loading
code into two functions.
This also fixes leaking the provider when loading a theme from a builtin
resource.