Commit Graph

117 Commits

Author SHA1 Message Date
John Lindgren
6d53c2339f Use minimum/natural size semantics
Rewrites gtk_tree_view_column_request_width() and
gtk_tree_view_size_allocate_columns() to respect the minimum and natural
sizes that are already being returned by
gtk_cell_area_context_get_preferred_width().

The convoluted logic explained (not!) by this comment has been removed:
“Only update the expand value if the width of the widget has changed, or
the number of expand columns has changed, or if there are no expand
columns, or if we didn't have an size-allocation yet after the last
validated node.”  This logic seems to have been a workaround for the
“jumping” behavior fixed in 16195ad and is no longer necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=691751
2013-01-15 14:41:20 +01:00
John Lindgren
16195adc92 Use fixed width for resizing
Removes the hidden “resized-width” and “use-resized-width” properties
from GtkTreeViewColumn and instead uses the “fixed-width” property to
serve the same purpose.  “fixed-width”, if set, will now override the
auto-sized width (-1 is now a legal value meaning “not set”).

Additional “cleanups” in this commit:

1. When the user resizes the column the “expand” property is now also
set to FALSE, in order to prevent the column from suddenly jumping to a
different width when the window is resized.

2. The code that translated mouse movement to column sizes has been
simplified:
the change in column width is now calculated directly from the distance
the mouse cursor has traveled.  Weird behavior that might have happened
previously if the position of the column changed during resizing, is now
prevented.

3. There was some lengthy logic handling the keyboard shortcuts used to
resize treeview columns, which would call gtk_widget_error_bell() once
the minimum or maximum width was reached.  Instead of rewriting these
checks I simply set the “fixed-width” property to what was requested,
relying on the fact that it is already clamped between the minimum and
maximum width during size allocation.
I will greatly surprised if anyone notices the missing error bell.

https://bugzilla.gnome.org/show_bug.cgi?id=691751
2013-01-15 14:40:40 +01:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
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
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
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
Kristian Rietveld
4ed781778d Introduce gtk_tree_view_is_blank_at_pos()
This function is useful to figure out whether the tree view is "blank"
at a given location.  For such locations you might want to popup a
custom popup menu, clear the current selection or start rubber banding.
In the future, we are planning on updating GtkTreeView's user
interactions to take advantage of this new function.

Part of bug 350618.
2011-01-07 15:38:06 +01:00
Kristian Rietveld
c8d130efa7 Revisit "Handle clicks in indentation area"
Check (x, y) is inside background area.  If yes, continue processing
and clamp the coordinates into cell area.  This way we will properly
handle getting a cell (which is only used for setting the focus cell)
for clicks in the indentation area (in LTR and RTL mode) and clicks
in the focus rectangle area in case focus-line-width is large.
2010-12-15 23:55:26 +01:00
Kristian Rietveld
ff39c76bfd Welcome _gtk_tree_view_column_get_cell_at_pos to the second dimension 2010-12-12 15:22:49 +01:00
Tristan Van Berkom
bf1aa2ad87 Changed GtkTreeViewColumn->requested_width to ->padding
Now we bookkeep the treeview assigned padding asides from the
requested width stored in the GtkCellAreaContext, this removes
the need for bookkeeping the deepest expanded depth in gtktreeview.c

