gtktreeview.c 351 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"
Havoc Pennington's avatar
Havoc Pennington committed
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
36
#include "gtkhbox.h"
#include "gtkarrow.h"
37
#include "gtkintl.h"
38
#include "gtkbindings.h"
39
40
#include "gtkcontainer.h"
#include "gtkentry.h"
Jonathan Blandford's avatar
Jonathan Blandford committed
41
#include "gtktreemodelsort.h"
42

43
#define GTK_TREE_VIEW_SEARCH_DIALOG_KEY "gtk-tree-view-search-dialog"
44

Jonathan Blandford's avatar
Jonathan Blandford committed
45
#define GTK_TREE_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
46
#define GTK_TREE_VIEW_PRIORITY_SCROLL_SYNC (GTK_TREE_VIEW_PRIORITY_VALIDATE + 2)
Jonathan Blandford's avatar
Jonathan Blandford committed
47
#define GTK_TREE_VIEW_NUM_ROWS_PER_IDLE 500
48
#define SCROLL_EDGE_SIZE 15
49
#define EXPANDER_EXTRA_PADDING 4
50

Havoc Pennington's avatar
Havoc Pennington committed
51
52
53
54
55
56
57
/* 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
58
#define CELL_HEIGHT(node, separator) ((BACKGROUND_HEIGHT (node)) - (separator))
Havoc Pennington's avatar
Havoc Pennington committed
59

60
61
#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)
62
63
64
65

/* 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)
66
67


68
typedef struct _GtkTreeViewChild GtkTreeViewChild;
69
70
71
72
73
struct _GtkTreeViewChild
{
  GtkWidget *widget;
  gint x;
  gint y;
74
75
  gint width;
  gint height;
76
77
};

Jonathan Blandford's avatar
Jonathan Blandford committed
78

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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 */
94
95
96
enum
{
  ROW_ACTIVATED,
97
98
99
100
  TEST_EXPAND_ROW,
  TEST_COLLAPSE_ROW,
  ROW_EXPANDED,
  ROW_COLLAPSED,
101
  COLUMNS_CHANGED,
102
  CURSOR_CHANGED,
103
  MOVE_CURSOR,
104
  SELECT_ALL,
105
  UNSELECT_ALL,
106
  SELECT_CURSOR_ROW,
107
108
109
  TOGGLE_CURSOR_ROW,
  EXPAND_COLLAPSE_CURSOR_ROW,
  SELECT_CURSOR_PARENT,
110
  START_INTERACTIVE_SEARCH,
111
112
113
  LAST_SIGNAL
};

114
/* Properties */
115
116
117
118
119
120
121
122
enum {
  PROP_0,
  PROP_MODEL,
  PROP_HADJUSTMENT,
  PROP_VADJUSTMENT,
  PROP_HEADERS_VISIBLE,
  PROP_HEADERS_CLICKABLE,
  PROP_EXPANDER_COLUMN,
123
  PROP_REORDERABLE,
124
125
  PROP_RULES_HINT,
  PROP_ENABLE_SEARCH,
126
127
  PROP_SEARCH_COLUMN,
  PROP_FIXED_HEIGHT_MODE
128
};
129
130

static void     gtk_tree_view_class_init           (GtkTreeViewClass *klass);
131
132
133
134
static void     gtk_tree_view_init                 (GtkTreeView      *tree_view);

/* object signals */
static void     gtk_tree_view_finalize             (GObject          *object);
135
136
137
static void     gtk_tree_view_set_property         (GObject         *object,
						    guint            prop_id,
						    const GValue    *value,
Jonathan Blandford's avatar
Jonathan Blandford committed
138
						    GParamSpec      *pspec);
139
140
141
static void     gtk_tree_view_get_property         (GObject         *object,
						    guint            prop_id,
						    GValue          *value,
Jonathan Blandford's avatar
Jonathan Blandford committed
142
						    GParamSpec      *pspec);
143

144
/* gtkobject signals */
Jonathan Blandford's avatar
Jonathan Blandford committed
145
146
static void     gtk_tree_view_destroy              (GtkObject        *object);

147
/* gtkwidget signals */
148
149
150
151
152
153
154
155
156
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);
157
158
static gboolean gtk_tree_view_key_press            (GtkWidget        *widget,
						    GdkEventKey      *event);
