gtktreeview.c 463 KB
Newer Older
1 2 3
/* gtktreeview.c
 * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
 *
4
 * This library is free software; you can redistribute it and/or
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */


21
#include "config.h"
Manish Singh's avatar
Manish Singh committed
22 23 24
#include <string.h>
#include <gdk/gdkkeysyms.h>

25 26
#include "gtktreeview.h"
#include "gtkrbtree.h"
27
#include "gtktreednd.h"
28 29 30
#include "gtktreeprivate.h"
#include "gtkcellrenderer.h"
#include "gtkmain.h"
31
#include "gtkmarshalers.h"
Johan Dahlin's avatar
Johan Dahlin committed
32
#include "gtkbuildable.h"
33 34 35
#include "gtkbutton.h"
#include "gtkalignment.h"
#include "gtklabel.h"
Havoc Pennington's avatar
Havoc Pennington committed
36
#include "gtkhbox.h"
Jonathan Blandford's avatar
Jonathan Blandford committed
37
#include "gtkvbox.h"
Havoc Pennington's avatar
Havoc Pennington committed
38
#include "gtkarrow.h"
39
#include "gtkintl.h"
40
#include "gtkbindings.h"
41 42
#include "gtkcontainer.h"
#include "gtkentry.h"
43
#include "gtkframe.h"
Jonathan Blandford's avatar
Jonathan Blandford committed
44
#include "gtktreemodelsort.h"
45
#include "gtktooltip.h"
46
#include "gtkprivate.h"
47

Jonathan Blandford's avatar
Jonathan Blandford committed
48
#define GTK_TREE_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
49
#define GTK_TREE_VIEW_PRIORITY_SCROLL_SYNC (GTK_TREE_VIEW_PRIORITY_VALIDATE + 2)
50
#define GTK_TREE_VIEW_TIME_MS_PER_IDLE 30
51
#define SCROLL_EDGE_SIZE 15
52
#define EXPANDER_EXTRA_PADDING 4
Jonathan Blandford's avatar
Jonathan Blandford committed
53
#define GTK_TREE_VIEW_SEARCH_DIALOG_TIMEOUT 5000
54 55
#define AUTO_EXPAND_TIMEOUT 500

56 57 58 59 60 61 62
/* The "background" areas of all rows/cells add up to cover the entire tree.
 * The background includes all inter-row and inter-cell spacing.
 * The "cell" areas are the cell_area passed in to gtk_cell_renderer_render(),
 * i.e. just the cells, no spacing.
 */

#define BACKGROUND_HEIGHT(node) (GTK_RBNODE_GET_HEIGHT (node))
Kristian Rietveld's avatar
Kristian Rietveld committed
63
#define CELL_HEIGHT(node, separator) ((BACKGROUND_HEIGHT (node)) - (separator))
64

65 66 67
/* Translate from bin_window coordinates to rbtree (tree coordinates) and
 * vice versa.
 */
68 69
#define TREE_WINDOW_Y_TO_RBTREE_Y(tree_view,y) ((y) + tree_view->priv->dy)
#define RBTREE_Y_TO_TREE_WINDOW_Y(tree_view,y) ((y) - tree_view->priv->dy)
70

71
/* This is in bin_window coordinates */
72 73
#define BACKGROUND_FIRST_PIXEL(tree_view,tree,node) (RBTREE_Y_TO_TREE_WINDOW_Y (tree_view, _gtk_rbtree_node_find_offset ((tree), (node))))
#define CELL_FIRST_PIXEL(tree_view,tree,node,separator) (BACKGROUND_FIRST_PIXEL (tree_view,tree,node) + separator/2)
74

75 76
#define ROW_HEIGHT(tree_view,height) \
  ((height > 0) ? (height) : (tree_view)->priv->expander_size)
77

78

79
typedef struct _GtkTreeViewChild GtkTreeViewChild;
80 81 82 83 84
struct _GtkTreeViewChild
{
  GtkWidget *widget;
  gint x;
  gint y;
85 86
  gint width;
  gint height;
87 88
};

Jonathan Blandford's avatar
Jonathan Blandford committed
89

90 91 92 93
typedef struct _TreeViewDragInfo TreeViewDragInfo;
struct _TreeViewDragInfo
{
  GdkModifierType start_button_mask;
94
  GtkTargetList *_unused_source_target_list;
95 96
  GdkDragAction source_actions;

97
  GtkTargetList *_unused_dest_target_list;
98 99 100 101 102 103 104

  guint source_set : 1;
  guint dest_set : 1;
};


/* Signals */
105 106 107
enum
{
  ROW_ACTIVATED,
108 109 110 111
  TEST_EXPAND_ROW,
  TEST_COLLAPSE_ROW,
  ROW_EXPANDED,
  ROW_COLLAPSED,
112
  COLUMNS_CHANGED,
113
  CURSOR_CHANGED,
114
  MOVE_CURSOR,
115
  SELECT_ALL,
116
  UNSELECT_ALL,
117
  SELECT_CURSOR_ROW,
118 119 120
  TOGGLE_CURSOR_ROW,
  EXPAND_COLLAPSE_CURSOR_ROW,
  SELECT_CURSOR_PARENT,
121
  START_INTERACTIVE_SEARCH,
122 123 124
  LAST_SIGNAL
};

125
/* Properties */
126 127 128 129 130 131 132 133
enum {
  PROP_0,
  PROP_MODEL,
  PROP_HADJUSTMENT,
  PROP_VADJUSTMENT,
  PROP_HEADERS_VISIBLE,
  PROP_HEADERS_CLICKABLE,
  PROP_EXPANDER_COLUMN,
134
  PROP_REORDERABLE,
135 136
  PROP_RULES_HINT,
  PROP_ENABLE_SEARCH,
137
  PROP_SEARCH_COLUMN,
138
  PROP_FIXED_HEIGHT_MODE,
139
  PROP_HOVER_SELECTION,
Kristian Rietveld's avatar
Kristian Rietveld committed
140 141
  PROP_HOVER_EXPAND,
  PROP_SHOW_EXPANDERS,
142
  PROP_LEVEL_INDENTATION,
143 144
  PROP_RUBBER_BANDING,
  PROP_ENABLE_GRID_LINES,
145 146
  PROP_ENABLE_TREE_LINES,
  PROP_TOOLTIP_COLUMN
147
};
148

149 150
/* object signals */
static void     gtk_tree_view_finalize             (GObject          *object);
151 152 153
static void     gtk_tree_view_set_property         (GObject         *object,
						    guint            prop_id,
						    const GValue    *value,
Jonathan Blandford's avatar
Jonathan Blandford committed
154
						    GParamSpec      *pspec);
