gtklist.c 61.7 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Elliot Lee's avatar
Elliot Lee committed
2 3 4
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
6 7 8 9 10
 * 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
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
12
 * Lesser General Public License for more details.
Elliot Lee's avatar
Elliot Lee committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15 16 17
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
18
 */
19 20

/*
21
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22 23 24 25 26
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 */

27
#include "config.h"
28 29
#include <string.h> /* memset */

30 31 32
#undef GTK_DISABLE_DEPRECATED
#define __GTK_LIST_C__

Elliot Lee's avatar
Elliot Lee committed
33 34 35 36
#include "gtklist.h"
#include "gtklistitem.h"
#include "gtkmain.h"
#include "gtksignal.h"
37
#include "gtklabel.h"
38
#include "gtkmarshalers.h"
39
#include "gtkintl.h"
40

41
#include "gtkalias.h"
Elliot Lee's avatar
Elliot Lee committed
42 43 44 45 46 47 48 49

enum {
  SELECTION_CHANGED,
  SELECT_CHILD,
  UNSELECT_CHILD,
  LAST_SIGNAL
};

50 51 52 53 54
enum {
  ARG_0,
  ARG_SELECTION_MODE
};

55 56
#define SCROLL_TIME  100

57
/*** GtkList Methods ***/
58 59
static void gtk_list_class_init	     (GtkListClass   *klass);
static void gtk_list_init	     (GtkList	     *list);
60 61 62 63 64 65
static void gtk_list_set_arg         (GtkObject      *object,
				      GtkArg         *arg,
				      guint           arg_id);
static void gtk_list_get_arg         (GtkObject      *object,
				      GtkArg         *arg,
				      guint           arg_id);
66
/*** GtkObject Methods ***/
Tim Janik's avatar
Tim Janik committed
67
static void gtk_list_dispose	     (GObject	     *object);
68

69
/*** GtkWidget Methods ***/
70 71 72 73 74
static void gtk_list_size_request    (GtkWidget	     *widget,
				      GtkRequisition *requisition);
static void gtk_list_size_allocate   (GtkWidget	     *widget,
				      GtkAllocation  *allocation);
static void gtk_list_realize	     (GtkWidget	     *widget);
75
static void gtk_list_unmap	     (GtkWidget	     *widget);
76 77
static void gtk_list_style_set	     (GtkWidget      *widget,
				      GtkStyle       *previous_style);
78 79
static gint gtk_list_motion_notify   (GtkWidget      *widget,
				      GdkEventMotion *event);
Elliot Lee's avatar
Elliot Lee committed
80 81
static gint gtk_list_button_press    (GtkWidget      *widget,
				      GdkEventButton *event);
82
static gint gtk_list_button_release  (GtkWidget	     *widget,
Elliot Lee's avatar
Elliot Lee committed
83
				      GdkEventButton *event);
84

85 86 87
static gboolean gtk_list_focus       (GtkWidget        *widget,
                                      GtkDirectionType  direction);

88
/*** GtkContainer Methods ***/
89 90 91 92 93 94 95 96 97 98 99 100
static void gtk_list_add	     (GtkContainer     *container,
				      GtkWidget        *widget);
static void gtk_list_remove	     (GtkContainer     *container,
				      GtkWidget        *widget);
static void gtk_list_forall	     (GtkContainer     *container,
				      gboolean          include_internals,
				      GtkCallback       callback,
				      gpointer          callback_data);
static GtkType gtk_list_child_type   (GtkContainer     *container);
static void gtk_list_set_focus_child (GtkContainer     *container,
				      GtkWidget        *widget);

101
/*** GtkList Private Functions ***/
102 103 104 105 106 107 108 109 110
static void gtk_list_move_focus_child      (GtkList       *list,
					    GtkScrollType  scroll_type,
					    gfloat         position);
static gint gtk_list_horizontal_timeout    (GtkWidget     *list);
static gint gtk_list_vertical_timeout      (GtkWidget     *list);
static void gtk_list_remove_items_internal (GtkList       *list,
					    GList         *items,
					    gboolean       no_unref);

111
/*** GtkList Selection Methods ***/
112 113 114 115 116
static void gtk_real_list_select_child	        (GtkList   *list,
						 GtkWidget *child);
static void gtk_real_list_unselect_child        (GtkList   *list,
						 GtkWidget *child);

117
/*** GtkList Selection Functions ***/
118 119 120 121 122 123 124 125 126 127
static void gtk_list_set_anchor                 (GtkList   *list,
					         gboolean   add_mode,
					         gint       anchor,
					         GtkWidget *undo_focus_child);
static void gtk_list_fake_unselect_all          (GtkList   *list,
			                         GtkWidget *item);
static void gtk_list_fake_toggle_row            (GtkList   *list,
					         GtkWidget *item);
static void gtk_list_update_extended_selection  (GtkList   *list,
					         gint       row);
128
static void gtk_list_reset_extended_selection   (GtkList   *list);
129

