gtktreeview.c 401 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"
32 33 34
#include "gtkbutton.h"
#include "gtkalignment.h"
#include "gtklabel.h"
Havoc Pennington's avatar
Havoc Pennington committed
35
#include "gtkhbox.h"
Jonathan Blandford's avatar
Jonathan Blandford committed
36
#include "gtkvbox.h"
Havoc Pennington's avatar
Havoc Pennington committed
37
#include "gtkarrow.h"
38
#include "gtkintl.h"
39
#include "gtkbindings.h"
40 41
#include "gtkcontainer.h"
#include "gtkentry.h"
42
#include "gtkframe.h"
Jonathan Blandford's avatar
Jonathan Blandford committed
43
#include "gtktreemodelsort.h"
44
#include "gtkprivate.h"
45
#include "gtkalias.h"
46

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

55 56 57 58 59 60 61
/* 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
62
#define CELL_HEIGHT(node, separator) ((BACKGROUND_HEIGHT (node)) - (separator))
63

64 65
#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)
66 67 68 69

/* This is in Window coordinates */
#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)
70

71 72
#define ROW_HEIGHT(tree_view,height) \
  ((height > 0) ? (height) : (tree_view)->priv->expander_size)
73

74

75
typedef struct _GtkTreeViewChild GtkTreeViewChild;
76 77 78 79 80
struct _GtkTreeViewChild
{
  GtkWidget *widget;
  gint x;
  gint y;
81 82
  gint width;
  gint height;
83 84
};

Jonathan Blandford's avatar
Jonathan Blandford committed
85

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
typedef struct _TreeViewDragInfo TreeViewDragInfo;
struct _TreeViewDragInfo
{
  GdkModifierType start_button_mask;
  GtkTargetList *source_target_list;
  GdkDragAction source_actions;

  GtkTargetList *dest_target_list;

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


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

121
/* Properties */
122 123 124 125 126 127 128 129
enum {
  PROP_0,
  PROP_MODEL,
  PROP_HADJUSTMENT,
  PROP_VADJUSTMENT,
  PROP_HEADERS_VISIBLE,
  PROP_HEADERS_CLICKABLE,
  PROP_EXPANDER_COLUMN,
130
  PROP_REORDERABLE,
131 132
  PROP_RULES_HINT,
  PROP_ENABLE_SEARCH,
133
  PROP_SEARCH_COLUMN,
134
  PROP_FIXED_HEIGHT_MODE,
135
  PROP_HOVER_SELECTION,
Kristian Rietveld's avatar
Kristian Rietveld committed
136 137 138
  PROP_HOVER_EXPAND,
  PROP_SHOW_EXPANDERS,
  PROP_LEVEL_INDENTATION
139
};
140

141 142
/* object signals */
static void     gtk_tree_view_finalize             (GObject          *object);
143 144 145
static void     gtk_tree_view_set_property         (GObject         *object,
						    guint            prop_id,
						    const GValue    *value,
Jonathan Blandford's avatar
Jonathan Blandford committed
146
						    GParamSpec      *pspec);
147 148 149
static void     gtk_tree_view_get_property         (GObject         *object,
						    guint            prop_id,
						    GValue          *value,
Jonathan Blandford's avatar
Jonathan Blandford committed
150
						    GParamSpec      *pspec);
151

152
/* gtkobject signals */
Jonathan Blandford's avatar
Jonathan Blandford committed
153 154
static void     gtk_tree_view_destroy              (GtkObject        *object);

155
/* gtkwidget signals */
156 157 158 159 160 161 162 163 164
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);
165 166
static gboolean gtk_tree_view_key_press            (GtkWidget        *widget,
						    GdkEventKey      *event);
Jonathan Blandford's avatar
Jonathan Blandford committed
167 168
static gboolean gtk_tree_view_key_release          (GtkWidget        *widget,
						    GdkEventKey      *event);
169 170 171 172 173 174 175 176 177 178
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);
179 180
static gboolean gtk_tree_view_grab_broken          (GtkWidget          *widget,
						    GdkEventGrabBroken *event);
181 182 183 184 185
#if 0
static gboolean gtk_tree_view_configure            (GtkWidget         *widget,
						    GdkEventConfigure *event);
#endif

186 187
static void     gtk_tree_view_set_focus_child      (GtkContainer     *container,
						    GtkWidget        *child);
188 189
static gint     gtk_tree_view_focus_out            (GtkWidget        *widget,
						    GdkEventFocus    *event);