155 156 157
static void     gtk_tree_view_get_property         (GObject         *object,
						    guint            prop_id,
						    GValue          *value,
Jonathan Blandford's avatar
Jonathan Blandford committed
158
						    GParamSpec      *pspec);
159

160
/* gtkobject signals */
Jonathan Blandford's avatar
Jonathan Blandford committed
161 162
static void     gtk_tree_view_destroy              (GtkObject        *object);

163
/* gtkwidget signals */
164 165 166 167 168 169 170 171 172
static void     gtk_tree_view_realize              (GtkWidget        *widget);
static void     gtk_tree_view_unrealize            (GtkWidget        *widget);
static void     gtk_tree_view_map                  (GtkWidget        *widget);
static void     gtk_tree_view_size_request         (GtkWidget        *widget,
						    GtkRequisition   *requisition);
static void     gtk_tree_view_size_allocate        (GtkWidget        *widget,
						    GtkAllocation    *allocation);
static gboolean gtk_tree_view_expose               (GtkWidget        *widget,
						    GdkEventExpose   *event);
173 174
static gboolean gtk_tree_view_key_press            (GtkWidget        *widget,
						    GdkEventKey      *event);
Jonathan Blandford's avatar
Jonathan Blandford committed
175 176
static gboolean gtk_tree_view_key_release          (GtkWidget        *widget,
						    GdkEventKey      *event);
177 178 179 180 181 182 183 184 185 186
static gboolean gtk_tree_view_motion               (GtkWidget        *widget,
						    GdkEventMotion   *event);
static gboolean gtk_tree_view_enter_notify         (GtkWidget        *widget,
						    GdkEventCrossing *event);
static gboolean gtk_tree_view_leave_notify         (GtkWidget        *widget,
						    GdkEventCrossing *event);
static gboolean gtk_tree_view_button_press         (GtkWidget        *widget,
						    GdkEventButton   *event);
static gboolean gtk_tree_view_button_release       (GtkWidget        *widget,
						    GdkEventButton   *event);
187 188
static gboolean gtk_tree_view_grab_broken          (GtkWidget          *widget,
						    GdkEventGrabBroken *event);
189 190 191 192 193
#if 0
static gboolean gtk_tree_view_configure            (GtkWidget         *widget,
						    GdkEventConfigure *event);
#endif

194 195
static void     gtk_tree_view_set_focus_child      (GtkContainer     *container,
						    GtkWidget        *child);
196 197
static gint     gtk_tree_view_focus_out            (GtkWidget        *widget,
						    GdkEventFocus    *event);
198
static gint     gtk_tree_view_focus                (GtkWidget        *widget,
199
						    GtkDirectionType  direction);
200
static void     gtk_tree_view_grab_focus           (GtkWidget        *widget);
Kristian Rietveld's avatar
Kristian Rietveld committed
201 202
static void     gtk_tree_view_style_set            (GtkWidget        *widget,
						    GtkStyle         *previous_style);
203 204
static void     gtk_tree_view_grab_notify          (GtkWidget        *widget,
						    gboolean          was_grabbed);
205 206
static void     gtk_tree_view_state_changed        (GtkWidget        *widget,
						    GtkStateType      previous_state);
207 208 209 210 211 212 213 214 215

/* container signals */
static void     gtk_tree_view_remove               (GtkContainer     *container,
						    GtkWidget        *widget);
static void     gtk_tree_view_forall               (GtkContainer     *container,
						    gboolean          include_internals,
						    GtkCallback       callback,
						    gpointer          callback_data);

Havoc Pennington's avatar
Havoc Pennington committed
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
/* Source side drag signals */
static void gtk_tree_view_drag_begin       (GtkWidget        *widget,
                                            GdkDragContext   *context);
static void gtk_tree_view_drag_end         (GtkWidget        *widget,
                                            GdkDragContext   *context);
static void gtk_tree_view_drag_data_get    (GtkWidget        *widget,
                                            GdkDragContext   *context,
                                            GtkSelectionData *selection_data,
                                            guint             info,
                                            guint             time);
static void gtk_tree_view_drag_data_delete (GtkWidget        *widget,
                                            GdkDragContext   *context);

/* Target side drag signals */
static void     gtk_tree_view_drag_leave         (GtkWidget        *widget,
                                                  GdkDragContext   *context,
                                                  guint             time);
static gboolean gtk_tree_view_drag_motion        (GtkWidget        *widget,
                                                  GdkDragContext   *context,
                                                  gint              x,
                                                  gint              y,
                                                  guint             time);
static gboolean gtk_tree_view_drag_drop          (GtkWidget        *widget,
                                                  GdkDragContext   *context,
                                                  gint              x,
                                                  gint              y,
                                                  guint             time);
static void     gtk_tree_view_drag_data_received (GtkWidget        *widget,
                                                  GdkDragContext   *context,
                                                  gint              x,
                                                  gint              y,
                                                  GtkSelectionData *selection_data,
                                                  guint             info,
                                                  guint             time);

251
/* tree_model signals */
252 253 254
static void gtk_tree_view_set_adjustments                 (GtkTreeView     *tree_view,
							   GtkAdjustment   *hadj,
							   GtkAdjustment   *vadj);
255
static gboolean gtk_tree_view_real_move_cursor            (GtkTreeView     *tree_view,
256
							   GtkMovementStep  step,
257
							   gint             count);
258 259 260
static gboolean gtk_tree_view_real_select_all             (GtkTreeView     *tree_view);
static gboolean gtk_tree_view_real_unselect_all           (GtkTreeView     *tree_view);
static gboolean gtk_tree_view_real_select_cursor_row      (GtkTreeView     *tree_view,
261
							   gboolean         start_editing);
262 263 264 265 266 267
static gboolean gtk_tree_view_real_toggle_cursor_row      (GtkTreeView     *tree_view);
static gboolean gtk_tree_view_real_expand_collapse_cursor_row (GtkTreeView     *tree_view,
							       gboolean         logical,
							       gboolean         expand,
							       gboolean         open_all);