At allocation time, just remove the padding from the allocated width
of the column and feed the rest to the underlying cell area.
2010-12-06 16:31:07 +09:00
Kristian Rietveld
924359c31d Clean up _gtk_tree_view_column_cell_event 2010-12-05 17:12:37 +01:00
Kristian Rietveld
6c73647727 Remove the need for _gtk_tree_view_column_get_focus_area 2010-12-05 17:10:21 +01:00
Kristian Rietveld
77d972e436 Remove private accessor for focus column 2010-12-05 15:20:17 +01:00
Kristian Rietveld
0a1982aff3 Move _gtk_tree_view_column_cell_focus to gtktreeview.c 2010-12-05 15:18:13 +01:00
Tristan Van Berkom
81e1d02de3 Created _gtk_tree_view_column_request_width().
Removed gtk_tree_view_get_real_requested_width_from_column() from
gtktreeview.c in favor of this function in the treeviewcolumn domain
(since this function goes and checks treeviewcolumn internals, settings
and derives the real requested width, seems logical this should be done
by the treeviewcolumn instead).
2010-12-05 22:12:16 +09:00
Tristan Van Berkom
cf8299f098 Changed _gtk_tree_view_column_set_width for _gtk_tree_view_column_allocate
Now the GtkTreeViewColumn takes care of move/resizing its window and
allocating its button (except for the special case of current drag_column
where the column doesnt actually get reallocated).
2010-12-05 22:11:50 +09:00
Tristan Van Berkom
4038cd76b3 Removed GtkTreeViewPrivate from gtktreeprivate.h and added a few more accessors.
This actually much simplifies interaction with GtkTreeSelection
(at least reduces code size where dealing width the treeview anchor path).
2010-12-05 22:11:37 +09:00
Tristan Van Berkom
4b5c80dc0f Removed the private sharing of internal treeview macros from gtktreeprivate.h
Added them directly to gtktreeview.c.
2010-12-05 22:11:21 +09:00
Tristan Van Berkom
9f4f22faf1 Removed all variables from GtkTreeViewColumn and created GtkTreeViewColumnPrivate
Some details:
  - button_request was not needed, consult the minimum request of the button
  - gtk_tree_view_column_get_button() needed to be public as people can set
    tooltips on the button (and libgail accesses the button).
2010-12-05 22:11:08 +09:00
Tristan Van Berkom
b39521dcf7 Make GtkTreeView tell the column about expand space instead of just assigning column->width.
Also modified the api to open up the way for treeview to tell the column
about how much of its size is really used to render the area.
2010-11-29 18:04:47 +09:00
Kristian Rietveld
6fe9df2f1d First go at migrating GtkTreeView(Column) to GtkCellArea
This is still very much a work in progress, but it renders and more or
less works.  I will be fixing up the details in the very near future.

Important: this commit breaks ABI as it modifies the GtkTreeViewColumn
structure in gtktreeviewcolumn.h.  This is a sealed structure that needs
to be moved to an internal header file, most likely gtktreeprivate.h.
2010-11-28 19:54:24 +01:00
Tristan Van Berkom
3fe0fb4ed9 Added GtkScrollablePolicy property to scrollable interface
This patch adds the GtkScrollablePolicy type property to GtkScrollable
and implements it in all subclasses. GtkScrolledWindow observes this
property to make a good guess about when to show/hide scrollbars for
height-for-width content.

Most scrollable children do not do height-for-width *yet* but
most certainly will (toolpalette, treeview, iconview, textview
widgets all TODO), for scrollable widgets that do have a minimum
and natural size, it's important for them to observe the state
of this property in order to properly drive the scroll adjustments
according to the desired GtkScrollablePolicy. This patch makes
GtkViewport do this.

Patch also adds tests/testscrolledwindow.c to display the effects
of this property.
2010-10-26 10:15:56 +09:00
Alberto Garcia
d6a73fd5b0 Assign all g_signal_connect() and friends to gulong variables
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=87821
2010-10-22 18:58:47 +02:00
Tadej Borovšak
55196a705f Add GtkScrollable interface
The GtkScrollable interface provides "hadjustment" and "vadjustment"
properties that are used by GtkScrolledWindow. It replaces
the ::set_scroll_adjustment signal. The scrollable interface
also has ::min-display-width/height properties that can be
used to control the minimally visible part inside a scrolled window.
2010-10-22 11:03:45 +02:00
Benjamin Otte
f085bc67cd treeview: Convert GtkTreeViewColumn rendering to Cairo 2010-09-26 15:03:01 +02:00
Benjamin Otte
da426ec97c treeview: Draw lines with Cairo 2010-07-26 16:42:47 +02:00
Matthias Clasen
bd4609b140 Merge the xi2-for-master branch 2010-05-25 18:38:44 -04:00
Kristian Rietveld
f59294fd93 Correct problems with earlier fix for bug #480065
Initialize event_last_[xy] to out of range coordinates and also update
these values in enter and leave notify.  Fix up calls to
update_prelight() from size allocate.  Unconditionally doing these calls
caused problems with hover selection.  Now we only do this call when
the "width before the expander column" has changed.  (Which might be
awkward, but it is the best heuristic I could come up with so far).
2009-12-21 22:42:15 +01:00
Kristian Rietveld
f223577a88 Bug 480065 - wrong tree collapsed (or expanded) after having scrolled
Commit again after revert.

