gtkpathbar.c 55 KB
Newer Older
1
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
2
/* gtkpathbar.c
3 4 5 6 7 8 9 10 11 12 13 14 15
 * Copyright (C) 2004  Red Hat, Inc.,  Jonathan Blandford <jrb@gnome.org>
 *
 * This library is free software; you can redistribute it and/or
 * 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
Javier Jardón's avatar
Javier Jardón committed
16
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 18
 */

19
#include "config.h"
20

21
#include "gtkpathbar.h"
22 23 24

#include <string.h>

25
#include "gtkbox.h"
26
#include "gtkcssnodeprivate.h"
27
#include "gtkdnd.h"
28
#include "gtkdragsource.h"
29
#include "gtkicontheme.h"
30 31
#include "gtkimage.h"
#include "gtkintl.h"
32
#include "gtklabel.h"
33 34
#include "gtkmain.h"
#include "gtkmarshalers.h"
35 36
#include "gtksettings.h"
#include "gtktogglebutton.h"
37
#include "gtkwidgetpath.h"
38
#include "gtkwidgetprivate.h"
39

40 41 42 43 44 45 46
struct _GtkPathBarPrivate
{
  GtkFileSystem *file_system;
  GFile *root_file;
  GFile *home_file;
  GFile *desktop_file;

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
  /* List of running GCancellable.  When we cancel one, we remove it from this list.
   * The pathbar cancels all outstanding cancellables when it is disposed.
   *
   * In code that queues async I/O operations:
   *
   *   - Obtain a cancellable from the async I/O APIs, and call add_cancellable().
   *
   * To cancel a cancellable:
   *
   *   - Call cancel_cancellable().
   *
   * In async I/O callbacks:
   *
   *   - Check right away if g_cancellable_is_cancelled():  if true, just
   *     g_object_unref() the cancellable and return early (also free your
   *     closure data if you have one).
   *
   *   - If it was not cancelled, call cancellable_async_done().  This will
   *     unref the cancellable and unqueue it from the pathbar's outstanding
   *     cancellables.  Do your normal work to process the async result and free
   *     your closure data if you have one.
   */
  GList *cancellables;

71 72
  GCancellable *get_info_cancellable;

73 74 75
  GIcon *root_icon;
  GIcon *home_icon;
  GIcon *desktop_icon;
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

  GdkWindow *event_window;

  GList *button_list;
  GList *first_scrolled_button;
  GList *fake_root;
  GtkWidget *up_slider_button;
  GtkWidget *down_slider_button;
  guint settings_signal_id;
  gint16 slider_width;
  gint16 button_offset;
  guint timer;
  guint slider_visible : 1;
  guint need_timer     : 1;
  guint ignore_click   : 1;
  guint scrolling_up   : 1;
  guint scrolling_down : 1;
};
94 95 96 97 98 99

enum {
  PATH_CLICKED,
  LAST_SIGNAL
};

100 101 102 103
typedef enum {
  NORMAL_BUTTON,
  ROOT_BUTTON,
  HOME_BUTTON,
104
  DESKTOP_BUTTON
105 106
} ButtonType;

107 108
#define BUTTON_DATA(x) ((ButtonData *)(x))

109
#define SCROLL_DELAY_FACTOR 5
110 111
#define TIMEOUT_INITIAL     500
#define TIMEOUT_REPEAT      50
112

113 114
static guint path_bar_signals [LAST_SIGNAL] = { 0 };

115
/* Icon size for if we can't get it from the theme */
116
#define FALLBACK_ICON_SIZE 16
117

118 119 120 121 122 123 124
typedef struct _ButtonData ButtonData;

struct _ButtonData
{
  GtkWidget *button;
  ButtonType type;
  char *dir_name;
125
  GFile *file;
126 127
  GtkWidget *image;
  GtkWidget *label;
128
  GCancellable *cancellable;
129 130
  guint ignore_changes : 1;
  guint file_is_hidden : 1;
131
};
132 133 134 135 136
/* This macro is used to check if a button can be used as a fake root.
 * All buttons in front of a fake root are automatically hidden when in a
 * directory below a fake root and replaced with the "<" arrow button.
 */
#define BUTTON_IS_FAKE_ROOT(button) ((button)->type == HOME_BUTTON)
137

138
G_DEFINE_TYPE_WITH_PRIVATE (GtkPathBar, gtk_path_bar, GTK_TYPE_CONTAINER)
139

140 141
static void gtk_path_bar_finalize                 (GObject          *object);
static void gtk_path_bar_dispose                  (GObject          *object);
142 143
static void gtk_path_bar_realize                  (GtkWidget        *widget);
static void gtk_path_bar_unrealize                (GtkWidget        *widget);
144 145 146 147 148 149
static void gtk_path_bar_get_preferred_width      (GtkWidget        *widget,
                                                   gint             *minimum,
                                                   gint             *natural);
static void gtk_path_bar_get_preferred_height     (GtkWidget        *widget,
                                                   gint             *minimum,
                                                   gint             *natural);
150 151
static void gtk_path_bar_map                      (GtkWidget        *widget);
static void gtk_path_bar_unmap                    (GtkWidget        *widget);
152 153 154 155 156 157 158 159 160 161
static void gtk_path_bar_size_allocate            (GtkWidget        *widget,
						   GtkAllocation    *allocation);
static void gtk_path_bar_add                      (GtkContainer     *container,
						   GtkWidget        *widget);
static void gtk_path_bar_remove                   (GtkContainer     *container,
						   GtkWidget        *widget);
static void gtk_path_bar_forall                   (GtkContainer     *container,
						   gboolean          include_internals,
						   GtkCallback       callback,
						   gpointer          callback_data);
162 163 164 165
static gboolean gtk_path_bar_scroll               (GtkWidget        *widget,
						   GdkEventScroll   *event);