190
static gint     gtk_tree_view_focus                (GtkWidget        *widget,
191
						    GtkDirectionType  direction);
192
static void     gtk_tree_view_grab_focus           (GtkWidget        *widget);
Kristian Rietveld's avatar
Kristian Rietveld committed
193 194
static void     gtk_tree_view_style_set            (GtkWidget        *widget,
						    GtkStyle         *previous_style);
195 196
static void     gtk_tree_view_grab_notify          (GtkWidget        *widget,
						    gboolean          was_grabbed);
197 198
static void     gtk_tree_view_state_changed        (GtkWidget        *widget,
						    GtkStateType      previous_state);
199 200 201 202 203 204 205 206 207

/* 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
208 209 210 211 212 213 214 215 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
/* 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);

243
/* tree_model signals */
244 245 246
static void gtk_tree_view_set_adjustments                 (GtkTreeView     *tree_view,
							   GtkAdjustment   *hadj,
							   GtkAdjustment   *vadj);
247
static gboolean gtk_tree_view_real_move_cursor            (GtkTreeView     *tree_view,
248
							   GtkMovementStep  step,
249
							   gint             count);
250 251 252
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,
253
							   gboolean         start_editing);
254 255 256 257 258 259
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);
260
static void gtk_tree_view_row_changed                     (GtkTreeModel    *model,
261 262 263
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
264
static void gtk_tree_view_row_inserted                    (GtkTreeModel    *model,
265 266 267
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
268
static void gtk_tree_view_row_has_child_toggled           (GtkTreeModel    *model,
269 270 271
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
272
static void gtk_tree_view_row_deleted                     (GtkTreeModel    *model,
273 274
							   GtkTreePath     *path,
							   gpointer         data);
275
static void gtk_tree_view_rows_reordered                  (GtkTreeModel    *model,
276 277 278 279 280
							   GtkTreePath     *parent,
							   GtkTreeIter     *iter,
							   gint            *new_order,
							   gpointer         data);

Jonathan Blandford's avatar
Jonathan Blandford committed
281 282 283 284 285 286 287 288
/* 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);
289 290
static gboolean do_validate_rows         (GtkTreeView *tree_view,
					  gboolean     size_request);
291
static gboolean validate_rows            (GtkTreeView *tree_view);
Jonathan Blandford's avatar
Jonathan Blandford committed
292 293
static gboolean presize_handler_callback (gpointer     data);
static void     install_presize_handler  (GtkTreeView *tree_view);
294
static void     install_scroll_sync_handler (GtkTreeView *tree_view);
295
static void	gtk_tree_view_dy_to_top_row (GtkTreeView *tree_view);
296
static void     gtk_tree_view_top_row_to_dy (GtkTreeView *tree_view);
297
static void     invalidate_empty_focus      (GtkTreeView *tree_view);
298

299
/* Internal functions */
300 301 302 303 304
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,
305
							      gboolean           add_shifted_binding,
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
							      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,
							      GdkRectangle      *clip_rect);
static void     gtk_tree_view_queue_draw_arrow               (GtkTreeView       *tree_view,
							      GtkRBTree         *tree,
							      GtkRBNode         *node,
							      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,
323
							      GtkRBTree         *tree,
324 325 326 327 328 329 330 331 332 333 334
							      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,
Jonathan Blandford's avatar
Jonathan Blandford committed
335
							      gboolean           recurse);
336 337 338
static gboolean gtk_tree_view_discover_dirty_iter            (GtkTreeView       *tree_view,
							      GtkTreeIter       *iter,
							      gint               depth,
339 340
							      gint              *height,
							      GtkRBNode         *node);
341 342 343 344 345 346 347
static void     gtk_tree_view_discover_dirty                 (GtkTreeView       *tree_view,
							      GtkRBTree         *tree,
							      GtkTreeIter       *iter,
							      gint               depth);
static void     gtk_tree_view_clamp_node_visible             (GtkTreeView       *tree_view,
							      GtkRBTree         *tree,
							      GtkRBNode         *node);
348 349
static void     gtk_tree_view_clamp_column_visible           (GtkTreeView       *tree_view,
							      GtkTreeViewColumn *column);
350 351 352 353 354 355 356 357 358 359 360 361 362 363
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,
364 365
							      GtkRBNode         *node,
							      gboolean           animate);
366 367 368 369
static gboolean gtk_tree_view_real_expand_row                (GtkTreeView       *tree_view,
							      GtkTreePath       *path,
							      GtkRBTree         *tree,
							      GtkRBNode         *node,
370 371
							      gboolean           open_all,
							      gboolean           animate);
372 373
static void     gtk_tree_view_real_set_cursor                (GtkTreeView       *tree_view,
							      GtkTreePath       *path,
374 375
							      gboolean           clear_and_select,
							      gboolean           clamp_node);
376
static gboolean gtk_tree_view_has_special_cell               (GtkTreeView       *tree_view);
377 378 379
static void     column_sizing_notify                         (GObject           *object,
                                                              GParamSpec        *pspec,
                                                              gpointer           data);
Kristian Rietveld's avatar
Kristian Rietveld committed
380
static gboolean expand_collapse_timeout                      (gpointer           data);
Kristian Rietveld's avatar
Kristian Rietveld committed
381
static gboolean do_expand_collapse                           (GtkTreeView       *tree_view);
Kristian Rietveld's avatar
Kristian Rietveld committed
382

383
/* interactive search */
Jonathan Blandford's avatar
Jonathan Blandford committed
384
static void     gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view);
385
static void     gtk_tree_view_search_dialog_hide     (GtkWidget        *search_dialog,
386 387
							 GtkTreeView      *tree_view);