Store (x, y) of last motion event.  From
gtk_tree_view_adjustment_changed(), call prelight_or_select() so that
the prelight is recalculated.  We do the same from
gtk_tree_view_size_allocate() for the case that clicking on an expander
shows new rows that resize the column(s) left of the expander.  This
means that the expander is moved horizontally, in such a case the
prelight also has to be reconsidered.
2009-12-21 22:42:15 +01:00
Benjamin Otte
9647285441 Revert dd511e825a
The patch completely breaks entry completion - as can be seen when using
epiphany. Bug 480065 has been reopened.
2009-12-16 11:48:11 +01:00
Kristian Rietveld
2ef9b989bf Bug 596473 - Second double-click of GtkTreeView row doesn't emit...
Rework double click handling in GtkTreeView.  We cannot blindly use
the 2BUTTON_PRESS and 3BUTTON_PRESS events.  In case a user does two
fast double clicks, we receive a 3BUTTON_PRESS and BUTTON_PRESS.  We
cannot easily deduce two double clicks from this.

We have removed the bookkeeping using row references of the last paths
clicked.  Instead we monitor event time, (x, y) coordinates and compare
against double-click-time and double-click-distance ourselves.
2009-11-27 13:48:16 +01:00
Kristian Rietveld
dd511e825a Bug 480065 - wrong tree collapsed (or expanded) after having scrolled
Store (x, y) of last motion event.  From
gtk_tree_view_adjustment_changed(), call prelight_or_select() so that
the prelight is recalculated.  We do the same from
gtk_tree_view_size_allocate() for the case that clicking on an expander
shows new rows that resize the column(s) left of the expander.  This
means that the expander is moved horizontally, in such a case the
prelight also has to be reconsidered.
2009-11-27 13:48:16 +01:00
Kristian Rietveld
d3592dc22c Logically re-group fields in GtkTreePrivate structure
This should now cause much less of a headache than before.  Fields have
been properly reordered, each group has been given a comment.  Since the
GtkTreePrivate structure is private (as the name says), this should not
have any effect on ABI.
2009-11-27 13:48:16 +01:00
Javier Jardón
12061507b4 Use G_STRFUNC and G_STRLOC instead __FUNCTION__ and __FILE__ 2009-10-26 18:46:19 +01:00
Federico Mena Quintero
2b3de3dd75 bgo#580560 - Make Backspace work in the file chooser to to to the parent directory
GtkFileChooserDefault actually implements a binding signal for
Backspace, to make it go to the parent directory.  However,
GtkTreeView was eating our Backspace, and thus the file chooser was
not getting a chance to execute its binding signal.

GtkTreeView implements a Backspace binding itself, which it uses to
move to the parent node of the current cursor node.  However, the
binding handler would return TRUE even if there was no parent to the
current node.  Now the binding handler only returns TRUE if it
actually changed the cursor.

