Commit Graph

1004 Commits

Author SHA1 Message Date
Benjamin Otte
5fe947640c treeview: Add internal get_cursor_node() API 2012-02-11 03:02:20 +01:00
Benjamin Otte
00a810ae04 treeview: Add private get_focus_column() API 2012-02-11 02:49:12 +01:00
Benjamin Otte
f90ff5d50b treeview: Notify accessible about focus changes 2012-02-11 02:38:48 +01:00
Benjamin Otte
a4559f1e19 treeview: Tell accessible about focus column changes 2012-02-11 01:59:19 +01:00
Carlos Garcia Campos
349b1eff03 gtktreeview: Use symbolic names for button numbers 2012-01-27 09:47:44 +01:00
Benjamin Otte
2f3ffd5fde treeview: Fix comparison to catch all cases
Otherwise, we could sometimes fail to update the cursor node when the
right row was deleted.

Also, I'd like to file a formal complaint that this node/tree
differentiation makes writing comparisons too complicated.

https://bugzilla.gnome.org/show_bug.cgi?id=668169
2012-01-24 17:55:14 +01:00
Paolo Borelli
208bfbd053 Do not leak tree path when setting the model. 2012-01-14 14:33:23 +01:00
Benjamin Otte
133179fd25 treeview: Do not focus a path on model change
Instead, focus nothing and wait until we get focus before doing so. This
restores previous behaviour but still emits proper cursor-changed
events.

Fixes a bunch of bugs in the filechooser which populates the treeview
asynchronously.