static void gtk_path_bar_scroll_up                (GtkPathBar       *path_bar);
static void gtk_path_bar_scroll_down              (GtkPathBar       *path_bar);
166
static void gtk_path_bar_stop_scrolling           (GtkPathBar       *path_bar);
167 168 169 170 171 172
static gboolean gtk_path_bar_slider_up_defocus    (GtkWidget        *widget,
						   GdkEventButton   *event,
						   GtkPathBar       *path_bar);
static gboolean gtk_path_bar_slider_down_defocus  (GtkWidget        *widget,
						   GdkEventButton   *event,
						   GtkPathBar       *path_bar);
173 174 175 176 177 178 179 180 181 182
static gboolean gtk_path_bar_slider_button_press  (GtkWidget        *widget,
						   GdkEventButton   *event,
						   GtkPathBar       *path_bar);
static gboolean gtk_path_bar_slider_button_release(GtkWidget        *widget,
						   GdkEventButton   *event,
						   GtkPathBar       *path_bar);
static void gtk_path_bar_grab_notify              (GtkWidget        *widget,
						   gboolean          was_grabbed);
static void gtk_path_bar_state_changed            (GtkWidget        *widget,
						   GtkStateType      previous_state);
183
static void gtk_path_bar_style_updated            (GtkWidget        *widget);
184 185 186 187 188 189
static void gtk_path_bar_screen_changed           (GtkWidget        *widget,
						   GdkScreen        *previous_screen);
static void gtk_path_bar_check_icon_theme         (GtkPathBar       *path_bar);
static void gtk_path_bar_update_button_appearance (GtkPathBar       *path_bar,
						   ButtonData       *button_data,
						   gboolean          current_dir);
190

191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
static void
add_cancellable (GtkPathBar   *path_bar,
		 GCancellable *cancellable)
{
  g_assert (g_list_find (path_bar->priv->cancellables, cancellable) == NULL);
  path_bar->priv->cancellables = g_list_prepend (path_bar->priv->cancellables, cancellable);
}

static void
drop_node_for_cancellable (GtkPathBar *path_bar,
			   GCancellable *cancellable)
{
  GList *node;

  node = g_list_find (path_bar->priv->cancellables, cancellable);
  g_assert (node != NULL);
  node->data = NULL;
  path_bar->priv->cancellables = g_list_delete_link (path_bar->priv->cancellables, node);
}

static void
cancel_cancellable (GtkPathBar   *path_bar,
		    GCancellable *cancellable)
{
  drop_node_for_cancellable (path_bar, cancellable);
  g_cancellable_cancel (cancellable);
}

static void
cancellable_async_done (GtkPathBar   *path_bar,
			GCancellable *cancellable)
{
  drop_node_for_cancellable (path_bar, cancellable);
  g_object_unref (cancellable);
}

static void
cancel_all_cancellables (GtkPathBar *path_bar)
{
  while (path_bar->priv->cancellables)
    {
      GCancellable *cancellable = path_bar->priv->cancellables->data;
      cancel_cancellable (path_bar, cancellable);
    }
}

237 238 239 240
static void
on_slider_unmap (GtkWidget  *widget,
		 GtkPathBar *path_bar)
{
241 242 243
  if (path_bar->priv->timer &&
      ((widget == path_bar->priv->up_slider_button && path_bar->priv->scrolling_up) ||
       (widget == path_bar->priv->down_slider_button && path_bar->priv->scrolling_down)))
244
    gtk_path_bar_stop_scrolling (path_bar);
245 246
}

247 248
static void
gtk_path_bar_init (GtkPathBar *path_bar)
249
{
250 251
  GtkStyleContext *context;

252
  path_bar->priv = gtk_path_bar_get_instance_private (path_bar);
253

254
  gtk_widget_init_template (GTK_WIDGET (path_bar));
255

256 257 258 259
  /* Add the children manually because GtkPathBar derives from an abstract class,
   * Glade cannot edit a <template> in gtkpathbar.ui if it's only a GtkContainer.
   */
  gtk_container_add (GTK_CONTAINER (path_bar), path_bar->priv->up_slider_button);
260
  gtk_container_add (GTK_CONTAINER (path_bar), path_bar->priv->down_slider_button);
261

262 263 264 265 266 267 268
  /* GtkBuilder wont let us connect 'swapped' without specifying the signal's
   * user data in the .ui file
   */
  g_signal_connect_swapped (path_bar->priv->up_slider_button, "clicked",
			    G_CALLBACK (gtk_path_bar_scroll_up), path_bar);
  g_signal_connect_swapped (path_bar->priv->down_slider_button, "clicked",
			    G_CALLBACK (gtk_path_bar_scroll_down), path_bar);
269

270
  gtk_widget_set_has_window (GTK_WIDGET (path_bar), FALSE);
271 272
  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);

273
  context = gtk_widget_get_style_context (GTK_WIDGET (path_bar));
274
  gtk_style_context_add_class (context, "path-bar");
275 276
  gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);

277
  path_bar->priv->get_info_cancellable = NULL;
278
  path_bar->priv->cancellables = NULL;
279 280 281 282 283 284 285 286 287 288 289 290 291
}

