gtktreeview.c 372 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
#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

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
Jonathan Blandford's avatar
Jonathan Blandford committed
50
#define GTK_TREE_VIEW_SEARCH_DIALOG_TIMEOUT 5000
51
52
#define AUTO_EXPAND_TIMEOUT 500

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

62
63
#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)
64
65
66
67

/* 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)
68

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

72

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

Jonathan Blandford's avatar
Jonathan Blandford committed
83

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

119
/* Properties */
120
121
122
123
124
125
126
127
enum {
  PROP_0,
  PROP_MODEL,
  PROP_HADJUSTMENT,
  PROP_VADJUSTMENT,
  PROP_HEADERS_VISIBLE,
  PROP_HEADERS_CLICKABLE,
  PROP_EXPANDER_COLUMN,
128
  PROP_REORDERABLE,
129
130
  PROP_RULES_HINT,
  PROP_ENABLE_SEARCH,
131
  PROP_SEARCH_COLUMN,
132
  PROP_FIXED_HEIGHT_MODE,
133
134
  PROP_HOVER_SELECTION,
  PROP_HOVER_EXPAND
135
};
136
137

static void     gtk_tree_view_class_init           (GtkTreeViewClass *klass);
138
139
140
141
static void     gtk_tree_view_init                 (GtkTreeView      *tree_view);

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

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

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

183
184
static void     gtk_tree_view_set_focus_child      (GtkContainer     *container,
						    GtkWidget        *child);
185
186
static gint     gtk_tree_view_focus_out            (GtkWidget        *widget,
						    GdkEventFocus    *event);
187
static gint     gtk_tree_view_focus                (GtkWidget        *widget,
188
						    GtkDirectionType  direction);
189
static void     gtk_tree_view_grab_focus           (GtkWidget        *widget);
Kristian Rietveld's avatar
Kristian Rietveld committed
190
191
static void     gtk_tree_view_style_set            (GtkWidget        *widget,
						    GtkStyle         *previous_style);
192
193
194
195
196
197
198
199
200

/* 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
201
202
203
204
205
206
207
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
/* 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);

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

Jonathan Blandford's avatar
Jonathan Blandford committed
274
275
276
277
278
279
280
281
/* 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);
282
static gboolean validate_rows            (GtkTreeView *tree_view);
Jonathan Blandford's avatar
Jonathan Blandford committed
283
284
static gboolean presize_handler_callback (gpointer     data);
static void     install_presize_handler  (GtkTreeView *tree_view);
285
static void     install_scroll_sync_handler (GtkTreeView *tree_view);
286
static void	gtk_tree_view_dy_to_top_row (GtkTreeView *tree_view);
287
static void     gtk_tree_view_top_row_to_dy (GtkTreeView *tree_view);
288
289


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

373
/* interactive search */
Jonathan Blandford's avatar
Jonathan Blandford committed
374
static void     gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view);
375
static void     gtk_tree_view_search_dialog_hide     (GtkWidget        *search_dialog,
376
377
378
							 GtkTreeView      *tree_view);
static void     gtk_tree_view_search_position_func      (GtkTreeView      *tree_view,
							 GtkWidget        *search_dialog);
379
380
381
static void     gtk_tree_view_search_disable_popdown    (GtkEntry         *entry,
							 GtkMenu          *menu,
							 gpointer          data);
Jonathan Blandford's avatar
Jonathan Blandford committed
382
383
static void     gtk_tree_view_search_preedit_changed    (GtkIMContext     *im_context,
							 GtkTreeView      *tree_view);
384
385
386
static gboolean gtk_tree_view_real_search_enable_popdown(gpointer          data);
static void     gtk_tree_view_search_enable_popdown     (GtkWidget        *widget,
							 gpointer          data);
387
388
389
390
391
392
393
394
395
396
397
398
399
400
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,
401
							 const gchar      *key,
402
403
							 GtkTreeIter      *iter,
							 gpointer          search_data);
404
405
406
static gboolean gtk_tree_view_search_iter               (GtkTreeModel     *model,
							 GtkTreeSelection *selection,
							 GtkTreeIter      *iter,
407
							 const gchar      *text,
408
409
410
411
							 gint             *count,
							 gint              n);