static gboolean gtk_tree_view_real_select_cursor_parent   (GtkTreeView     *tree_view);
268
static void gtk_tree_view_row_changed                     (GtkTreeModel    *model,
269 270 271
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
272
static void gtk_tree_view_row_inserted                    (GtkTreeModel    *model,
273 274 275
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
276
static void gtk_tree_view_row_has_child_toggled           (GtkTreeModel    *model,
277 278 279
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
280
static void gtk_tree_view_row_deleted                     (GtkTreeModel    *model,
281 282
							   GtkTreePath     *path,
							   gpointer         data);
283
static void gtk_tree_view_rows_reordered                  (GtkTreeModel    *model,
284 285 286 287 288
							   GtkTreePath     *parent,
							   GtkTreeIter     *iter,
							   gint            *new_order,
							   gpointer         data);

Jonathan Blandford's avatar
Jonathan Blandford committed
289 290 291 292 293 294 295 296
/* Incremental reflow */
static gboolean validate_row             (GtkTreeView *tree_view,
					  GtkRBTree   *tree,
					  GtkRBNode   *node,
					  GtkTreeIter *iter,
					  GtkTreePath *path);
static void     validate_visible_area    (GtkTreeView *tree_view);
static gboolean validate_rows_handler    (GtkTreeView *tree_view);
297 298
static gboolean do_validate_rows         (GtkTreeView *tree_view,
					  gboolean     size_request);
299
static gboolean validate_rows            (GtkTreeView *tree_view);
Jonathan Blandford's avatar
Jonathan Blandford committed
300 301
static gboolean presize_handler_callback (gpointer     data);
static void     install_presize_handler  (GtkTreeView *tree_view);
302
static void     install_scroll_sync_handler (GtkTreeView *tree_view);
303 304 305
static void     gtk_tree_view_set_top_row   (GtkTreeView *tree_view,
					     GtkTreePath *path,
					     gint         offset);
306
static void	gtk_tree_view_dy_to_top_row (GtkTreeView *tree_view);
307
static void     gtk_tree_view_top_row_to_dy (GtkTreeView *tree_view);
308
static void     invalidate_empty_focus      (GtkTreeView *tree_view);
309

310
/* Internal functions */
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
static gboolean gtk_tree_view_is_expander_column             (GtkTreeView        *tree_view,
							      GtkTreeViewColumn  *column);
static void     gtk_tree_view_add_move_binding               (GtkBindingSet      *binding_set,
							      guint               keyval,
							      guint               modmask,
							      gboolean            add_shifted_binding,
							      GtkMovementStep     step,
							      gint                count);
static gint     gtk_tree_view_unref_and_check_selection_tree (GtkTreeView        *tree_view,
							      GtkRBTree          *tree);
static void     gtk_tree_view_queue_draw_path                (GtkTreeView        *tree_view,
							      GtkTreePath        *path,
							      const GdkRectangle *clip_rect);
static void     gtk_tree_view_queue_draw_arrow               (GtkTreeView        *tree_view,
							      GtkRBTree          *tree,
							      GtkRBNode          *node,
							      const GdkRectangle *clip_rect);
static void     gtk_tree_view_draw_arrow                     (GtkTreeView        *tree_view,
							      GtkRBTree          *tree,
							      GtkRBNode          *node,
							      gint                x,
							      gint                y);
static void     gtk_tree_view_get_arrow_xrange               (GtkTreeView        *tree_view,
							      GtkRBTree          *tree,
							      gint               *x1,
							      gint               *x2);
static gint     gtk_tree_view_new_column_width               (GtkTreeView        *tree_view,
							      gint                i,
							      gint               *x);
static void     gtk_tree_view_adjustment_changed             (GtkAdjustment      *adjustment,
							      GtkTreeView        *tree_view);
static void     gtk_tree_view_build_tree                     (GtkTreeView        *tree_view,
							      GtkRBTree          *tree,
							      GtkTreeIter        *iter,
							      gint                depth,
							      gboolean            recurse);
static void     gtk_tree_view_clamp_node_visible             (GtkTreeView        *tree_view,
							      GtkRBTree          *tree,
							      GtkRBNode          *node);
static void     gtk_tree_view_clamp_column_visible           (GtkTreeView        *tree_view,
							      GtkTreeViewColumn  *column,
							      gboolean            focus_to_cell);
static gboolean gtk_tree_view_maybe_begin_dragging_row       (GtkTreeView        *tree_view,
							      GdkEventMotion     *event);
static void     gtk_tree_view_focus_to_cursor                (GtkTreeView        *tree_view);
static void     gtk_tree_view_move_cursor_up_down            (GtkTreeView        *tree_view,
							      gint                count);
static void     gtk_tree_view_move_cursor_page_up_down       (GtkTreeView        *tree_view,
							      gint                count);
static void     gtk_tree_view_move_cursor_left_right         (GtkTreeView        *tree_view,
							      gint                count);
static void     gtk_tree_view_move_cursor_start_end          (GtkTreeView        *tree_view,
							      gint                count);
static gboolean gtk_tree_view_real_collapse_row              (GtkTreeView        *tree_view,
							      GtkTreePath        *path,
							      GtkRBTree          *tree,
							      GtkRBNode          *node,
							      gboolean            animate);
static gboolean gtk_tree_view_real_expand_row                (GtkTreeView        *tree_view,
							      GtkTreePath        *path,
							      GtkRBTree          *tree,
							      GtkRBNode          *node,
							      gboolean            open_all,
							      gboolean            animate);
static void     gtk_tree_view_real_set_cursor                (GtkTreeView        *tree_view,
							      GtkTreePath        *path,
							      gboolean            clear_and_select,
							      gboolean            clamp_node);
static gboolean gtk_tree_view_has_special_cell               (GtkTreeView        *tree_view);
static void     column_sizing_notify                         (GObject            *object,
                                                              GParamSpec         *pspec,
                                                              gpointer            data);
static gboolean expand_collapse_timeout                      (gpointer            data);
384 385 386 387 388 389
static void     add_expand_collapse_timeout                  (GtkTreeView        *tree_view,
                                                              GtkRBTree          *tree,
                                                              GtkRBNode          *node,
                                                              gboolean            expand);
static void     remove_expand_collapse_timeout               (GtkTreeView        *tree_view);
static void     cancel_arrow_animation                       (GtkTreeView        *tree_view);
390 391
static gboolean do_expand_collapse                           (GtkTreeView        *tree_view);
static void     gtk_tree_view_stop_rubber_band               (GtkTreeView        *tree_view);
392 393 394
static void     update_prelight                              (GtkTreeView        *tree_view,
                                                              int                 x,
                                                              int                 y);
Kristian Rietveld's avatar
Kristian Rietveld committed
395

396
/* interactive search */
Jonathan Blandford's avatar
Jonathan Blandford committed
397
static void     gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view);
398 399 400
static void     gtk_tree_view_search_dialog_hide        (GtkWidget        *search_dialog,
                                                         GtkTreeView      *tree_view,
                                                         GdkDevice        *device);
401
static void     gtk_tree_view_search_position_func      (GtkTreeView      *tree_view,
402 403
							 GtkWidget        *search_dialog,
							 gpointer          user_data);
404 405 406
static void     gtk_tree_view_search_disable_popdown    (GtkEntry         *entry,
							 GtkMenu          *menu,
							 gpointer          data);
Jonathan Blandford's avatar
Jonathan Blandford committed
407 408
static void     gtk_tree_view_search_preedit_changed    (GtkIMContext     *im_context,
							 GtkTreeView      *tree_view);
409 410
static void     gtk_tree_view_search_activate           (GtkEntry         *entry,
							 GtkTreeView      *tree_view);
411 412 413
static gboolean gtk_tree_view_real_search_enable_popdown(gpointer          data);
static void     gtk_tree_view_search_enable_popdown     (GtkWidget        *widget,
							 gpointer          data);
414 415 416 417 418 419
static gboolean gtk_tree_view_search_delete_event       (GtkWidget        *widget,
							 GdkEventAny      *event,
							 GtkTreeView      *tree_view);
static gboolean gtk_tree_view_search_button_press_event (GtkWidget        *widget,
							 GdkEventButton   *event,
							 GtkTreeView      *tree_view);
420 421 422
static gboolean gtk_tree_view_search_scroll_event       (GtkWidget        *entry,
							 GdkEventScroll   *event,
							 GtkTreeView      *tree_view);
423 424 425
static gboolean gtk_tree_view_search_key_press_event    (GtkWidget        *entry,
							 GdkEventKey      *event,
							 GtkTreeView      *tree_view);
426
static gboolean gtk_tree_view_search_move               (GtkWidget        *window,
427 428 429 430
							 GtkTreeView      *tree_view,
							 gboolean          up);
static gboolean gtk_tree_view_search_equal_func         (GtkTreeModel     *model,
							 gint              column,
431
							 const gchar      *key,
432 433
							 GtkTreeIter      *iter,
							 gpointer          search_data);
434 435 436
static gboolean gtk_tree_view_search_iter               (GtkTreeModel     *model,
							 GtkTreeSelection *selection,
							 GtkTreeIter      *iter,
437
							 const gchar      *text,
438 439 440 441
							 gint             *count,
							 gint              n);
static void     gtk_tree_view_search_init               (GtkWidget        *entry,
							 GtkTreeView      *tree_view);
442 443 444 445 446 447
static void     gtk_tree_view_put                       (GtkTreeView      *tree_view,
							 GtkWidget        *child_widget,
							 gint              x,
							 gint              y,
							 gint              width,
							 gint              height);
448 449 450 451 452 453 454 455 456
static gboolean gtk_tree_view_start_editing             (GtkTreeView      *tree_view,
							 GtkTreePath      *cursor_path);
static void gtk_tree_view_real_start_editing (GtkTreeView       *tree_view,
					      GtkTreeViewColumn *column,
					      GtkTreePath       *path,
					      GtkCellEditable   *cell_editable,
					      GdkRectangle      *cell_area,
					      GdkEvent          *event,
					      guint              flags);
Jonathan Blandford's avatar
Jonathan Blandford committed
457 458
static void gtk_tree_view_stop_editing                  (GtkTreeView *tree_view,
							 gboolean     cancel_editing);
Jonathan Blandford's avatar
Jonathan Blandford committed
459
static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view,
460
                                                             GdkDevice   *device,
Jonathan Blandford's avatar
Jonathan Blandford committed
461 462
							     gboolean     keybinding);
static gboolean gtk_tree_view_start_interactive_search      (GtkTreeView *tree_view);
463 464 465
static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView       *tree_view,
							 GtkTreeViewColumn *column,
							 gint               drop_position);