static void
gtk_path_bar_class_init (GtkPathBarClass *path_bar_class)
{
  GObjectClass *gobject_class;
  GtkWidgetClass *widget_class;
  GtkContainerClass *container_class;

  gobject_class = (GObjectClass *) path_bar_class;
  widget_class = (GtkWidgetClass *) path_bar_class;
  container_class = (GtkContainerClass *) path_bar_class;

292
  gobject_class->finalize = gtk_path_bar_finalize;
293
  gobject_class->dispose = gtk_path_bar_dispose;
294

295 296
  widget_class->get_preferred_width = gtk_path_bar_get_preferred_width;
  widget_class->get_preferred_height = gtk_path_bar_get_preferred_height;
297 298 299
  widget_class->realize = gtk_path_bar_realize;
  widget_class->unrealize = gtk_path_bar_unrealize;
  widget_class->map = gtk_path_bar_map;
300
  widget_class->unmap = gtk_path_bar_unmap;
301
  widget_class->size_allocate = gtk_path_bar_size_allocate;
302
  widget_class->style_updated = gtk_path_bar_style_updated;
303
  widget_class->screen_changed = gtk_path_bar_screen_changed;
304 305
  widget_class->grab_notify = gtk_path_bar_grab_notify;
  widget_class->state_changed = gtk_path_bar_state_changed;
306
  widget_class->scroll_event = gtk_path_bar_scroll;
307 308 309 310

  container_class->add = gtk_path_bar_add;
  container_class->forall = gtk_path_bar_forall;
  container_class->remove = gtk_path_bar_remove;
311
  gtk_container_class_handle_border_width (container_class);
312 313
  /* FIXME: */
  /*  container_class->child_type = gtk_path_bar_child_type;*/
314 315

  path_bar_signals [PATH_CLICKED] =
316
    g_signal_new (I_("path-clicked"),
317
		  G_OBJECT_CLASS_TYPE (gobject_class),
318 319 320
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkPathBarClass, path_clicked),
		  NULL, NULL,
321 322 323
		  _gtk_marshal_VOID__POINTER_POINTER_BOOLEAN,
		  G_TYPE_NONE, 3,
		  G_TYPE_POINTER,
Federico Mena Quintero's avatar
Federico Mena Quintero committed
324 325
		  G_TYPE_POINTER,
		  G_TYPE_BOOLEAN);
326 327 328 329

  /* Bind class to template
   */
  gtk_widget_class_set_template_from_resource (widget_class,
330
					       "/org/gtk/libgtk/ui/gtkpathbar.ui");
331

332 333
  gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, up_slider_button);
  gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, down_slider_button);
334 335 336 337 338 339 340 341

  gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_slider_button_press);
  gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_slider_button_release);
  gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_slider_up_defocus);
  gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_slider_down_defocus);
  gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_scroll_up);
  gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_scroll_down);
  gtk_widget_class_bind_template_callback (widget_class, on_slider_unmap);
342 343 344 345
}


static void
346
gtk_path_bar_finalize (GObject *object)
347 348 349 350
{
  GtkPathBar *path_bar;

  path_bar = GTK_PATH_BAR (object);
351

352
  cancel_all_cancellables (path_bar);
353 354
  gtk_path_bar_stop_scrolling (path_bar);

355
  g_list_free (path_bar->priv->button_list);
356 357 358 359 360 361 362 363 364
  g_clear_object (&path_bar->priv->root_file);
  g_clear_object (&path_bar->priv->home_file);
  g_clear_object (&path_bar->priv->desktop_file);

  g_clear_object (&path_bar->priv->root_icon);
  g_clear_object (&path_bar->priv->home_icon);
  g_clear_object (&path_bar->priv->desktop_icon);

  g_clear_object (&path_bar->priv->file_system);
365

366
  G_OBJECT_CLASS (gtk_path_bar_parent_class)->finalize (object);
367 368
}

369 370 371 372 373
/* Removes the settings signal handler.  It's safe to call multiple times */
static void
remove_settings_signal (GtkPathBar *path_bar,
			GdkScreen  *screen)
{
374
  if (path_bar->priv->settings_signal_id)
375 376 377 378 379
    {
      GtkSettings *settings;

      settings = gtk_settings_get_for_screen (screen);
      g_signal_handler_disconnect (settings,
380 381
				   path_bar->priv->settings_signal_id);
      path_bar->priv->settings_signal_id = 0;
382 383 384 385 386 387
    }
}

static void
gtk_path_bar_dispose (GObject *object)
{
388 389 390 391
  GtkPathBar *path_bar = GTK_PATH_BAR (object);

  remove_settings_signal (path_bar, gtk_widget_get_screen (GTK_WIDGET (object)));

392
  path_bar->priv->get_info_cancellable = NULL;
393
  cancel_all_cancellables (path_bar);
394 395 396 397

  G_OBJECT_CLASS (gtk_path_bar_parent_class)->dispose (object);
}

398 399 400 401 402 403
/* Size requisition:
 * 
 * Ideally, our size is determined by another widget, and we are just filling
 * available space.
 */
static void
404 405 406
gtk_path_bar_get_preferred_width (GtkWidget *widget,
                                  gint      *minimum,
                                  gint      *natural)
407
{
408
  ButtonData *button_data;
409 410
  GtkPathBar *path_bar;
  GList *list;
411 412 413
  gint child_height;
  gint height;
  gint child_min, child_nat;
414 415 416

  path_bar = GTK_PATH_BAR (widget);

417 418
  *minimum = *natural = 0;
  height = 0;
419

420
  for (list = path_bar->priv->button_list; list; list = list->next)
421
    {
422
      button_data = BUTTON_DATA (list->data);
423 424 425
      gtk_widget_get_preferred_width (button_data->button, &child_min, &child_nat);
      gtk_widget_get_preferred_height (button_data->button, &child_height, NULL);
      height = MAX (height, child_height);
426

427
      if (button_data->type == NORMAL_BUTTON)
428 429 430 431 432 433 434
        {
          /* Use 2*Height as button width because of ellipsized label.  */
          child_min = MAX (child_min, child_height * 2);
          child_nat = MAX (child_min, child_height * 2);
        }

      *minimum = MAX (*minimum, child_min);
435
      *natural = *natural + child_nat;
436 437 438 439 440 441
    }

  /* Add space for slider, if we have more than one path */
  /* Theoretically, the slider could be bigger than the other button.  But we're
   * not going to worry about that now.
   */
442 443 444
  path_bar->priv->slider_width = 0;

  gtk_widget_get_preferred_width (path_bar->priv->up_slider_button, &child_min, &child_nat);
445
  if (path_bar->priv->button_list && path_bar->priv->button_list->next != NULL)
446
    {
447 448
      *minimum += child_min;
      *natural += child_nat;
449
    }
450 451 452 453 454 455 456 457 458
  path_bar->priv->slider_width = MAX (path_bar->priv->slider_width, child_min);

  gtk_widget_get_preferred_width (path_bar->priv->down_slider_button, &child_min, &child_nat);
  if (path_bar->priv->button_list && path_bar->priv->button_list->next != NULL)
    {
      *minimum += child_min;
      *natural += child_nat;
    }
  path_bar->priv->slider_width = MAX (path_bar->priv->slider_width, child_min);
459
}
460