static void     gtk_tree_view_search_init               (GtkWidget        *entry,
							 GtkTreeView      *tree_view);
412
413
414
415
416
417
static void     gtk_tree_view_put                       (GtkTreeView      *tree_view,
							 GtkWidget        *child_widget,
							 gint              x,
							 gint              y,
							 gint              width,
							 gint              height);
418
419
420
421
422
423
424
425
426
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
427
428
static void gtk_tree_view_stop_editing                  (GtkTreeView *tree_view,
							 gboolean     cancel_editing);
Jonathan Blandford's avatar
Jonathan Blandford committed
429
430
431
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);
432
433
434
static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView       *tree_view,
							 GtkTreeViewColumn *column,
							 gint               drop_position);
435

436
437
438
439
440
static void gtk_tree_view_tree_window_to_tree_coords (GtkTreeView *tree_view,
						      gint         wx,
						      gint         wy,
						      gint        *tx,
						      gint        *ty);
441

442
443

static GtkContainerClass *parent_class = NULL;
444
static guint tree_view_signals [LAST_SIGNAL] = { 0 };
445

446
447
448
449
450


/* GType Methods
 */

Manish Singh's avatar
Manish Singh committed
451
GType
452
453
gtk_tree_view_get_type (void)
{
Manish Singh's avatar
Manish Singh committed
454
  static GType tree_view_type = 0;
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470

  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
471
472
473
      tree_view_type =
	g_type_register_static (GTK_TYPE_CONTAINER, "GtkTreeView",
				&tree_view_info, 0);
474
475
476
477
478
479
480
481
    }

  return tree_view_type;
}