159
160
161
162
163
164
165
166
167
168
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);
169
170
static void     gtk_tree_view_set_focus_child      (GtkContainer     *container,
						    GtkWidget        *child);
171
172
static gint     gtk_tree_view_focus_out            (GtkWidget        *widget,
						    GdkEventFocus    *event);
173
static gint     gtk_tree_view_focus                (GtkWidget        *widget,
174
						    GtkDirectionType  direction);
175
static void     gtk_tree_view_grab_focus           (GtkWidget        *widget);
Kristian Rietveld's avatar
Kristian Rietveld committed
176
177
static void     gtk_tree_view_style_set            (GtkWidget        *widget,
						    GtkStyle         *previous_style);
178
179
180
181
182
183
184
185
186

/* 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/* 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);

222
/* tree_model signals */
223
224
225
static void gtk_tree_view_set_adjustments                 (GtkTreeView     *tree_view,
							   GtkAdjustment   *hadj,
							   GtkAdjustment   *vadj);
226
static gboolean gtk_tree_view_real_move_cursor            (GtkTreeView     *tree_view,
227
							   GtkMovementStep  step,
228
							   gint             count);
229
230
231
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,
232
							   gboolean         start_editing);
233
234
235
236
237
238
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);
239
static void gtk_tree_view_row_changed                     (GtkTreeModel    *model,
240
241
242
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
243
static void gtk_tree_view_row_inserted                    (GtkTreeModel    *model,
244
245
246
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
247
static void gtk_tree_view_row_has_child_toggled           (GtkTreeModel    *model,
248
249
250
							   GtkTreePath     *path,
							   GtkTreeIter     *iter,
							   gpointer         data);
251
static void gtk_tree_view_row_deleted                     (GtkTreeModel    *model,
252
253
							   GtkTreePath     *path,
							   gpointer         data);
254
static void gtk_tree_view_rows_reordered                  (GtkTreeModel    *model,
255
256
257
258
259
							   GtkTreePath     *parent,
							   GtkTreeIter     *iter,
							   gint            *new_order,
							   gpointer         data);

Jonathan Blandford's avatar
Jonathan Blandford committed
260
261
262
263
264
265
266
267
/* 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);
268
static gboolean validate_rows            (GtkTreeView *tree_view);
Jonathan Blandford's avatar
Jonathan Blandford committed
269
270
static gboolean presize_handler_callback (gpointer     data);
static void     install_presize_handler  (GtkTreeView *tree_view);
271
static void     install_scroll_sync_handler (GtkTreeView *tree_view);
272
static void	gtk_tree_view_dy_to_top_row (GtkTreeView *tree_view);
273
static void     gtk_tree_view_top_row_to_dy (GtkTreeView *tree_view);
274
275


276
/* Internal functions */
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
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,
							      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,
299
							      GtkRBTree         *tree,
300
301
302
303
304
305
306
307
308
309
310
							      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
311
							      gboolean           recurse);
312
313
314
static gboolean gtk_tree_view_discover_dirty_iter            (GtkTreeView       *tree_view,
							      GtkTreeIter       *iter,
							      gint               depth,
315
316
							      gint              *height,
							      GtkRBNode         *node);
317
318
319
320
321
322
323
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);
324
325
static void     gtk_tree_view_clamp_column_visible           (GtkTreeView       *tree_view,
							      GtkTreeViewColumn *column);
326
327
328
329
330
331
332
333
334
335
336
337
338
339
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,
340
341
							      GtkRBNode         *node,
							      gboolean           animate);
342
343
344
345
static gboolean gtk_tree_view_real_expand_row                (GtkTreeView       *tree_view,
							      GtkTreePath       *path,
							      GtkRBTree         *tree,
							      GtkRBNode         *node,
346
347
							      gboolean           open_all,
							      gboolean           animate);
348
349
static void     gtk_tree_view_real_set_cursor                (GtkTreeView       *tree_view,
							      GtkTreePath       *path,
350
351
							      gboolean           clear_and_select,
							      gboolean           clamp_node);
352
static gboolean gtk_tree_view_has_special_cell               (GtkTreeView       *tree_view);
353
354
355
356
357
static void     column_sizing_notify                         (GObject           *object,
                                                              GParamSpec        *pspec,
                                                              gpointer           data);