461 462 463 464 465 466 467 468 469 470 471 472 473 474
static void
gtk_path_bar_get_preferred_height (GtkWidget *widget,
                                   gint      *minimum,
                                   gint      *natural)
{
  ButtonData *button_data;
  GtkPathBar *path_bar;
  GList *list;
  gint child_min, child_nat;

  path_bar = GTK_PATH_BAR (widget);

  *minimum = *natural = 0;

475
  for (list = path_bar->priv->button_list; list; list = list->next)
476 477 478 479 480 481 482
    {
      button_data = BUTTON_DATA (list->data);
      gtk_widget_get_preferred_height (button_data->button, &child_min, &child_nat);

      *minimum = MAX (*minimum, child_min);
      *natural = MAX (*natural, child_nat);
    }
483 484 485 486 487 488 489 490

  gtk_widget_get_preferred_height (path_bar->priv->up_slider_button, &child_min, &child_nat);
  *minimum = MAX (*minimum, child_min);
  *natural = MAX (*natural, child_nat);

  gtk_widget_get_preferred_height (path_bar->priv->down_slider_button, &child_min, &child_nat);
  *minimum = MAX (*minimum, child_min);
  *natural = MAX (*natural, child_nat);
491 492 493 494 495
}

static void
gtk_path_bar_update_slider_buttons (GtkPathBar *path_bar)
{
496
  if (path_bar->priv->button_list)
497 498 499
    {
      GtkWidget *button;

500
      button = BUTTON_DATA (path_bar->priv->button_list->data)->button;
501
      if (gtk_widget_get_child_visible (button))
502 503
	{
	  gtk_path_bar_stop_scrolling (path_bar);
504
	  gtk_widget_set_sensitive (path_bar->priv->down_slider_button, FALSE);
505
	}
506
      else
507
	gtk_widget_set_sensitive (path_bar->priv->down_slider_button, TRUE);
508

509
      button = BUTTON_DATA (g_list_last (path_bar->priv->button_list)->data)->button;
510
      if (gtk_widget_get_child_visible (button))
511 512
	{
	  gtk_path_bar_stop_scrolling (path_bar);
513
	  gtk_widget_set_sensitive (path_bar->priv->up_slider_button, FALSE);
514
	}
515
      else
516
	gtk_widget_set_sensitive (path_bar->priv->up_slider_button, TRUE);
517 518 519
    }
}

520 521 522
static void
gtk_path_bar_map (GtkWidget *widget)
{
523
  gdk_window_show (GTK_PATH_BAR (widget)->priv->event_window);
524 525 526 527

  GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->map (widget);
}

528 529 530 531
static void
gtk_path_bar_unmap (GtkWidget *widget)
{
  gtk_path_bar_stop_scrolling (GTK_PATH_BAR (widget));
532
  gdk_window_hide (GTK_PATH_BAR (widget)->priv->event_window);
533 534 535 536

  GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->unmap (widget);
}

537 538 539 540
static void
gtk_path_bar_realize (GtkWidget *widget)
{
  GtkPathBar *path_bar;
541 542
  GtkAllocation allocation;
  GdkWindow *window;
543 544 545
  GdkWindowAttr attributes;
  gint attributes_mask;

546
  gtk_widget_set_realized (widget, TRUE);
547 548

  path_bar = GTK_PATH_BAR (widget);
549 550 551 552 553
  window = gtk_widget_get_parent_window (widget);
  gtk_widget_set_window (widget, window);
  g_object_ref (window);

  gtk_widget_get_allocation (widget, &allocation);
554 555

  attributes.window_type = GDK_WINDOW_CHILD;
556 557 558 559
  attributes.x = allocation.x;
  attributes.y = allocation.y;
  attributes.width = allocation.width;
  attributes.height = allocation.height;
560 561 562 563 564
  attributes.wclass = GDK_INPUT_ONLY;
  attributes.event_mask = gtk_widget_get_events (widget);
  attributes.event_mask |= GDK_SCROLL_MASK;
  attributes_mask = GDK_WA_X | GDK_WA_Y;

565
  path_bar->priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
566
                                           &attributes, attributes_mask);
567
  gtk_widget_register_window (widget, path_bar->priv->event_window);
568 569 570 571 572 573 574 575 576
}

static void
gtk_path_bar_unrealize (GtkWidget *widget)
{
  GtkPathBar *path_bar;

  path_bar = GTK_PATH_BAR (widget);

577 578 579
  gtk_widget_unregister_window (widget, path_bar->priv->event_window);
  gdk_window_destroy (path_bar->priv->event_window);
  path_bar->priv->event_window = NULL;
580

581
  GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->unrealize (widget);
582 583
}

584 585 586 587 588 589 590 591 592 593 594 595 596
/* This is a tad complicated
 */