static void     gtk_tree_view_search_position_func      (GtkTreeView      *tree_view,
388 389
							 GtkWidget        *search_dialog,
							 gpointer          user_data);
390 391 392
static void     gtk_tree_view_search_disable_popdown    (GtkEntry         *entry,
							 GtkMenu          *menu,
							 gpointer          data);
Jonathan Blandford's avatar
Jonathan Blandford committed
393 394
static void     gtk_tree_view_search_preedit_changed    (GtkIMContext     *im_context,
							 GtkTreeView      *tree_view);
395 396
static void     gtk_tree_view_search_activate           (GtkEntry         *entry,
							 GtkTreeView      *tree_view);
397 398 399
static gboolean gtk_tree_view_real_search_enable_popdown(gpointer          data);
static void     gtk_tree_view_search_enable_popdown     (GtkWidget        *widget,
							 gpointer          data);
400 401 402 403 404 405
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);
406 407 408
static gboolean gtk_tree_view_search_scroll_event       (GtkWidget        *entry,
							 GdkEventScroll   *event,
							 GtkTreeView      *tree_view);
409 410 411 412 413 414 415 416
static gboolean gtk_tree_view_search_key_press_event    (GtkWidget        *entry,
							 GdkEventKey      *event,
							 GtkTreeView      *tree_view);
static void     gtk_tree_view_search_move               (GtkWidget        *window,
							 GtkTreeView      *tree_view,
							 gboolean          up);
static gboolean gtk_tree_view_search_equal_func         (GtkTreeModel     *model,
							 gint              column,
417
							 const gchar      *key,
418 419
							 GtkTreeIter      *iter,
							 gpointer          search_data);
420 421 422
static gboolean gtk_tree_view_search_iter               (GtkTreeModel     *model,
							 GtkTreeSelection *selection,
							 GtkTreeIter      *iter,
423
							 const gchar      *text,
424 425 426 427
							 gint             *count,
							 gint              n);
static void     gtk_tree_view_search_init               (GtkWidget        *entry,
							 GtkTreeView      *tree_view);
428 429 430 431 432 433
static void     gtk_tree_view_put                       (GtkTreeView      *tree_view,
							 GtkWidget        *child_widget,
							 gint              x,
							 gint              y,
							 gint              width,
							 gint              height);
434 435 436 437 438 439 440 441 442
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
443 444
static void gtk_tree_view_stop_editing                  (GtkTreeView *tree_view,
							 gboolean     cancel_editing);
Jonathan Blandford's avatar
Jonathan Blandford committed
445 446 447
static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view,
							     gboolean     keybinding);
static gboolean gtk_tree_view_start_interactive_search      (GtkTreeView *tree_view);
448 449 450
static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView       *tree_view,
							 GtkTreeViewColumn *column,
							 gint               drop_position);
451

452 453 454 455 456
static void gtk_tree_view_tree_window_to_tree_coords (GtkTreeView *tree_view,
						      gint         wx,
						      gint         wy,
						      gint        *tx,
						      gint        *ty);
457

458