Additionally, gtk_tree_view_key_press() sees if no bindings handled a
key press; in that case, it re-sends the key press to the treeview's
search entry.  However, sending a Backspace to an empty entry makes
the entry beep.  Thus, we add a flag that gets set from GtkTreeView's
Backspace binding handler, to tell gtk_tree_view_key_press() when it
should *not* re-emit the key press on the search entry.  Sort of,
"yeah, I didn't handle this key press, but I don't want you to send it
to the search entry, either!".

Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-06-15 12:37:07 -05:00
Kristian Rietveld
2cc1247433 Fix #316087.
2008-07-11  Kristian Rietveld  <kris@gtk.org>

	Bug 316087 - Resizing columns is chaotic

	* gtk/gtktreeprivate.h: add new member fields.

	* gtk/gtktreeview.c (gtk_tree_view_init), (validate_row): set post
	validation flag,
	(gtk_tree_view_size_allocate_columns): rework the size allocation
	mechanism to only recalculate the expand values if the width of the
	widget, content or the column configuration has changed,
	(gtk_tree_view_size_allocate): move call to size_allocate_columns()
	to before the adjustment updates so the proper width is used after
	we updated it,
	(gtk_tree_view_button_press), (gtk_tree_view_motion_resize_column):
	use the column width minus the expand value for the resized width,
	(gtk_tree_view_move_column_after): update call to
	gtk_tree_view_size_allocate_columns().

	* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_expand): set use
	resized width to FALSE.

	* tests/Makefile.am:
	* tests/testtreecolumnsizing.c: new interactive test program
	for testing column resizing with different column configurations.


svn path=/trunk/; revision=20818
2008-07-11 14:17:49 +00:00
Michael Natterer
fe8a946e87 deprecate GtkDestroyNotify.
2008-06-18  Michael Natterer  <mitch@imendio.com>

	* gtk/gtktypeutils.h: deprecate GtkDestroyNotify.

	* gtk/gtkactiongroup.[ch]
	* gtk/gtkcombobox.[ch]
	* gtk/gtkcontainer.[ch]
	* gtk/gtkliststore.[ch]
	* gtk/gtkmain.[ch]
	* gtk/gtkmenu.c
	* gtk/gtkstock.[ch]
	* gtk/gtktreedatalist.[ch]
	* gtk/gtktreemodelfilter.[ch]
	* gtk/gtktreemodelsort.[ch]
	* gtk/gtktreeprivate.h
	* gtk/gtktreeselection.[ch]
	* gtk/gtktreesortable.[ch]
	* gtk/gtktreestore.[ch]
	* gtk/gtktreeview.[ch]
	* gtk/gtktreeviewcolumn.[ch]: s/GtkDestroyNotify/GDestroyNotify/g.


svn path=/trunk/; revision=20448
2008-06-18 09:12:32 +00:00
Michael Natterer
a362eecc4a gtk/gtkbutton.h gtk/gtkcellrenderer.h gtk/gtkimcontext.h gtk/gtkstyle.h
2008-01-25  Michael Natterer  <mitch@imendio.com>

	* gtk/gtkbutton.h
	* gtk/gtkcellrenderer.h
	* gtk/gtkimcontext.h
	* gtk/gtkstyle.h
	* gtk/gtktoolbar.h
	* gtk/gtktooltip.h
	* gtk/gtktreeprivate.h
	* gtk/gtktreeviewcolumn.h
	* gtk/gtkwidget.h: add const to constant structs which are passed
	into GTK+. Also add some forgotten const for const strings.

	* gtk/gtkbutton.c
	* gtk/gtkcellrenderer.c
	* gtk/gtkimcontext.c
	* gtk/gtkstyle.c
	* gtk/gtktoolbar.c
	* gtk/gtktooltip.c
	* gtk/gtktreeview.c
	* gtk/gtktreeviewcolumn.c
	* gtk/gtkwidget.c: changed accordingly.


svn path=/trunk/; revision=19399
2008-01-25 09:30:40 +00:00
Kristian Rietveld
244380529a Fix #477175, reported by Juri Pakaste.
2008-01-10  Kristian Rietveld  <kris@imendio.com>

	Fix #477175, reported by Juri Pakaste.

	* gtk/gtktreeprivate.h:
	* gtk/gtktreeview.c (gtk_tree_view_top_row_to_dy): do not set
	tree_view->priv->dy here directly, just calculate the new value
	and set it on the adjustment,
	(gtk_tree_view_adjustment_changed): add guards to not call
	gtk_tree_view_dy_to_top_row() if we are currently in
	gtk_tree_view_top_row_to_dy(),
	(gtk_tree_view_put): fix coordinate annotation: these are bin_window
	coordinates, not tree coordinates,
	(gtk_tree_view_real_start_editing): add cast.

	* gtk/tests/treeview-scrolling.c: add an assertion for checking the
	position of the editable in the "create new row and start editing"
	tests.