static void
gtk_path_bar_size_allocate (GtkWidget     *widget,
			    GtkAllocation *allocation)
{
  GtkWidget *child;
  GtkPathBar *path_bar = GTK_PATH_BAR (widget);
  GtkTextDirection direction;
  GtkAllocation child_allocation;
  GList *list, *first_button;
  gint width;
  gint allocation_width;
597
  gboolean need_sliders = TRUE;
598
  gint up_slider_offset = 0;
599
  gint down_slider_offset = 0;
600
  GtkRequisition child_requisition;
601

602
  gtk_widget_set_allocation (widget, allocation);
603

604
  if (gtk_widget_get_realized (widget))
605
    gdk_window_move_resize (path_bar->priv->event_window,
606 607 608
			    allocation->x, allocation->y,
			    allocation->width, allocation->height);

609
  /* No path is set; we don't have to allocate anything. */
610
  if (path_bar->priv->button_list == NULL)
611
    {
612
      _gtk_widget_set_simple_clip (widget, NULL);
613 614 615

      return;
    }
616 617

  direction = gtk_widget_get_direction (widget);
618
  allocation_width = allocation->width;
619 620

  /* First, we check to see if we need the scrollbars. */
621
  if (path_bar->priv->fake_root)
622
    width = path_bar->priv->slider_width;
623
  else
624
    width = 0;
625

626
  for (list = path_bar->priv->button_list; list; list = list->next)
627
    {
628
      child = BUTTON_DATA (list->data)->button;
629

630
      gtk_widget_get_preferred_size (child, &child_requisition, NULL);
631

632
      width += child_requisition.width;
633
      if (list == path_bar->priv->fake_root)
634
	break;
635 636 637 638
    }

  if (width <= allocation_width)
    {
639 640
      if (path_bar->priv->fake_root)
	first_button = path_bar->priv->fake_root;
641
      else
642
	first_button = g_list_last (path_bar->priv->button_list);
643 644 645 646
    }
  else
    {
      gboolean reached_end = FALSE;
647
      gint slider_space = 2 * path_bar->priv->slider_width;
648

649 650
      if (path_bar->priv->first_scrolled_button)
	first_button = path_bar->priv->first_scrolled_button;
651
      else
652
	first_button = path_bar->priv->button_list;
653
      need_sliders = TRUE;
654

655 656 657 658 659
      /* To see how much space we have, and how many buttons we can display.
       * We start at the first button, count forward until hit the new
       * button, then count backwards.
       */
      /* Count down the path chain towards the end. */
660 661
      gtk_widget_get_preferred_size (BUTTON_DATA (first_button->data)->button,
                                     &child_requisition, NULL);
662 663

      width = child_requisition.width;
664 665 666
      list = first_button->prev;
      while (list && !reached_end)
	{
667
	  child = BUTTON_DATA (list->data)->button;
668

669
          gtk_widget_get_preferred_size (child, &child_requisition, NULL);
670

671
	  if (width + child_requisition.width + slider_space > allocation_width)
672
	    reached_end = TRUE;
673
	  else if (list == path_bar->priv->fake_root)
674
	    break;
675
	  else
676
	    width += child_requisition.width;
677 678 679 680 681 682

	  list = list->prev;
	}

      /* Finally, we walk up, seeing how many of the previous buttons we can
       * add */
683
      while (first_button->next && !reached_end)
684
	{
685
	  child = BUTTON_DATA (first_button->next->data)->button;
686

687
          gtk_widget_get_preferred_size (child, &child_requisition, NULL);
688

689
	  if (width + child_requisition.width + slider_space > allocation_width)
690 691 692 693 694
	    {
	      reached_end = TRUE;
	    }
	  else
	    {
695
	      width += child_requisition.width;
696
	      if (first_button == path_bar->priv->fake_root)
697
		break;
698 699 700 701 702 703
	      first_button = first_button->next;
	    }
	}
    }

  /* Now, we allocate space to the buttons */
704 705
  child_allocation.y = allocation->y;
  child_allocation.height = allocation->height;
706 707 708

  if (direction == GTK_TEXT_DIR_RTL)
    {
709
      child_allocation.x = allocation->x + allocation->width;
710
      if (need_sliders || path_bar->priv->fake_root)
711
	{
712
	  child_allocation.x -= path_bar->priv->slider_width;
713
	  up_slider_offset = allocation->width - path_bar->priv->slider_width;
714 715 716 717
	}
    }
  else
    {
718
      child_allocation.x = allocation->x;
719
      if (need_sliders || path_bar->priv->fake_root)
720
	{
721
	  up_slider_offset = 0;
722
	  child_allocation.x += path_bar->priv->slider_width;
723 724 725 726 727
	}
    }

  for (list = first_button; list; list = list->prev)
    {
728
      GtkAllocation widget_allocation;
729 730 731 732 733
      ButtonData *button_data;

      button_data = BUTTON_DATA (list->data);
      child = button_data->button;

734
      gtk_widget_get_preferred_size (child, &child_requisition, NULL);
735 736

      child_allocation.width = MIN (child_requisition.width,
737
				    allocation_width - 2 * path_bar->priv->slider_width);
738

739 740
      if (direction == GTK_TEXT_DIR_RTL)
	child_allocation.x -= child_allocation.width;
741 742 743 744

      /* Check to see if we've don't have any more space to allocate buttons */
      if (need_sliders && direction == GTK_TEXT_DIR_RTL)
	{
745
          gtk_widget_get_allocation (widget, &widget_allocation);
746
	  if (child_allocation.x - path_bar->priv->slider_width < widget_allocation.x)
747 748 749 750
	    break;
	}
      else if (need_sliders && direction == GTK_TEXT_DIR_LTR)
	{
751
          gtk_widget_get_allocation (widget, &widget_allocation);
752
	  if (child_allocation.x + child_allocation.width + path_bar->priv->slider_width >
753
	      widget_allocation.x + allocation_width)
754 755 756
	    break;
	}

757
      if (child_allocation.width < child_requisition.width)
758 759 760 761 762 763 764 765
	{
	  if (!gtk_widget_get_has_tooltip (child))
	    gtk_widget_set_tooltip_text (child, button_data->dir_name);
	}
      else if (gtk_widget_get_has_tooltip (child))
	gtk_widget_set_tooltip_text (child, NULL);
      
      gtk_widget_set_child_visible (child, TRUE);
766 767
      gtk_widget_size_allocate (child, &child_allocation);

768 769 770 771 772 773 774 775 776
      if (direction == GTK_TEXT_DIR_RTL)
        {
          down_slider_offset = child_allocation.x - allocation->x - path_bar->priv->slider_width;
        }
      else
        {
          down_slider_offset += child_allocation.width;
          child_allocation.x += child_allocation.width;
        }
777 778 779 780
    }
  /* Now we go hide all the widgets that don't fit */
  while (list)
    {
781 782
      child = BUTTON_DATA (list->data)->button;
      gtk_widget_set_child_visible (child, FALSE);
783 784 785 786
      list = list->prev;
    }
  for (list = first_button->next; list; list = list->next)
    {
787 788
      child = BUTTON_DATA (list->data)->button;
      gtk_widget_set_child_visible (child, FALSE);
789 790
    }

791
  if (need_sliders || path_bar->priv->fake_root)
792
    {
793
      child_allocation.width = path_bar->priv->slider_width;
794
      child_allocation.x = up_slider_offset + allocation->x;
795
      gtk_widget_size_allocate (path_bar->priv->up_slider_button, &child_allocation);
796

797 798
      gtk_widget_set_child_visible (path_bar->priv->up_slider_button, TRUE);
      gtk_widget_show_all (path_bar->priv->up_slider_button);
799 800 801

      if (direction == GTK_TEXT_DIR_LTR)
        down_slider_offset += path_bar->priv->slider_width;
802 803
    }
  else
804
    {
805
      gtk_widget_set_child_visible (path_bar->priv->up_slider_button, FALSE);
806
    }
807

808 809
  if (need_sliders)
    {
810
      child_allocation.width = path_bar->priv->slider_width;
811
      child_allocation.x = down_slider_offset + allocation->x;
812
      
813
      gtk_widget_size_allocate (path_bar->priv->down_slider_button, &child_allocation);
814

815 816
      gtk_widget_set_child_visible (path_bar->priv->down_slider_button, TRUE);
      gtk_widget_show_all (path_bar->priv->down_slider_button);
817 818 819
      gtk_path_bar_update_slider_buttons (path_bar);
    }
  else
820
    {
821
      gtk_widget_set_child_visible (path_bar->priv->down_slider_button, FALSE);
822
    }
823

824
  _gtk_widget_set_simple_clip (widget, NULL);
825 826
}