459
static guint tree_view_signals [LAST_SIGNAL] = { 0 };
460

461 462 463 464 465


/* GType Methods
 */

Matthias Clasen's avatar
Matthias Clasen committed
466
G_DEFINE_TYPE (GtkTreeView, gtk_tree_view, GTK_TYPE_CONTAINER)
467 468 469 470

static void
gtk_tree_view_class_init (GtkTreeViewClass *class)
{
471
  GObjectClass *o_class;
472 473 474
  GtkObjectClass *object_class;
  GtkWidgetClass *widget_class;
  GtkContainerClass *container_class;
475
  GtkBindingSet *binding_set;
476

477
  binding_set = gtk_binding_set_by_class (class);
478

479 480 481 482 483
  o_class = (GObjectClass *) class;
  object_class = (GtkObjectClass *) class;
  widget_class = (GtkWidgetClass *) class;
  container_class = (GtkContainerClass *) class;

484
  /* GObject signals */
485 486
  o_class->set_property = gtk_tree_view_set_property;
  o_class->get_property = gtk_tree_view_get_property;
487
  o_class->finalize = gtk_tree_view_finalize;
488

489
  /* GtkObject signals */
Jonathan Blandford's avatar
Jonathan Blandford committed
490
  object_class->destroy = gtk_tree_view_destroy;
491

492 493
  /* GtkWidget signals */
  widget_class->map = gtk_tree_view_map;
494 495 496 497
  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;
498 499
  widget_class->button_press_event = gtk_tree_view_button_press;
  widget_class->button_release_event = gtk_tree_view_button_release;
500
  widget_class->grab_broken_event = gtk_tree_view_grab_broken;
501
  /*widget_class->configure_event = gtk_tree_view_configure;*/
502
  widget_class->motion_notify_event = gtk_tree_view_motion;
503
  widget_class->expose_event = gtk_tree_view_expose;
504
  widget_class->key_press_event = gtk_tree_view_key_press;
Jonathan Blandford's avatar
Jonathan Blandford committed
505
  widget_class->key_release_event = gtk_tree_view_key_release;
506 507 508
  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
509 510 511 512 513 514 515 516
  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;
517
  widget_class->focus = gtk_tree_view_focus;
518
  widget_class->grab_focus = gtk_tree_view_grab_focus;
Kristian Rietveld's avatar
Kristian Rietveld committed
519
  widget_class->style_set = gtk_tree_view_style_set;
520
  widget_class->grab_notify = gtk_tree_view_grab_notify;
521
  widget_class->state_changed = gtk_tree_view_state_changed;
522

523
  /* GtkContainer signals */
524
  container_class->remove = gtk_tree_view_remove;
525 526
  container_class->forall = gtk_tree_view_forall;
  container_class->set_focus_child = gtk_tree_view_set_focus_child;
527 528

  class->set_scroll_adjustments = gtk_tree_view_set_adjustments;
529
  class->move_cursor = gtk_tree_view_real_move_cursor;
530
  class->select_all = gtk_tree_view_real_select_all;
531
  class->unselect_all = gtk_tree_view_real_unselect_all;
532
  class->select_cursor_row = gtk_tree_view_real_select_cursor_row;
533 534 535
  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
536
  class->start_interactive_search = gtk_tree_view_start_interactive_search;
537

538
  /* Properties */
539

540 541
  g_object_class_install_property (o_class,
                                   PROP_MODEL,
Tim Janik's avatar
Tim Janik committed
542
                                   g_param_spec_object ("model",
543 544
							P_("TreeView Model"),
							P_("The model for the tree view"),
Tim Janik's avatar
Tim Janik committed
545
							GTK_TYPE_TREE_MODEL,
546
							GTK_PARAM_READWRITE));
Jonathan Blandford's avatar
Jonathan Blandford committed
547

548 549 550
  g_object_class_install_property (o_class,
                                   PROP_HADJUSTMENT,
                                   g_param_spec_object ("hadjustment",
551 552
							P_("Horizontal Adjustment"),
                                                        P_("Horizontal Adjustment for the widget"),
553
                                                        GTK_TYPE_ADJUSTMENT,
554
                                                        GTK_PARAM_READWRITE));
555 556 557 558

  g_object_class_install_property (o_class,
                                   PROP_VADJUSTMENT,
                                   g_param_spec_object ("vadjustment",
559 560
							P_("Vertical Adjustment"),
                                                        P_("Vertical Adjustment for the widget"),
561
                                                        GTK_TYPE_ADJUSTMENT,
562
                                                        GTK_PARAM_READWRITE));
563 564 565

  g_object_class_install_property (o_class,
                                   PROP_HEADERS_VISIBLE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
566
                                   g_param_spec_boolean ("headers-visible",
567
							 P_("Headers Visible"),
568
							 P_("Show the column header buttons"),
569
							 TRUE,
570
							 GTK_PARAM_READWRITE));
571 572 573

  g_object_class_install_property (o_class,
                                   PROP_HEADERS_CLICKABLE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
574
                                   g_param_spec_boolean ("headers-clickable",
575 576
							 P_("Headers Clickable"),
							 P_("Column headers respond to click events"),
577
							 FALSE,
578
							 GTK_PARAM_READWRITE));
579 580 581

  g_object_class_install_property (o_class,
                                   PROP_EXPANDER_COLUMN,
Matthias Clasen's avatar
x  
Matthias Clasen committed
582
                                   g_param_spec_object ("expander-column",
583 584
							P_("Expander Column"),
							P_("Set the column for the expander column"),
585
							GTK_TYPE_TREE_VIEW_COLUMN,
586
							GTK_PARAM_READWRITE));
587

588 589 590
  g_object_class_install_property (o_class,
                                   PROP_REORDERABLE,
                                   g_param_spec_boolean ("reorderable",
591 592
							 P_("Reorderable"),
							 P_("View is reorderable"),
593
							 FALSE,
594
							 GTK_PARAM_READWRITE));
595

596 597
  g_object_class_install_property (o_class,
                                   PROP_RULES_HINT,
Matthias Clasen's avatar
x  
Matthias Clasen committed
598
                                   g_param_spec_boolean ("rules-hint",
599 600
							 P_("Rules Hint"),
							 P_("Set a hint to the theme engine to draw rows in alternating colors"),
601
							 FALSE,
602
							 GTK_PARAM_READWRITE));
603

604 605
    g_object_class_install_property (o_class,
				     PROP_ENABLE_SEARCH,
Matthias Clasen's avatar
x  
Matthias Clasen committed
606
				     g_param_spec_boolean ("enable-search",
607 608
							   P_("Enable Search"),
							   P_("View allows user to search through columns interactively"),
609
							   TRUE,
610
							   GTK_PARAM_READWRITE));
611

612 613
    g_object_class_install_property (o_class,
				     PROP_SEARCH_COLUMN,
Matthias Clasen's avatar
x  
Matthias Clasen committed
614
				     g_param_spec_int ("search-column",
615 616
						       P_("Search Column"),
						       P_("Model column to search through when searching through code"),
617 618
						       -1,
						       G_MAXINT,
619
						       -1,
620
						       GTK_PARAM_READWRITE));
621

622 623 624 625 626 627 628 629 630 631 632
    /**
     * 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
     **/
633 634
    g_object_class_install_property (o_class,
                                     PROP_FIXED_HEIGHT_MODE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
635
                                     g_param_spec_boolean ("fixed-height-mode",
636 637
                                                           P_("Fixed Height Mode"),
                                                           P_("Speeds up GtkTreeView by assuming that all rows have the same height"),
638
                                                           FALSE,
639
                                                           GTK_PARAM_READWRITE));
640 641 642 643 644 645
    
    /**
     * 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
646 647 648
     * Currently, this works only for the selection modes 
     * %GTK_SELECTION_SINGLE and %GTK_SELECTION_BROWSE.
     *
649 650 651 652 653 654 655
     * This mode is primarily indended for treeviews in popups, e.g.
     * 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
656
                                     g_param_spec_boolean ("hover-selection",
657 658 659
                                                           P_("Hover Selection"),
                                                           P_("Whether the selection should follow the pointer"),
                                                           FALSE,
660
                                                           GTK_PARAM_READWRITE));
661

662 663 664 665 666 667 668 669 670 671 672 673 674 675
    /**
     * GtkTreeView:hover-expand:
     * 
     * Enables of disables the hover expansion mode of @tree_view.
     * Hover expansion makes rows expand or collaps if the pointer moves 
     * over them.
     *
     * This mode is primarily indended for treeviews in popups, e.g.
     * 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
676
                                     g_param_spec_boolean ("hover-expand",
677
                                                           P_("Hover Expand"),
678
                                                           P_("Whether rows should be expanded/collapsed when the pointer moves over them"),
679
                                                           FALSE,
680
                                                           GTK_PARAM_READWRITE));
681

Kristian Rietveld's avatar
Kristian Rietveld committed
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
    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));

    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));

700
  /* Style properties */
701
#define _TREE_VIEW_EXPANDER_SIZE 12
702
#define _TREE_VIEW_VERTICAL_SEPARATOR 2
703
#define _TREE_VIEW_HORIZONTAL_SEPARATOR 2
704
    
705
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
706
					   g_param_spec_int ("expander-size",
707 708
							     P_("Expander Size"),
							     P_("Size of the expander arrow"),
709 710
							     0,
							     G_MAXINT,
711
							     _TREE_VIEW_EXPANDER_SIZE,
712
							     GTK_PARAM_READABLE));