static void
gtk_tree_view_class_init (GtkTreeViewClass *class)
{
482
  GObjectClass *o_class;
483
484
485
  GtkObjectClass *object_class;
  GtkWidgetClass *widget_class;
  GtkContainerClass *container_class;
486
  GtkBindingSet *binding_set;
487

488
  parent_class = g_type_class_peek_parent (class);
489
  binding_set = gtk_binding_set_by_class (class);
490

491
492
493
494
495
  o_class = (GObjectClass *) class;
  object_class = (GtkObjectClass *) class;
  widget_class = (GtkWidgetClass *) class;
  container_class = (GtkContainerClass *) class;

496
  /* GObject signals */
497
498
  o_class->set_property = gtk_tree_view_set_property;
  o_class->get_property = gtk_tree_view_get_property;
499
  o_class->finalize = gtk_tree_view_finalize;
500

501
  /* GtkObject signals */
Jonathan Blandford's avatar
Jonathan Blandford committed
502
  object_class->destroy = gtk_tree_view_destroy;
503

504
505
  /* GtkWidget signals */
  widget_class->map = gtk_tree_view_map;
506
507
508
509
  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;
510
511
  widget_class->button_press_event = gtk_tree_view_button_press;
  widget_class->button_release_event = gtk_tree_view_button_release;
512
  /*widget_class->configure_event = gtk_tree_view_configure;*/
513
  widget_class->motion_notify_event = gtk_tree_view_motion;
514
  widget_class->expose_event = gtk_tree_view_expose;
515
  widget_class->key_press_event = gtk_tree_view_key_press;
Jonathan Blandford's avatar
Jonathan Blandford committed
516
  widget_class->key_release_event = gtk_tree_view_key_release;
517
518
519
  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
520
521
522
523
524
525
526
527
  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;
528
  widget_class->focus = gtk_tree_view_focus;
529
  widget_class->grab_focus = gtk_tree_view_grab_focus;
Kristian Rietveld's avatar
Kristian Rietveld committed
530
  widget_class->style_set = gtk_tree_view_style_set;
531

532
  /* GtkContainer signals */
533
  container_class->remove = gtk_tree_view_remove;
534
535
  container_class->forall = gtk_tree_view_forall;
  container_class->set_focus_child = gtk_tree_view_set_focus_child;
536
537

  class->set_scroll_adjustments = gtk_tree_view_set_adjustments;
538
  class->move_cursor = gtk_tree_view_real_move_cursor;
539
  class->select_all = gtk_tree_view_real_select_all;
540
  class->unselect_all = gtk_tree_view_real_unselect_all;
541
  class->select_cursor_row = gtk_tree_view_real_select_cursor_row;
542
543
544
  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
545
  class->start_interactive_search = gtk_tree_view_start_interactive_search;
546

547
  /* Properties */
548

549
550
  g_object_class_install_property (o_class,
                                   PROP_MODEL,
Tim Janik's avatar
Tim Janik committed
551
                                   g_param_spec_object ("model",
552
553
							P_("TreeView Model"),
							P_("The model for the tree view"),
Tim Janik's avatar
Tim Janik committed
554
555
							GTK_TYPE_TREE_MODEL,
							G_PARAM_READWRITE));
Jonathan Blandford's avatar
Jonathan Blandford committed
556

557
558
559
  g_object_class_install_property (o_class,
                                   PROP_HADJUSTMENT,
                                   g_param_spec_object ("hadjustment",
560
561
							P_("Horizontal Adjustment"),
                                                        P_("Horizontal Adjustment for the widget"),
562
563
564
565
566
567
                                                        GTK_TYPE_ADJUSTMENT,
                                                        G_PARAM_READWRITE));

  g_object_class_install_property (o_class,
                                   PROP_VADJUSTMENT,
                                   g_param_spec_object ("vadjustment",
568
569
							P_("Vertical Adjustment"),
                                                        P_("Vertical Adjustment for the widget"),
570
571
572
573
574
575
                                                        GTK_TYPE_ADJUSTMENT,
                                                        G_PARAM_READWRITE));

  g_object_class_install_property (o_class,
                                   PROP_HEADERS_VISIBLE,
                                   g_param_spec_boolean ("headers_visible",
576
577
							 P_("Visible"),
							 P_("Show the column header buttons"),
578
							 TRUE,
579
580
581
582
583
							 G_PARAM_READWRITE));

  g_object_class_install_property (o_class,
                                   PROP_HEADERS_CLICKABLE,
                                   g_param_spec_boolean ("headers_clickable",
584
585
							 P_("Headers Clickable"),
							 P_("Column headers respond to click events"),
586
							 FALSE,
587
							 G_PARAM_WRITABLE));
588
589
590

  g_object_class_install_property (o_class,
                                   PROP_EXPANDER_COLUMN,
591
                                   g_param_spec_object ("expander_column",
592
593
							P_("Expander Column"),
							P_("Set the column for the expander column"),
594
595
							GTK_TYPE_TREE_VIEW_COLUMN,
							G_PARAM_READWRITE));
596

597
598
599
  g_object_class_install_property (o_class,
                                   PROP_REORDERABLE,
                                   g_param_spec_boolean ("reorderable",
600
601
							 P_("Reorderable"),
							 P_("View is reorderable"),
602
603
604
							 FALSE,
							 G_PARAM_READWRITE));

605
606
607
  g_object_class_install_property (o_class,
                                   PROP_RULES_HINT,
                                   g_param_spec_boolean ("rules_hint",
608
609
							 P_("Rules Hint"),
							 P_("Set a hint to the theme engine to draw rows in alternating colors"),
610
611
612
							 FALSE,
							 G_PARAM_READWRITE));

613
614
615
    g_object_class_install_property (o_class,
				     PROP_ENABLE_SEARCH,
				     g_param_spec_boolean ("enable_search",
616
617
							   P_("Enable Search"),
							   P_("View allows user to search through columns interactively"),
618
619
							   TRUE,
							   G_PARAM_READWRITE));
620

621
622
623
    g_object_class_install_property (o_class,
				     PROP_SEARCH_COLUMN,
				     g_param_spec_int ("search_column",
624
625
						       P_("Search Column"),
						       P_("Model column to search through when searching through code"),
626
627
						       -1,
						       G_MAXINT,
628
						       -1,
629
						       G_PARAM_READWRITE));
630

631
632
633
634
635
636
637
638
639
640
641
    /**
     * 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
     **/
642
643
644
    g_object_class_install_property (o_class,
                                     PROP_FIXED_HEIGHT_MODE,
                                     g_param_spec_boolean ("fixed_height_mode",
645
646
                                                           P_("Fixed Height Mode"),
                                                           P_("Speeds up GtkTreeView by assuming that all rows have the same height"),
647
648
                                                           FALSE,
                                                           G_PARAM_READWRITE));
649
650
651
652
653
654
    
    /**
     * 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
655
656
657
     * Currently, this works only for the selection modes 
     * %GTK_SELECTION_SINGLE and %GTK_SELECTION_BROWSE.
     *
658
659
660
661
662
663
664
665
666
667
668
669
     * 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,
                                     g_param_spec_boolean ("hover_selection",
                                                           P_("Hover Selection"),
                                                           P_("Whether the selection should follow the pointer"),
                                                           FALSE,
                                                           G_PARAM_READWRITE));
670

671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
    /**
     * 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,
                                     g_param_spec_boolean ("hover_expand",
                                                           P_("Hover Expand"),
                                                           P_("Whether rows should be expanded/collaped when the pointer moves over them"),
                                                           FALSE,
                                                           G_PARAM_READWRITE));

691
  /* Style properties */
692
#define _TREE_VIEW_EXPANDER_SIZE 10
693
#define _TREE_VIEW_VERTICAL_SEPARATOR 2
694
#define _TREE_VIEW_HORIZONTAL_SEPARATOR 2
695
    
696
  gtk_widget_class_install_style_property (widget_class,
697
					   g_param_spec_int ("expander_size",
698
699
							     P_("Expander Size"),
							     P_("Size of the expander arrow"),
700
701
							     0,
							     G_MAXINT,
702
							     _TREE_VIEW_EXPANDER_SIZE,
703
							     G_PARAM_READABLE));
704

705
706
  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_int ("vertical_separator",
707
708
							     P_("Vertical Separator Width"),
							     P_("Vertical space between cells.  Must be an even number"),
709
710
711
712
							     0,
							     G_MAXINT,
							     _TREE_VIEW_VERTICAL_SEPARATOR,
							     G_PARAM_READABLE));