static void     gtk_tree_view_set_fixed_height_mode          (GtkTreeView       *tree_view,
                                                              gboolean           enable);
358

Kristian Rietveld's avatar
Kristian Rietveld committed
359
static gboolean expand_collapse_timeout                      (gpointer           data);
Kristian Rietveld's avatar
Kristian Rietveld committed
360
static gboolean do_expand_collapse                           (GtkTreeView       *tree_view);
Kristian Rietveld's avatar
Kristian Rietveld committed
361

362
363
364
365
366
/* interactive search */
static void     gtk_tree_view_search_dialog_destroy     (GtkWidget        *search_dialog,
							 GtkTreeView      *tree_view);
static void     gtk_tree_view_search_position_func      (GtkTreeView      *tree_view,
							 GtkWidget        *search_dialog);
367
368
369
370
371
372
static void     gtk_tree_view_search_disable_popdown    (GtkEntry         *entry,
							 GtkMenu          *menu,
							 gpointer          data);
static gboolean gtk_tree_view_real_search_enable_popdown(gpointer          data);
static void     gtk_tree_view_search_enable_popdown     (GtkWidget        *widget,
							 gpointer          data);
373
374
375
376
377
378
379
380
381
382
383
384
385
386
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);
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,
387
							 const gchar      *key,
388
389
							 GtkTreeIter      *iter,
							 gpointer          search_data);
390
391
392
static gboolean gtk_tree_view_search_iter               (GtkTreeModel     *model,
							 GtkTreeSelection *selection,
							 GtkTreeIter      *iter,
393
							 const gchar      *text,
394
395
396
397
							 gint             *count,
							 gint              n);
static void     gtk_tree_view_search_init               (GtkWidget        *entry,
							 GtkTreeView      *tree_view);
398
399
400
401
402
403
static void     gtk_tree_view_put                       (GtkTreeView      *tree_view,
							 GtkWidget        *child_widget,
							 gint              x,
							 gint              y,
							 gint              width,
							 gint              height);
404
405
406
407
408
409
410
411
412
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
413
414
static void gtk_tree_view_stop_editing                  (GtkTreeView *tree_view,
							 gboolean     cancel_editing);
415
static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view);
416
417
418
static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView       *tree_view,
							 GtkTreeViewColumn *column,
							 gint               drop_position);
419

420
421

static GtkContainerClass *parent_class = NULL;
422
static guint tree_view_signals [LAST_SIGNAL] = { 0 };
423

424
425
426
427
428


/* GType Methods
 */

Manish Singh's avatar
Manish Singh committed
429
GType
430
431
gtk_tree_view_get_type (void)
{
Manish Singh's avatar
Manish Singh committed
432
  static GType tree_view_type = 0;
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448

  if (!tree_view_type)
    {
      static const GTypeInfo tree_view_info =
      {
        sizeof (GtkTreeViewClass),
	NULL,		/* base_init */
	NULL,		/* base_finalize */
        (GClassInitFunc) gtk_tree_view_class_init,
	NULL,		/* class_finalize */
	NULL,		/* class_data */
        sizeof (GtkTreeView),
	0,              /* n_preallocs */
        (GInstanceInitFunc) gtk_tree_view_init
      };

Manish Singh's avatar
Manish Singh committed
449
450
451
      tree_view_type =
	g_type_register_static (GTK_TYPE_CONTAINER, "GtkTreeView",
				&tree_view_info, 0);
452
453
454
455
456
457
458
459
    }

  return tree_view_type;
}