713

714
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
715
					   g_param_spec_int ("vertical-separator",
716 717
							     P_("Vertical Separator Width"),
							     P_("Vertical space between cells.  Must be an even number"),
718 719 720
							     0,
							     G_MAXINT,
							     _TREE_VIEW_VERTICAL_SEPARATOR,
721
							     GTK_PARAM_READABLE));
722

723
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
724
					   g_param_spec_int ("horizontal-separator",
725 726
							     P_("Horizontal Separator Width"),
							     P_("Horizontal space between cells.  Must be an even number"),
727 728 729
							     0,
							     G_MAXINT,
							     _TREE_VIEW_HORIZONTAL_SEPARATOR,
730
							     GTK_PARAM_READABLE));
731

732
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
733
					   g_param_spec_boolean ("allow-rules",
734 735
								 P_("Allow Rules"),
								 P_("Allow drawing of alternating color rows"),
736
								 TRUE,
737
								 GTK_PARAM_READABLE));
738

739
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
740
					   g_param_spec_boolean ("indent-expanders",
741 742
								 P_("Indent Expanders"),
								 P_("Make the expanders indented"),
743
								 TRUE,
744
								 GTK_PARAM_READABLE));
Manish Singh's avatar
Manish Singh committed
745

746
  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
747
                                           g_param_spec_boxed ("even-row-color",
748 749
                                                               P_("Even Row Color"),
                                                               P_("Color to use for even rows"),
750
							       GDK_TYPE_COLOR,
751
							       GTK_PARAM_READABLE));