466

Johan Dahlin's avatar
Johan Dahlin committed
467
/* GtkBuildable */
468 469 470 471 472 473 474 475
static void     gtk_tree_view_buildable_add_child          (GtkBuildable      *tree_view,
							    GtkBuilder        *builder,
							    GObject           *child,
							    const gchar       *type);
static GObject *gtk_tree_view_buildable_get_internal_child (GtkBuildable      *buildable,
							    GtkBuilder        *builder,
							    const gchar       *childname);
static void     gtk_tree_view_buildable_init               (GtkBuildableIface *iface);
Johan Dahlin's avatar
Johan Dahlin committed
476 477


478 479 480
static gboolean scroll_row_timeout                   (gpointer     data);
static void     add_scroll_timeout                   (GtkTreeView *tree_view);
static void     remove_scroll_timeout                (GtkTreeView *tree_view);
481

482
static guint tree_view_signals [LAST_SIGNAL] = { 0 };
483

484 485 486 487 488


/* GType Methods
 */

Johan Dahlin's avatar
Johan Dahlin committed
489 490 491
G_DEFINE_TYPE_WITH_CODE (GtkTreeView, gtk_tree_view, GTK_TYPE_CONTAINER,
			 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
						gtk_tree_view_buildable_init))
492 493 494 495