827
static void
828
gtk_path_bar_style_updated (GtkWidget *widget)
829
{
830
  GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->style_updated (widget);
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848

  gtk_path_bar_check_icon_theme (GTK_PATH_BAR (widget));
}

static void
gtk_path_bar_screen_changed (GtkWidget *widget,
			     GdkScreen *previous_screen)
{
  if (GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->screen_changed)
    GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->screen_changed (widget, previous_screen);

  /* We might nave a new settings, so we remove the old one */
  if (previous_screen)
    remove_settings_signal (GTK_PATH_BAR (widget), previous_screen);

  gtk_path_bar_check_icon_theme (GTK_PATH_BAR (widget));
}

849 850 851 852 853 854 855 856 857 858 859 860 861 862
static gboolean
gtk_path_bar_scroll (GtkWidget      *widget,
		     GdkEventScroll *event)
{
  switch (event->direction)
    {
    case GDK_SCROLL_RIGHT:
    case GDK_SCROLL_DOWN:
      gtk_path_bar_scroll_down (GTK_PATH_BAR (widget));
      break;
    case GDK_SCROLL_LEFT:
    case GDK_SCROLL_UP:
      gtk_path_bar_scroll_up (GTK_PATH_BAR (widget));
      break;
Benjamin Otte's avatar
Benjamin Otte committed
863 864
    case GDK_SCROLL_SMOOTH:
      break;
865 866 867 868 869
    }

  return TRUE;
}

870 871 872
static void
gtk_path_bar_add (GtkContainer *container,
		  GtkWidget    *widget)
873

874 875 876 877
{
  gtk_widget_set_parent (widget, GTK_WIDGET (container));
}

878 879 880 881
static void
gtk_path_bar_remove_1 (GtkContainer *container,
		       GtkWidget    *widget)
{
882
  gboolean was_visible = gtk_widget_get_visible (widget);
883 884 885 886 887
  gtk_widget_unparent (widget);
  if (was_visible)
    gtk_widget_queue_resize (GTK_WIDGET (container));
}

888 889 890 891 892 893 894 895 896
static void
gtk_path_bar_remove (GtkContainer *container,
		     GtkWidget    *widget)
{
  GtkPathBar *path_bar;
  GList *children;

  path_bar = GTK_PATH_BAR (container);

897
  if (widget == path_bar->priv->up_slider_button)
898 899
    {
      gtk_path_bar_remove_1 (container, widget);
900
      path_bar->priv->up_slider_button = NULL;
901 902 903
      return;
    }

904
  if (widget == path_bar->priv->down_slider_button)
905 906
    {
      gtk_path_bar_remove_1 (container, widget);
907
      path_bar->priv->down_slider_button = NULL;
908 909
      return;
    }
910

911
  children = path_bar->priv->button_list;
912 913
  while (children)
    {
914
      if (widget == BUTTON_DATA (children->data)->button)
915
	{
916
	  gtk_path_bar_remove_1 (container, widget);
917
	  path_bar->priv->button_list = g_list_remove_link (path_bar->priv->button_list, children);
918
	  g_list_free (children);
919
	  return;
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
	}
      
      children = children->next;
    }
}

static void
gtk_path_bar_forall (GtkContainer *container,
		     gboolean      include_internals,
		     GtkCallback   callback,
		     gpointer      callback_data)
{
  GtkPathBar *path_bar;
  GList *children;

  g_return_if_fail (callback != NULL);
  path_bar = GTK_PATH_BAR (container);

938
  children = path_bar->priv->button_list;
939 940 941
  while (children)
    {
      GtkWidget *child;
942
      child = BUTTON_DATA (children->data)->button;
943 944 945 946 947
      children = children->next;

      (* callback) (child, callback_data);
    }

948 949
  if (path_bar->priv->up_slider_button)
    (* callback) (path_bar->priv->up_slider_button, callback_data);
950

951 952
  if (path_bar->priv->down_slider_button)
    (* callback) (path_bar->priv->down_slider_button, callback_data);
953 954
}