752 753

  gtk_widget_class_install_style_property (widget_class,
Matthias Clasen's avatar
x  
Matthias Clasen committed
754
                                           g_param_spec_boxed ("odd-row-color",
755 756
                                                               P_("Odd Row Color"),
                                                               P_("Color to use for odd rows"),
757
							       GDK_TYPE_COLOR,
758
							       GTK_PARAM_READABLE));
759

760 761 762 763 764 765 766
  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));

767
  /* Signals */
768
  widget_class->set_scroll_adjustments_signal =
Matthias Clasen's avatar
Matthias Clasen committed
769
    g_signal_new (I_("set_scroll_adjustments"),
Manish Singh's avatar
Manish Singh committed
770 771 772 773 774 775 776 777
		  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);
778

779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
  /**
   * 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.
   */
794
  tree_view_signals[ROW_ACTIVATED] =
Matthias Clasen's avatar
Matthias Clasen committed
795
    g_signal_new (I_("row_activated"),
Manish Singh's avatar
Manish Singh committed
796 797 798 799 800 801 802 803
		  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);
804

805 806 807 808 809 810 811 812 813 814 815
  /**
   * 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.
   *
   * Returns: %TRUE to allow expansion, %FALSE to reject
   */
816
  tree_view_signals[TEST_EXPAND_ROW] =
817
    g_signal_new (I_("test-expand-row"),
Manish Singh's avatar
Manish Singh committed
818 819 820 821 822 823 824 825
		  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);
826

827 828 829 830 831 832 833 834 835 836 837
  /**
   * 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.
   *
   * Returns: %TRUE to allow expansion, %FALSE to reject
   */
838
  tree_view_signals[TEST_COLLAPSE_ROW] =
839
    g_signal_new (I_("test-collapse-row"),
Manish Singh's avatar
Manish Singh committed
840 841 842 843 844 845 846 847
		  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);
848

849 850 851 852 853 854 855 856
  /**
   * 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).
   */
857
  tree_view_signals[ROW_EXPANDED] =
858
    g_signal_new (I_("row-expanded"),
Manish Singh's avatar
Manish Singh committed
859 860 861 862 863 864 865 866
		  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);