static void
gtk_tree_view_class_init (GtkTreeViewClass *class)
{
496
  GObjectClass *o_class;
497 498 499
  GtkObjectClass *object_class;
  GtkWidgetClass *widget_class;
  GtkContainerClass *container_class;
500
  GtkBindingSet *binding_set;
501

502
  binding_set = gtk_binding_set_by_class (class);
503

504 505 506 507 508
  o_class = (GObjectClass *) class;
  object_class = (GtkObjectClass *) class;
  widget_class = (GtkWidgetClass *) class;
  container_class = (GtkContainerClass *) class;

509
  /* GObject signals */
510 511
  o_class->set_property = gtk_tree_view_set_property;
  o_class->get_property = gtk_tree_view_get_property;
512
  o_class->finalize = gtk_tree_view_finalize;
513

514
  /* GtkObject signals */
Jonathan Blandford's avatar
Jonathan Blandford committed
515
  object_class->destroy = gtk_tree_view_destroy;
516

517 518
  /* GtkWidget signals */
  widget_class->map = gtk_tree_view_map;
519 520 521 522
  widget_class->realize = gtk_tree_view_realize;
  widget_class->unrealize = gtk_tree_view_unrealize;
  widget_class->size_request = gtk_tree_view_size_request;
  widget_class->size_allocate = gtk_tree_view_size_allocate;
523 524
  widget_class->button_press_event = gtk_tree_view_button_press;
  widget_class->button_release_event = gtk_tree_view_button_release;
525
  widget_class->grab_broken_event = gtk_tree_view_grab_broken;
526
  /*widget_class->configure_event = gtk_tree_view_configure;*/
527
  widget_class->motion_notify_event = gtk_tree_view_motion;
528
  widget_class->expose_event = gtk_tree_view_expose;
529
  widget_class->key_press_event = gtk_tree_view_key_press;
Jonathan Blandford's avatar
Jonathan Blandford committed
530
  widget_class->key_release_event = gtk_tree_view_key_release;
531 532 533
  widget_class->enter_notify_event = gtk_tree_view_enter_notify;
  widget_class->leave_notify_event = gtk_tree_view_leave_notify;
  widget_class->focus_out_event = gtk_tree_view_focus_out;
Havoc Pennington's avatar
Havoc Pennington committed
534 535 536 537 538 539 540 541
  widget_class->drag_begin = gtk_tree_view_drag_begin;
  widget_class->drag_end = gtk_tree_view_drag_end;
  widget_class->drag_data_get = gtk_tree_view_drag_data_get;
  widget_class->drag_data_delete = gtk_tree_view_drag_data_delete;
  widget_class->drag_leave = gtk_tree_view_drag_leave;
  widget_class->drag_motion = gtk_tree_view_drag_motion;
  widget_class->drag_drop = gtk_tree_view_drag_drop;
  widget_class->drag_data_received = gtk_tree_view_drag_data_received;
542
  widget_class->focus = gtk_tree_view_focus;
543
  widget_class->grab_focus = gtk_tree_view_grab_focus;
Kristian Rietveld's avatar
Kristian Rietveld committed
544
  widget_class->style_set = gtk_tree_view_style_set;
545
  widget_class->grab_notify = gtk_tree_view_grab_notify;
546
  widget_class->state_changed = gtk_tree_view_state_changed;
547

548
  /* GtkContainer signals */
549
  container_class->remove = gtk_tree_view_remove;
550 551
  container_class->forall = gtk_tree_view_forall;
  container_class->set_focus_child = gtk_tree_view_set_focus_child;
552 553

  class->set_scroll_adjustments = gtk_tree_view_set_adjustments;
554
  class->move_cursor = gtk_tree_view_real_move_cursor;
555
  class->select_all = gtk_tree_view_real_select_all;
556
  class->unselect_all = gtk_tree_view_real_unselect_all;
557
  class->select_cursor_row = gtk_tree_view_real_select_cursor_row;
558 559 560
  class->toggle_cursor_row = gtk_tree_view_real_toggle_cursor_row;
  class->expand_collapse_cursor_row = gtk_tree_view_real_expand_collapse_cursor_row;
  class->select_cursor_parent = gtk_tree_view_real_select_cursor_parent;
Jonathan Blandford's avatar
Jonathan Blandford committed
561
  class->start_interactive_search = gtk_tree_view_start_interactive_search;
562

563
  /* Properties */
564

565 566
  g_object_class_install_property (o_class,
                                   PROP_MODEL,
Tim Janik's avatar
Tim Janik committed
567
                                   g_param_spec_object ("model",
568 569
							P_("TreeView Model"),
							P_("The model for the tree view"),
Tim Janik's avatar
Tim Janik committed
570
							GTK_TYPE_TREE_MODEL,
571
							GTK_PARAM_READWRITE));
Jonathan Blandford's avatar
Jonathan Blandford committed
572

573 574 575
  g_object_class_install_property (o_class,
                                   PROP_HADJUSTMENT,
                                   g_param_spec_object ("hadjustment",
576 577
							P_("Horizontal Adjustment"),
                                                        P_("Horizontal Adjustment for the widget"),
578
                                                        GTK_TYPE_ADJUSTMENT,
579
                                                        GTK_PARAM_READWRITE));
580 581 582 583

  g_object_class_install_property (o_class,
                                   PROP_VADJUSTMENT,
                                   g_param_spec_object ("vadjustment",
584 585
							P_("Vertical Adjustment"),
                                                        P_("Vertical Adjustment for the widget"),
586
                                                        GTK_TYPE_ADJUSTMENT,
587
                                                        GTK_PARAM_READWRITE));
588 589 590

  g_object_class_install_property (o_class,
                                   PROP_HEADERS_VISIBLE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
591
                                   g_param_spec_boolean ("headers-visible",
592
							 P_("Headers Visible"),
593
							 P_("Show the column header buttons"),
594
							 TRUE,
595
							 GTK_PARAM_READWRITE));
596 597 598

  g_object_class_install_property (o_class,
                                   PROP_HEADERS_CLICKABLE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
599
                                   g_param_spec_boolean ("headers-clickable",
600 601
							 P_("Headers Clickable"),
							 P_("Column headers respond to click events"),
602
							 TRUE,
603
							 GTK_PARAM_READWRITE));
604 605 606

  g_object_class_install_property (o_class,
                                   PROP_EXPANDER_COLUMN,
Matthias Clasen's avatar
x  
Matthias Clasen committed
607
                                   g_param_spec_object ("expander-column",
608 609
							P_("Expander Column"),
							P_("Set the column for the expander column"),
610
							GTK_TYPE_TREE_VIEW_COLUMN,
611
							GTK_PARAM_READWRITE));
612

613 614 615
  g_object_class_install_property (o_class,
                                   PROP_REORDERABLE,
                                   g_param_spec_boolean ("reorderable",
616 617
							 P_("Reorderable"),
							 P_("View is reorderable"),
618
							 FALSE,
619
							 GTK_PARAM_READWRITE));
620

621 622
  g_object_class_install_property (o_class,
                                   PROP_RULES_HINT,
Matthias Clasen's avatar
x  
Matthias Clasen committed
623
                                   g_param_spec_boolean ("rules-hint",
624 625
							 P_("Rules Hint"),
							 P_("Set a hint to the theme engine to draw rows in alternating colors"),
626
							 FALSE,
627
							 GTK_PARAM_READWRITE));
628

629 630
    g_object_class_install_property (o_class,
				     PROP_ENABLE_SEARCH,
Matthias Clasen's avatar
x  
Matthias Clasen committed
631
				     g_param_spec_boolean ("enable-search",
632 633
							   P_("Enable Search"),
							   P_("View allows user to search through columns interactively"),
634
							   TRUE,
635
							   GTK_PARAM_READWRITE));
636

637 638
    g_object_class_install_property (o_class,
				     PROP_SEARCH_COLUMN,
Matthias Clasen's avatar
x  
Matthias Clasen committed
639
				     g_param_spec_int ("search-column",
640
						       P_("Search Column"),
641
						       P_("Model column to search through during interactive search"),
642 643
						       -1,
						       G_MAXINT,
644
						       -1,
645
						       GTK_PARAM_READWRITE));
646

647 648 649 650 651 652 653 654 655 656 657
    /**
     * GtkTreeView:fixed-height-mode:
     *
     * Setting the ::fixed-height-mode property to %TRUE speeds up 
     * #GtkTreeView by assuming that all rows have the same height. 
     * Only enable this option if all rows are the same height.  
     * Please see gtk_tree_view_set_fixed_height_mode() for more 
     * information on this option.
     *
     * Since: 2.4
     **/
658 659
    g_object_class_install_property (o_class,
                                     PROP_FIXED_HEIGHT_MODE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
660
                                     g_param_spec_boolean ("fixed-height-mode",
661 662
                                                           P_("Fixed Height Mode"),
                                                           P_("Speeds up GtkTreeView by assuming that all rows have the same height"),
663
                                                           FALSE,
664
                                                           GTK_PARAM_READWRITE));
665 666 667 668 669 670
    
    /**
     * GtkTreeView:hover-selection:
     * 
     * Enables of disables the hover selection mode of @tree_view.
     * Hover selection makes the selected row follow the pointer.
Matthias Clasen's avatar
Matthias Clasen committed
671 672 673
     * Currently, this works only for the selection modes 
     * %GTK_SELECTION_SINGLE and %GTK_SELECTION_BROWSE.
     *
Matthias Clasen's avatar
Matthias Clasen committed
674
     * This mode is primarily intended for treeviews in popups, e.g.
675 676 677 678 679 680
     * in #GtkComboBox or #GtkEntryCompletion.
     *
     * Since: 2.6
     */
    g_object_class_install_property (o_class,
                                     PROP_HOVER_SELECTION,
Matthias Clasen's avatar
x  
Matthias Clasen committed
681
                                     g_param_spec_boolean ("hover-selection",
682 683 684
                                                           P_("Hover Selection"),
                                                           P_("Whether the selection should follow the pointer"),
                                                           FALSE,
685
                                                           GTK_PARAM_READWRITE));
686

687 688 689 690
    /**
     * GtkTreeView:hover-expand:
     * 
     * Enables of disables the hover expansion mode of @tree_view.
Matthias Clasen's avatar
Matthias Clasen committed
691
     * Hover expansion makes rows expand or collapse if the pointer moves 
692 693
     * over them.
     *
Matthias Clasen's avatar
Matthias Clasen committed
694
     * This mode is primarily intended for treeviews in popups, e.g.
695 696 697 698 699 700
     * in #GtkComboBox or #GtkEntryCompletion.
     *
     * Since: 2.6
     */
    g_object_class_install_property (o_class,
                                     PROP_HOVER_EXPAND,
Matthias Clasen's avatar
x  
Matthias Clasen committed
701
                                     g_param_spec_boolean ("hover-expand",
702
                                                           P_("Hover Expand"),
703
                                                           P_("Whether rows should be expanded/collapsed when the pointer moves over them"),
704
                                                           FALSE,
705
                                                           GTK_PARAM_READWRITE));
706

Matthias Clasen's avatar
Matthias Clasen committed
707 708 709 710 711 712 713
    /**
     * GtkTreeView:show-expanders:
     *
     * %TRUE if the view has expanders.
     *
     * Since: 2.12
     */
Kristian Rietveld's avatar
Kristian Rietveld committed
714 715 716 717 718 719 720 721
    g_object_class_install_property (o_class,
				     PROP_SHOW_EXPANDERS,
				     g_param_spec_boolean ("show-expanders",
							   P_("Show Expanders"),
							   P_("View has expanders"),
							   TRUE,
							   GTK_PARAM_READWRITE));

Matthias Clasen's avatar
Matthias Clasen committed
722 723 724 725 726 727 728
    /**
     * GtkTreeView:level-indentation:
     *
     * Extra indentation for each level.
     *
     * Since: 2.12
     */
Kristian Rietveld's avatar
Kristian Rietveld committed
729 730 731 732 733 734 735 736 737 738
    g_object_class_install_property (o_class,
				     PROP_LEVEL_INDENTATION,
				     g_param_spec_int ("level-indentation",
						       P_("Level Indentation"),
						       P_("Extra indentation for each level"),
						       0,
						       G_MAXINT,
						       0,
						       GTK_PARAM_READWRITE));

739 740 741 742 743 744 745 746
    g_object_class_install_property (o_class,
                                     PROP_RUBBER_BANDING,
                                     g_param_spec_boolean ("rubber-banding",
                                                           P_("Rubber Banding"),
                                                           P_("Whether to enable selection of multiple items by dragging the mouse pointer"),
                                                           FALSE,
                                                           GTK_PARAM_READWRITE));

747 748
    g_object_class_install_property (o_class,
                                     PROP_ENABLE_GRID_LINES,
749 750 751 752 753 754
                                     g_param_spec_enum ("enable-grid-lines",
							P_("Enable Grid Lines"),
							P_("Whether grid lines should be drawn in the tree view"),
							GTK_TYPE_TREE_VIEW_GRID_LINES,
							GTK_TREE_VIEW_GRID_LINES_NONE,
							GTK_PARAM_READWRITE));
755 756 757 758 759 760 761 762 763

    g_object_class_install_property (o_class,
                                     PROP_ENABLE_TREE_LINES,
                                     g_param_spec_boolean ("enable-tree-lines",
                                                           P_("Enable Tree Lines"),
                                                           P_("Whether tree lines should be drawn in the tree view"),
                                                           FALSE,
                                                           GTK_PARAM_READWRITE));

764 765 766 767 768 769 770 771 772 773
    g_object_class_install_property (o_class,
				     PROP_TOOLTIP_COLUMN,
				     g_param_spec_int ("tooltip-column",
						       P_("Tooltip Column"),
						       P_("The column in the model containing the tooltip texts for the rows"),
						       -1,
						       G_MAXINT,
						       -1,
						       GTK_PARAM_READWRITE));

774
  /* Style properties */
775
#define _TREE_VIEW_EXPANDER_SIZE 12
776
#define _TREE_VIEW_VERTICAL_SEPARATOR 2
777
#define _TREE_VIEW_HORIZONTAL_SEPARATOR 2
778

779
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
780
					   g_param_spec_int ("expander-size",
781 782
							     P_("Expander Size"),
							     P_("Size of the expander arrow"),
783 784
							     0,
							     G_MAXINT,
785
							     _TREE_VIEW_EXPANDER_SIZE,
786
							     GTK_PARAM_READABLE));