955
static void
956
gtk_path_bar_scroll_down (GtkPathBar *path_bar)
957
{
958
  GtkAllocation allocation, button_allocation;
959
  GList *list;
960
  GList *down_button = NULL;
961
  gint space_available;
962

963
  if (path_bar->priv->ignore_click)
964
    {
965
      path_bar->priv->ignore_click = FALSE;
966 967 968
      return;   
    }

969
  if (gtk_widget_get_child_visible (BUTTON_DATA (path_bar->priv->button_list->data)->button))
970 971 972 973 974
    {
      /* Return if the last button is already visible */
      return;
    }

975 976
  gtk_widget_queue_resize (GTK_WIDGET (path_bar));

977 978
  /* We find the button at the 'down' end that we have to make
   * visible */
979
  for (list = path_bar->priv->button_list; list; list = list->next)
980
    {
981
      if (list->next && gtk_widget_get_child_visible (BUTTON_DATA (list->next->data)->button))
982 983 984 985 986 987
	{
	  down_button = list;
	  break;
	}
    }

988 989 990 991
  gtk_widget_get_allocation (GTK_WIDGET (path_bar), &allocation);
  gtk_widget_get_allocation (BUTTON_DATA (down_button->data)->button, &button_allocation);

  space_available = (allocation.width
992
		     - 2 * path_bar->priv->slider_width
993
                     - button_allocation.width);
994
  path_bar->priv->first_scrolled_button = down_button;
995 996 997
  
  /* We have space_available free space that's not being used.  
   * So we walk down from the end, adding buttons until we use all free space.
998
   */
999
  while (space_available > 0)
1000
    {
1001
      path_bar->priv->first_scrolled_button = down_button;
1002 1003 1004
      down_button = down_button->next;
      if (!down_button)
	break;
1005
      space_available -= button_allocation.width;
1006 1007 1008 1009
    }
}

static void
1010
gtk_path_bar_scroll_up (GtkPathBar *path_bar)
1011 1012 1013
{
  GList *list;

1014
  if (path_bar->priv->ignore_click)
1015
    {
1016
      path_bar->priv->ignore_click = FALSE;
1017 1018 1019
      return;   
    }

1020
  list = g_list_last (path_bar->priv->button_list);
1021 1022 1023 1024 1025 1026 1027

  if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button))
    {
      /* Return if the first button is already visible */
      return;
    }

1028 1029
  gtk_widget_queue_resize (GTK_WIDGET (path_bar));

1030
  for ( ; list; list = list->prev)
1031
    {
1032
      if (list->prev && gtk_widget_get_child_visible (BUTTON_DATA (list->prev->data)->button))
1033
	{
1034 1035 1036
	  if (list->prev == path_bar->priv->fake_root)
	    path_bar->priv->fake_root = NULL;
	  path_bar->priv->first_scrolled_button = list;
1037 1038 1039 1040 1041
	  return;
	}
    }
}

1042 1043 1044 1045 1046
static gboolean
gtk_path_bar_scroll_timeout (GtkPathBar *path_bar)
{
  gboolean retval = FALSE;

1047
  if (path_bar->priv->timer)
1048
    {
1049
      if (path_bar->priv->scrolling_up)
1050
	gtk_path_bar_scroll_up (path_bar);
1051
      else if (path_bar->priv->scrolling_down)
1052
	gtk_path_bar_scroll_down (path_bar);
1053

1054
      if (path_bar->priv->need_timer) 
1055
	{
1056
	  path_bar->priv->need_timer = FALSE;
1057

1058
	  path_bar->priv->timer = gdk_threads_add_timeout (TIMEOUT_REPEAT * SCROLL_DELAY_FACTOR,
1059 1060
					   (GSourceFunc)gtk_path_bar_scroll_timeout,
					   path_bar);
1061
          g_source_set_name_by_id (path_bar->priv->timer, "[gtk+] gtk_path_bar_scroll_timeout");
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
	}
      else
	retval = TRUE;
    }

  return retval;
}

static void 
gtk_path_bar_stop_scrolling (GtkPathBar *path_bar)
{
1073
  if (path_bar->priv->timer)
1074
    {
1075 1076 1077
      g_source_remove (path_bar->priv->timer);
      path_bar->priv->timer = 0;
      path_bar->priv->need_timer = FALSE;
1078 1079 1080
    }
}

1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
static gboolean
gtk_path_bar_slider_up_defocus (GtkWidget      *widget,
                                    GdkEventButton *event,
                                    GtkPathBar     *path_bar)
{
  GList *list;
  GList *up_button = NULL;

  if (event->type != GDK_FOCUS_CHANGE)
    return FALSE;

1092
  for (list = g_list_last (path_bar->priv->button_list); list; list = list->prev)
1093 1094 1095 1096 1097 1098 1099 1100 1101
    {
      if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button))
        {
          up_button = list;
          break;
        }
    }

  /* don't let the focus vanish */
1102 1103
  if ((!gtk_widget_is_sensitive (path_bar->priv->up_slider_button)) ||
      (!gtk_widget_get_child_visible (path_bar->priv->up_slider_button)))
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119
    gtk_widget_grab_focus (BUTTON_DATA (up_button->data)->button);

  return FALSE;
}

static gboolean
gtk_path_bar_slider_down_defocus (GtkWidget      *widget,
                                    GdkEventButton *event,
                                    GtkPathBar     *path_bar)
{
  GList *list;
  GList *down_button = NULL;

  if (event->type != GDK_FOCUS_CHANGE)
    return FALSE;

1120
  for (list = path_bar->priv->button_list; list; list = list->next)
1121 1122 1123 1124 1125 1126 1127 1128 1129
    {
      if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button))
        {
          down_button = list;
          break;
        }
    }

  /* don't let the focus vanish */
1130 1131
  if ((!gtk_widget_is_sensitive (path_bar->priv->down_slider_button)) ||
      (!gtk_widget_get_child_visible (path_bar->priv->down_slider_button)))
1132 1133 1134 1135 1136
    gtk_widget_grab_focus (BUTTON_DATA (down_button->data)->button);

  return FALSE;
}