867

868 869 870 871 872 873 874 875
  /**
   * 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).
   */
876
  tree_view_signals[ROW_COLLAPSED] =
877
    g_signal_new (I_("row-collapsed"),
Manish Singh's avatar
Manish Singh committed
878 879 880 881 882 883 884 885
		  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);
886

887 888 889 890 891 892
  /**
   * GtkTreeView::columns-changed:
   * @tree_view: the object on which the signal is emitted 
   * 
   * The number of columns of the treeview has changed.
   */
893
  tree_view_signals[COLUMNS_CHANGED] =
894
    g_signal_new (I_("columns-changed"),
Manish Singh's avatar
Manish Singh committed
895 896 897 898 899 900
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkTreeViewClass, columns_changed),
		  NULL, NULL,
		  _gtk_marshal_NONE__NONE,
		  G_TYPE_NONE, 0);
901

902 903 904 905 906 907
  /**
   * GtkTreeView::cursor-changed:
   * @tree_view: the object on which the signal is emitted
   * 
   * The position of the cursor (focused cell) has changed.
   */
908
  tree_view_signals[CURSOR_CHANGED] =
909
    g_signal_new (I_("cursor-changed"),
Manish Singh's avatar
Manish Singh committed
910 911 912 913 914 915
		  G_TYPE_FROM_CLASS (o_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkTreeViewClass, cursor_changed),
		  NULL, NULL,
		  _gtk_marshal_NONE__NONE,
		  G_TYPE_NONE, 0);
916

917
  tree_view_signals[MOVE_CURSOR] =
Matthias Clasen's avatar
Matthias Clasen committed
918
    g_signal_new (I_("move_cursor"),
Manish Singh's avatar
Manish Singh committed
919 920 921 922 923 924 925 926
		  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);
927

928
  tree_view_signals[SELECT_ALL] =
Matthias Clasen's avatar
Matthias Clasen committed
929
    g_signal_new (I_("select_all"),
Manish Singh's avatar
Manish Singh committed
930 931 932 933
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_all),
		  NULL, NULL,
934 935
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
936

937
  tree_view_signals[UNSELECT_ALL] =
Matthias Clasen's avatar
Matthias Clasen committed
938
    g_signal_new (I_("unselect_all"),
939
		  G_TYPE_FROM_CLASS (object_class),
Manish Singh's avatar
Manish Singh committed
940
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
941 942
		  G_STRUCT_OFFSET (GtkTreeViewClass, unselect_all),
		  NULL, NULL,
943 944
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
945

946
  tree_view_signals[SELECT_CURSOR_ROW] =
Matthias Clasen's avatar
Matthias Clasen committed
947
    g_signal_new (I_("select_cursor_row"),
Manish Singh's avatar
Manish Singh committed
948 949 950 951
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_row),
		  NULL, NULL,
952 953
		  _gtk_marshal_BOOLEAN__BOOLEAN,
		  G_TYPE_BOOLEAN, 1,
954
		  G_TYPE_BOOLEAN);
955

956
  tree_view_signals[TOGGLE_CURSOR_ROW] =
Matthias Clasen's avatar
Matthias Clasen committed
957
    g_signal_new (I_("toggle_cursor_row"),
Manish Singh's avatar
Manish Singh committed
958 959 960 961
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, toggle_cursor_row),
		  NULL, NULL,
962 963
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
964

965
  tree_view_signals[EXPAND_COLLAPSE_CURSOR_ROW] =
Matthias Clasen's avatar
Matthias Clasen committed
966
    g_signal_new (I_("expand_collapse_cursor_row"),
Manish Singh's avatar
Manish Singh committed
967 968 969 970
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, expand_collapse_cursor_row),
		  NULL, NULL,
971 972
		  _gtk_marshal_BOOLEAN__BOOLEAN_BOOLEAN_BOOLEAN,
		  G_TYPE_BOOLEAN, 3,
Manish Singh's avatar
Manish Singh committed
973 974 975
		  G_TYPE_BOOLEAN,
		  G_TYPE_BOOLEAN,
		  G_TYPE_BOOLEAN);
976

977
  tree_view_signals[SELECT_CURSOR_PARENT] =
Matthias Clasen's avatar
Matthias Clasen committed
978
    g_signal_new (I_("select_cursor_parent"),
Manish Singh's avatar
Manish Singh committed
979 980 981 982
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_parent),
		  NULL, NULL,