svn path=/trunk/; revision=19331
2008-01-10 09:24:11 +00:00
Kristian Rietveld
b1ec5f7556 add more convenience API.
2007-07-19  Kristian Rietveld  <kris@imendio.com>

	* gtk/gtk.symbols:
	* gtk/gtktreeprivate.h:
	* gtk/gtktreeview.[ch] (gtk_tree_view_get_tooltip_context),
	(gtk_tree_view_[sg]et_tooltip_column): add more convenience API.

	* tests/testtooltip.c (query_tooltip_tree_view_cb): use
	gtk_tree_view_get_tooltip_context().

	* demos/gtk-demo/demo.ui: add a tooltip column to the list store,
	set tooltip-column on the tree view.


svn path=/trunk/; revision=18496
2007-07-19 13:21:09 +00:00
Kristian Rietveld
3bd51183a8 add _gtk_tree_view_column_get_focus_area().
2007-03-20  Kristian Rietveld  <kris@gtk.org>

	* gtk/gtktreeviewcolumn.c:
	* gtk/gtktreeprivate.h: add _gtk_tree_view_column_get_focus_area().

	* gtk/gtktreeview.c (gtk_tree_view_clamp_column_visible): add
	focus_to_cell parameter, rework to handle clamping columns which
	are bigger than the available page size better,
	(gtk_tree_view_key_press): remove code handling moving the focus
	to other column headers,
	(gtk_tree_view_header_focus): add clamp_column_visible parameter,
	fix RTL support, don't wrap around when moving focus to other
	column headers, call gtk_tree_view_clamp_column_visible() instead
	of duplicating code,
	(gtk_tree_view_focus): only clamp the column visible when we are
	explicitly moving to another column header (fixes #399555, Charles
	Kerr),
	(gtk_tree_view_move_cursor_left_right): update call to
	gtk_tree_view_clamp_column_visible().