787

788
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
789
					   g_param_spec_int ("vertical-separator",
790 791
							     P_("Vertical Separator Width"),
							     P_("Vertical space between cells.  Must be an even number"),
792 793 794
							     0,
							     G_MAXINT,
							     _TREE_VIEW_VERTICAL_SEPARATOR,
795
							     GTK_PARAM_READABLE));
796

797
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
798
					   g_param_spec_int ("horizontal-separator",
799 800
							     P_("Horizontal Separator Width"),
							     P_("Horizontal space between cells.  Must be an even number"),
801 802 803
							     0,
							     G_MAXINT,
							     _TREE_VIEW_HORIZONTAL_SEPARATOR,
804
							     GTK_PARAM_READABLE));
805

806
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
807
					   g_param_spec_boolean ("allow-rules",
808 809
								 P_("Allow Rules"),
								 P_("Allow drawing of alternating color rows"),
810
								 TRUE,
811
								 GTK_PARAM_READABLE));
812

813
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
814
					   g_param_spec_boolean ("indent-expanders",
815 816
								 P_("Indent Expanders"),
								 P_("Make the expanders indented"),
817
								 TRUE,
818
								 GTK_PARAM_READABLE));
Manish Singh's avatar
Manish Singh committed
819

820
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
821
                                           g_param_spec_boxed ("even-row-color",
822 823
                                                               P_("Even Row Color"),
                                                               P_("Color to use for even rows"),
824
							       GDK_TYPE_COLOR,
825
							       GTK_PARAM_READABLE));