1137 1138 1139 1140 1141
static gboolean
gtk_path_bar_slider_button_press (GtkWidget      *widget, 
				  GdkEventButton *event,
				  GtkPathBar     *path_bar)
{
1142
  if (event->type != GDK_BUTTON_PRESS || event->button != GDK_BUTTON_PRIMARY)
1143 1144
    return FALSE;

1145
  path_bar->priv->ignore_click = FALSE;
1146

1147
  if (widget == path_bar->priv->up_slider_button)
1148
    {
1149 1150
      path_bar->priv->scrolling_down = FALSE;
      path_bar->priv->scrolling_up = TRUE;
1151
      gtk_path_bar_scroll_up (path_bar);
1152
    }
1153
  else if (widget == path_bar->priv->down_slider_button)
1154
    {
1155 1156
      path_bar->priv->scrolling_up = FALSE;
      path_bar->priv->scrolling_down = TRUE;
1157
      gtk_path_bar_scroll_down (path_bar);
1158
    }
1159

1160
  if (!path_bar->priv->timer)
1161
    {
1162
      path_bar->priv->need_timer = TRUE;
1163
      path_bar->priv->timer = gdk_threads_add_timeout (TIMEOUT_INITIAL,
1164 1165
				       (GSourceFunc)gtk_path_bar_scroll_timeout,
				       path_bar);
1166
      g_source_set_name_by_id (path_bar->priv->timer, "[gtk+] gtk_path_bar_scroll_timeout");
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179
    }

  return FALSE;
}

static gboolean
gtk_path_bar_slider_button_release (GtkWidget      *widget, 
				    GdkEventButton *event,
				    GtkPathBar     *path_bar)
{
  if (event->type != GDK_BUTTON_RELEASE)
    return FALSE;

1180
  path_bar->priv->ignore_click = TRUE;
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
  gtk_path_bar_stop_scrolling (path_bar);

  return FALSE;
}

static void
gtk_path_bar_grab_notify (GtkWidget *widget,
			  gboolean   was_grabbed)
{
  if (!was_grabbed)
    gtk_path_bar_stop_scrolling (GTK_PATH_BAR (widget));
}

static void
gtk_path_bar_state_changed (GtkWidget    *widget,
			    GtkStateType  previous_state)
{
1198
  if (!gtk_widget_is_sensitive (widget))
1199 1200 1201 1202
    gtk_path_bar_stop_scrolling (GTK_PATH_BAR (widget));
}


1203 1204 1205 1206 1207 1208
/* Changes the icons wherever it is needed */
static void
reload_icons (GtkPathBar *path_bar)
{
  GList *list;

1209 1210 1211
  g_clear_object (&path_bar->priv->root_icon);
  g_clear_object (&path_bar->priv->home_icon);
  g_clear_object (&path_bar->priv->desktop_icon);
1212

1213
  for (list = path_bar->priv->button_list; list; list = list->next)
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
    {
      ButtonData *button_data;
      gboolean current_dir;

      button_data = BUTTON_DATA (list->data);
      if (button_data->type != NORMAL_BUTTON)
	{
	  current_dir = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_data->button));
	  gtk_path_bar_update_button_appearance (path_bar, button_data, current_dir);
	}
    }
}

static void
change_icon_theme (GtkPathBar *path_bar)
{
  reload_icons (path_bar);
}
1232

1233 1234 1235 1236 1237 1238 1239 1240 1241 1242
/* Callback used when a GtkSettings value changes */
static void
settings_notify_cb (GObject    *object,
		    GParamSpec *pspec,
		    GtkPathBar *path_bar)
{
  const char *name;

  name = g_param_spec_get_name (pspec);

1243
  if (strcmp (name, "gtk-icon-theme-name") == 0)
1244 1245 1246 1247 1248 1249
    change_icon_theme (path_bar);
}

static void
gtk_path_bar_check_icon_theme (GtkPathBar *path_bar)
{
1250 1251 1252
  if (path_bar->priv->settings_signal_id == 0)
    {
      GtkSettings *settings;
1253

1254 1255 1256 1257
      settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (path_bar)));
      path_bar->priv->settings_signal_id = g_signal_connect (settings, "notify",
                                                             G_CALLBACK (settings_notify_cb), path_bar);
    }
1258 1259 1260 1261 1262

  change_icon_theme (path_bar);
}

/* Public functions and their helpers */
1263 1264 1265
static void
gtk_path_bar_clear_buttons (GtkPathBar *path_bar)
{
1266
  while (path_bar->priv->button_list != NULL)
1267
    {
1268
      gtk_container_remove (GTK_CONTAINER (path_bar), BUTTON_DATA (path_bar->priv->button_list->data)->button);
1269
    }
1270 1271
  path_bar->priv->first_scrolled_button = NULL;
  path_bar->priv->fake_root = NULL;
1272 1273
}

1274 1275 1276 1277
static void
button_clicked_cb (GtkWidget *button,
		   gpointer   data)
{
1278
  ButtonData *button_data;
Federico Mena Quintero's avatar
Federico Mena Quintero committed
1279 1280 1281
  GtkPathBar *path_bar;
  GList *button_list;
  gboolean child_is_hidden;
1282
  GFile *child_file;
1283 1284 1285 1286

  button_data = BUTTON_DATA (data);
  if (button_data->ignore_changes)
    return;
1287

1288
  path_bar = GTK_PATH_BAR (gtk_widget_get_parent (button));
Federico Mena Quintero's avatar
Federico Mena Quintero committed
1289

1290
  button_list = g_list_find (path_bar->priv->button_list, button_data);
Federico Mena Quintero's avatar
Federico Mena Quintero committed
1291 1292
  g_assert (button_list != NULL);

1293 1294
  g_signal_handlers_block_by_func (button,
				   G_CALLBACK (button_clicked_cb), data);
1295
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
1296 1297
  g_signal_handlers_unblock_by_func (button,
				     G_CALLBACK (button_clicked_cb), data);
1298

Federico Mena Quintero's avatar
Federico Mena Quintero committed
1299 1300 1301 1302 1303
  if (button_list->prev)
    {
      ButtonData *child_data;

      child_data = BUTTON_DATA (button_list->prev->data);
1304
      child_file = child_data->file;
Federico Mena Quintero's avatar
Federico Mena Quintero committed
1305 1306 1307
      child_is_hidden = child_data->file_is_hidden;
    }
  else
Matthias Clasen's avatar