static void
gtk_tree_view_class_init (GtkTreeViewClass *class)
{
460
  GObjectClass *o_class;
461
462
463
  GtkObjectClass *object_class;
  GtkWidgetClass *widget_class;
  GtkContainerClass *container_class;
464
  GtkBindingSet *binding_set;
465

466
  parent_class = g_type_class_peek_parent (class);
467
  binding_set = gtk_binding_set_by_class (class);
468

469
470
471
472
473
  o_class = (GObjectClass *) class;
  object_class = (GtkObjectClass *) class;
  widget_class = (GtkWidgetClass *) class;
  container_class = (GtkContainerClass *) class;

474
  /* GObject signals */
475
476
  o_class->set_property = gtk_tree_view_set_property;
  o_class->get_property = gtk_tree_view_get_property;
477
  o_class->finalize = gtk_tree_view_finalize;
478

479
  /* GtkObject signals */
Jonathan Blandford's avatar
Jonathan Blandford committed
480
  object_class->destroy = gtk_tree_view_destroy;
481

482
483
  /* GtkWidget signals */
  widget_class->map = gtk_tree_view_map;
484
485
486
487
  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;
488
489
  widget_class->button_press_event = gtk_tree_view_button_press;
  widget_class->button_release_event = gtk_tree_view_button_release;
490
  widget_class->motion_notify_event = gtk_tree_view_motion;
491
  widget_class->expose_event = gtk_tree_view_expose;
492
  widget_class->key_press_event = gtk_tree_view_key_press;
493
494
495
  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
496
497
498
499
500
501
502
503
  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;
504
  widget_class->focus = gtk_tree_view_focus;
505
  widget_class->grab_focus = gtk_tree_view_grab_focus;
Kristian Rietveld's avatar
Kristian Rietveld committed
506
  widget_class->style_set = gtk_tree_view_style_set;
507

508
  /* GtkContainer signals */
509
  container_class->remove = gtk_tree_view_remove;
510
511
  container_class->forall = gtk_tree_view_forall;
  container_class->set_focus_child = gtk_tree_view_set_focus_child;
512
513

  class->set_scroll_adjustments = gtk_tree_view_set_adjustments;
514
  class->move_cursor = gtk_tree_view_real_move_cursor;
515
  class->select_all = gtk_tree_view_real_select_all;
516
  class->unselect_all = gtk_tree_view_real_unselect_all;
517
  class->select_cursor_row = gtk_tree_view_real_select_cursor_row;
518
519
520
  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;
521
  class->start_interactive_search = gtk_tree_view_real_start_interactive_search;
522

523
  /* Properties */
524

525
526
  g_object_class_install_property (o_class,
                                   PROP_MODEL,
Tim Janik's avatar
Tim Janik committed
527
                                   g_param_spec_object ("model",
528
529
							P_("TreeView Model"),
							P_("The model for the tree view"),
Tim Janik's avatar
Tim Janik committed
530
531
							GTK_TYPE_TREE_MODEL,
							G_PARAM_READWRITE));
Jonathan Blandford's avatar
Jonathan Blandford committed
532

533
534
535
  g_object_class_install_property (o_class,
                                   PROP_HADJUSTMENT,
                                   g_param_spec_object ("hadjustment",
536
537
							P_("Horizontal Adjustment"),
                                                        P_("Horizontal Adjustment for the widget"),
538
539
540
541
542
543
                                                        GTK_TYPE_ADJUSTMENT,
                                                        G_PARAM_READWRITE));

  g_object_class_install_property (o_class,
                                   PROP_VADJUSTMENT,
                                   g_param_spec_object ("vadjustment",
544
545
							P_("Vertical Adjustment"),
                                                        P_("Vertical Adjustment for the widget"),
546
547
548
549
550
551
                                                        GTK_TYPE_ADJUSTMENT,
                                                        G_PARAM_READWRITE));

  g_object_class_install_property (o_class,
                                   PROP_HEADERS_VISIBLE,
                                   g_param_spec_boolean ("headers_visible",
552
553
							 P_("Visible"),
							 P_("Show the column header buttons"),
554
							 TRUE,
555
556
557
558
559
							 G_PARAM_READWRITE));

  g_object_class_install_property (o_class,
                                   PROP_HEADERS_CLICKABLE,
                                   g_param_spec_boolean ("headers_clickable",
560
561
							 P_("Headers Clickable"),
							 P_("Column headers respond to click events"),
562
							 FALSE,
563
							 G_PARAM_WRITABLE));
564
565
566

  g_object_class_install_property (o_class,
                                   PROP_EXPANDER_COLUMN,
567
                                   g_param_spec_object ("expander_column",
568
569
							P_("Expander Column"),
							P_("Set the column for the expander column"),
570
571
							GTK_TYPE_TREE_VIEW_COLUMN,
							G_PARAM_READWRITE));
572

573
574
575
  g_object_class_install_property (o_class,
                                   PROP_REORDERABLE,
                                   g_param_spec_boolean ("reorderable",
576
577
							 P_("Reorderable"),
							 P_("View is reorderable"),
578
579
580
							 FALSE,
							 G_PARAM_READWRITE));

581
582
583
  g_object_class_install_property (o_class,
                                   PROP_RULES_HINT,
                                   g_param_spec_boolean ("rules_hint",
584
585
							 P_("Rules Hint"),
							 P_("Set a hint to the theme engine to draw rows in alternating colors"),
586
587
588
							 FALSE,
							 G_PARAM_READWRITE));

589
590
591
    g_object_class_install_property (o_class,
				     PROP_ENABLE_SEARCH,
				     g_param_spec_boolean ("enable_search",
592
593
							   P_("Enable Search"),
							   P_("View allows user to search through columns interactively"),
594
595
							   TRUE,
							   G_PARAM_READWRITE));
596

597
598
599
    g_object_class_install_property (o_class,
				     PROP_SEARCH_COLUMN,
				     g_param_spec_int ("search_column",
600
601
						       P_("Search Column"),
						       P_("Model column to search through when searching through code"),
602
603
604
605
						       -1,
						       G_MAXINT,
						       0,
						       G_PARAM_READWRITE));
606

607
608
609
    g_object_class_install_property (o_class,
                                     PROP_FIXED_HEIGHT_MODE,
                                     g_param_spec_boolean ("fixed_height_mode",
610
611
                                                           P_("Fixed Height Mode"),
                                                           P_("Speeds up GtkTreeView by assuming that all rows have the same height"),
612
613
614
                                                           FALSE,
                                                           G_PARAM_READWRITE));

615
  /* Style properties */
616
#define _TREE_VIEW_EXPANDER_SIZE 10
617
#define _TREE_VIEW_VERTICAL_SEPARATOR 2
618
#define _TREE_VIEW_HORIZONTAL_SEPARATOR 2
619
    
620
  gtk_widget_class_install_style_property (widget_class,
621
					   g_param_spec_int ("expander_size",
622
623
							     P_("Expander Size"),
							     P_("Size of the expander arrow"),
624
625
							     0,
							     G_MAXINT,
626
							     _TREE_VIEW_EXPANDER_SIZE,
627
							     G_PARAM_READABLE));
628

629
630
  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_int ("vertical_separator",
631
632
							     P_("Vertical Separator Width"),
							     P_("Vertical space between cells.  Must be an even number"),
633
634
635
636
							     0,
							     G_MAXINT,
							     _TREE_VIEW_VERTICAL_SEPARATOR,
							     G_PARAM_READABLE));