713

714
  gtk_widget_class_install_style_property (widget_class,
715
					   g_param_spec_int ("horizontal_separator",
716
717
							     P_("Horizontal Separator Width"),
							     P_("Horizontal space between cells.  Must be an even number"),
718
719
720
721
722
							     0,
							     G_MAXINT,
							     _TREE_VIEW_HORIZONTAL_SEPARATOR,
							     G_PARAM_READABLE));

723
724
  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_boolean ("allow_rules",
725
726
								 P_("Allow Rules"),
								 P_("Allow drawing of alternating color rows"),
727
728
729
								 TRUE,
								 G_PARAM_READABLE));

730
731
  gtk_widget_class_install_style_property (widget_class,
					   g_param_spec_boolean ("indent_expanders",
732
733
								 P_("Indent Expanders"),
								 P_("Make the expanders indented"),
734
								 TRUE,
735
								 G_PARAM_READABLE));
Manish Singh's avatar
Manish Singh committed
736

737
738
  gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_boxed ("even_row_color",
739
740
                                                               P_("Even Row Color"),
                                                               P_("Color to use for even rows"),
741
742
743
744
745
							       GDK_TYPE_COLOR,
G_PARAM_READABLE));

  gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_boxed ("odd_row_color",
746
747
                                                               P_("Odd Row Color"),
                                                               P_("Color to use for odd rows"),
748
749
750
							       GDK_TYPE_COLOR,
G_PARAM_READABLE));

751
  /* Signals */
752
  widget_class->set_scroll_adjustments_signal =
Manish Singh's avatar
Manish Singh committed
753
754
755
756
757
758
759
760
761
    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);
762

763
  tree_view_signals[ROW_ACTIVATED] =
Manish Singh's avatar
Manish Singh committed
764
765
766
767
768
769
770
771
772
    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);
773

774
  tree_view_signals[TEST_EXPAND_ROW] =
775
    g_signal_new ("test_expand_row",
Manish Singh's avatar
Manish Singh committed
776
777
778
779
780
781
782
783
		  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);
784

785
  tree_view_signals[TEST_COLLAPSE_ROW] =
786
    g_signal_new ("test_collapse_row",
Manish Singh's avatar
Manish Singh committed
787
788
789
790
791
792
793
794
		  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);
795

796
  tree_view_signals[ROW_EXPANDED] =