983 984
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
985

986
  tree_view_signals[START_INTERACTIVE_SEARCH] =
Matthias Clasen's avatar
Matthias Clasen committed
987
    g_signal_new (I_("start_interactive_search"),
Manish Singh's avatar
Manish Singh committed
988 989 990 991
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, start_interactive_search),
		  NULL, NULL,
992 993
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
994

995
  /* Key bindings */
996
  gtk_tree_view_add_move_binding (binding_set, GDK_Up, 0, TRUE,
997
				  GTK_MOVEMENT_DISPLAY_LINES, -1);
998
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Up, 0, TRUE,
999
				  GTK_MOVEMENT_DISPLAY_LINES, -1);
1000

1001
  gtk_tree_view_add_move_binding (binding_set, GDK_Down, 0, TRUE,
1002
				  GTK_MOVEMENT_DISPLAY_LINES, 1);
1003
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Down, 0, TRUE,
1004
				  GTK_MOVEMENT_DISPLAY_LINES, 1);
1005

1006
  gtk_tree_view_add_move_binding (binding_set, GDK_p, GDK_CONTROL_MASK, FALSE,
1007 1008
				  GTK_MOVEMENT_DISPLAY_LINES, -1);

1009
  gtk_tree_view_add_move_binding (binding_set, GDK_n, GDK_CONTROL_MASK, FALSE,
1010 1011
				  GTK_MOVEMENT_DISPLAY_LINES, 1);

1012
  gtk_tree_view_add_move_binding (binding_set, GDK_Home, 0, TRUE,
1013
				  GTK_MOVEMENT_BUFFER_ENDS, -1);
1014
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Home, 0, TRUE,
1015
				  GTK_MOVEMENT_BUFFER_ENDS, -1);
1016

1017
  gtk_tree_view_add_move_binding (binding_set, GDK_End, 0, TRUE,
1018
				  GTK_MOVEMENT_BUFFER_ENDS, 1);
1019
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_End, 0, TRUE,
1020
				  GTK_MOVEMENT_BUFFER_ENDS, 1);
1021

1022
  gtk_tree_view_add_move_binding (binding_set, GDK_Page_Up, 0, TRUE,
1023
				  GTK_MOVEMENT_PAGES, -1);
1024
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Page_Up, 0, TRUE,
1025
				  GTK_MOVEMENT_PAGES, -1);
1026

1027
  gtk_tree_view_add_move_binding (binding_set, GDK_Page_Down, 0, TRUE,
1028
				  GTK_MOVEMENT_PAGES, 1);
1029
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Page_Down, 0, TRUE,
1030 1031
				  GTK_MOVEMENT_PAGES, 1);

1032

1033
  gtk_binding_entry_add_signal (binding_set, GDK_Right, 0, "move_cursor", 2,
Manish Singh's avatar
Manish Singh committed
1034 1035
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, 1);
1036

1037
  gtk_binding_entry_add_signal (binding_set, GDK_Left, 0, "move_cursor", 2,
Manish Singh's avatar
Manish Singh committed
1038 1039
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, -1);
1040

1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, 0, "move_cursor", 2,
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, 1);

  gtk_binding_entry_add_signal (binding_set, GDK_KP_Left, 0, "move_cursor", 2,
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, -1);

  gtk_binding_entry_add_signal (binding_set, GDK_Right, GDK_CONTROL_MASK,
                                "move_cursor", 2,
Manish Singh's avatar
Manish Singh committed
1051 1052
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, 1);
1053

1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065
  gtk_binding_entry_add_signal (binding_set, GDK_Left, GDK_CONTROL_MASK,
                                "move_cursor", 2,
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, -1);

  gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
                                "move_cursor", 2,
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, 1);

  gtk_binding_entry_add_signal (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
                                "move_cursor", 2,
Manish Singh's avatar
Manish Singh committed
1066 1067
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, -1);
1068

1069 1070
  gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, "toggle_cursor_row", 0);

1071
  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK, "select_all", 0);
1072 1073 1074 1075
  gtk_binding_entry_add_signal (binding_set, GDK_slash, GDK_CONTROL_MASK, "select_all", 0);

  gtk_binding_entry_add_signal (binding_set, GDK_A, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "unselect_all", 0);
  gtk_binding_entry_add_signal (binding_set, GDK_backslash, GDK_CONTROL_MASK