637

638
  gtk_widget_class_install_style_property (widget_class,
639
					   g_param_spec_int ("horizontal_separator",
640
641
							     P_("Horizontal Separator Width"),
							     P_("Horizontal space between cells.  Must be an even number"),
642
643
644
645
646
							     0,
							     G_MAXINT,
							     _TREE_VIEW_HORIZONTAL_SEPARATOR,
							     G_PARAM_READABLE));

647
648
  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_boolean ("allow_rules",
649
650
								 P_("Allow Rules"),
								 P_("Allow drawing of alternating color rows"),
651
652
653
								 TRUE,
								 G_PARAM_READABLE));

654
655
  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_boolean ("indent_expanders",
656
657
								 P_("Indent Expanders"),
								 P_("Make the expanders indented"),
658
								 TRUE,
659
								 G_PARAM_READABLE));
Manish Singh's avatar
Manish Singh committed
660

661
662
  gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_boxed ("even_row_color",
663
664
                                                               P_("Even Row Color"),
                                                               P_("Color to use for even rows"),
665
666
667
668
669
							       GDK_TYPE_COLOR,
G_PARAM_READABLE));

  gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_boxed ("odd_row_color",
670
671
                                                               P_("Odd Row Color"),
                                                               P_("Color to use for odd rows"),
672
673
674
							       GDK_TYPE_COLOR,
G_PARAM_READABLE));

675
  /* Signals */
676
  widget_class->set_scroll_adjustments_signal =
Manish Singh's avatar
Manish Singh committed
677
678
679
680
681
682
683
684
685
    g_signal_new ("set_scroll_adjustments",
		  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);
686