https://bugzilla.gnome.org/show_bug.cgi?id=613728
2012-01-12 19:37:15 +01:00
Rui Matos
440663f3fe treeview: Use the widget state flags as a base for drawing expanders 2012-01-09 16:45:44 +00:00
Rui Matos
2972236fdb treeview: Stop setting state flags on the style context for drawing 2012-01-09 16:45:44 +00:00
Javier Jardón
d005b01319 gtk/*: Use g_list_free_full() convenience function 2012-01-05 04:22:43 +01:00
Federico Mena Quintero
022c576bd2 treeview: bgo#666685 - Crash when toggling the selected status of a row
The refactoring from e01af5c5c seems to have caused this inadvertently.

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
2012-01-03 15:08:34 -06:00
Cosimo Cecchi
13f5706488 treeview: fix an uninitialised variable warning 2011-12-20 11:41:46 +01:00
Benjamin Otte
eed9cc94e1 treeview: Only set focus column in setter function
Single point of entry. It's actually going to become more complicated
with a11y now.
2011-12-19 16:17:12 +01:00
Matthias Clasen
020c1846b7 Use the workarea when placing popups
This uses the new workarea API to avoid placing popups underneath
panels, docks, etc.
2011-12-18 14:29:16 -05:00
Benjamin Otte
d78971b31d treeview: Run unref helper for all rows
Don't do shortcuts. Because all rows need to be unreffed.
Introduced in 92929b968b.
2011-12-16 13:39:43 +01:00
Benjamin Otte
ccabccc42f treeview: Send changed signal directly to a11y code
No more signal handler is needed, therefore the code can also get rid of
tracking the treemodel. And we use a faster approach for iterating the
changed cellrenderers: We just iterate all columns instead of over all
cell accessibles, as that number is likely quite a bit smaller.
2011-12-16 04:53:15 +01:00
Benjamin Otte
f5621a3a8e treeview: Emit cursor-changed signal when new model is set 2011-12-16 04:53:15 +01:00
Benjamin Otte
0005d820c7 treeview: Remove unnecessary accessible_expanded()
Instead, just call remove_state().
2011-12-16 04:53:15 +01:00
Benjamin Otte
c7b82c2cea treeview: Add add() function to accessible
... and use that to emit the insertion signals.
2011-12-16 04:53:14 +01:00
Benjamin Otte
82a9f6faa0 treeview: Set expandable flag from treeview
... instead of trying to update it manually.
2011-12-16 04:53:14 +01:00
Benjamin Otte
adf183b71f treeview: Set EXPANDED state directly on a11y elements 2011-12-16 04:53:14 +01:00
Benjamin Otte
6fa72300be treeview: Deprecate gtk_tree_view_set_destroy_count_func()
The accessibility code doesn't need it anymore.
2011-12-16 04:53:14 +01:00
Benjamin Otte
95dc248790 treeview: Don't use signals in a11y row expansion
Instead, add a function and call it directly.
2011-12-16 04:53:14 +01:00
Benjamin Otte
175043bd8d treeview: Set the new flags when rendering the cell 2011-12-16 04:53:13 +01:00
Benjamin Otte
92929b968b treeview: Ensure selection's changed signal
There was a corner case where the changed signal was not emitted.
If rows were built like this:
  1    (not selected)
  + 2  (selected)
  + 3  (not selected)
And row 1 was removed, no signal would be emitted.

I like it when writing tests actually finds bugs that have been around
since 2003 - introduced by 4a03ea2334
actually. :)
2011-12-10 08:00:26 +01:00
Benjamin Otte
d4d2cc14d2 treeview: Don't try to optimize away selection_changed signal
We get certain cases, in particular with SELECTION_MULTIPLE, where we
cannot figure out in advance of real_set_cursor() if the selection will
actually change.
2011-12-10 08:00:26 +01:00
Benjamin Otte
559c3c7da1 treeview: Add a CURSOR_INVALID flag to set_cursor_row()
This is necessary so the code doesn't attempt to do things with the
previous cursor, which currently cause crashes.
2011-12-10 08:00:26 +01:00
Benjamin Otte
d3bccfbb6d treeview: Replace lots of boolean args with flags
I want to add more and 3 boolean args is essentially unreadable code.
2011-12-10 08:00:26 +01:00
Benjamin Otte
1a2932ba29 treeview: Handle the case where the cursor row gets deleted
Previously, the cursor would just become invalid, which used to
reselect the first row in the treeview later on (without a
cursor-changed signal). This leads to a crash now with the recent
refactorings.

The patch is longer than I'd like it to be, but the situation is kinda
complicated, because we want to make sure to move the cursor to a good
row. It works like this:
1) From the deleted row, search forward for the first row that is not
   going to be deleted and is not a separator.
2) If no such row exists, search backwards for a row that is not a
   separator.
3) If no such node exists, clear the cursor.
2011-12-10 08:00:26 +01:00
Benjamin Otte
e01af5c5c9 treeview: Replace cursor handling by keeping the node
Previously the code used a GtkTreeRowReference, which was (a) less
performant and more importantly (b) hiding errors.
The errors being hidden were the referenced row becoming invalid or
collapsed, because such rows would not be valid cursor rows and it would
be necesary to select a new row and emit a "cursor-changed" signal.

So if a crash bisects down to this commit, it is very likely that the
cursor has not correctly been updated and the cursor row is invalid.
2011-12-10 08:00:26 +01:00
Benjamin Otte
807a449f29 treeview: Fix crash when scrolling to end
This broke in a4630d0e7b

https://bugzilla.gnome.org/show_bug.cgi?id=665741
2011-12-07 20:12:12 +01:00
Benjamin Otte
7d3109a855 treeview: Properly change cursor when row is collapsed
Previously, when the cursor was a descendant of the collapsed row,
the cursor path was set to the collapsed row, but this was not
communicated via cursor-changed events.
2011-11-29 20:44:57 +01:00
Benjamin Otte
bbf00265fc treeview: Reorder code a bit
This is mainly in preparation for the next commit, but also to reorder
the code to
1) prepare modification of tree
2) modify tree
3) emit signals
2011-11-29 20:44:57 +01:00
Benjamin Otte
c070e7acf5 treeview: Simplify code
Since the changes in commit 2b3de3dd this simplification is possible.
2011-11-29 20:44:57 +01:00
Benjamin Otte
806dca0677 treeview: Rename function
_gtk_tree_view_find_path() was not a name that not really described what
the function does. And I kept forgetting it. Also, it took the tree view
as an argument and that was completely unnecessary.
2011-11-29 20:44:57 +01:00
Benjamin Otte
416b3ed204 treeview: Notify a11y about reordered rows
That way, no more signal handler is needed in the a11y code. Plus, we
avoid needless signal emissions for rows we don't care about.
2011-11-24 18:29:44 +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
Rui Matos
e60fa49fa7 Bug 653676 - Expand/Collapse doesn't respond after one click
Ignore leave-notify-event when mode is GDK_CROSSING_GTK_[UN]GRAB.
Just [un]grabbing shouldn't cause us to [un]prelight the current arrow
and node.
2011-11-20 21:00:08 +01:00
Kristian Rietveld
44a064fe30 Don't call scroll to cell if the tree view is empty
Account for the case when gtk_drag_finish() didn't actually add a row
(can happen when dragging from an empty tree view to itself ...).
2011-11-20 20:15:48 +01:00
Kristian Rietveld
a069ec662f Bug 660554 - gtk_tree_view_drag_begin: assertion `path != NULL' failed
Turned assertion into silent return.

This assertion is only hit when dragging from an empty tree view.  In
this case, gtk_tree_view_begin_drag() is triggered from gtkdnd.c and not
from gtk_tree_view_maybe_begin_dragging_row().  We actually want to
cancel the drag at this point, but that is not possible with the GTK+
API as far as I can see.

The alternative is to not allowing the drag to start.  This could be
done by simply unsetting the tree view as drag source when it is empty
and setting it as drag source again when rows are added.  I didn't
choose to go with this for now, since this will likely break third party
code.
2011-11-20 20:15:39 +01:00
Xan Lopez
2c065d716b treeview: fix the build 2011-11-16 22:41:57 +01:00
Cosimo Cecchi
9986b26c0b treeview: use gtk_tree_view_ensure_background() consistently
In gtk_tree_view_state_flags_changed() we were setting the background on
the bin_window without the necessary "view" style class, making the
treeview render with the wrong color in some circumstances (such as when
adding an empty treeview in a window, as spotted by Brian Smith).
2011-11-16 16:09:00 -05:00
Cosimo Cecchi
8d97d8ca3c treeview: factor out gtk_tree_view_ensure_background()
We'll use it shortly.
2011-11-16 15:59:47 -05:00
Benjamin Otte
a4b88c47cd treeview: Call a11y functions for culmn changes directly
This way, the a11y code knows if a column was reordered, added or
removed and can do the right things instead of trying to guess and
getting it wrong.

Also, this patch finalizes the changes so that only visible columns
exist to the accessibility interface.
2011-11-16 04:39:25 +01:00
Benjamin Otte
18181f5417 API: treeview: Add gtk_tree_view_get_n_columns() 2011-11-16 04:39:25 +01:00
Benjamin Otte
aa1cab1ec2 treeview: Simplify a check
Use the same method as elsewhere.
2011-11-16 04:39:25 +01:00
Benjamin Otte
81f9082d2a treeview: Minor beautification 2011-11-16 04:39:24 +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
e927a5b2c7 treeview: Redo row tracking
Track the RBNode/RBTree instead of keeping a TreeRowReference. This is a
whole lot faster and less error-prone.

Also, notify the accessible of removal of rows before actually removing
them, so we have a chance to clean up.
2011-11-16 04:39:23 +01:00
Benjamin Otte
5096df14c3 treeview: Remove unnecessary variable
tmptree has the same value as tree everywhere, so just use tree instead.
2011-11-16 04:39:23 +01:00
Benjamin Otte
b526375e8f gtk: Fix compiler warnings from include fixes 2011-11-16 04:31:06 +01:00
Benjamin Otte
1a241f2348 treeview: Only compute parity once when rendering
This shouldn't affect performance too much, but it I just found it so I
fixed it.
2011-11-16 04:31:05 +01:00
Martin Pitt
1c222372d9 Fix gtk_tree_view_get_tooltip_context() transfer annotation
The default (out) transfer mode is "full", but the passed "model" pointer gets
set to gtk_tree_view_get_model() which is "transfer none". This caused Python
programs to free the model after calling this, causing crashes.
2011-11-14 14:33:51 +01:00
Alexander Larsson
96bae6ad08 Add include to fix the build 2011-11-10 17:25:02 +01:00
Matthias Clasen
a7958f06e3 treeview: Work around deprecations 2011-11-09 23:42:11 -05:00
Kristian Rietveld
91ae19768e Bug 661997 - Gtk crashes when changing the TreeView model while ...
Simply stopping rubber banding in gtk_tree_view_set_model() eliminates
the crash.  Reported by Thomas Perl.
2011-11-09 08:45:34 +01:00
Benjamin Otte
2783158f8d treeview: Do a simple replace for gdk_window_get_pointer()
Replace it with the equivalent gdk_window_get_device_position() with the
core pointer.
2011-11-09 03:23:43 +01:00
Benjamin Otte
28d3d6e039 treeview: Remove unused crack code
No, querying the pointer position in a draw callback is not a good idea.
No, setting FOCUSSED based on that position is not a good idea either.
2011-11-08 21:14:06 +01:00
Benjamin Otte
a1fb2c863b treeview: Remove call to gtk_widget_get_pointer() 2011-11-08 21:14:06 +01:00
Benjamin Otte
1425ecbc52 treeview: Fix warnings from fixing warnings
Warnings introdcued by fixing deprecation warnings in
2ead4c6038
2011-11-08 21:14:05 +01:00
Matthias Clasen
2ead4c6038 Remove some more uses of gdk_window_get_pointer 2011-11-02 08:10:42 -04:00
Matthias Clasen
8370052180 Don't use *DISABLE_DEPRECATED guards
Instead define GDK_DISABLE_DEPRECATION_WARNINGS where appropriate.
2011-11-01 22:35:57 -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
Javier Jardón
0853ce3077 Use G_VALUE_INIT
Instead of an explicit { 0, } when declaring the variable.
2011-10-15 16:45:16 +01:00
Michael Natterer
87cc0dc79f gtk: use the new modifier API instead of GTK_DEFAULT_ACCEL_MOD_MASK
in gtkimcontextsimple and gtktreeview, which are the easy places,
but also true bugfixes, because on OSX we can't use the virtual META
here, we needs MOD2 as delivered in key events.
2011-10-07 09:33:07 +02:00
Benjamin Otte
58d9c7e53e docs: Fix typo in treeview docs 2011-09-30 00:26:22 +02:00
Michael Natterer
11f8c1ba6f gtk: remove the private GTK_EXTEND/MODIFY_SELECTION_MOD_MASK
and use the new public modifier abstraction API instead.
2011-09-27 12:06:10 +02:00
Michael Natterer
0955a59563 app: abstract which modifiers are used for extending and modifying selections
which are SHIFT and MOD2 on the Mac, and SHIFT and CONTROL otherwise.
Use the new define all over the place and rename variables and
members to not say "shift" or "control".
2011-09-26 16:01:50 +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
Benjamin Otte
9e8b2f2521 treeview: Return FALSE from draw handler
... like every widget should.

https://bugzilla.gnome.org/show_bug.cgi?id=658981
2011-09-14 16:10:14 +02:00
Matthias Clasen
3a1ce87c7e Fix typos in gtk_tree_view_set_reorderable docs
As pointed out in bug 530253.
2011-09-04 23:52:36 -04:00
Matthias Clasen
eaed6d1912 Improve gtk_tree_view_set_drag_dest_row docs
As requested in bug 581435.
2011-09-04 23:42:42 -04:00
Cosimo Cecchi
640f06928f treeview: add GTK_STYLE_CLASS_SEPARATOR for tree view separators
https://bugzilla.gnome.org/show_bug.cgi?id=657985
2011-09-02 15:11:15 -04:00
Matthias Clasen
6f39855c08 More include cleanups 2011-08-28 01:54:55 -04: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
Kristian Rietveld
dca9db124b Bug 655545 - condition can never be true in gtk_tree_view_real_set_cursor
Spotted by Ben Pfaff.
2011-07-30 23:01:38 +02:00
Matthias Clasen
6012f096c9 Convert GailTreeView to GtkTreeViewAccessible
Mostly code rearrangement and cleanup, but also a memory
leak fix in gtk_tree_view_accessible_get_column_description().
2011-07-05 16:08:56 -04:00
Matthias Clasen
8771f2ce9c Don't rely on button allocations for invisible headers
Now that we are not allocating treeview column buttons anymore
with invisible headers, we can't rely on their allocations for
other things like cell area computations anymore. Use x-offset
and width of the column directly, instead.
2011-06-10 00:17:56 -04:00
Matthias Clasen
a081485269 GtkTreeView: Don't short-circuit header-height calculation
The code was putting header_height at zero when there is
no model. That leads to temporary underallocation of header
buttons.
2011-06-09 21:40:08 -04:00
Matthias Clasen
7d3c5b2763 Drop unneeded includes: gtkalignment.h 2011-06-07 21:53:11 -04: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
c5af8c7e3a treeview: Remove unused variables
... and all the code doing complex computations to assign values to
them.
2011-05-27 16:11:10 +02:00
Cosimo Cecchi
f398745a15 treeview: don't arbitrairly add 2 to the expander size
Bump the default expander size by 2 pixels instead.

https://bugzilla.gnome.org/show_bug.cgi?id=650424
2011-05-18 11:12:47 -04:00
Cosimo Cecchi
42f5856e77 treeview: render a frame around the rows, after drawing their background
https://bugzilla.gnome.org/show_bug.cgi?id=650424
2011-05-18 11:12:31 -04:00
Micah Carrick
86f5849158 Fix annotation for Gtk.TreeView.enable_model_drag_source
https://bugzilla.gnome.org/show_bug.cgi?id=649979
2011-05-11 16:15:23 -04:00
Kristian Rietveld
874dfc24b2 treeview: Do not unconditionally set width_changed to TRUE, which redraws
Patches by Benjamin Otte.

The "invalidate last column" hack is removed.  It is now of no use since
the entire widget will be redrawn when a single column changes.
2011-04-17 01:14:51 +02:00
Kristian Rietveld
4d5d915afe treeview: if we are below rows that changed height: redraw
We have to redraw if we are below a couple of rows that changed height
in do_validate_rows().  This will still require a redraw for a large
amount of cases, can we do better?  You would expect that a redraw of
the tree view is not required when the dy changes with the same delta
as the delta of the height accrued when validating the nodes.  This
further optimization will likely require changes to the top_row/dy
synchronization code.
2011-04-17 01:14:51 +02:00
Kristian Rietveld
4594370b46 treeview: Avoid queueing a redraw in do_validate_rows()
If the changed rows are not visible, we likely do not have to redraw
in conjunction to resize.  Spotted by Benjamin Otte.
2011-04-17 01:14:51 +02:00
Kristian Rietveld
84ebafc305 Merge two if-blocks with same condition 2011-04-16 20:16:03 +02:00
Xavier Claessens
00fa4a2fc0 Do not call invalidate_empty_focus() when not realized
Fixes bug 626503
2011-04-16 20:13:51 +02:00
Garrett Regier
793d12d70d Fix leaking calls to gdk_device_manager_list_devices()
gdk_device_manager_list_devices() returns a newly allocated list.

https://bugzilla.gnome.org/show_bug.cgi?id=645234
2011-03-21 10:37:10 -04:00
Cosimo Cecchi
151cf7204b treeview: add the separator style class to the tree view separator lines 2011-03-17 17:12:58 -04:00
Cosimo Cecchi
96d6c2d108 treeview: propagate the selected state from the row
An expander in a row can't be selected on its own otherwise. This way
themes can override the expander colors when the row is selected.

https://bugzilla.gnome.org/show_bug.cgi?id=644089
2011-03-07 08:12:48 -05:00
Matthias Clasen
405b54c72e Check the return value of gtk_tree_model_get_iter
Noticed in passing, didn't really see it crash there, but
better safe than sorry.
2011-02-16 18:48:42 -05:00
Matthias Clasen
beb8c290d1 Always chain up in ::style-updated
This was not handled consistently, but the default handler
does useful things, so we should always chain up.
2011-02-07 07:30:37 -05:00
Matthias Clasen
8448780a6c Make treeview expanders work reliably
It turns out that the gtk_grab_remove() can trigger a do_prelight()
call, which may end up changing prelight_node, and then the state
gets messed up. Moving the grab removal until after we're done with
button_pressed_node and prlight_node makes expanders work reliably.

One thing that is still not right is that the expander doesn't get
prelight again after the animation is done, if you manage to release
without any additional motion events.

https://bugzilla.gnome.org/show_bug.cgi?id=641039
2011-02-01 01:32:02 -05:00
Carlos Garnacho
08af1783c5 Make GtkTreeView use GtkStyleContext
Expander animation has been replaced by implicit animations
from the style context.

Column headers are also properly themed, GtkContainer::get_path_for_child()
is implemented and the treeview resets column buttons style on columns
being reordered.

The default CSS has changed to theme treeviews sensibly.
2011-01-27 20:57:11 +01:00
Martin Pitt
d7b71be49b [GI] Fix gtk_tree_view_get_cursor() transfer annotation 2011-01-26 14:39:50 +01:00