Commit Graph

70 Commits

Author SHA1 Message Date
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
bbd94b5a9f gtk: Strip newlines from g_warning and g_error
g_logv adds one for us already.
2016-02-28 12:23:12 -05:00
Matthias Clasen
3526b08e01 Clean up debug features
Introduce a GTK_DEBUG_CHECK() macro and use it to check for
GTK_DEBUG flags everywhere. Also guard all such places by
2015-09-09 06:32:46 -04:00
Benjamin Otte
12683da8f7 gtk: Make functions static that don't need to be non-static
Also remove the starting underscore from function names where
appropriate, as those functions are static now and not exported anymore.

This is part of a bunch of fixes for gcc complaining about
-Wmissing-declarations.
2012-10-02 19:32:51 +02:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Benjamin Otte
710a8435cc rbtree: Add _gtk_rbtree_contains()
It's useful in a bunch of places, so split it out
2011-12-10 08:00:25 +01:00
Benjamin Otte
6d0499a500 rbtree: Rewrite to not lose node order
_gtk_rbtree_reorder() was moving the node's data while reordering. As we
use the node pointer in the a11y code as a hash key, this didn't work.

So this rewrite changes that. As a bonus, it is less code and faster.
Woohoo!
2011-11-22 23:29:04 +01:00
Benjamin Otte
d8b6414567 rbtree: Remove needless tests
if the checks are run on the nil node, they will get the second test the
  way we expect it anyway, so it's unnecessary.
2011-11-22 03:42:31 +01:00
Benjamin Otte
ae99a9e04a rbtree: Simplify rotation functions
- Make sure the rotated nodes aren't nil
- Use existing functions for complex computations
- Don't use NULL checks for variables guaranteed to not be NULL/nil
2011-11-22 03:32:56 +01:00
Benjamin Otte
37786804e1 rbtree: Remove the nil member 2011-11-22 03:32:56 +01:00
Benjamin Otte
a4630d0e7b rbtree: Introduce _gtk_rbtree_is_nil()
Makes for more readable code than "== tree->nil" and allows removing the
nil member later.
2011-11-22 03:32:56 +01:00
Benjamin Otte
c3056951db rbtree: Introduce _gtk_rbtree_first()
... and use it.
2011-11-22 03:32:56 +01:00
Benjamin Otte
73a834336f rbtree: Replace nil node allocation with a preallocated nil
This has one major caveat: The new value is const, so read-only memory.
Any attempt to write to it will cause a crash. Note that we are not ever
supposed to write to it, but bugs happen...
2011-11-22 03:32:56 +01:00
Benjamin Otte
647c441e26 rbtree: Don't write to nil node
The code used to set nil->parent, which could cause segfaults. Don't do
that. We also need to pass the parent explicitly to the fixup code,
because the node during fixup may be the nil node.
2011-11-21 22:33:46 +01:00
Benjamin Otte
f4fe921a17 rbtree: Add a local variable
This will be needed in the next patch, and I wanted to split that patch
up.
2011-11-21 22:33:46 +01:00
Benjamin Otte
02671f9ec9 rbtree: Move to an approach where we don't move contents
So instead of copying the children and height to the new node, we keep
the old node and copy all the old stuff to it.