687
  tree_view_signals[ROW_ACTIVATED] =
Manish Singh's avatar
Manish Singh committed
688
689
690
691
692
693
694
695
696
    g_signal_new ("row_activated",
		  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);
697

698
  tree_view_signals[TEST_EXPAND_ROW] =
699
    g_signal_new ("test_expand_row",
Manish Singh's avatar
Manish Singh committed
700
701
702
703
704
705
706
707
		  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);
708

709
  tree_view_signals[TEST_COLLAPSE_ROW] =
710
    g_signal_new ("test_collapse_row",
Manish Singh's avatar
Manish Singh committed
711
712
713
714
715
716
717
718
		  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);
719

720
  tree_view_signals[ROW_EXPANDED] =
721
    g_signal_new ("row_expanded",
Manish Singh's avatar
Manish Singh committed
722
723
724
725
726
727
728
729
		  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);
730
731

  tree_view_signals[ROW_COLLAPSED] =
732
    g_signal_new ("row_collapsed",
Manish Singh's avatar
Manish Singh committed
733
734
735
736
737
738
739
740
		  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);
741

742
  tree_view_signals[COLUMNS_CHANGED] =
743
    g_signal_new ("columns_changed",
Manish Singh's avatar
Manish Singh committed
744
745
746
747
748
749
		  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);
750

751
752
  tree_view_signals[CURSOR_CHANGED] =
    g_signal_new ("cursor_changed",
Manish Singh's avatar
Manish Singh committed
753
754
755
756
757
758
		  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);
759

760
  tree_view_signals[MOVE_CURSOR] =
761
    g_signal_new ("move_cursor",
Manish Singh's avatar
Manish Singh committed
762
763
764
765
766
767
768
769
		  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);
770

771
772
  tree_view_signals[SELECT_ALL] =
    g_signal_new ("select_all",
Manish Singh's avatar
Manish Singh committed
773
774
775
776
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_all),
		  NULL, NULL,
777
778
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
779

780
781
782
  tree_view_signals[UNSELECT_ALL] =
    g_signal_new ("unselect_all",
		  G_TYPE_FROM_CLASS (object_class),
Manish Singh's avatar
Manish Singh committed
783
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
784
785
		  G_STRUCT_OFFSET (GtkTreeViewClass, unselect_all),
		  NULL, NULL,
786
787
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
788

789
  tree_view_signals[SELECT_CURSOR_ROW] =
790
    g_signal_new ("select_cursor_row",
Manish Singh's avatar
Manish Singh committed
791
792
793
794
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_row),
		  NULL, NULL,
795
796
		  _gtk_marshal_BOOLEAN__BOOLEAN,
		  G_TYPE_BOOLEAN, 1,
797
		  G_TYPE_BOOLEAN);
798

799
  tree_view_signals[TOGGLE_CURSOR_ROW] =
800
    g_signal_new ("toggle_cursor_row",
Manish Singh's avatar
Manish Singh committed
801
802
803
804
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, toggle_cursor_row),
		  NULL, NULL,
805
806
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
807

808
  tree_view_signals[EXPAND_COLLAPSE_CURSOR_ROW] =
809
    g_signal_new ("expand_collapse_cursor_row",
Manish Singh's avatar
Manish Singh committed
810
811
812
813
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, expand_collapse_cursor_row),
		  NULL, NULL,
814
815
		  _gtk_marshal_BOOLEAN__BOOLEAN_BOOLEAN_BOOLEAN,
		  G_TYPE_BOOLEAN, 3,
Manish Singh's avatar
Manish Singh committed
816
817
818
		  G_TYPE_BOOLEAN,
		  G_TYPE_BOOLEAN,
		  G_TYPE_BOOLEAN);
819

820
  tree_view_signals[SELECT_CURSOR_PARENT] =
821
    g_signal_new ("select_cursor_parent",
Manish Singh's avatar
Manish Singh committed
822
823
824
825
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_parent),
		  NULL, NULL,
826
827
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
828

829
830
  tree_view_signals[START_INTERACTIVE_SEARCH] =
    g_signal_new ("start_interactive_search",
Manish Singh's avatar
Manish Singh committed
831
832
833
834
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, start_interactive_search),
		  NULL, NULL,
835
836
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
837