svn path=/trunk/; revision=17546
2007-03-20 12:32:19 +00:00
Kristian Rietveld
c24c88fe30 add cursor_offset field.
2007-02-16  Kristian Rietveld  <kris@gtk.org>

	* gtk/gtktreeprivate.h: add cursor_offset field.

	* gtk/gtktreeview.c (gtk_tree_view_init),
	(gtk_tree_view_move_cursor_page_up_down): fix off by one error
	in page up/down handling by memorizing the offset into the cursor
	row.  (Fixes #399809, reported by Bruce Bowler).


svn path=/trunk/; revision=17316
2007-02-16 21:35:31 +00:00
Kristian Rietveld
61f4d77d55 Another fix for #164884.
2006-07-18  Kristian Rietveld  <kris@imendio.com>

	Another fix for #164884.

	* gtk/gtktreeprivate.h: add in_grab field.

	* gtk/gtktreeview.c (gtk_tree_view_button_press): only save press
	to possibly begin a drag when there's no grab pending,
	(gtk_tree_view_grab_notify): toggle in_grab field.
2006-07-18 12:33:25 +00:00
Kristian Rietveld
7a6a6ebcff Introduce grid and tree lines in GtkTreeView. (#106406, Martyn Russell).
2006-06-12  Kristian Rietveld  <kris@imendio.com>

	Introduce grid and tree lines in GtkTreeView. (#106406,
	Martyn Russell).

	* gtk/gtktreeprivate.h: add new fields to GtkTreePrivate.

	* gtk/gtkenums.h: add GtkTreeViewGridLines.

	* gtk/gtktreeview.[ch] (gtk_tree_view_set_grid_lines),
	(gtk_tree_view_get_grid_lines),
	(gtk_tree_view_set_enable_tree_lines),
	(gtk_tree_view_get_enable_tree_lines): new API,
	(gtk_tree_view_class_init): new properties,
	(gtk_tree_view_init), (gtk_tree_view_{get,set}_property),
	(gtk_tree_view_realize), (gtk_tree_view_draw_grid_lines),
	(gtk_tree_view_bin_expose): implement.

	* gtk/gtk.symbols: update.
2006-06-12 18:17:35 +00:00
Kristian Rietveld
f6c583f74e Rubber banding for GtkTreeView, #80127. Uses same method as GtkIconView.
2006-06-02  Kristian Rietveld  <kris@imendio.com>

	Rubber banding for GtkTreeView, #80127.  Uses same method as
	GtkIconView.

	* gtk/gtktreeview.c (gtk_tree_view_class_init),
	(gtk_tree_view_init), (gtk_tree_view_get_property),
	(gtk_tree_view_set_property), (gtk_tree_view_set_rubber_banding),
	(gtk_tree_view_get_rubber_banding): add property,
	(gtk_tree_view_button_press): start rubber banding if enabled and
	press is on a non-selected node,
	(gtk_tree_view_button_release): stop rubber banding,
	(gtk_tree_view_motion_bin_window), (scrool_row_timeout): enable/update
	the rubber band,
	(gtk_tree_view_bin_expose): draw rubber band if active,
	(gtk_tree_view_stop_rubberband),
	(gtk_tree_view_update_rubber_band_selection_range),
	(gtk_tree_view_update_rubber_band_selection),
	(gtk_tree_view_update_rubber_band),
	(gtk_tree_view_paint_rubber_band): new functions.

	* gtk/gtktreeview.h: add new set/get function for rubber banding
	property.

	* gtk/gtktreeprivate.h: add a bunch of new private fields.
2006-06-02 20:40:33 +00:00
Kristian Rietveld
ebe22cb38a (broken pipe) 2006-04-26 12:39:25 +00:00
Kristian Rietveld
2e6ba401cc rename to _gtk_tree_selection_row_is_selectable and export internally,
2006-03-01  Kristian Rietveld  <kris@imendio.com>

	* gtk/gtktreeselection.c (row_is_selectable): rename to
	_gtk_tree_selection_row_is_selectable and export internally,
	(gtk_tree_selection_real_select_node): changed so it is always
	possible to unselect insensitive nodes, changed the logic a bit to
	be more clear.

	* gtk/gtktreeprivate.h: add _gtk_tree_selection_row_is_selectable.

	* gtk/gtktreeview.c (gtk_tree_view_row_changed): Unselect a row if
	it became insensitive.
2006-03-01 12:18:57 +00:00
Kristian Rietveld
58e77fe25b #322591, Jonathan Blandford.
2006-01-24  Kristian Rietveld  <kris@gtk.org>

	#322591, Jonathan Blandford.

	* gtk/gtktreeview.[ch] (gtk_tree_view_get_search_entry),
	(gtk_tree_view_set_search_entry),
	(gtk_tree_view_get_search_position_func),
	(gtk_tree_view_set_search_position_func): New functions,
	and small adaptions to the tree view code to allow for setting
	the entry and search position function.

	* gtk/gtktreeprivate.h: Removed GtkTreeViewSearchDialogPositionFunc
	typedef, which is now in gtktreeview.h as
	GtkTreeViewSearchPositionFunc.  Add/update fields.

	* gtk/gtk.symbols: Add new functions.

	* tests/testtreesort.c: Add a little test for _set_search_entry().
2006-01-24 10:49:29 +00:00
Matthias Clasen
924765a2fe Properly handle model changes in GtkTreeSelection: (#322569, Milosz
2005-11-29  Matthias Clasen  <mclasen@redhat.com>

	Properly handle model changes in GtkTreeSelection: (#322569,
	Milosz Derezynski)

	* gtk/gtktreeselection.c (gtk_tree_selection_selected_foreach):
	Get a reference to the model, and stop the iteration if the model
	of the treeview is changed on the way.

	* gtk/gtktreeprivate.h:
	* gtk/gtktreeselection.c (_gtk_tree_selection_emit_changed): New
	private function to emit the GtkTreeSelection::changed signal.

	* gtk/gtktreeview.c (gtk_tree_view_set_model): Call
	_gtk_tree_selection_emit_changed() when the model changes.
2005-11-29 19:34:15 +00:00