130
/*** GtkListItem Signal Functions ***/
131 132 133
static void gtk_list_signal_drag_begin         (GtkWidget      *widget,
						GdkDragContext *context,
						GtkList        *list);
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
static void gtk_list_signal_toggle_focus_row   (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_select_all         (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_unselect_all       (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_undo_selection     (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_start_selection    (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_end_selection      (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_extend_selection   (GtkListItem   *list_item,
						GtkScrollType  scroll_type,
						gfloat         position,
						gboolean       auto_start_selection,
						GtkList       *list);
static void gtk_list_signal_scroll_horizontal  (GtkListItem   *list_item,
						GtkScrollType  scroll_type,
						gfloat         position,
						GtkList       *list);
static void gtk_list_signal_scroll_vertical    (GtkListItem   *list_item,
						GtkScrollType  scroll_type,
						gfloat         position,
						GtkList       *list);
static void gtk_list_signal_toggle_add_mode    (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_item_select        (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_item_deselect      (GtkListItem   *list_item,
						GtkList       *list);
static void gtk_list_signal_item_toggle        (GtkListItem   *list_item,
						GtkList       *list);
Elliot Lee's avatar
Elliot Lee committed
167 168


169 170 171 172
static void gtk_list_drag_begin (GtkWidget      *widget,
				 GdkDragContext *context);


Elliot Lee's avatar
Elliot Lee committed
173
static GtkContainerClass *parent_class = NULL;
174
static guint list_signals[LAST_SIGNAL] = { 0 };
Elliot Lee's avatar
Elliot Lee committed
175

176
static const gchar vadjustment_key[] = "gtk-vadjustment";
177
static guint        vadjustment_key_id = 0;
178
static const gchar hadjustment_key[] = "gtk-hadjustment";
179
static guint        hadjustment_key_id = 0;
Elliot Lee's avatar
Elliot Lee committed
180

181
GtkType
182
gtk_list_get_type (void)
Elliot Lee's avatar
Elliot Lee committed
183
{
184
  static GtkType list_type = 0;
Elliot Lee's avatar
Elliot Lee committed
185 186 187

  if (!list_type)
    {
188
      static const GtkTypeInfo list_info =
Elliot Lee's avatar
Elliot Lee committed
189 190 191 192 193 194
      {
	"GtkList",
	sizeof (GtkList),
	sizeof (GtkListClass),
	(GtkClassInitFunc) gtk_list_class_init,
	(GtkObjectInitFunc) gtk_list_init,
195 196
	/* reserved_1 */ NULL,
	/* reserved_2 */ NULL,
197
        (GtkClassInitFunc) NULL,
Elliot Lee's avatar
Elliot Lee committed
198 199
      };

200
      I_("GtkList");
201
      list_type = gtk_type_unique (GTK_TYPE_CONTAINER, &list_info);
Elliot Lee's avatar
Elliot Lee committed
202 203 204 205 206 207 208 209
    }

  return list_type;
}

static void
gtk_list_class_init (GtkListClass *class)
{
210
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
Elliot Lee's avatar
Elliot Lee committed
211 212 213 214 215 216 217 218
  GtkObjectClass *object_class;
  GtkWidgetClass *widget_class;
  GtkContainerClass *container_class;

  object_class = (GtkObjectClass*) class;
  widget_class = (GtkWidgetClass*) class;
  container_class = (GtkContainerClass*) class;

219
  parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
Elliot Lee's avatar
Elliot Lee committed
220

221 222 223
  vadjustment_key_id = g_quark_from_static_string (vadjustment_key);
  hadjustment_key_id = g_quark_from_static_string (hadjustment_key);

Tim Janik's avatar
Tim Janik committed
224
  gobject_class->dispose = gtk_list_dispose;
225

Elliot Lee's avatar
Elliot Lee committed
226

227 228
  object_class->set_arg = gtk_list_set_arg;
  object_class->get_arg = gtk_list_get_arg;
Elliot Lee's avatar
Elliot Lee committed
229 230

  widget_class->unmap = gtk_list_unmap;
231
  widget_class->style_set = gtk_list_style_set;
Elliot Lee's avatar
Elliot Lee committed
232 233 234
  widget_class->realize = gtk_list_realize;
  widget_class->button_press_event = gtk_list_button_press;
  widget_class->button_release_event = gtk_list_button_release;
235
  widget_class->motion_notify_event = gtk_list_motion_notify;
Elliot Lee's avatar
Elliot Lee committed
236 237
  widget_class->size_request = gtk_list_size_request;
  widget_class->size_allocate = gtk_list_size_allocate;
238
  widget_class->drag_begin = gtk_list_drag_begin;
239 240
  widget_class->focus = gtk_list_focus;
  
Elliot Lee's avatar
Elliot Lee committed
241 242
  container_class->add = gtk_list_add;
  container_class->remove = gtk_list_remove;
243
  container_class->forall = gtk_list_forall;
244
  container_class->child_type = gtk_list_child_type;
245
  container_class->set_focus_child = gtk_list_set_focus_child;
Elliot Lee's avatar
Elliot Lee committed
246 247 248 249

  class->selection_changed = NULL;
  class->select_child = gtk_real_list_select_child;
  class->unselect_child = gtk_real_list_unselect_child;
250 251

  list_signals[SELECTION_CHANGED] =
252
    gtk_signal_new (I_("selection-changed"),
253 254 255
		    GTK_RUN_FIRST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GtkListClass, selection_changed),
256
		    _gtk_marshal_VOID__VOID,
257 258
		    GTK_TYPE_NONE, 0);
  list_signals[SELECT_CHILD] =
259
    gtk_signal_new (I_("select-child"),
260 261 262
		    GTK_RUN_FIRST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GtkListClass, select_child),
263
		    _gtk_marshal_VOID__OBJECT,
264 265 266
		    GTK_TYPE_NONE, 1,
		    GTK_TYPE_WIDGET);
  list_signals[UNSELECT_CHILD] =
267
    gtk_signal_new (I_("unselect-child"),
268 269 270
		    GTK_RUN_FIRST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GtkListClass, unselect_child),
271
		    _gtk_marshal_VOID__OBJECT,
272 273
		    GTK_TYPE_NONE, 1,
		    GTK_TYPE_WIDGET);
274
  
275 276 277
  gtk_object_add_arg_type ("GtkList::selection-mode",
			   GTK_TYPE_SELECTION_MODE, 
			   GTK_ARG_READWRITE | G_PARAM_STATIC_NAME,
278
			   ARG_SELECTION_MODE);
Elliot Lee's avatar
Elliot Lee committed
279 280 281 282 283 284 285
}

static void
gtk_list_init (GtkList *list)
{
  list->children = NULL;
  list->selection = NULL;
286 287 288 289 290 291 292 293 294 295 296 297 298 299

  list->undo_selection = NULL;
  list->undo_unselection = NULL;

  list->last_focus_child = NULL;
  list->undo_focus_child = NULL;

  list->htimer = 0;
  list->vtimer = 0;

  list->anchor = -1;
  list->drag_pos = -1;
  list->anchor_state = GTK_STATE_SELECTED;

Elliot Lee's avatar
Elliot Lee committed
300
  list->selection_mode = GTK_SELECTION_SINGLE;
301 302
  list->drag_selection = FALSE;
  list->add_mode = FALSE;
Elliot Lee's avatar
Elliot Lee committed
303 304
}

305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
static void
gtk_list_set_arg (GtkObject      *object,
		  GtkArg         *arg,
		  guint           arg_id)
{
  GtkList *list = GTK_LIST (object);
  
  switch (arg_id)
    {
    case ARG_SELECTION_MODE:
      gtk_list_set_selection_mode (list, GTK_VALUE_ENUM (*arg));
      break;
    }
}

static void
gtk_list_get_arg (GtkObject      *object,
		  GtkArg         *arg,
		  guint           arg_id)
{
  GtkList *list = GTK_LIST (object);
  
  switch (arg_id)
    {
    case ARG_SELECTION_MODE: 
      GTK_VALUE_ENUM (*arg) = list->selection_mode; 
      break;
    default:
      arg->type = GTK_TYPE_INVALID;
      break;
    }
}

Elliot Lee's avatar
Elliot Lee committed
338
GtkWidget*
339
gtk_list_new (void)
Elliot Lee's avatar
Elliot Lee committed
340
{
341
  return GTK_WIDGET (gtk_type_new (GTK_TYPE_LIST));
Elliot Lee's avatar
Elliot Lee committed
342 343
}

344 345 346

/* Private GtkObject Methods :
 * 
Tim Janik's avatar
Tim Janik committed
347
 * gtk_list_dispose
348
 */
349
static void
Tim Janik's avatar
Tim Janik committed
350
gtk_list_dispose (GObject *object)
351 352
{
  gtk_list_clear_items (GTK_LIST (object), 0, -1);
353

Tim Janik's avatar
Tim Janik committed
354
  G_OBJECT_CLASS (parent_class)->dispose (object);
355 356
}

357 358 359 360 361 362 363 364 365 366 367

/* Private GtkWidget Methods :
 * 
 * gtk_list_size_request
 * gtk_list_size_allocate
 * gtk_list_realize
 * gtk_list_unmap
 * gtk_list_motion_notify
 * gtk_list_button_press
 * gtk_list_button_release
 */
368
static void
369 370
gtk_list_size_request (GtkWidget      *widget,
		       GtkRequisition *requisition)
371
{
372
  GtkList *list = GTK_LIST (widget);
373 374
  GtkWidget *child;
  GList *children;
375

376 377
  requisition->width = 0;
  requisition->height = 0;
378

379 380
  children = list->children;
  while (children)
381
    {
382 383
      child = children->data;
      children = children->next;
384

385 386
      if (GTK_WIDGET_VISIBLE (child))
	{
387 388 389
	  GtkRequisition child_requisition;
	  
	  gtk_widget_size_request (child, &child_requisition);
390

391
	  requisition->width = MAX (requisition->width,
392 393
				    child_requisition.width);
	  requisition->height += child_requisition.height;
394 395
	}
    }
396

397 398
  requisition->width += GTK_CONTAINER (list)->border_width * 2;
  requisition->height += GTK_CONTAINER (list)->border_width * 2;
399

400 401
  requisition->width = MAX (requisition->width, 1);
  requisition->height = MAX (requisition->height, 1);
402 403
}

404 405 406
static void
gtk_list_size_allocate (GtkWidget     *widget,
			GtkAllocation *allocation)
Elliot Lee's avatar
Elliot Lee committed
407
{
408
  GtkList *list = GTK_LIST (widget);
409 410 411
  GtkWidget *child;
  GtkAllocation child_allocation;
  GList *children;
Elliot Lee's avatar
Elliot Lee committed
412

413 414 415 416 417
  widget->allocation = *allocation;
  if (GTK_WIDGET_REALIZED (widget))
    gdk_window_move_resize (widget->window,
			    allocation->x, allocation->y,
			    allocation->width, allocation->height);
418

419
  if (list->children)
Elliot Lee's avatar
Elliot Lee committed
420
    {
421 422
      child_allocation.x = GTK_CONTAINER (list)->border_width;
      child_allocation.y = GTK_CONTAINER (list)->border_width;
423
      child_allocation.width = MAX (1, (gint)allocation->width -
424
				    child_allocation.x * 2);
Elliot Lee's avatar
Elliot Lee committed
425

426
      children = list->children;
Elliot Lee's avatar
Elliot Lee committed
427

428
      while (children)
Elliot Lee's avatar
Elliot Lee committed
429
	{
430 431
	  child = children->data;
	  children = children->next;
Elliot Lee's avatar
Elliot Lee committed
432

433 434
	  if (GTK_WIDGET_VISIBLE (child))
	    {
435 436 437 438
	      GtkRequisition child_requisition;
	      gtk_widget_get_child_requisition (child, &child_requisition);
	      
	      child_allocation.height = child_requisition.height;
Elliot Lee's avatar
Elliot Lee committed
439

440
	      gtk_widget_size_allocate (child, &child_allocation);
Elliot Lee's avatar
Elliot Lee committed
441

442 443
	      child_allocation.y += child_allocation.height;
	    }
Elliot Lee's avatar
Elliot Lee committed
444 445
	}
    }
446
}
Elliot Lee's avatar
Elliot Lee committed
447

448 449 450 451 452
static void
gtk_list_realize (GtkWidget *widget)
{
  GdkWindowAttr attributes;
  gint attributes_mask;
Elliot Lee's avatar
Elliot Lee committed
453

454
  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
Elliot Lee's avatar
Elliot Lee committed
455

456 457 458 459 460 461 462 463 464
  attributes.window_type = GDK_WINDOW_CHILD;
  attributes.x = widget->allocation.x;
  attributes.y = widget->allocation.y;
  attributes.width = widget->allocation.width;
  attributes.height = widget->allocation.height;
  attributes.wclass = GDK_INPUT_OUTPUT;
  attributes.visual = gtk_widget_get_visual (widget);
  attributes.colormap = gtk_widget_get_colormap (widget);
  attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
Elliot Lee's avatar
Elliot Lee committed
465

466
  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
Elliot Lee's avatar
Elliot Lee committed
467

468 469 470
  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
				   &attributes, attributes_mask);
  gdk_window_set_user_data (widget->window, widget);
Elliot Lee's avatar
Elliot Lee committed
471

472 473 474
  widget->style = gtk_style_attach (widget->style, widget->window);
  gdk_window_set_background (widget->window, 
			     &widget->style->base[GTK_STATE_NORMAL]);
Elliot Lee's avatar
Elliot Lee committed
475 476
}

477 478 479 480 481 482 483 484
static gboolean
list_has_grab (GtkList *list)
{
  return (GTK_WIDGET_HAS_GRAB (list) &&
	  gdk_display_pointer_is_grabbed (gtk_widget_get_display (GTK_WIDGET (list))));
	  
}

485 486
static void
gtk_list_unmap (GtkWidget *widget)
487
{
488
  GtkList *list = GTK_LIST (widget);
489

490 491 492
  if (!GTK_WIDGET_MAPPED (widget))
    return;

493
  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
494

495
  if (list_has_grab (list))
496 497 498
    {
      gtk_list_end_drag_selection (list);

499
      if (list->anchor != -1 && list->selection_mode == GTK_SELECTION_MULTIPLE)
500 501 502
	gtk_list_end_selection (list);
    }

503
  gdk_window_hide (widget->window);
504 505
}

506 507 508
static gint
gtk_list_motion_notify (GtkWidget      *widget,
			GdkEventMotion *event)
Elliot Lee's avatar
Elliot Lee committed
509
{
510
  GtkList *list = GTK_LIST (widget);
511 512 513 514 515 516 517 518 519
  GtkWidget *item = NULL;
  GtkAdjustment *adj;
  GtkContainer *container;
  GList *work;
  gint x;
  gint y;
  gint row = -1;
  gint focus_row = 0;
  gint length = 0;
520

521 522
  if (!list->drag_selection || !list->children)
    return FALSE;
Elliot Lee's avatar
Elliot Lee committed
523

524
  container = GTK_CONTAINER (widget);
525

526 527
  if (event->is_hint || event->window != widget->window)
    gdk_window_get_pointer (widget->window, &x, &y, NULL);
528 529 530 531 532
  else
    {
      x = event->x;
      y = event->y;
    }
Elliot Lee's avatar
Elliot Lee committed
533

534
  adj = gtk_object_get_data_by_id (GTK_OBJECT (list), hadjustment_key_id);
Elliot Lee's avatar
Elliot Lee committed
535

536 537 538 539 540
  /* horizontal autoscrolling */
  if (adj && widget->allocation.width > adj->page_size &&
      (x < adj->value || x >= adj->value + adj->page_size))
    {
      if (list->htimer == 0)
Elliot Lee's avatar
Elliot Lee committed
541
	{
542
	  list->htimer = gdk_threads_add_timeout
543
	    (SCROLL_TIME, (GSourceFunc) gtk_list_horizontal_timeout, widget);
544 545 546 547
	  
	  if (!((x < adj->value && adj->value <= 0) ||
		(x > adj->value + adj->page_size &&
		 adj->value >= adj->upper - adj->page_size)))
Elliot Lee's avatar
Elliot Lee committed
548
	    {
549
	      gdouble value;
Elliot Lee's avatar
Elliot Lee committed
550

551 552 553 554
	      if (x < adj->value)
		value = adj->value + (x - adj->value) / 2 - 1;
	      else
		value = adj->value + 1 + (x - adj->value - adj->page_size) / 2;
Elliot Lee's avatar
Elliot Lee committed
555

556 557 558 559 560 561 562 563
	      gtk_adjustment_set_value (adj,
					CLAMP (value, 0.0,
					       adj->upper - adj->page_size));
	    }
	}
      else
	return FALSE;
    }
Tim Janik's avatar
Tim Janik committed
564

565 566 567 568 569
  
  /* vertical autoscrolling */
  for (work = list->children; work; length++, work = work->next)
    {
      if (row < 0)
Elliot Lee's avatar
Elliot Lee committed
570
	{
571 572 573 574 575
	  item = GTK_WIDGET (work->data);
	  if (item->allocation.y > y || 
	      (item->allocation.y <= y &&
	       item->allocation.y + item->allocation.height > y))
	    row = length;
Elliot Lee's avatar
Elliot Lee committed
576 577
	}

578 579
      if (work->data == container->focus_child)
	focus_row = length;
Elliot Lee's avatar
Elliot Lee committed
580
    }
581 582 583
  
  if (row < 0)
    row = length - 1;
Elliot Lee's avatar
Elliot Lee committed
584

585 586
  if (list->vtimer != 0)
    return FALSE;
Elliot Lee's avatar
Elliot Lee committed
587

588 589
  if (!((y < 0 && focus_row == 0) ||
	(y > widget->allocation.height && focus_row >= length - 1)))
590
    list->vtimer = gdk_threads_add_timeout (SCROLL_TIME,
591
				  (GSourceFunc) gtk_list_vertical_timeout,
592
				  list);
Elliot Lee's avatar
Elliot Lee committed
593

594 595
  if (row != focus_row)
    gtk_widget_grab_focus (item);
596

597 598 599 600 601
  switch (list->selection_mode)
    {
    case GTK_SELECTION_BROWSE:
      gtk_list_select_child (list, item);
      break;
602
    case GTK_SELECTION_MULTIPLE:
603 604 605 606 607
      gtk_list_update_extended_selection (list, row);
      break;
    default:
      break;
    }
Elliot Lee's avatar
Elliot Lee committed
608

609
  return FALSE;
Elliot Lee's avatar
Elliot Lee committed
610 611
}

612 613 614
static gint
gtk_list_button_press (GtkWidget      *widget,
		       GdkEventButton *event)
Elliot Lee's avatar
Elliot Lee committed
615
{
616
  GtkList *list = GTK_LIST (widget);
617
  GtkWidget *item;
Elliot Lee's avatar
Elliot Lee committed
618

619 620
  if (event->button != 1)
    return FALSE;
Elliot Lee's avatar
Elliot Lee committed
621

622
  item = gtk_get_event_widget ((GdkEvent*) event);
Elliot Lee's avatar
Elliot Lee committed
623

624 625
  while (item && !GTK_IS_LIST_ITEM (item))
    item = item->parent;
Elliot Lee's avatar
Elliot Lee committed
626

627
  if (item && (item->parent == widget))
Elliot Lee's avatar
Elliot Lee committed
628
    {
629 630
      gint last_focus_row;
      gint focus_row;
Elliot Lee's avatar
Elliot Lee committed
631

632 633 634
      if (event->type == GDK_BUTTON_PRESS)
	{
	  gtk_grab_add (widget);
635
	  list->drag_selection = TRUE;
636
	}
637
      else if (list_has_grab (list))
638 639 640 641
	gtk_list_end_drag_selection (list);
	  
      if (!GTK_WIDGET_HAS_FOCUS(item))
	gtk_widget_grab_focus (item);
Elliot Lee's avatar
Elliot Lee committed
642

643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
      if (list->add_mode)
	{
	  list->add_mode = FALSE;
	  gtk_widget_queue_draw (item);
	}
      
      switch (list->selection_mode)
	{
	case GTK_SELECTION_SINGLE:
	  if (event->type != GDK_BUTTON_PRESS)
	    gtk_list_select_child (list, item);
	  else
	    list->undo_focus_child = item;
	  break;
	  
	case GTK_SELECTION_BROWSE:
	  break;
Elliot Lee's avatar
Elliot Lee committed
660

661
	case GTK_SELECTION_MULTIPLE:
662
	  focus_row = g_list_index (list->children, item);
Elliot Lee's avatar
Elliot Lee committed
663

664 665 666 667 668 669 670 671
	  if (list->last_focus_child)
	    last_focus_row = g_list_index (list->children,
					   list->last_focus_child);
	  else
	    {
	      last_focus_row = focus_row;
	      list->last_focus_child = item;
	    }
672

673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
	  if (event->type != GDK_BUTTON_PRESS)
	    {
	      if (list->anchor >= 0)
		{
		  gtk_list_update_extended_selection (list, focus_row);
		  gtk_list_end_selection (list);
		}
	      gtk_list_select_child (list, item);
	      break;
	    }
	      
	  if (event->state & GDK_CONTROL_MASK)
	    {
	      if (event->state & GDK_SHIFT_MASK)
		{
		  if (list->anchor < 0)
		    {
		      g_list_free (list->undo_selection);
		      g_list_free (list->undo_unselection);
		      list->undo_selection = NULL;
		      list->undo_unselection = NULL;
694

695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
		      list->anchor = last_focus_row;
		      list->drag_pos = last_focus_row;
		      list->undo_focus_child = list->last_focus_child;
		    }
		  gtk_list_update_extended_selection (list, focus_row);
		}
	      else
		{
		  if (list->anchor < 0)
		    gtk_list_set_anchor (list, TRUE,
					 focus_row, list->last_focus_child);
		  else
		    gtk_list_update_extended_selection (list, focus_row);
		}
	      break;
	    }
711

712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
	  if (event->state & GDK_SHIFT_MASK)
	    {
	      gtk_list_set_anchor (list, FALSE,
				   last_focus_row, list->last_focus_child);
	      gtk_list_update_extended_selection (list, focus_row);
	      break;
	    }

	  if (list->anchor < 0)
	    gtk_list_set_anchor (list, FALSE, focus_row,
				 list->last_focus_child);
	  else
	    gtk_list_update_extended_selection (list, focus_row);
	  break;
	  
	default:
	  break;
	}
730 731

      return TRUE;
732
    }
Elliot Lee's avatar
Elliot Lee committed
733

734 735
  return FALSE;
}
Elliot Lee's avatar
Elliot Lee committed
736

737 738 739
static gint
gtk_list_button_release (GtkWidget	*widget,
			 GdkEventButton *event)
Elliot Lee's avatar
Elliot Lee committed
740
{
741
  GtkList *list = GTK_LIST (widget);
742
  GtkWidget *item;
Elliot Lee's avatar
Elliot Lee committed
743

744 745 746
  /* we don't handle button 2 and 3 */
  if (event->button != 1)
    return FALSE;
Elliot Lee's avatar
Elliot Lee committed
747

748
  if (list->drag_selection)
Elliot Lee's avatar
Elliot Lee committed
749
    {
750
      gtk_list_end_drag_selection (list);
Elliot Lee's avatar
Elliot Lee committed
751

752 753
      switch (list->selection_mode)
	{
754
	case GTK_SELECTION_MULTIPLE:
755 756 757
 	  if (!(event->state & GDK_SHIFT_MASK))
	    gtk_list_end_selection (list);
	  break;
Elliot Lee's avatar
Elliot Lee committed
758

759
	case GTK_SELECTION_SINGLE:
Elliot Lee's avatar
Elliot Lee committed
760

761 762 763 764 765 766 767 768 769 770 771 772
	  item = gtk_get_event_widget ((GdkEvent*) event);
  
	  while (item && !GTK_IS_LIST_ITEM (item))
	    item = item->parent;
	  
	  if (item && item->parent == widget)
	    {
	      if (list->undo_focus_child == item)
		gtk_list_toggle_row (list, item);
	    }
	  list->undo_focus_child = NULL;
	  break;
Elliot Lee's avatar
Elliot Lee committed
773

774 775 776
	default:
	  break;
	}
777 778

      return TRUE;
779 780 781
    }
  
  return FALSE;
Elliot Lee's avatar
Elliot Lee committed
782 783
}

784 785 786 787 788 789 790
static void 
gtk_list_style_set	(GtkWidget      *widget,
			 GtkStyle       *previous_style)
{
  if (previous_style && GTK_WIDGET_REALIZED (widget))
    gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
}
791 792 793 794 795 796 797 798 799

/* GtkContainer Methods :
 * gtk_list_add
 * gtk_list_remove
 * gtk_list_forall
 * gtk_list_child_type
 * gtk_list_set_focus_child
 * gtk_list_focus
 */
800
static void
801 802
gtk_list_add (GtkContainer *container,
	      GtkWidget	   *widget)
803
{
804
  GList *item_list;
805

806
  g_return_if_fail (GTK_IS_LIST_ITEM (widget));
807

808 809 810 811
  item_list = g_list_alloc ();
  item_list->data = widget;
  
  gtk_list_append_items (GTK_LIST (container), item_list);
812 813
}

814 815 816
static void
gtk_list_remove (GtkContainer *container,
		 GtkWidget    *widget)
817
{
818
  GList *item_list;
819

820 821 822 823 824 825 826 827 828
  g_return_if_fail (container == GTK_CONTAINER (widget->parent));
  
  item_list = g_list_alloc ();
  item_list->data = widget;
  
  gtk_list_remove_items (GTK_LIST (container), item_list);
  
  g_list_free (item_list);
}
829

830 831 832 833 834
static void
gtk_list_forall (GtkContainer  *container,
		 gboolean       include_internals,
		 GtkCallback	callback,
		 gpointer	callback_data)
835
{
836
  GtkList *list = GTK_LIST (container);
837 838
  GtkWidget *child;
  GList *children;
839

840
  children = list->children;
841

842 843 844 845
  while (children)
    {
      child = children->data;
      children = children->next;
846

847 848 849
      (* callback) (child, callback_data);
    }
}
850

851 852 853 854
static GtkType
gtk_list_child_type (GtkContainer *container)
{
  return GTK_TYPE_LIST_ITEM;
855 856
}

857 858 859
static void
gtk_list_set_focus_child (GtkContainer *container,
			  GtkWidget    *child)
Elliot Lee's avatar
Elliot Lee committed
860
{
861
  GtkList *list;
862

863
  g_return_if_fail (GTK_IS_LIST (container));
864
 
865 866
  if (child)
    g_return_if_fail (GTK_IS_WIDGET (child));
867

868
  list = GTK_LIST (container);
869

870
  if (child != container->focus_child)
871
    {
872
      if (container->focus_child)
873 874
	{
	  list->last_focus_child = container->focus_child;
Michael Natterer's avatar
Michael Natterer committed
875
	  g_object_unref (container->focus_child);
876
	}
877 878
      container->focus_child = child;
      if (container->focus_child)
879
        g_object_ref (container->focus_child);
880 881
    }

882 883
  /* check for v adjustment */
  if (container->focus_child)
884
    {
885
      GtkAdjustment *adjustment;
886

887 888 889 890 891 892 893
      adjustment = gtk_object_get_data_by_id (GTK_OBJECT (container),
					      vadjustment_key_id);
      if (adjustment)
        gtk_adjustment_clamp_page (adjustment,
                                   container->focus_child->allocation.y,
                                   (container->focus_child->allocation.y +
                                    container->focus_child->allocation.height));
894 895 896 897 898
      switch (list->selection_mode)
	{
	case GTK_SELECTION_BROWSE:
	  gtk_list_select_child (list, child);
	  break;
899
	case GTK_SELECTION_MULTIPLE:
900 901 902 903 904 905 906 907 908 909
	  if (!list->last_focus_child && !list->add_mode)
	    {
	      list->undo_focus_child = list->last_focus_child;
	      gtk_list_unselect_all (list);
	      gtk_list_select_child (list, child);
	    }
	  break;
	default:
	  break;
	}
910
    }
Elliot Lee's avatar
Elliot Lee committed
911 912
}

913 914
static gboolean
gtk_list_focus (GtkWidget        *widget,
915
		GtkDirectionType  direction)
Elliot Lee's avatar
Elliot Lee committed
916
{
917
  gint return_val = FALSE;
918
  GtkContainer *container;
Elliot Lee's avatar
Elliot Lee committed
919

920 921
  container = GTK_CONTAINER (widget);
  
922
  if (container->focus_child == NULL ||
923 924
      !GTK_WIDGET_HAS_FOCUS (container->focus_child))
    {
925 926 927 928
      if (GTK_LIST (container)->last_focus_child)
	gtk_container_set_focus_child
	  (container, GTK_LIST (container)->last_focus_child);

929 930 931
      if (GTK_WIDGET_CLASS (parent_class)->focus)
	return_val = GTK_WIDGET_CLASS (parent_class)->focus (widget,
                                                             direction);
932
    }
933

934 935 936
  if (!return_val)
    {
      GtkList *list;
937

938
      list =  GTK_LIST (container);
939
      if (list->selection_mode == GTK_SELECTION_MULTIPLE && list->anchor >= 0)
940
	gtk_list_end_selection (list);
941 942 943

      if (container->focus_child)
	list->last_focus_child = container->focus_child;
944
    }
945

946 947
  return return_val;
}
Elliot Lee's avatar
Elliot Lee committed
948

949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976

/* Public GtkList Methods :
 *
 * gtk_list_insert_items
 * gtk_list_append_items
 * gtk_list_prepend_items
 * gtk_list_remove_items
 * gtk_list_remove_items_no_unref
 * gtk_list_clear_items
 *
 * gtk_list_child_position
 */
void
gtk_list_insert_items (GtkList *list,
		       GList   *items,
		       gint	position)
{
  GtkWidget *widget;
  GList *tmp_list;
  GList *last;
  gint nchildren;

  g_return_if_fail (GTK_IS_LIST (list));

  if (!items)
    return;

  gtk_list_end_drag_selection (list);
977
  if (list->selection_mode == GTK_SELECTION_MULTIPLE && list->anchor >= 0)
978 979 980 981
    gtk_list_end_selection (list);

  tmp_list = items;
  while (tmp_list)
982
    {
983 984
      widget = tmp_list->data;
      tmp_list = tmp_list->next;
985

986
      gtk_widget_set_parent (widget, GTK_WIDGET (list));
987
      gtk_signal_connect (GTK_OBJECT (widget), "drag-begin",
988
			  G_CALLBACK (gtk_list_signal_drag_begin),
989
			  list);
990
      gtk_signal_connect (GTK_OBJECT (widget), "toggle-focus-row",
991
			  G_CALLBACK (gtk_list_signal_toggle_focus_row),
992
			  list);
993
      gtk_signal_connect (GTK_OBJECT (widget), "select-all",
994
			  G_CALLBACK (gtk_list_signal_select_all),
995
			  list);
996
      gtk_signal_connect (GTK_OBJECT (widget), "unselect-all",
997
			  G_CALLBACK (gtk_list_signal_unselect_all),
998
			  list);
999
      gtk_signal_connect (GTK_OBJECT (widget), "undo-selection",
1000
			  G_CALLBACK (gtk_list_signal_undo_selection),
1001
			  list);
1002
      gtk_signal_connect (GTK_OBJECT (widget), "start-selection",
1003
			  G_CALLBACK (gtk_list_signal_start_selection),
1004
			  list);
1005
      gtk_signal_connect (GTK_OBJECT (widget), "end-selection",
1006
			  G_CALLBACK (gtk_list_signal_end_selection),
1007
			  list);
1008
      gtk_signal_connect (GTK_OBJECT (widget), "extend-selection",
1009
			  G_CALLBACK (gtk_list_signal_extend_selection),
1010
			  list);
1011
      gtk_signal_connect (GTK_OBJECT (widget), "scroll-horizontal",
1012
			  G_CALLBACK (gtk_list_signal_scroll_horizontal),
1013
			  list);
1014
      gtk_signal_connect (GTK_OBJECT (widget), "scroll-vertical",
1015
			  G_CALLBACK (gtk_list_signal_scroll_vertical),
1016
			  list);
1017
      gtk_signal_connect (GTK_OBJECT (widget), "toggle-add-mode",
1018
			  G_CALLBACK (gtk_list_signal_toggle_add_mode),
1019 1020
			  list);
      gtk_signal_connect (GTK_OBJECT (widget), "select",
1021
			  G_CALLBACK (gtk_list_signal_item_select),
1022 1023
			  list);
      gtk_signal_connect (GTK_OBJECT (widget), "deselect",
1024
			  G_CALLBACK (gtk_list_signal_item_deselect),
1025 1026
			  list);
      gtk_signal_connect (GTK_OBJECT (widget), "toggle",
1027
			  G_CALLBACK (gtk_list_signal_item_toggle),
1028 1029
			  list);
    }
1030

1031

1032 1033 1034 1035 1036 1037 1038
  nchildren = g_list_length (list->children);
  if ((position < 0) || (position > nchildren))
    position = nchildren;

  if (position == nchildren)
    {
      if (list->children)
1039
	{
1040 1041 1042
	  tmp_list = g_list_last (list->children);
	  tmp_list->next = items;
	  items->prev = tmp_list;
1043
	}
1044
      else
1045
	{
1046 1047 1048 1049 1050 1051 1052
	  list->children = items;
	}
    }
  else
    {
      tmp_list = g_list_nth (list->children, position);
      last = g_list_last (items);
1053

1054 1055 1056 1057 1058
      if (tmp_list->prev)
	tmp_list->prev->next = items;
      last->next = tmp_list;
      items->prev = tmp_list->prev;
      tmp_list->prev = last;
1059

1060 1061 1062
      if (tmp_list == list->children)
	list->children = items;
    }
1063
  
1064 1065 1066 1067 1068 1069 1070
  if (list->children && !list->selection &&
      (list->selection_mode == GTK_SELECTION_BROWSE))
    {
      widget = list->children->data;
      gtk_list_select_child (list, widget);
    }
}
1071

1072 1073 1074 1075 1076
void
gtk_list_append_items (GtkList *list,
		       GList   *items)
{
  g_return_if_fail (GTK_IS_LIST (list));
1077

1078 1079
  gtk_list_insert_items (list, items, -1);
}
1080

1081 1082 1083 1084 1085 1086 1087
void
gtk_list_prepend_items (GtkList *list,
			GList	*items)
{
  g_return_if_fail (GTK_IS_LIST (list));

  gtk_list_insert_items (list, items, 0);
Elliot Lee's avatar
Elliot Lee committed
1088 1089
}

1090 1091 1092
void
gtk_list_remove_items (GtkList	*list,
		       GList	*items)
Elliot Lee's avatar
Elliot Lee committed
1093
{
1094 1095
  gtk_list_remove_items_internal (list, items, FALSE);
}
Elliot Lee's avatar
Elliot Lee committed
1096

1097 1098 1099 1100 1101 1102
void
gtk_list_remove_items_no_unref (GtkList	 *list,
				GList	 *items)
{
  gtk_list_remove_items_internal (list, items, TRUE);
}
Elliot Lee's avatar
Elliot Lee committed
1103

1104 1105 1106 1107 1108
void
gtk_list_clear_items (GtkList *list,
		      gint     start,
		      gint     end)
{
1109
  GtkContainer *container;
1110
  GtkWidget *widget;
1111
  GtkWidget *new_focus_child = NULL;
1112 1113 1114 1115
  GList *start_list;
  GList *end_list;
  GList *tmp_list;
  guint nchildren;
1116
  gboolean grab_focus = FALSE;
Elliot Lee's avatar
Elliot Lee committed
1117

1118
  g_return_if_fail (GTK_IS_LIST (list));
1119

1120 1121
  nchildren = g_list_length (list->children);

1122 1123
  if (nchildren == 0)
    return;
1124

1125 1126
  if ((end < 0) || (end > nchildren))
    end = nchildren;
1127

1128 1129
  if (start >= end)
    return;
1130

1131
  container = GTK_CONTAINER (list);
1132

1133
  gtk_list_end_drag_selection (list);
1134
  if (list->selection_mode == GTK_SELECTION_MULTIPLE)
1135 1136
    {
      if (list->anchor >= 0)
1137
	gtk_list_end_selection (list);
1138

1139 1140
      gtk_list_reset_extended_selection (list);
    }
1141

1142 1143
  start_list = g_list_nth (list->children, start);
  end_list = g_list_nth (list->children, end);
1144

1145 1146 1147 1148 1149 1150 1151 1152
  if (start_list->prev)
    start_list->prev->next = end_list;
  if (end_list && end_list->prev)
    end_list->prev->next = NULL;
  if (end_list)
    end_list->prev = start_list->prev;
  if (start_list == list->children)
    list->children = end_list;
1153

1154 1155 1156 1157 1158 1159 1160
  if (container->focus_child)
    {
      if (g_list_find (start_list, container->focus_child))
	{
	  if (start_list->prev)
	    new_focus_child = start_list->prev->data;
	  else if (list->children)
1161
	    new_focus_child = list->children->data;
1162

1163 1164
	  if (GTK_WIDGET_HAS_FOCUS (container->focus_child))
	    grab_focus = TRUE;
1165
	}
1166 1167 1168 1169 1170 1171 1172 1173
    }

  tmp_list = start_list;
  while (tmp_list)
    {
      widget = tmp_list->data;
      tmp_list = tmp_list->next;

1174
      g_object_ref (widget);
1175

1176 1177 1178
      if (widget->state == GTK_STATE_SELECTED)
	gtk_list_unselect_child (list, widget);

1179 1180 1181
      gtk_signal_disconnect_by_data (GTK_OBJECT (widget), (gpointer) list);
      gtk_widget_unparent (widget);
      
1182 1183 1184 1185
      if (widget == list->undo_focus_child)
	list->undo_focus_child = NULL;
      if (widget == list->last_focus_child)
	list->last_focus_child = NULL;
1186

Michael Natterer's avatar
Michael Natterer committed
1187
      g_object_unref (widget);
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
    }

  g_list_free (start_list);

  if (new_focus_child)
    {
      if (grab_focus)
	gtk_widget_grab_focus (new_focus_child);
      else if (container->focus_child)
	gtk_container_set_focus_child (container, new_focus_child);
1198

1199
      if ((list->selection_mode == GTK_SELECTION_BROWSE ||
1200
	   list->selection_mode == GTK_SELECTION_MULTIPLE) && !list->selection)
1201
	{
1202 1203
	  list->last_focus_child = new_focus_child; 
	  gtk_list_select_child (list, new_focus_child);
1204 1205
	}
    }
1206 1207 1208

  if (GTK_WIDGET_VISIBLE (list))
    gtk_widget_queue_resize (GTK_WIDGET (list));
Elliot Lee's avatar
Elliot Lee committed
1209 1210
}

1211 1212 1213
gint
gtk_list_child_position (GtkList   *list,
			 GtkWidget *child)
Elliot Lee's avatar
Elliot Lee committed
1214 1215
{
  GList *children;
1216
  gint pos;
Elliot Lee's avatar
Elliot Lee committed
1217

1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261
  g_return_val_if_fail (GTK_IS_LIST (list), -1);
  g_return_val_if_fail (child != NULL, -1);

  pos = 0;
  children = list->children;

  while (children)
    {
      if (child == GTK_WIDGET (children->data))
	return pos;

      pos += 1;
      children = children->next;
    }

  return -1;
}


/* Private GtkList Insert/Remove Item Functions:
 *
 * gtk_list_remove_items_internal
 */
static void
gtk_list_remove_items_internal (GtkList	 *list,
				GList	 *items,
				gboolean  no_unref)
{
  GtkWidget *widget;
  GtkWidget *new_focus_child;
  GtkWidget *old_focus_child;
  GtkContainer *container;
  GList *tmp_list;
  GList *work;
  gboolean grab_focus = FALSE;
  
  g_return_if_fail (GTK_IS_LIST (list));

  if (!items)
    return;
  
  container = GTK_CONTAINER (list);

  gtk_list_end_drag_selection (list);
1262
  if (list->selection_mode == GTK_SELECTION_MULTIPLE)
1263 1264 1265 1266
    {
      if (list->anchor >= 0)
	gtk_list_end_selection (list);

1267
      gtk_list_reset_extended_selection (list);
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
    }

  tmp_list = items;
  while (tmp_list)
    {
      widget = tmp_list->data;
      tmp_list = tmp_list->next;
      
      if (widget->state == GTK_STATE_SELECTED)
	gtk_list_unselect_child (list, widget);
1278
    }
Elliot Lee's avatar
Elliot Lee committed
1279

1280 1281 1282 1283 1284
  if (container->focus_child)
    {
      old_focus_child = new_focus_child = container->focus_child;
      if (GTK_WIDGET_HAS_FOCUS (container->focus_child))
	grab_focus = TRUE;
1285
    }
1286 1287
  else
    old_focus_child = new_focus_child = list->last_focus_child;
Elliot Lee's avatar
Elliot Lee committed
1288