838
  /* Key bindings */
839
840
  gtk_tree_view_add_move_binding (binding_set, GDK_Up, 0,
				  GTK_MOVEMENT_DISPLAY_LINES, -1);
841
842
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Up, 0,
				  GTK_MOVEMENT_DISPLAY_LINES, -1);
843
844
845

  gtk_tree_view_add_move_binding (binding_set, GDK_Down, 0,
				  GTK_MOVEMENT_DISPLAY_LINES, 1);
846
847
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Down, 0,
				  GTK_MOVEMENT_DISPLAY_LINES, 1);
848
849
850
851
852
853
854
855
856

  gtk_tree_view_add_move_binding (binding_set, GDK_p, GDK_CONTROL_MASK,
				  GTK_MOVEMENT_DISPLAY_LINES, -1);

  gtk_tree_view_add_move_binding (binding_set, GDK_n, GDK_CONTROL_MASK,
				  GTK_MOVEMENT_DISPLAY_LINES, 1);

  gtk_tree_view_add_move_binding (binding_set, GDK_Home, 0,
				  GTK_MOVEMENT_BUFFER_ENDS, -1);
857
858
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Home, 0,
				  GTK_MOVEMENT_BUFFER_ENDS, -1);
859
860
861

  gtk_tree_view_add_move_binding (binding_set, GDK_End, 0,
				  GTK_MOVEMENT_BUFFER_ENDS, 1);
862
863
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_End, 0,
				  GTK_MOVEMENT_BUFFER_ENDS, 1);
864
865
866

  gtk_tree_view_add_move_binding (binding_set, GDK_Page_Up, 0,
				  GTK_MOVEMENT_PAGES, -1);
867
868
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Page_Up, 0,
				  GTK_MOVEMENT_PAGES, -1);
869
870
871

  gtk_tree_view_add_move_binding (binding_set, GDK_Page_Down, 0,
				  GTK_MOVEMENT_PAGES, 1);
872
873
874
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Page_Down, 0,
				  GTK_MOVEMENT_PAGES, 1);

875

876
  gtk_binding_entry_add_signal (binding_set, GDK_Right, 0, "move_cursor", 2,
Manish Singh's avatar
Manish Singh committed
877
878
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, 1);
879

880
  gtk_binding_entry_add_signal (binding_set, GDK_Left, 0, "move_cursor", 2,
Manish Singh's avatar
Manish Singh committed
881
882
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, -1);
883

884
885
886
887
888
889
890
891
892
893
  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
894
895
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, 1);
896

897
898
899
900
901
902
903
904
905
906
907
908
  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
909
910
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, -1);
911

912
913
  gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, "toggle_cursor_row", 0);

914
  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK, "select_all", 0);
915
916
917
918
  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, "unselect_all", 0);
919

920
  gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_SHIFT_MASK, "select_cursor_row", 1,
Manish Singh's avatar
Manish Singh committed
921
				G_TYPE_BOOLEAN, TRUE);
922
923

  gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "select_cursor_row", 1,
Manish Singh's avatar
Manish Singh committed
924
				G_TYPE_BOOLEAN, TRUE);
925
926
927
928
929
930
  gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "select_cursor_row", 1,
				G_TYPE_BOOLEAN, TRUE);
  gtk_binding_entry_add_signal (binding_set, GDK_ISO_Enter, 0, "select_cursor_row", 1,
				G_TYPE_BOOLEAN, TRUE);
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "select_cursor_row", 1,
				G_TYPE_BOOLEAN, TRUE);
931

932
933
  /* expand and collapse rows */
  gtk_binding_entry_add_signal (binding_set, GDK_plus, 0, "expand_collapse_cursor_row", 3,
934
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
935
936
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, FALSE);
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959

  gtk_binding_entry_add_signal (binding_set, GDK_asterisk, 0,
                                "expand_collapse_cursor_row", 3,
                                G_TYPE_BOOLEAN, TRUE,
                                G_TYPE_BOOLEAN, TRUE,
                                G_TYPE_BOOLEAN, TRUE);
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Multiply, 0,
                                "expand_collapse_cursor_row", 3,
                                G_TYPE_BOOLEAN, TRUE,
                                G_TYPE_BOOLEAN, TRUE,
                                G_TYPE_BOOLEAN, TRUE);

  gtk_binding_entry_add_signal (binding_set, GDK_slash, 0,
                                "expand_collapse_cursor_row", 3,
                                G_TYPE_BOOLEAN, TRUE,
                                G_TYPE_BOOLEAN, FALSE,
                                G_TYPE_BOOLEAN, FALSE);
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Divide, 0,
                                "expand_collapse_cursor_row", 3,
                                G_TYPE_BOOLEAN, TRUE,
                                G_TYPE_BOOLEAN, FALSE,
                                G_TYPE_BOOLEAN, FALSE);