This is necessary so the accessibility code can use the node as a key in
the hash table or store the node as a reference to the row instead of
GtkTreeRowReference. And because it already does that (oops), this fixes
a bunch of segfaults with a11y enabled.
2011-11-21 22:33:45 +01:00
Benjamin Otte
1dd9dd45c1 rbtree: Use gtk_rbnode_adjust() even more
Use it for the modified node in gtk_rbnode_remove(). Cleans up the code
quite a lot.
2011-11-21 22:33:45 +01:00
Benjamin Otte
769186dbff rbtree: Use gtk_rbnode_adjust()
Make gtk_rbnode_remove() use it when unlinking the node.
2011-11-21 22:33:45 +01:00
Benjamin Otte
ba7a0a0188 rbtree: Use gtk_rbnode_adjust() more.
Make _gtk_rbtree_node_set_height() use it.
2011-11-21 22:33:45 +01:00
Benjamin Otte
7b2d414222 rbtree: Use gtk_rbnode_adjust() more
Make _gtk_rbtree_insert_before() use it.
2011-11-21 22:33:45 +01:00
Benjamin Otte
01a44e2a16 rbtree: Use gtk_rbnode_adjust()
Make _gtk_rbtree_insert_after() use it.
2011-11-21 22:33:45 +01:00
Benjamin Otte
22a4c15b4f rbtree: Split out a common function
gtk_rbtree_adjust() will adjust the summed values of a node and all its
parents in the tree. Currently only implemented by splitting out the
function from gtk_rbtree_free().
2011-11-21 22:33:45 +01:00
Benjamin Otte
54f3fbfe26 rbtree: Don't set variable twice 2011-11-21 22:33:45 +01:00
Benjamin Otte
6168a64713 rbtree: Add assertions to clarify usage 2011-11-21 22:33:45 +01:00
Benjamin Otte
69a516018f rbtree: Mark all debug sections as debug 2011-11-21 22:33:45 +01:00
Benjamin Otte
af2ebe638c rbtree: Make debug functions private
They're not used elsewhere
2011-11-21 22:33:45 +01:00
Benjamin Otte
a890a61253 treeview: Add _gtk_rbtree_node_get_index()
.. as a replacement for _gtk_rbtree_node_find_parity(). Instead of 1 or
0, the function now returns the index of node in the complete tree
(counting from the root). And this is of course identical to the row
number.
2011-11-16 04:39:24 +01:00
Benjamin Otte
635e53433d treeview: Add _gtk_rbtree_find_index()
Uses the parity to do an O(log N) search for the nth element in the
tree in display order of the treeview.
2011-11-16 04:31:06 +01:00
Benjamin Otte
59097ecef4 treeview: Rename "parity" to "total_count"
Now that we use it to actually count the rows instead of just even/odd,
it's better to reflect that in the variable name.
2011-11-16 04:31:06 +01:00
Benjamin Otte
320df163a2 treeview: Make the parity actually store the row number
Instead of just storing the least significant bit of the row number,
store the full row number. This will soon be useful for accessibility.
But CSS could like it, too.
2011-11-16 04:31:06 +01:00
Benjamin Otte
c8e2cd27e9 treeview: Remove special cases when computing parity
The parity of the nil npode is always 0, so no need to check for the nil
node first.
2011-11-16 04:31:06 +01:00
Tor Lillqvist
801875b805 Replace gtk_debug_flags with getter and setter functions
Preferrably should be made just into a local variable for libgtk like
_gdk_debug_flags for libgdk. But for now used by
gtk/tests/textbuffer.c and modules/printbackends/cups/gtkprintbackendcups.c.
2010-09-08 21:31:34 +03:00
Javier Jardón
0a07e9733b gtk/: fully remove gtkalias hacks
https://bugzilla.gnome.org/show_bug.cgi?id=623845
2010-07-10 02:51:26 +02:00
Javier Jardón
5bcf3ba72a Fix compilation warning: move function to proper location
Move _count_nodes() auxiliar function inside the
G_ENABLE_DEBUG define, where other auxiliar functions are.
2010-04-12 22:10:38 +02:00
Johan Dahlin
d97cdbdf53 Include "config.h" instead of <config.h> Command used: find -name
2008-06-21  Johan Dahlin  <jdahlin@async.com.br>

    * *.[ch]: Include "config.h" instead of <config.h>
    Command used:
    find -name \*.[ch]|xargs perl -p -i -e 's/^#include <config.h>/#include "config.h"/g'
    Rubberstamped by Mitch and Tim