826 827

  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
828
                                           g_param_spec_boxed ("odd-row-color",
829 830
                                                               P_("Odd Row Color"),
                                                               P_("Color to use for odd rows"),
831
							       GDK_TYPE_COLOR,
832
							       GTK_PARAM_READABLE));
833

834 835 836 837 838 839 840
  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_boolean ("row-ending-details",
								 P_("Row Ending details"),
								 P_("Enable extended row background theming"),
								 FALSE,
								 GTK_PARAM_READABLE));

841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868
  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_int ("grid-line-width",
							     P_("Grid line width"),
							     P_("Width, in pixels, of the tree view grid lines"),
							     0, G_MAXINT, 1,
							     GTK_PARAM_READABLE));

  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_int ("tree-line-width",
							     P_("Tree line width"),
							     P_("Width, in pixels, of the tree view lines"),
							     0, G_MAXINT, 1,
							     GTK_PARAM_READABLE));

  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_string ("grid-line-pattern",
								P_("Grid line pattern"),
								P_("Dash pattern used to draw the tree view grid lines"),
								"\1\1",
								GTK_PARAM_READABLE));

  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_string ("tree-line-pattern",
								P_("Tree line pattern"),
								P_("Dash pattern used to draw the tree view lines"),
								"\1\1",
								GTK_PARAM_READABLE));

869
  /* Signals */
870 871 872 873 874 875 876 877 878
  /**
   * GtkTreeView::set-scroll-adjustments
   * @horizontal: the horizontal #GtkAdjustment
   * @vertical: the vertical #GtkAdjustment
   *
   * Set the scroll adjustments for the tree view. Usually scrolled containers
   * like #GtkScrolledWindow will emit this signal to connect two instances
   * of #GtkScrollbar to the scroll directions of the #GtkTreeView.
   */
879
  widget_class->set_scroll_adjustments_signal =
880
    g_signal_new (I_("set-scroll-adjustments"),
Manish Singh's avatar
Manish Singh committed
881 882 883 884 885 886 887 888
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, set_scroll_adjustments),
		  NULL, NULL,
		  _gtk_marshal_VOID__OBJECT_OBJECT,
		  G_TYPE_NONE, 2,
		  GTK_TYPE_ADJUSTMENT,
		  GTK_TYPE_ADJUSTMENT);
889

890 891 892 893 894 895 896 897 898 899 900 901 902 903 904
  /**
   * GtkTreeView::row-activated:
   * @tree_view: the object on which the signal is emitted
   * @path: the #GtkTreePath for the activated row
   * @column: the #GtkTreeViewColumn in which the activation occurred
   *
   * The "row-activated" signal is emitted when the method
   * gtk_tree_view_row_activated() is called or the user double clicks 
   * a treeview row. It is also emitted when a non-editable row is 
   * selected and one of the keys: Space, Shift+Space, Return or 
   * Enter is pressed.
   * 
   * For selection handling refer to the <link linkend="TreeWidget">tree 
   * widget conceptual overview</link> as well as #GtkTreeSelection.
   */
905
  tree_view_signals[ROW_ACTIVATED] =
906
    g_signal_new (I_("row-activated"),
Manish Singh's avatar
Manish Singh committed
907 908 909 910 911 912 913 914
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, row_activated),
		  NULL, NULL,
		  _gtk_marshal_VOID__BOXED_OBJECT,
		  G_TYPE_NONE, 2,
		  GTK_TYPE_TREE_PATH,
		  GTK_TYPE_TREE_VIEW_COLUMN);
915

916 917 918 919 920 921 922 923 924
  /**
   * GtkTreeView::test-expand-row:
   * @tree_view: the object on which the signal is emitted
   * @iter: the tree iter of the row to expand
   * @path: a tree path that points to the row 
   * 
   * The given row is about to be expanded (show its children nodes). Use this
   * signal if you need to control the expandability of individual rows.
   *
925
   * Returns: %FALSE to allow expansion, %TRUE to reject
926
   */
927
  tree_view_signals[TEST_EXPAND_ROW] =
928
    g_signal_new (I_("test-expand-row"),
Manish Singh's avatar
Manish Singh committed
929 930 931 932 933 934 935 936
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkTreeViewClass, test_expand_row),
		  _gtk_boolean_handled_accumulator, NULL,
		  _gtk_marshal_BOOLEAN__BOXED_BOXED,
		  G_TYPE_BOOLEAN, 2,
		  GTK_TYPE_TREE_ITER,
		  GTK_TYPE_TREE_PATH);
937

938 939 940 941 942 943 944 945 946
  /**
   * GtkTreeView::test-collapse-row:
   * @tree_view: the object on which the signal is emitted
   * @iter: the tree iter of the row to collapse
   * @path: a tree path that points to the row 
   * 
   * The given row is about to be collapsed (hide its children nodes). Use this
   * signal if you need to control the collapsibility of individual rows.
   *
947
   * Returns: %FALSE to allow collapsing, %TRUE to reject
948
   */
949
  tree_view_signals[TEST_COLLAPSE_ROW] =
950
    g_signal_new (I_("test-collapse-row"),
Manish Singh's avatar
Manish Singh committed
951 952 953 954 955 956 957 958
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkTreeViewClass, test_collapse_row),
		  _gtk_boolean_handled_accumulator, NULL,
		  _gtk_marshal_BOOLEAN__BOXED_BOXED,
		  G_TYPE_BOOLEAN, 2,
		  GTK_TYPE_TREE_ITER,
		  GTK_TYPE_TREE_PATH);
959

960 961 962 963 964 965 966 967
  /**
   * GtkTreeView::row-expanded:
   * @tree_view: the object on which the signal is emitted
   * @iter: the tree iter of the expanded row
   * @path: a tree path that points to the row 
   * 
   * The given row has been expanded (child nodes are shown).
   */
968
  tree_view_signals[ROW_EXPANDED] =