797
    g_signal_new ("row_expanded",
Manish Singh's avatar
Manish Singh committed
798
799
800
801
802
803
804
805
		  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);
806
807

  tree_view_signals[ROW_COLLAPSED] =
808
    g_signal_new ("row_collapsed",
Manish Singh's avatar
Manish Singh committed
809
810
811
812
813
814
815
816
		  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);
817

818
  tree_view_signals[COLUMNS_CHANGED] =
819
    g_signal_new ("columns_changed",
Manish Singh's avatar
Manish Singh committed
820
821
822
823
824
825
		  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);
826

827
828
  tree_view_signals[CURSOR_CHANGED] =
    g_signal_new ("cursor_changed",
Manish Singh's avatar
Manish Singh committed
829
830
831
832
833
834
		  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);
835

836
  tree_view_signals[MOVE_CURSOR] =
837
    g_signal_new ("move_cursor",
Manish Singh's avatar
Manish Singh committed
838
839
840
841
842
843
844
845
		  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);
846

847
848
  tree_view_signals[SELECT_ALL] =
    g_signal_new ("select_all",
Manish Singh's avatar
Manish Singh committed
849
850
851
852
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_all),
		  NULL, NULL,
853
854
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
855

856
857
858
  tree_view_signals[UNSELECT_ALL] =
    g_signal_new ("unselect_all",
		  G_TYPE_FROM_CLASS (object_class),
Manish Singh's avatar
Manish Singh committed
859
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
860
861
		  G_STRUCT_OFFSET (GtkTreeViewClass, unselect_all),
		  NULL, NULL,
862
863
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
864

865
  tree_view_signals[SELECT_CURSOR_ROW] =
866
    g_signal_new ("select_cursor_row",
Manish Singh's avatar
Manish Singh committed
867
868
869
870
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_row),
		  NULL, NULL,
871
872
		  _gtk_marshal_BOOLEAN__BOOLEAN,
		  G_TYPE_BOOLEAN, 1,
873
		  G_TYPE_BOOLEAN);
874

875
  tree_view_signals[TOGGLE_CURSOR_ROW] =
876
    g_signal_new ("toggle_cursor_row",
Manish Singh's avatar
Manish Singh committed
877
878
879
880
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, toggle_cursor_row),
		  NULL, NULL,
881
882
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
883

884
  tree_view_signals[EXPAND_COLLAPSE_CURSOR_ROW] =
885
    g_signal_new ("expand_collapse_cursor_row",
Manish Singh's avatar
Manish Singh committed
886
887
888
889
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, expand_collapse_cursor_row),
		  NULL, NULL,
890
891
		  _gtk_marshal_BOOLEAN__BOOLEAN_BOOLEAN_BOOLEAN,
		  G_TYPE_BOOLEAN, 3,
Manish Singh's avatar
Manish Singh committed
892
893
894
		  G_TYPE_BOOLEAN,
		  G_TYPE_BOOLEAN,
		  G_TYPE_BOOLEAN);
895

896
  tree_view_signals[SELECT_CURSOR_PARENT] =
897
    g_signal_new ("select_cursor_parent",
Manish Singh's avatar
Manish Singh committed
898
899
900
901
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_parent),
		  NULL, NULL,
902
903
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
904

905
906
  tree_view_signals[START_INTERACTIVE_SEARCH] =
    g_signal_new ("start_interactive_search",
Manish Singh's avatar
Manish Singh committed
907
908
909
910
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkTreeViewClass, start_interactive_search),
		  NULL, NULL,
911
912
		  _gtk_marshal_BOOLEAN__NONE,
		  G_TYPE_BOOLEAN, 0);
913

914
  /* Key bindings */
915
916
  gtk_tree_view_add_move_binding (binding_set, GDK_Up, 0,
				  GTK_MOVEMENT_DISPLAY_LINES, -1);
917
918
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Up, 0,
				  GTK_MOVEMENT_DISPLAY_LINES, -1);
919
920
921

  gtk_tree_view_add_move_binding (binding_set, GDK_Down, 0,
				  GTK_MOVEMENT_DISPLAY_LINES, 1);
922
923
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Down, 0,
				  GTK_MOVEMENT_DISPLAY_LINES, 1);
924
925
926
927
928
929
930
931
932

  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);