svn path=/trunk/; revision=20669
2008-06-22 14:28:52 +00:00
Matthias Clasen
07e7719441 Apply a cleanup patch by Kjartan Maraas (#341812)
2006-10-08  Matthias Clasen  <mclasen@redhat.com>

	* Apply a cleanup patch by Kjartan Maraas  (#341812)
2006-10-08 05:07:55 +00:00
Matthias Clasen
1e05106801 Fix several g_new() calls which were using extra indirections or pointless
2006-01-18  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkrbtree.c:
	* gtk/gtktreemodel.c: Fix several g_new() calls which
	were using extra indirections or pointless casts.
	(#327423, Morten Welinder)
2006-01-18 05:23:24 +00:00
Tim Janik
d6a9db9095 get rid of GAllocator usage, allocate and free nodes via the g_slice_*()
Tue Nov  1 16:18:24 2005  Tim Janik  <timj@imendio.com>

        * gtk/gtkrbtree.[hc]: get rid of GAllocator usage, allocate and free
        nodes via the g_slice_*() API.
        _gtk_rbtree_new(): fixed wrong node allocation via g_new().
2005-11-01 18:10:51 +00:00
Matthias Clasen
463aab93dd Various cleanups. (#315360, Kjartan Maraas)
2005-09-13  Matthias Clasen  <mclasen@redhat.com>

	* gtk/*.c: Various cleanups.  (#315360, Kjartan Maraas)
2005-09-13 19:57:42 +00:00
Kristian Rietveld
7f5b9100ed Fixes #165034, reported by Jorn Baayen.
2005-07-08  Kristian Rietveld  <kris@gtk.org>

	Fixes #165034, reported by Jorn Baayen.

	* gtk/gtkrbtree.[ch] (_gtk_rbtree_set_fixed_height): add a
	mark_valid parameter (so we can mark all nodes as valid when we
	are setting them to the fixed height).

	* gtk/gtktreeview.c (initialized_fixed_height_mode): mark all
	nodes as valid when setting the fixed height,
	(do_validate_rows): update call to _set_fixed_height,
	(gtk_tree_view_row_inserted): mark node as valid when fixed
	height mode is enabled and a height has been set,
	(gtk_tree_view_build_tree): if fixed height mode is enabled,
	mark new nodes as valid in addition to setting the height.
2005-07-08 19:17:10 +00:00
Matthias Clasen
cca8dd6347 Make PLT-reduction work with gcc4, and don't include everything in
2005-03-20  Matthias Clasen  <mclasen@redhat.com>

	Make PLT-reduction work with gcc4, and don't include
	everything in gdkalias.h:

	* gtk/grk.symbols: Group symbols by header and source file.
	* gtk/makegtkalias.pl: Protect definitions by the same
	preprocessor symbols used to guard the headers. Move
	the alias declarations to a separate file which is
	produced when calling makegtkalias.pl -def
	* gdk/Makefile.am (gtkaliasdef.c): Add a rule to generate
	this file.
	* gtk/*.c: Include gtkalias.h after the other headers,
	include gtkaliasdef.c at the bottom.
	* gtk/*.h: Small cleanups.
2005-03-20 07:01:23 +00:00
Matthias Clasen
d5f92150d4 Fix many sparse warnings. 2004-10-28 15:00:05 +00:00
Matthias Clasen
3612aee585 Add hidden aliases for exported symbols which are used internally in order
Mon Aug  9 12:48:04 2004  Matthias Clasen  <maclas@gmx.de>

	Add hidden aliases for exported symbols which are
	used internally in order to get rid of many PLT
	entries.  (#145519, Arjan van de Ven)

	* gtk/Makefile.am: Add rules to generate gtk.def and
	from gtk.symbols, and make make check check the abi
	with abicheck.sh.
	(gtk_private_h_sources): Add gtkinternals.h
	(gtk_built_private_headers): Add gtkalias.h
	(gtk_extra_sources): Add gtk.symbols
	(EXTRA_DIST): Add makegtkalias.pl and abicheck.sh

	* gtk/gtk.symbols: New file. Definition of the GTK+ ABI.
	The file can be processed by cpp to filter out certain
	subsets of symbols.

	* gtk/abicheck.sh: New file. Script to check the actually
	symbols exported from libgtk-x11.2.0.so against the symbols
	found in gtk.symbols.

	* gtk/makegtkalias.pl: New file. Perl script to generate the
	header containing the alias definitions for internally used
	exported symbols from a list of symbols.

	* gtk/gtkinternals.h: New file. An uninstalled header listing
	symbols which must be exported for some reason and do not appear
	in any other header.

	* gtk/*.c: Include gtkalias.h
2004-08-09 16:59:53 +00:00
Federico Mena Quintero
80581c3011 Fixes #136082 and #135265, patch by Morten Welinder.
2004-03-05  Federico Mena Quintero  <federico@ximian.com>

	Fixes #136082 and #135265, patch by Morten Welinder.

	* configure.in: Use AC_SYS_LARGEFILE.

	* */*.c: #include <config.h>
2004-03-06 03:38:59 +00:00
Jonathan Blandford
89911e24da null initialize reorder's members so Purify won't complain.
Mon Mar 31 13:52:13 2003  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtkrbtree.c (_gtk_rbtree_reorder): null initialize reorder's
	members so Purify won't complain.
2003-03-31 19:44:06 +00:00
Kristian Rietveld
83e9cd5320 return a value in the range of [-1, 1] instead [0, 1],
Wed Nov 20 19:29:50 2002  Kristian Rietveld  <kris@gtk.org>

        * gtk/gtkrbtree.c (gtk_rbtree_reorder_sort_func): return a value
        in the range of [-1, 1] instead [0, 1],
        (gtk_rbtree_reorder_invert_func): ditto,
        This makes treeview reordering working on platforms as FreeBSD and
        solaris, thanks go to Heiner Eichmann for finding this out and
        sending in a patch (#98251).

Wed Nov 20 19:27:07 2002  Kristian Rietveld  <kris@gtk.org>

        * gtk/gtktreestore.c (node_free): only free the data list if
        node->data is not NULL,
        (gtk_tree_store_remove): free the data list from the node if
        needed. (#94728, pointed out by Peter Bloomfield).

Wed Nov 20 19:23:13 2002  Kristian Rietveld  <kris@gtk.org>

        * gtk/gtktreeview.c (gtk_tree_view_remove_column): stop editing
        and set the edited_column to NULL if edited_column is set.
        (#91288, modified patch from Josh Parsons).

Wed Nov 20 19:20:34 2002  Kristian Rietveld  <kris@gtk.org>

        * gtk/gtktreeview.c (gtk_tree_view_size_allocate): do a full
        redraw if vadjustment->value is bigger than tree_view->priv->height,
        (gtk_tree_view_row_deleted): free the row ref if it isn't valid
        anymore. (#83726, reported by Robert Kinsella).
2002-11-20 18:15:28 +00:00
Kristian Rietveld
3f6c03182b don't leak the GArray (figured out by Matthias Clasen, fixes #82026).
Thu Jun  6 17:27:01 2002  Kristian Rietveld  <kris@gtk.org>

        * gtk/gtkrbtree.c (_gtk_rbtree_reorder): don't leak the GArray
        (figured out by Matthias Clasen, fixes #82026).
2002-06-06 15:18:52 +00:00
Jonathan Blandford
100cde1ce6 include missing #ifdef G_ENA\BLE_DEBUG
Thu May 16 17:29:08 2002  Jonathan Blandford  <jrb@redhat.com>

        * gtk/gtkrbtree.c (_gtk_rbtree_remove): include missing #ifdef G_ENA\BLE_DEBUG
2002-05-16 21:37:49 +00:00
Owen Taylor
85a8bdb1fc Fixes for #78258
Thu May 16 14:51:14 2002  Owen Taylor  <otaylor@redhat.com>

        Fixes for #78258

        * gtk/gtkrbtree.c demos/gtk-demo/editable-cells.c:
        Fix some 64-bit warning problems. (Patch from Matthias
        Clasen.)

        * gtk/gtkrbtree.c (_gtk_rbtree_debug_spew_helper): Surround
        a bunch of debug code with G_ENABLE_DEBUG.

        * configure.in demos/gtk-demo/main.c: Replace
        #ifndef G_OS_WIN32 with proper #ifdef HAVE_FLOCKFILE.
2002-05-16 19:11:43 +00:00
Kristian Rietveld
92febe2720 add _gtk_rbtree_set_fixed_height()
Wed Mar 20 22:59:23 2002  Kristian Rietveld  <kris@gtk.org>

        * gtk/gtkrbtree.[ch]: add _gtk_rbtree_set_fixed_height()

        * gtk/gtktreeprivate.h: add fixed_height_check field

        * gtk/gtktreeview.c (gtk_tree_view_init): initialize
        scroll_sync_timer and fixed_height_check
        (do_validate_rows): add fixed_height_check. If all validated rows
        in the first cycle have the same height, then we set that height for
        the entire tree. This is some sort of 'fake' optimization, but helps
        a lot for the common case. We keep validating the entire tree in
        the background though.
        (gtk_tree_view_set_model): reset fixed_height_check
2002-03-20 22:06:05 +00:00