960
961
  /* Not doable on US keyboards */
  gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
962
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
963
964
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
965
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, 0, "expand_collapse_cursor_row", 3,
966
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
967
968
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, FALSE);
969
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
970
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
971
972
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
973
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
974
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
975
976
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
977
978
  gtk_binding_entry_add_signal (binding_set, GDK_Right, GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
979
				G_TYPE_BOOLEAN, FALSE,
Manish Singh's avatar
Manish Singh committed
980
981
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
982
983
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
984
				G_TYPE_BOOLEAN, FALSE,
985
986
987
988
989
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
  gtk_binding_entry_add_signal (binding_set, GDK_Right,
                                GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
990
				G_TYPE_BOOLEAN, FALSE,
991
992
993
994
995
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Right,
                                GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
996
				G_TYPE_BOOLEAN, FALSE,
997
998
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
999
1000

  gtk_binding_entry_add_signal (binding_set, GDK_minus, 0, "expand_collapse_cursor_row", 3,
1001
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1002
1003
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE);
1004
  gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
1005
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1006
1007
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
1008
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Subtract, 0, "expand_collapse_cursor_row", 3,
1009
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1010
1011
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE);
1012
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Subtract, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
1013
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1014
1015
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
  gtk_binding_entry_add_signal (binding_set, GDK_Left, GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Left, GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
  gtk_binding_entry_add_signal (binding_set, GDK_Left,
                                GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
Manish Singh's avatar
Manish Singh committed
1029
1030
1031
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
1032
1033
1034
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Left,
                                GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
1035
1036
1037
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
1038
1039
1040

  gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0, "select_cursor_parent", 0);

1041
  gtk_binding_entry_add_signal (binding_set, GDK_f, GDK_CONTROL_MASK, "start_interactive_search", 0);
1042

1043
  gtk_binding_entry_add_signal (binding_set, GDK_F, GDK_CONTROL_MASK, "start_interactive_search", 0);
1044
1045
1046
1047
1048
1049
1050
1051
}

static void
gtk_tree_view_init (GtkTreeView *tree_view)
{
  tree_view->priv = g_new0 (GtkTreeViewPrivate, 1);
  GTK_WIDGET_SET_FLAGS (tree_view, GTK_CAN_FOCUS);

1052
1053
  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (tree_view), FALSE);

1054
1055
1056
  tree_view->priv->flags =  GTK_TREE_VIEW_SHOW_EXPANDERS
                            | GTK_TREE_VIEW_DRAW_KEYFOCUS
                            | GTK_TREE_VIEW_HEADERS_VISIBLE;
1057
1058

  /* We need some padding */
1059
  tree_view->priv->dy = 0;
1060
  tree_view->priv->n_columns = 0;
1061
1062
1063
  tree_view->priv->header_height = 1;
  tree_view->priv->x_drag = 0;
  tree_view->priv->drag_pos = -1;
1064
  tree_view->priv->header_has_focus = FALSE;
Havoc Pennington's avatar
Havoc Pennington committed
1065
1066
1067
  tree_view->priv->pressed_button = -1;
  tree_view->priv->press_start_x = -1;
  tree_view->priv->press_start_y = -1;
1068
  tree_view->priv->reorderable = FALSE;
Jonathan Blandford's avatar
Jonathan Blandford committed
1069
  tree_view->priv->presize_handler_timer = 0;
1070
  tree_view->priv->scroll_sync_timer = 0;
1071
1072
  tree_view->priv->fixed_height = -1;
  tree_view->priv->fixed_height_mode = 0;
1073
  tree_view->priv->fixed_height_check = 0;
1074
  gtk_tree_view_set_adjustments (tree_view, NULL, NULL);