933
934
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Home, 0,
				  GTK_MOVEMENT_BUFFER_ENDS, -1);
935
936
937

  gtk_tree_view_add_move_binding (binding_set, GDK_End, 0,
				  GTK_MOVEMENT_BUFFER_ENDS, 1);
938
939
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_End, 0,
				  GTK_MOVEMENT_BUFFER_ENDS, 1);
940
941
942

  gtk_tree_view_add_move_binding (binding_set, GDK_Page_Up, 0,
				  GTK_MOVEMENT_PAGES, -1);
943
944
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Page_Up, 0,
				  GTK_MOVEMENT_PAGES, -1);
945
946
947

  gtk_tree_view_add_move_binding (binding_set, GDK_Page_Down, 0,
				  GTK_MOVEMENT_PAGES, 1);
948
949
950
  gtk_tree_view_add_move_binding (binding_set, GDK_KP_Page_Down, 0,
				  GTK_MOVEMENT_PAGES, 1);

951

952
  gtk_binding_entry_add_signal (binding_set, GDK_Right, 0, "move_cursor", 2,
Manish Singh's avatar
Manish Singh committed
953
954
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, 1);
955

956
  gtk_binding_entry_add_signal (binding_set, GDK_Left, 0, "move_cursor", 2,
Manish Singh's avatar
Manish Singh committed
957
958
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, -1);
959

960
961
962
963
964
965
966
967
968
969
  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
970
971
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, 1);
972

973
974
975
976
977
978
979
980
981
982
983
984
  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
985
986
				G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
				G_TYPE_INT, -1);
987

988
989
  gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_CONTROL_MASK, "toggle_cursor_row", 0);

990
  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK, "select_all", 0);
991
992
993
994
  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);
995

996
  gtk_binding_entry_add_signal (binding_set, GDK_space, GDK_SHIFT_MASK, "select_cursor_row", 1,
Manish Singh's avatar
Manish Singh committed
997
				G_TYPE_BOOLEAN, TRUE);
998
999

  gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "select_cursor_row", 1,
Manish Singh's avatar
Manish Singh committed
1000
				G_TYPE_BOOLEAN, TRUE);
1001
1002
1003
1004
1005
1006
  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);
1007

1008
1009
  /* expand and collapse rows */
  gtk_binding_entry_add_signal (binding_set, GDK_plus, 0, "expand_collapse_cursor_row", 3,
1010
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1011
1012
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, FALSE);
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035

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

1036
1037
  /* Not doable on US keyboards */
  gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
1038
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1039
1040
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
1041
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, 0, "expand_collapse_cursor_row", 3,
1042
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1043
1044
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, FALSE);
1045
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
1046
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1047
1048
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
1049
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
1050
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1051
1052
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
1053
1054
  gtk_binding_entry_add_signal (binding_set, GDK_Right, GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
1055
				G_TYPE_BOOLEAN, FALSE,
Manish Singh's avatar
Manish Singh committed
1056
1057
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
1058
1059
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
1060
				G_TYPE_BOOLEAN, FALSE,
1061
1062
1063
1064
1065
				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,
1066
				G_TYPE_BOOLEAN, FALSE,
1067
1068
1069
1070
1071
				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,
1072
				G_TYPE_BOOLEAN, FALSE,
1073
1074
				G_TYPE_BOOLEAN, TRUE,
				G_TYPE_BOOLEAN, TRUE);
1075
1076

  gtk_binding_entry_add_signal (binding_set, GDK_minus, 0, "expand_collapse_cursor_row", 3,
1077
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1078
1079
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE);
1080
  gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
1081
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1082
1083
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
1084
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Subtract, 0, "expand_collapse_cursor_row", 3,
1085
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1086
1087
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE);
1088
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Subtract, GDK_SHIFT_MASK, "expand_collapse_cursor_row", 3,
1089
				G_TYPE_BOOLEAN, TRUE,
Manish Singh's avatar
Manish Singh committed
1090
1091
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
  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
1105
1106
1107
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
1108
1109
1110
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Left,
                                GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                                "expand_collapse_cursor_row", 3,
1111
1112
1113
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, FALSE,
				G_TYPE_BOOLEAN, TRUE);
1114
1115
1116

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