969
    g_signal_new (I_("row-expanded"),
Manish Singh's avatar
Manish Singh committed
970 971 972 973 974 975 976 977
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkTreeViewClass, row_expanded),
		  NULL, NULL,
		  _gtk_marshal_VOID__BOXED_BOXED,
		  G_TYPE_NONE, 2,
		  GTK_TYPE_TREE_ITER,
		  GTK_TYPE_TREE_PATH);
978

979 980 981 982 983 984 985 986
  /**
   * GtkTreeView::row-collapsed:
   * @tree_view: the object on which the signal is emitted
   * @iter: the tree iter of the collapsed row
   * @path: a tree path that points to the row 
   * 
   * The given row has been collapsed (child nodes are hidden).
   */
987
  tree_view_signals[ROW_COLLAPSED] =
988
    g_signal_new (I_("row-collapsed"),
Manish Singh's avatar
Manish Singh committed
989 990 991 992 993 994 995 996
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkTreeViewClass, row_collapsed),
		  NULL, NULL,
		  _gtk_marshal_VOID__BOXED_BOXED,
		  G_TYPE_NONE, 2,
		  GTK_TYPE_TREE_ITER,
		  GTK_TYPE_TREE_PATH);
997

998 999 1000 1001 1002 1003
  /**
   * GtkTreeView::columns-changed:
   * @tree_view: the object on which the signal is emitted 
   * 
   * The number of columns of the treeview has changed.
   */
1004
  tree_view_signals[COLUMNS_CHANGED] =
1005
    g_signal_new (I_("columns-changed"),
Manish Singh's avatar
Manish Singh committed
1006 1007 1008 1009
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkTreeViewClass, columns_changed),
		  NULL, NULL,
1010
		  _gtk_marshal_VOID__VOID,
Manish Singh's avatar
Manish Singh committed
1011
		  G_TYPE_NONE, 0);
1012

1013 1014 1015 1016 1017 1018
  /**
   * GtkTreeView::cursor-changed:
   * @tree_view: the object on which the signal is emitted
   * 
   * The position of the cursor (focused cell) has changed.
   */
1019
  tree_view_signals[CURSOR_CHANGED] =
1020
    g_signal_new (I_("cursor-changed"),
Manish Singh's avatar
Manish Singh committed
1021 1022 1023 1024
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkTreeViewClass, cursor_changed),
		  NULL, NULL,
1025
		  _gtk_marshal_VOID__VOID,
Manish Singh's avatar
Manish Singh committed
1026
		  G_TYPE_NONE, 0);
1027

1028
  tree_view_signals[MOVE_CURSOR] =
1029
    g_signal_new (I_("move-cursor"),
Manish Singh's avatar
Manish Singh committed
1030 1031 1032 1033 1034 1035 1036 1037
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, move_cursor),
		  NULL, NULL,
		  _gtk_marshal_BOOLEAN__ENUM_INT,
		  G_TYPE_BOOLEAN, 2,
		  GTK_TYPE_MOVEMENT_STEP,
		  G_TYPE_INT);
1038

1039
  tree_view_signals[SELECT_ALL] =
1040
    g_signal_new (I_("select-all"),
Manish Singh's avatar
Manish Singh committed
1041 1042 1043 1044
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_all),
		  NULL, NULL,
1045
		  _gtk_marshal_BOOLEAN__VOID,
1046
		  G_TYPE_BOOLEAN, 0);
1047

1048
  tree_view_signals[UNSELECT_ALL] =
1049
    g_signal_new (I_("unselect-all"),
1050
		  G_TYPE_FROM_CLASS (object_class),
Manish Singh's avatar
Manish Singh committed
1051
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
1052 1053
		  G_STRUCT_OFFSET (GtkTreeViewClass, unselect_all),
		  NULL, NULL,
1054
		  _gtk_marshal_BOOLEAN__VOID,
1055
		  G_TYPE_BOOLEAN, 0);
1056

1057
  tree_view_signals[SELECT_CURSOR_ROW] =
1058
    g_signal_new (I_("select-cursor-row"),
Manish Singh's avatar
Manish Singh committed
1059 1060 1061 1062
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_row),
		  NULL, NULL,
1063 1064
		  _gtk_marshal_BOOLEAN__BOOLEAN,
		  G_TYPE_BOOLEAN, 1,
1065
		  G_TYPE_BOOLEAN);
1066

1067
  tree_view_signals[TOGGLE_CURSOR_ROW] =
1068
    g_signal_new (I_("toggle-cursor-row"),
Manish Singh's avatar
Manish Singh committed
1069 1070 1071 1072
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, toggle_cursor_row),
		  NULL, NULL,
1073
		  _gtk_marshal_BOOLEAN__VOID,
1074
		  G_TYPE_BOOLEAN, 0);
1075

1076
  tree_view_signals[EXPAND_COLLAPSE_CURSOR_ROW] =
1077
    g_signal_new (I_("expand-collapse-cursor-row"),
Manish Singh's avatar
Manish Singh committed
1078 1079 1080 1081
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, expand_collapse_cursor_row),
		  NULL, NULL,
1082 1083
		  _gtk_marshal_BOOLEAN__BOOLEAN_BOOLEAN_BOOLEAN,
		  G_TYPE_BOOLEAN, 3,
Manish Singh's avatar
Manish Singh committed
1084 1085 1086
		  G_TYPE_BOOLEAN,
		  G_TYPE_BOOLEAN,
		  G_TYPE_BOOLEAN);
1087

1088
  tree_view_signals[SELECT_CURSOR_PARENT] =
1089
    g_signal_new (I_("select-cursor-parent"),
Manish Singh's avatar
Manish Singh committed
1090 1091 1092 1093
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_parent),
		  NULL, NULL,
1094
		  _gtk_marshal_BOOLEAN__VOID,
1095
		  G_TYPE_BOOLEAN, 0);
1096

1097
  tree_view_signals[START_INTERACTIVE_SEARCH] =
1098
    g_signal_new (I_("start-interactive-search"),
Manish Singh's avatar
Manish Singh committed
1099 1100 1101 1102
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, start_interactive_search),
		  NULL, NULL,
1103
		  _gtk_marshal_BOOLEAN__VOID,
1104
		  G_TYPE_BOOLEAN, 0);
1105

1106
  /* Key bindings */
1107
  gtk_tree_view_add_move_binding (binding_set, GDK_Up, 0, TRUE,
1108
				  GTK_MOVEMENT_DISPLAY_LINES, -1);
1109
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Up, 0, TRUE,
1110
				  GTK_MOVEMENT_DISPLAY_LINES, -1);
1111

1112
  gtk_tree_view_add_move_binding (binding_set, GDK_Down, 0, TRUE,
1113
				  GTK_MOVEMENT_DISPLAY_LINES, 1);
1114
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Down, 0, TRUE,
1115
				  GTK_MOVEMENT_DISPLAY_LINES, 1);
1116