~noskcaj/ubuntu/vivid/thunar/1.6.4

« back to all changes in this revision

Viewing changes to thunar/thunar-window.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2010-12-04 16:46:20 UTC
  • mto: (2.1.3 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 69.
  • Revision ID: james.westby@ubuntu.com-20101204164620-h7p4t2e9z6hfhz6l
Tags: upstream-1.1.4
ImportĀ upstreamĀ versionĀ 1.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* $Id$ */
2
2
/*-
3
3
 * Copyright (c) 2005-2007 Benedikt Meurer <benny@xfce.org>
 
4
 * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
4
5
 *
5
6
 * This program is free software; you can redistribute it and/or modify it
6
7
 * under the terms of the GNU General Public License as published by the Free
31
32
#include <gdk/gdkkeysyms.h>
32
33
 
33
34
#include <thunar/thunar-application.h>
 
35
#include <thunar/thunar-browser.h>
34
36
#include <thunar/thunar-clipboard-manager.h>
35
37
#include <thunar/thunar-compact-view.h>
36
38
#include <thunar/thunar-details-view.h>
37
39
#include <thunar/thunar-dialogs.h>
38
40
#include <thunar/thunar-shortcuts-pane.h>
 
41
#include <thunar/thunar-gio-extensions.h>
39
42
#include <thunar/thunar-gobject-extensions.h>
40
43
#include <thunar/thunar-gtk-extensions.h>
41
44
#include <thunar/thunar-history.h>
60
63
#include <glib.h>
61
64
 
62
65
 
 
66
 
63
67
/* Property identifiers */
64
68
enum
65
69
{
84
88
 
85
89
 
86
90
 
87
 
static void     thunar_window_class_init                  (ThunarWindowClass      *klass);
88
 
static void     thunar_window_init                        (ThunarWindow           *window);
89
91
static void     thunar_window_dispose                     (GObject                *object);
90
92
static void     thunar_window_finalize                    (GObject                *object);
91
93
static void     thunar_window_get_property                (GObject                *object,
107
109
static gboolean thunar_window_configure_event             (GtkWidget              *widget,
108
110
                                                           GdkEventConfigure      *event);
109
111
static void     thunar_window_merge_custom_preferences    (ThunarWindow           *window);
 
112
static void     thunar_window_merge_go_actions            (ThunarWindow           *window);
110
113
static void     thunar_window_install_location_bar        (ThunarWindow           *window,
111
114
                                                           GType                   type);
112
115
static void     thunar_window_install_sidepane            (ThunarWindow           *window,
135
138
                                                           ThunarWindow           *window);
136
139
static void     thunar_window_action_statusbar_changed    (GtkToggleAction        *action,
137
140
                                                           ThunarWindow           *window);
138
 
static void     thunar_window_action_toolbar_changed      (GtkToggleAction        *action,
139
 
                                                           ThunarWindow           *window);
140
141
static void     thunar_window_action_zoom_in              (GtkAction              *action,
141
142
                                                           ThunarWindow           *window);
142
143
static void     thunar_window_action_zoom_out             (GtkAction              *action,
166
167
                                                           ThunarWindow           *window);
167
168
static void     thunar_window_action_open_videos          (GtkAction              *action,
168
169
                                                           ThunarWindow           *window);
 
170
static void     thunar_window_action_open_file_system     (GtkAction              *action,
 
171
                                                           ThunarWindow           *window);
169
172
static void     thunar_window_action_open_trash           (GtkAction              *action,
170
173
                                                           ThunarWindow           *window);
 
174
static void     thunar_window_action_open_network         (GtkAction              *action,
 
175
                                                           ThunarWindow           *window);
171
176
static void     thunar_window_action_open_location        (GtkAction              *action,
172
177
                                                           ThunarWindow           *window);
173
178
static void     thunar_window_action_contents             (GtkAction              *action,
195
200
static void     thunar_window_notify_loading              (ThunarView             *view,
196
201
                                                           GParamSpec             *pspec,
197
202
                                                           ThunarWindow           *window);
198
 
static void     thunar_window_volume_pre_unmount          (ThunarVfsVolumeManager *volume_manager,
199
 
                                                           ThunarVfsVolume        *volume,
 
203
static void     thunar_window_mount_pre_unmount           (GVolumeMonitor         *volume_monitor,
 
204
                                                           GMount                 *mount,
200
205
                                                           ThunarWindow           *window);
201
206
static gboolean thunar_window_merge_idle                  (gpointer                user_data);
202
207
static void     thunar_window_merge_idle_destroy          (gpointer                user_data);
224
229
 
225
230
  /* support for custom preferences actions */
226
231
  ThunarxProviderFactory *provider_factory;
227
 
  gint                    custom_preferences_merge_id;
 
232
  guint                   custom_preferences_merge_id;
 
233
 
 
234
  /* UI manager merge ID for go menu actions */
 
235
  guint                   go_items_actions_merge_id;
228
236
 
229
237
  ThunarClipboardManager *clipboard;
230
238
 
235
243
  GtkActionGroup         *action_group;
236
244
  GtkUIManager           *ui_manager;
237
245
 
238
 
  /* to be able to change folder on "volume-pre-unmount" if required */
239
 
  ThunarVfsVolumeManager *volume_manager;
 
246
  /* to be able to change folder on "mount-pre-unmount" if required */
 
247
  GVolumeMonitor         *volume_monitor;
240
248
 
241
249
  /* closures for the menu_item_selected()/menu_item_deselected() callbacks */
242
250
  GClosure               *menu_item_selected_closure;
300
308
  { "open-parent", GTK_STOCK_GO_UP, N_ ("Open _Parent"), "<alt>Up", N_ ("Open the parent folder"), G_CALLBACK (thunar_window_action_go_up), },
301
309
  { "open-home", THUNAR_STOCK_HOME, N_ ("_Home"), "<alt>Home", N_ ("Go to the home folder"), G_CALLBACK (thunar_window_action_open_home), },
302
310
  { "open-desktop", THUNAR_STOCK_DESKTOP, "Desktop", NULL, N_ ("Go to the desktop folder"), G_CALLBACK (thunar_window_action_open_desktop), },
 
311
  { "open-file-system", GTK_STOCK_HARDDISK, N_ ("File System"), NULL, N_ ("Browse the file system"), G_CALLBACK (thunar_window_action_open_file_system), },
303
312
  { "open-documents", THUNAR_STOCK_DOCUMENTS, "Documents", NULL, N_ ("Go to the documents folder"), G_CALLBACK (thunar_window_action_open_documents), },
304
313
  { "open-downloads", THUNAR_STOCK_DOWNLOADS, "Download", NULL, N_ ("Go to the downloads folder"), G_CALLBACK (thunar_window_action_open_downloads), },
305
314
  { "open-music", THUNAR_STOCK_MUSIC, "Music", NULL, N_ ("Go to the music folder"), G_CALLBACK (thunar_window_action_open_music), },
325
334
 
326
335
 
327
336
 
328
 
static GObjectClass *thunar_window_parent_class;
329
 
static guint         window_signals[LAST_SIGNAL];
330
 
 
331
 
 
332
 
 
333
 
GType
334
 
thunar_window_get_type (void)
335
 
{
336
 
  static GType type = G_TYPE_INVALID;
337
 
 
338
 
  if (G_UNLIKELY (type == G_TYPE_INVALID))
339
 
    {
340
 
      static const GTypeInfo info =
341
 
      {
342
 
        sizeof (ThunarWindowClass),
343
 
        NULL,
344
 
        NULL,
345
 
        (GClassInitFunc) thunar_window_class_init,
346
 
        NULL,
347
 
        NULL,
348
 
        sizeof (ThunarWindow),
349
 
        0,
350
 
        (GInstanceInitFunc) thunar_window_init,
351
 
        NULL,
352
 
      };
353
 
 
354
 
      type = g_type_register_static (GTK_TYPE_WINDOW, I_("ThunarWindow"), &info, 0);
355
 
    }
356
 
 
357
 
  return type;
358
 
}
 
337
static guint window_signals[LAST_SIGNAL];
 
338
 
 
339
 
 
340
 
 
341
G_DEFINE_TYPE_WITH_CODE (ThunarWindow, thunar_window, GTK_TYPE_WINDOW,
 
342
                         G_IMPLEMENT_INTERFACE (THUNAR_TYPE_BROWSER, NULL))
359
343
 
360
344
 
361
345
 
366
350
  GtkBindingSet  *binding_set;
367
351
  GObjectClass   *gobject_class;
368
352
 
369
 
  /* determine the parent type class */
370
 
  thunar_window_parent_class = g_type_class_peek_parent (klass);
371
 
 
372
353
  gobject_class = G_OBJECT_CLASS (klass);
373
354
  gobject_class->dispose = thunar_window_dispose;
374
355
  gobject_class->finalize = thunar_window_finalize;
582
563
 
583
564
 
584
565
static inline GType
585
 
view_index2type (gint index)
 
566
view_index2type (gint idx)
586
567
{
587
568
  /* this necessary for platforms where sizeof(GType) != sizeof(gint),
588
569
   * see http://bugzilla.xfce.org/show_bug.cgi?id=2726 for details.
590
571
  if (sizeof (GType) == sizeof (gint))
591
572
    {
592
573
      /* no need to map anything */
593
 
      return (GType) index;
 
574
      return (GType) idx;
594
575
    }
595
576
  else
596
577
    {
597
578
      /* map from indices to unique types */
598
 
      switch (index)
 
579
      switch (idx)
599
580
        {
600
581
        case 0:  return THUNAR_TYPE_COMPACT_VIEW;
601
582
        case 1:  return THUNAR_TYPE_DETAILS_VIEW;
610
591
static void
611
592
thunar_window_setup_user_dir_menu_entries (ThunarWindow *window)
612
593
{
613
 
  gint i;
614
594
  static const gchar *callback_names[] = {
615
 
    "open-desktop", "open-documents", "open-downloads", "open-music",
616
 
    "open-pictures", "open-public", "open-templates", "open-videos"
 
595
    "open-desktop", 
 
596
    "open-documents", 
 
597
    "open-downloads", 
 
598
    "open-music",
 
599
    "open-pictures", 
 
600
    "open-public", 
 
601
    "open-templates", 
 
602
    "open-videos", 
 
603
    NULL
617
604
  };
618
 
 
619
 
#if !GLIB_CHECK_VERSION(2, 14, 0)
620
 
 
621
 
  for (i = 0; i < G_N_ELEMENTS(callback_names); i++)
622
 
    {
623
 
      GtkAction *action = gtk_action_group_get_action (window->action_group,
624
 
                                                       callback_names[i]);
625
 
      gtk_action_set_visible (GTK_ACTION (action), FALSE);
626
 
    }
627
 
 
628
 
#else  /* GLIB_CHECK_VERSION(2, 14, 0) */
629
 
 
630
 
  gchar *old_locale     = NULL;
631
 
  gchar *locale         = NULL;
632
 
  gchar *translation    = NULL;
633
 
  /* gchar *dir_name       = NULL;  */  // see below
634
 
  const gchar *home_dir = NULL;
 
605
  GtkAction          *action;
 
606
  GFile              *home_dir;
 
607
  GFile              *dir;
 
608
  gchar              *locale;
 
609
  gchar              *old_locale;
 
610
  const gchar        *path;
 
611
  gchar              *translation;
 
612
  gint                i;
635
613
 
636
614
  bindtextdomain (XDG_USER_DIRS_PACKAGE, PACKAGE_LOCALE_DIR);
637
615
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
646
624
  setlocale (LC_MESSAGES, locale);
647
625
  g_free (locale);
648
626
 
649
 
  home_dir = xfce_get_homedir ();
 
627
  home_dir = thunar_g_file_new_for_home ();
650
628
 
651
 
  for (i = 0; i < THUNAR_USER_N_DIRECTORIES; i++)
 
629
  for (i = 0; i < G_USER_N_DIRECTORIES; i++)
652
630
    {
653
 
      gboolean visible  = FALSE;
654
 
      GtkAction *action = gtk_action_group_get_action (window->action_group,
655
 
                                                       callback_names[i]);
656
 
      gchar *path       = g_strdup (g_get_user_special_dir (i));
 
631
      action = gtk_action_group_get_action (window->action_group, callback_names[i]);
 
632
      path = g_get_user_special_dir (i);
657
633
 
658
634
      /* special case: got NULL for the templates dir. Force it to ~/Templates */
659
 
      if (G_UNLIKELY (path == NULL && i == THUNAR_USER_DIRECTORY_TEMPLATES))
660
 
        path = g_build_path (home_dir, _thunar_user_directory_names[i], NULL);
 
635
      if (G_UNLIKELY (path == NULL && i == G_USER_DIRECTORY_TEMPLATES))
 
636
        dir = g_file_resolve_relative_path (home_dir, _thunar_user_directory_names[i]);
 
637
      else if (path != NULL)
 
638
        dir = g_file_new_for_path (path);
 
639
      else
 
640
        continue;
661
641
 
662
642
      /* xdg user dirs pointing to $HOME must be considered disabled */
663
 
      if (G_LIKELY((path != NULL) && (!exo_str_is_equal (path, home_dir)))) {
664
 
        ThunarVfsPath *vfs_path = thunar_vfs_path_new (path, NULL);
665
 
 
666
 
        if (G_LIKELY(vfs_path != NULL))
667
 
          {
668
 
            visible = TRUE;
669
 
            thunar_vfs_path_unref (vfs_path);
670
 
          }
671
 
      }
672
 
 
673
 
      gtk_action_set_visible (GTK_ACTION (action), visible);
674
 
 
675
 
      /* if an entry is invisible don't waste time translating it */
676
 
      if (G_UNLIKELY (visible == FALSE)) {
677
 
        g_free (path);
678
 
        continue;
679
 
      }
680
 
 
681
 
      /* menu entry label translation */
682
 
      translation = dgettext (XDG_USER_DIRS_PACKAGE, (gchar *) _thunar_user_directory_names[i]);
683
 
      g_object_set (action, "label", translation, NULL);
684
 
 
685
 
      g_free (path);
 
643
      if (G_LIKELY (path != NULL && !g_file_equal (dir, home_dir)))
 
644
        {
 
645
          /* menu entry label translation */
 
646
          translation = dgettext (XDG_USER_DIRS_PACKAGE, (gchar *) _thunar_user_directory_names[i]);
 
647
          g_object_set (action, "label", translation, NULL);
 
648
        }
 
649
      else
 
650
        gtk_action_set_visible (GTK_ACTION (action), FALSE);
 
651
 
 
652
      g_object_unref (dir);
686
653
    }
687
654
 
 
655
  g_object_unref (home_dir);
 
656
 
688
657
  setlocale (LC_MESSAGES, old_locale);
689
 
 
690
 
#endif /* GLIB_CHECK_VERSION(2,14,0) */
691
658
}
692
659
 
693
660
 
710
677
  gint            position;
711
678
  gint            width;
712
679
  gint            height;
 
680
  gboolean        maximized;
713
681
 
714
682
  /* grab a reference on the provider factory */
715
683
  window->provider_factory = thunarx_provider_factory_get_default ();
720
688
  /* allocate the scroll_to_files mapping */
721
689
  window->scroll_to_files = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, g_object_unref);
722
690
 
723
 
  /* connect to the volume manager */
724
 
  window->volume_manager = thunar_vfs_volume_manager_get_default ();
725
 
  g_signal_connect (G_OBJECT (window->volume_manager), "volume-pre-unmount", G_CALLBACK (thunar_window_volume_pre_unmount), window);
 
691
  /* connect to the volume monitor */
 
692
  window->volume_monitor = g_volume_monitor_get ();
 
693
  g_signal_connect (window->volume_monitor, "mount-pre-unmount", G_CALLBACK (thunar_window_mount_pre_unmount), window);
726
694
 
727
695
  /* allocate a closure for the menu_item_selected() callback */
728
696
  window->menu_item_selected_closure = g_cclosure_new_object (G_CALLBACK (thunar_window_menu_item_selected), G_OBJECT (window));
758
726
  /* rename the user dir menu entries and hide the unexisting ones */
759
727
  thunar_window_setup_user_dir_menu_entries (window);
760
728
 
761
 
  /* setup the "open-trash" action */
762
 
  action = thunar_trash_action_new ();
763
 
  g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (thunar_window_action_open_trash), window);
764
 
  gtk_action_group_add_action (window->action_group, action);
765
 
  g_object_unref (G_OBJECT (action));
766
 
 
767
729
  /*
768
730
   * add view options
769
731
   */
805
767
  g_signal_connect_swapped (G_OBJECT (window->launcher), "change-directory", G_CALLBACK (thunar_window_set_current_directory), window);
806
768
 
807
769
  /* determine the default window size from the preferences */
808
 
  g_object_get (G_OBJECT (window->preferences), "last-window-width", &width, "last-window-height", &height, NULL);
 
770
  g_object_get (G_OBJECT (window->preferences), "last-window-width", &width, "last-window-height", &height, "last-window-maximized", &maximized, NULL);
809
771
  gtk_window_set_default_size (GTK_WINDOW (window), width, height);
 
772
  
 
773
  /* restore the maxized state of the window */
 
774
  if (G_UNLIKELY (maximized))
 
775
    gtk_window_maximize (GTK_WINDOW (window));
810
776
 
811
777
  window->table = gtk_table_new (6, 1, FALSE);
812
778
  gtk_container_add (GTK_CONTAINER (window), window->table);
921
887
 
922
888
  /* activate the selected view */
923
889
  action = gtk_action_group_get_action (window->action_group, "view-as-icons");
924
 
  exo_gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), view_type2index (g_type_is_a (type, THUNAR_TYPE_VIEW) ? type : THUNAR_TYPE_ICON_VIEW));
 
890
  gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), view_type2index (g_type_is_a (type, THUNAR_TYPE_VIEW) ? type : THUNAR_TYPE_ICON_VIEW));
925
891
  g_signal_connect (G_OBJECT (action), "changed", G_CALLBACK (thunar_window_action_view_changed), window);
926
892
  thunar_window_action_view_changed (GTK_RADIO_ACTION (action), GTK_RADIO_ACTION (action), window);
927
893
 
951
917
      window->custom_preferences_merge_id = 0;
952
918
    }
953
919
 
 
920
  /* un-merge the go menu actions */
 
921
  if (G_LIKELY (window->go_items_actions_merge_id != 0))
 
922
    {
 
923
      gtk_ui_manager_remove_ui (window->ui_manager, window->go_items_actions_merge_id);
 
924
      window->go_items_actions_merge_id = 0;
 
925
    }
 
926
 
954
927
  /* disconnect from the current-directory */
955
928
  thunar_window_set_current_directory (window, NULL);
956
929
 
968
941
  g_closure_unref (window->menu_item_deselected_closure);
969
942
  g_closure_unref (window->menu_item_selected_closure);
970
943
 
971
 
  /* disconnect from the volume manager */
972
 
  g_signal_handlers_disconnect_matched (G_OBJECT (window->volume_manager), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, window);
973
 
  g_object_unref (G_OBJECT (window->volume_manager));
 
944
  /* disconnect from the volume monitor */
 
945
  g_signal_handlers_disconnect_matched (window->volume_monitor, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, window);
 
946
  g_object_unref (window->volume_monitor);
974
947
 
975
948
  /* disconnect from the ui manager */
976
 
  g_signal_handlers_disconnect_matched (G_OBJECT (window->ui_manager), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, window);
977
 
  g_object_unref (G_OBJECT (window->ui_manager));
 
949
  g_signal_handlers_disconnect_matched (window->ui_manager, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, window);
 
950
  g_object_unref (window->ui_manager);
978
951
 
979
 
  g_object_unref (G_OBJECT (window->action_group));
980
 
  g_object_unref (G_OBJECT (window->icon_factory));
981
 
  g_object_unref (G_OBJECT (window->launcher));
982
 
  g_object_unref (G_OBJECT (window->history));
 
952
  g_object_unref (window->action_group);
 
953
  g_object_unref (window->icon_factory);
 
954
  g_object_unref (window->launcher);
 
955
  g_object_unref (window->history);
983
956
 
984
957
  /* release our reference on the provider factory */
985
 
  g_object_unref (G_OBJECT (window->provider_factory));
 
958
  g_object_unref (window->provider_factory);
986
959
 
987
960
  /* release the preferences reference */
988
 
  g_object_unref (G_OBJECT (window->preferences));
 
961
  g_object_unref (window->preferences);
989
962
 
990
963
  /* release the scroll_to_files hash table */
991
964
  g_hash_table_destroy (window->scroll_to_files);
1419
1392
 
1420
1393
 
1421
1394
 
 
1395
void
 
1396
thunar_window_merge_go_actions (ThunarWindow *window)
 
1397
{
 
1398
  GtkAction *action;
 
1399
 
 
1400
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
 
1401
  _thunar_return_if_fail (window->go_items_actions_merge_id == 0);
 
1402
 
 
1403
  /* allocate a new merge id from the UI manager */
 
1404
  window->go_items_actions_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager);
 
1405
 
 
1406
  /* setup the "open-trash" action */
 
1407
  if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
 
1408
    {
 
1409
      /* add the trash action to the action group */
 
1410
      action = thunar_trash_action_new ();
 
1411
      g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (thunar_window_action_open_trash), window);
 
1412
      gtk_action_group_add_action (window->action_group, action);
 
1413
 
 
1414
      /* add the action to the UI manager */
 
1415
      gtk_ui_manager_add_ui (window->ui_manager,
 
1416
                             window->go_items_actions_merge_id,
 
1417
                             "/main-menu/go-menu/placeholder-go-items-actions",
 
1418
                             gtk_action_get_name (GTK_ACTION (action)),
 
1419
                             gtk_action_get_name (GTK_ACTION (action)),
 
1420
                             GTK_UI_MANAGER_MENUITEM, FALSE);
 
1421
 
 
1422
      g_object_unref (action);
 
1423
    }
 
1424
 
 
1425
  /* add the file system action to the UI manager */
 
1426
  {
 
1427
    action = gtk_action_group_get_action (window->action_group, "open-file-system");
 
1428
    gtk_ui_manager_add_ui (window->ui_manager,
 
1429
                           window->go_items_actions_merge_id,
 
1430
                           "/main-menu/go-menu/placeholder-go-items-actions",
 
1431
                           gtk_action_get_name (GTK_ACTION (action)),
 
1432
                           gtk_action_get_name (GTK_ACTION (action)),
 
1433
                           GTK_UI_MANAGER_MENUITEM, FALSE);
 
1434
  }
 
1435
 
 
1436
  /* setup the "open-network" action */
 
1437
  if (thunar_g_vfs_is_uri_scheme_supported ("network"))
 
1438
    {
 
1439
      /* create the network action */
 
1440
      action = gtk_action_new ("open-network", _("Network"), _("Browse the network"), 
 
1441
                               GTK_STOCK_NETWORK);
 
1442
      g_signal_connect (action, "activate", G_CALLBACK (thunar_window_action_open_network), window);
 
1443
 
 
1444
      /* add the network action to the action group */
 
1445
      gtk_action_group_add_action (window->action_group, action);
 
1446
 
 
1447
      /* add the action to the UI manager */
 
1448
      gtk_ui_manager_add_ui (window->ui_manager,
 
1449
                             window->go_items_actions_merge_id,
 
1450
                             "/main-menu/go-menu/placeholder-go-items-actions",
 
1451
                             gtk_action_get_name (GTK_ACTION (action)),
 
1452
                             gtk_action_get_name (GTK_ACTION (action)),
 
1453
                             GTK_UI_MANAGER_MENUITEM, FALSE);
 
1454
 
 
1455
      g_object_unref (action);
 
1456
    }
 
1457
}
 
1458
 
 
1459
 
 
1460
 
 
1461
static void
 
1462
thunar_window_open_or_launch (ThunarWindow *window,
 
1463
                              ThunarFile   *file)
 
1464
{
 
1465
  GError *error = NULL;
 
1466
 
 
1467
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
 
1468
  _thunar_return_if_fail (THUNAR_IS_FILE (file));
 
1469
 
 
1470
  if (thunar_file_is_directory (file))
 
1471
    {
 
1472
      /* open the new directory */
 
1473
      thunar_window_set_current_directory (window, file);
 
1474
    }
 
1475
  else
 
1476
    {
 
1477
      /* try to launch the selected file */
 
1478
      if (!thunar_file_launch (file, window, NULL, &error))
 
1479
        {
 
1480
          thunar_dialogs_show_error (window, error, _("Failed to launch \"%s\""),
 
1481
                                     thunar_file_get_display_name (file));
 
1482
          g_error_free (error);
 
1483
        }
 
1484
    }
 
1485
}
 
1486
 
 
1487
 
 
1488
 
 
1489
static void
 
1490
thunar_window_poke_file_finish (ThunarBrowser *browser,
 
1491
                                ThunarFile    *file,
 
1492
                                ThunarFile    *target_file,
 
1493
                                GError        *error,
 
1494
                                gpointer       ignored)
 
1495
{
 
1496
  _thunar_return_if_fail (THUNAR_IS_WINDOW (browser));
 
1497
  _thunar_return_if_fail (THUNAR_IS_FILE (file));
 
1498
 
 
1499
  if (error == NULL)
 
1500
    {
 
1501
      thunar_window_open_or_launch (THUNAR_WINDOW (browser), target_file);
 
1502
    }
 
1503
  else
 
1504
    {
 
1505
      thunar_dialogs_show_error (GTK_WIDGET (browser), error, 
 
1506
                                 _("Failed to open \"%s\""),
 
1507
                                 thunar_file_get_display_name (file));
 
1508
    }
 
1509
}
 
1510
 
 
1511
 
 
1512
 
1422
1513
static void
1423
1514
thunar_window_start_open_location (ThunarWindow *window,
1424
1515
                                   const gchar  *initial_text)
1425
1516
{
1426
1517
  ThunarFile *selected_file;
1427
1518
  GtkWidget  *dialog;
1428
 
  GError     *error = NULL;
 
1519
  
 
1520
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
1429
1521
 
1430
1522
  /* bring up the "Open Location"-dialog if the window has no location bar or the location bar
1431
1523
   * in the window does not support text entry by the user.
1452
1544
      /* run the dialog */
1453
1545
      if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
1454
1546
        {
 
1547
          /* be sure to hide the location dialog first */
 
1548
          gtk_widget_hide (dialog);
 
1549
 
1455
1550
          /* check if we have a new directory or a file to launch */
1456
1551
          selected_file = thunar_location_dialog_get_selected_file (THUNAR_LOCATION_DIALOG (dialog));
1457
 
          if (thunar_file_is_directory (selected_file))
1458
 
            {
1459
 
              /* open the new directory */
1460
 
              thunar_window_set_current_directory (window, selected_file);
1461
 
            }
1462
 
          else
1463
 
            {
1464
 
              /* be sure to hide the location dialog first */
1465
 
              gtk_widget_hide (dialog);
1466
 
 
1467
 
              /* try to launch the selected file */
1468
 
              if (!thunar_file_launch (selected_file, GTK_WIDGET (window), &error))
1469
 
                {
1470
 
                  thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to launch \"%s\""), thunar_file_get_display_name (selected_file));
1471
 
                  g_error_free (error);
1472
 
                }
 
1552
          if (selected_file != NULL)
 
1553
            {
 
1554
              thunar_browser_poke_file (THUNAR_BROWSER (window), selected_file, window, 
 
1555
                                        thunar_window_poke_file_finish, NULL);
1473
1556
            }
1474
1557
        }
1475
1558
 
1491
1574
  /* popup a new window */
1492
1575
  application = thunar_application_get ();
1493
1576
  new_window = thunar_application_open_window (application, window->current_directory,
1494
 
                                               gtk_widget_get_screen (GTK_WIDGET (window)));
 
1577
                                               gtk_widget_get_screen (GTK_WIDGET (window)), NULL);
1495
1578
  g_object_unref (G_OBJECT (application));
1496
1579
 
1497
1580
  /* determine the first visible file in the current window */
1515
1598
 
1516
1599
  /* launch the operation */
1517
1600
  application = thunar_application_get ();
1518
 
  thunar_application_empty_trash (application, GTK_WIDGET (window));
 
1601
  thunar_application_empty_trash (application, GTK_WIDGET (window), NULL);
1519
1602
  g_object_unref (G_OBJECT (application));
1520
1603
}
1521
1604
 
1878
1961
thunar_window_action_open_home (GtkAction    *action,
1879
1962
                                ThunarWindow *window)
1880
1963
{
1881
 
  ThunarVfsPath *home_path;
 
1964
  GFile         *home;
1882
1965
  ThunarFile    *home_file;
1883
1966
  GError        *error = NULL;
1884
1967
 
1885
 
  _thunar_return_if_fail (GTK_IS_ACTION (action));
1886
1968
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
1887
1969
 
1888
1970
  /* determine the path to the home directory */
1889
 
  home_path = thunar_vfs_path_get_for_home ();
 
1971
  home = thunar_g_file_new_for_home ();
1890
1972
 
1891
1973
  /* determine the file for the home directory */
1892
 
  home_file = thunar_file_get_for_path (home_path, &error);
 
1974
  home_file = thunar_file_get (home, &error);
1893
1975
  if (G_UNLIKELY (home_file == NULL))
1894
1976
    {
1895
1977
      /* display an error to the user */
1904
1986
    }
1905
1987
 
1906
1988
  /* release our reference on the home path */
1907
 
  thunar_vfs_path_unref (home_path);
 
1989
  g_object_unref (home);
1908
1990
}
1909
1991
 
1910
 
gboolean
 
1992
 
 
1993
 
 
1994
static gboolean
1911
1995
thunar_window_open_user_folder (GtkAction           *action,
1912
1996
                                ThunarWindow        *window,
1913
1997
                                ThunarUserDirectory  thunar_user_dir,
1914
1998
                                const gchar         *default_name)
1915
1999
{
1916
2000
  ThunarFile *user_file = NULL;
1917
 
  GError     *error     = NULL;
1918
 
  gchar      *user_dir  = NULL;
1919
 
  gboolean    result    = FALSE;
1920
 
 
1921
 
#if GLIB_CHECK_VERSION(2, 14, 0)
1922
 
  user_dir = g_strdup (g_get_user_special_dir (thunar_user_dir));
1923
 
#endif
1924
 
 
1925
 
  if (G_UNLIKELY (user_dir == NULL))
 
2001
  gboolean    result = FALSE;
 
2002
  GError     *error = NULL;
 
2003
  GFile      *home_dir;
 
2004
  GFile      *user_dir;
 
2005
  gchar      *path = NULL;
 
2006
 
 
2007
  path = g_strdup (g_get_user_special_dir (thunar_user_dir));
 
2008
 
 
2009
  if (G_UNLIKELY (path == NULL))
1926
2010
    {
1927
 
      user_dir = g_build_filename (G_DIR_SEPARATOR_S, xfce_get_homedir (),
1928
 
                                   default_name, NULL);
 
2011
      home_dir = thunar_g_file_new_for_home ();
 
2012
      user_dir = g_file_resolve_relative_path (home_dir, default_name);
 
2013
      path = g_file_get_path (user_dir);
 
2014
      g_object_unref (home_dir);
1929
2015
    }
 
2016
  else
 
2017
    user_dir = g_file_new_for_path (path);
1930
2018
 
1931
 
  user_file = thunar_file_get_for_uri (user_dir, &error);
1932
 
  if (G_UNLIKELY (user_file == NULL && error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_EXIST))
 
2019
  user_file = thunar_file_get (user_dir, &error);
 
2020
  if (G_UNLIKELY (user_file == NULL && error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT))
1933
2021
    {
1934
2022
      g_error_free (error);
1935
2023
      error = NULL;
1936
2024
 
1937
2025
      /* try to create the folder */
1938
 
      if (G_LIKELY (xfce_mkdirhier (user_dir, 0755, &error)))
1939
 
        user_file = thunar_file_get_for_uri (user_dir, &error);
 
2026
      if (G_LIKELY (xfce_mkdirhier (path, 0755, &error)))
 
2027
        user_file = thunar_file_get (user_dir, &error);
1940
2028
    }
1941
2029
 
1942
2030
  if (G_LIKELY (user_file != NULL))
1956
2044
        g_error_free (error);
1957
2045
    }
1958
2046
 
1959
 
  g_free (user_dir);
 
2047
  g_object_unref (user_dir);
 
2048
  g_free (path);
1960
2049
 
1961
2050
  return result;
1962
2051
}
1963
2052
 
 
2053
 
 
2054
 
1964
2055
static void
1965
2056
thunar_window_action_open_desktop (GtkAction     *action,
1966
2057
                                   ThunarWindow  *window)
1967
2058
{
1968
 
#if GLIB_CHECK_VERSION(2, 14, 0)
1969
2059
  _thunar_return_if_fail (GTK_IS_ACTION (action));
1970
2060
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
1971
2061
 
1972
2062
  thunar_window_open_user_folder (action, window,
1973
2063
                                  THUNAR_USER_DIRECTORY_DESKTOP,
1974
2064
                                  "Desktop");
1975
 
#endif
1976
2065
}
1977
2066
 
 
2067
 
 
2068
 
1978
2069
static void
1979
2070
thunar_window_action_open_documents (GtkAction     *action,
1980
2071
                                     ThunarWindow  *window)
1981
2072
{
1982
 
#if GLIB_CHECK_VERSION(2, 14, 0)
1983
2073
  _thunar_return_if_fail (GTK_IS_ACTION (action));
1984
2074
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
1985
2075
 
1986
2076
  thunar_window_open_user_folder (action, window,
1987
2077
                                  THUNAR_USER_DIRECTORY_DOCUMENTS,
1988
2078
                                  "Documents");
1989
 
#endif
1990
2079
}
1991
2080
 
 
2081
 
 
2082
 
1992
2083
static void
1993
2084
thunar_window_action_open_downloads (GtkAction     *action,
1994
2085
                                     ThunarWindow  *window)
1995
2086
{
1996
 
#if GLIB_CHECK_VERSION(2, 14, 0)
1997
2087
  _thunar_return_if_fail (GTK_IS_ACTION (action));
1998
2088
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
1999
2089
 
2000
2090
  thunar_window_open_user_folder (action, window,
2001
2091
                                  THUNAR_USER_DIRECTORY_DOWNLOAD,
2002
2092
                                  "Downloads");
2003
 
#endif
2004
2093
}
2005
2094
 
 
2095
 
 
2096
 
2006
2097
static void
2007
2098
thunar_window_action_open_music (GtkAction     *action,
2008
2099
                                 ThunarWindow  *window)
2009
2100
{
2010
 
#if GLIB_CHECK_VERSION(2, 14, 0)
2011
2101
  _thunar_return_if_fail (GTK_IS_ACTION (action));
2012
2102
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2013
2103
 
2014
2104
  thunar_window_open_user_folder (action, window,
2015
2105
                                  THUNAR_USER_DIRECTORY_MUSIC,
2016
2106
                                  "Music");
2017
 
#endif
2018
2107
}
2019
2108
 
 
2109
 
 
2110
 
2020
2111
static void
2021
2112
thunar_window_action_open_pictures (GtkAction     *action,
2022
2113
                                    ThunarWindow  *window)
2023
2114
{
2024
 
#if GLIB_CHECK_VERSION(2, 14, 0)
2025
2115
  _thunar_return_if_fail (GTK_IS_ACTION (action));
2026
2116
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2027
2117
 
2028
2118
  thunar_window_open_user_folder (action, window,
2029
2119
                                  THUNAR_USER_DIRECTORY_PICTURES,
2030
2120
                                  "Pictures");
2031
 
#endif
2032
2121
}
2033
2122
 
 
2123
 
 
2124
 
2034
2125
static void
2035
2126
thunar_window_action_open_public (GtkAction     *action,
2036
2127
                                  ThunarWindow  *window)
2037
2128
{
2038
 
#if GLIB_CHECK_VERSION(2, 14, 0)
2039
2129
  _thunar_return_if_fail (GTK_IS_ACTION (action));
2040
2130
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2041
2131
 
2042
2132
  thunar_window_open_user_folder (action, window,
2043
2133
                                  THUNAR_USER_DIRECTORY_PUBLIC_SHARE,
2044
2134
                                  "Public");
2045
 
#endif
2046
2135
}
2047
2136
 
 
2137
 
 
2138
 
2048
2139
static void
2049
2140
thunar_window_action_open_templates (GtkAction    *action,
2050
2141
                                     ThunarWindow *window)
2125
2216
}
2126
2217
 
2127
2218
 
 
2219
 
2128
2220
static void
2129
2221
thunar_window_action_open_videos (GtkAction     *action,
2130
2222
                                  ThunarWindow  *window)
2131
2223
{
2132
 
#if GLIB_CHECK_VERSION(2, 14, 0)
2133
2224
  _thunar_return_if_fail (GTK_IS_ACTION (action));
2134
2225
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2135
2226
 
2136
2227
  thunar_window_open_user_folder (action, window,
2137
2228
                                  THUNAR_USER_DIRECTORY_VIDEOS,
2138
2229
                                  "Videos");
2139
 
#endif
2140
 
}
 
2230
}
 
2231
 
 
2232
 
 
2233
 
 
2234
static void
 
2235
thunar_window_action_open_file_system (GtkAction    *action,
 
2236
                                       ThunarWindow *window)
 
2237
{
 
2238
  GFile         *root;
 
2239
  ThunarFile    *root_file;
 
2240
  GError        *error = NULL;
 
2241
 
 
2242
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
 
2243
 
 
2244
  /* determine the path to the root directory */
 
2245
  root = thunar_g_file_new_for_root ();
 
2246
 
 
2247
  /* determine the file for the root directory */
 
2248
  root_file = thunar_file_get (root, &error);
 
2249
  if (G_UNLIKELY (root_file == NULL))
 
2250
    {
 
2251
      /* display an error to the user */
 
2252
      thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the file system root folder"));
 
2253
      g_error_free (error);
 
2254
    }
 
2255
  else
 
2256
    {
 
2257
      /* open the root folder */
 
2258
      thunar_window_set_current_directory (window, root_file);
 
2259
      g_object_unref (G_OBJECT (root_file));
 
2260
    }
 
2261
 
 
2262
  /* release our reference on the home path */
 
2263
  g_object_unref (root);
 
2264
}
 
2265
 
2141
2266
 
2142
2267
 
2143
2268
static void
2144
2269
thunar_window_action_open_trash (GtkAction    *action,
2145
2270
                                 ThunarWindow *window)
2146
2271
{
2147
 
  ThunarVfsPath *trash_bin_path;
2148
 
  ThunarFile    *trash_bin;
2149
 
  GError        *error = NULL;
 
2272
  GFile      *trash_bin;
 
2273
  ThunarFile *trash_bin_file;
 
2274
  GError     *error = NULL;
2150
2275
 
2151
2276
  _thunar_return_if_fail (GTK_IS_ACTION (action));
2152
2277
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2153
2278
 
2154
2279
  /* determine the path to the trash bin */
2155
 
  trash_bin_path = thunar_vfs_path_get_for_trash ();
 
2280
  trash_bin = thunar_g_file_new_for_trash ();
2156
2281
 
2157
2282
  /* determine the file for the trash bin */
2158
 
  trash_bin = thunar_file_get_for_path (trash_bin_path, &error);
2159
 
  if (G_UNLIKELY (trash_bin == NULL))
 
2283
  trash_bin_file = thunar_file_get (trash_bin, &error);
 
2284
  if (G_UNLIKELY (trash_bin_file == NULL))
2160
2285
    {
2161
2286
      /* display an error to the user */
2162
2287
      thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to display the contents of the trash can"));
2165
2290
  else
2166
2291
    {
2167
2292
      /* open the trash folder */
2168
 
      thunar_window_set_current_directory (window, trash_bin);
2169
 
      g_object_unref (G_OBJECT (trash_bin));
 
2293
      thunar_window_set_current_directory (window, trash_bin_file);
 
2294
      g_object_unref (G_OBJECT (trash_bin_file));
2170
2295
    }
2171
2296
 
2172
2297
  /* release our reference on the trash bin path */
2173
 
  thunar_vfs_path_unref (trash_bin_path);
 
2298
  g_object_unref (trash_bin);
 
2299
}
 
2300
 
 
2301
 
 
2302
 
 
2303
static void
 
2304
thunar_window_action_open_network (GtkAction    *action,
 
2305
                                   ThunarWindow *window)
 
2306
{
 
2307
  ThunarFile *network_file;
 
2308
  GError     *error = NULL;
 
2309
  GFile      *network;
 
2310
 
 
2311
  _thunar_return_if_fail (GTK_IS_ACTION (action));
 
2312
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
 
2313
 
 
2314
  /* determine the network root location */
 
2315
  network = g_file_new_for_uri ("network://");
 
2316
 
 
2317
  /* determine the file for this location */
 
2318
  network_file = thunar_file_get (network, &error);
 
2319
  if (G_UNLIKELY (network_file == NULL))
 
2320
    {
 
2321
      /* display an error to the user */
 
2322
      thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to browse the network"));
 
2323
      g_error_free (error);
 
2324
    }
 
2325
  else
 
2326
    {
 
2327
      /* open the network root location */
 
2328
      thunar_window_set_current_directory (window, network_file);
 
2329
      g_object_unref (G_OBJECT (network_file));
 
2330
    }
 
2331
 
 
2332
  /* release our reference on the location itself */
 
2333
  g_object_unref (network);
2174
2334
}
2175
2335
 
2176
2336
 
2236
2396
 
2237
2397
  /* update the "Empty Trash" action */
2238
2398
  action = gtk_action_group_get_action (window->action_group, "empty-trash");
2239
 
  gtk_action_set_sensitive (action, (thunar_file_get_size (current_directory) > 0));
 
2399
  gtk_action_set_sensitive (action, (thunar_file_get_item_count (current_directory) > 0));
2240
2400
  gtk_action_set_visible (action, (thunar_file_is_root (current_directory) && thunar_file_is_trashed (current_directory)));
2241
2401
 
2242
2402
  /* set window title and icon */
2254
2414
thunar_window_current_directory_destroy (ThunarFile   *current_directory,
2255
2415
                                         ThunarWindow *window)
2256
2416
{
2257
 
  ThunarVfsPath *path;
2258
 
  ThunarVfsInfo *info;
2259
 
  ThunarFile    *file = NULL;
 
2417
  ThunarFile *new_directory = NULL;
 
2418
  GFile      *path;
 
2419
  GFile      *tmp;
2260
2420
 
2261
2421
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2262
2422
  _thunar_return_if_fail (THUNAR_IS_FILE (current_directory));
2263
2423
  _thunar_return_if_fail (window->current_directory == current_directory);
2264
2424
 
2265
2425
  /* determine the path of the current directory */
2266
 
  path = thunar_file_get_path (current_directory);
 
2426
  path = g_object_ref (thunar_file_get_file (current_directory));
2267
2427
 
2268
 
  /* determine the first still present parent directory */
2269
 
  for (path = thunar_vfs_path_get_parent (path); file == NULL && path != NULL; path = thunar_vfs_path_get_parent (path))
 
2428
  /* try to find a parent directory that still exists */
 
2429
  while (new_directory == NULL)
2270
2430
    {
2271
 
      /* try to determine the info for the path */
2272
 
      info = thunar_vfs_info_new_for_path (path, NULL);
2273
 
      if (G_LIKELY (info != NULL))
2274
 
        {
2275
 
          /* check if we have a directory here */
2276
 
          if (info->type == THUNAR_VFS_FILE_TYPE_DIRECTORY)
2277
 
            file = thunar_file_get_for_info (info);
2278
 
 
2279
 
          /* release the file info */
2280
 
          thunar_vfs_info_unref (info);
 
2431
      /* check whether the current directory exists */
 
2432
      if (g_file_query_exists (path, NULL))
 
2433
        {
 
2434
          /* it does, try to load the file */
 
2435
          new_directory = thunar_file_get (path, NULL);
 
2436
 
 
2437
          /* fall back to $HOME if loading the file failed */
 
2438
          if (new_directory == NULL)
 
2439
            break;
 
2440
        }
 
2441
      else
 
2442
        {
 
2443
          /* determine the parent of the directory */
 
2444
          tmp = g_file_get_parent (path);
 
2445
          
 
2446
          /* if there's no parent this means that we've found no parent
 
2447
           * that still exists at all. Fall back to $HOME then */
 
2448
          if (tmp == NULL)
 
2449
            break;
 
2450
 
 
2451
          /* free the old directory */
 
2452
          g_object_unref (path);
 
2453
 
 
2454
          /* check the parent next */
 
2455
          path = tmp;
2281
2456
        }
2282
2457
    }
2283
2458
 
 
2459
  /* make sure we don't leak */
 
2460
  if (path != NULL)
 
2461
    g_object_unref (path);
 
2462
 
2284
2463
  /* check if we have a new folder */
2285
 
  if (G_LIKELY (file != NULL))
 
2464
  if (G_LIKELY (new_directory != NULL))
2286
2465
    {
2287
2466
      /* enter the new folder */
2288
 
      thunar_window_set_current_directory (window, file);
 
2467
      thunar_window_set_current_directory (window, new_directory);
2289
2468
 
2290
2469
      /* release the file reference */
2291
 
      g_object_unref (G_OBJECT (file));
 
2470
      g_object_unref (new_directory);
 
2471
    }
 
2472
  else
 
2473
    {
 
2474
      /* enter the home folder */
 
2475
      thunar_window_action_open_home (NULL, window);
2292
2476
    }
2293
2477
}
2294
2478
 
2402
2586
 
2403
2587
 
2404
2588
static void
2405
 
thunar_window_volume_pre_unmount (ThunarVfsVolumeManager *volume_manager,
2406
 
                                  ThunarVfsVolume        *volume,
2407
 
                                  ThunarWindow           *window)
 
2589
thunar_window_mount_pre_unmount (GVolumeMonitor *volume_monitor,
 
2590
                                 GMount         *mount,
 
2591
                                 ThunarWindow   *window)
2408
2592
{
2409
 
  ThunarVfsPath *path;
2410
 
  ThunarFile    *file;
2411
 
  GtkAction     *action;
 
2593
  ThunarFile *file;
 
2594
  GtkAction  *action;
 
2595
  GFile      *mount_point;
2412
2596
 
2413
 
  _thunar_return_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER (volume_manager));
2414
 
  _thunar_return_if_fail (THUNAR_VFS_IS_VOLUME (volume));
 
2597
  _thunar_return_if_fail (G_IS_VOLUME_MONITOR (volume_monitor));
 
2598
  _thunar_return_if_fail (window->volume_monitor == volume_monitor);
 
2599
  _thunar_return_if_fail (G_IS_MOUNT (mount));
2415
2600
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2416
2601
 
2417
2602
  /* nothing to do if we don't have a current directory */
2418
2603
  if (G_UNLIKELY (window->current_directory == NULL))
2419
2604
    return;
2420
2605
 
2421
 
  /* determine the mount point for the volume */
2422
 
  path = thunar_vfs_volume_get_mount_point (volume);
2423
 
  if (G_UNLIKELY (path == NULL))
2424
 
    return;
 
2606
  /* try to get the ThunarFile for the mount point from the file cache */
 
2607
  mount_point = g_mount_get_root (mount);
 
2608
  file = thunar_file_cache_lookup (mount_point);
 
2609
  g_object_unref (mount_point);
2425
2610
 
2426
 
  /* check if a ThunarFile is known for the mount point */
2427
 
  file = thunar_file_cache_lookup (path);
2428
2611
  if (G_UNLIKELY (file == NULL))
2429
2612
    return;
2430
2613
 
2448
2631
  /* merge custom preferences from the providers */
2449
2632
  GDK_THREADS_ENTER ();
2450
2633
  thunar_window_merge_custom_preferences (window);
 
2634
  thunar_window_merge_go_actions (window);
2451
2635
  GDK_THREADS_LEAVE ();
2452
2636
 
2453
2637
  return FALSE;
2491
2675
              gtk_window_get_size (GTK_WINDOW (window), &width, &height);
2492
2676
 
2493
2677
              /* ...and remember them as default for new windows */
2494
 
              g_object_set (G_OBJECT (window->preferences), "last-window-width", width, "last-window-height", height, NULL);
 
2678
              g_object_set (G_OBJECT (window->preferences), "last-window-width", width, "last-window-height", height,
 
2679
                            "last-window-maximized", FALSE, NULL);
 
2680
            }
 
2681
          else
 
2682
            {
 
2683
              /* only store that the window is full screen */
 
2684
              g_object_set (G_OBJECT (window->preferences), "last-window-maximized", TRUE, NULL);
2495
2685
            }
2496
2686
        }
2497
2687
    }
2556
2746
                                     ThunarFile   *current_directory)
2557
2747
{
2558
2748
  ThunarFile *file;
 
2749
  ThunarFile *selected_file;
 
2750
  GList       selected_files;
2559
2751
 
2560
2752
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2561
2753
  _thunar_return_if_fail (current_directory == NULL || THUNAR_IS_FILE (current_directory));
2562
 
 
 
2754
  
2563
2755
  /* check if we already display the requested directory */
2564
2756
  if (G_UNLIKELY (window->current_directory == current_directory))
2565
2757
    return;
2619
2811
      file = g_hash_table_lookup (window->scroll_to_files, window->current_directory);
2620
2812
      if (G_LIKELY (file != NULL))
2621
2813
        thunar_window_scroll_to_file (window, file, FALSE, TRUE, 0.0f, 0.0f);
 
2814
 
 
2815
      /* reset the selected files list */
 
2816
      selected_files.data = NULL;
 
2817
      selected_files.prev = NULL;
 
2818
      selected_files.next = NULL;
 
2819
      
 
2820
      /* determine the next file in the history */
 
2821
      selected_file = thunar_history_peek_forward (window->history);
 
2822
      if (selected_file != NULL)
 
2823
        {
 
2824
          /* mark the file from history for selection if it is inside the new
 
2825
           * directory */
 
2826
          if (thunar_file_is_parent (window->current_directory, selected_file))
 
2827
            selected_files.data = selected_file;
 
2828
        }
 
2829
 
 
2830
      /* do the same with the previous file in the history */
 
2831
      if (selected_files.data == NULL)
 
2832
        {
 
2833
          selected_file = thunar_history_peek_back (window->history);
 
2834
          if (selected_file != NULL)
 
2835
            {
 
2836
              /* mark the file from history for selection if it is inside the 
 
2837
               * new directory */
 
2838
              if (thunar_file_is_parent (window->current_directory, selected_file))
 
2839
                selected_files.data = selected_file;
 
2840
            }
 
2841
        }
 
2842
 
 
2843
      /* select the previous or next file from the history if it is inside the
 
2844
       * new current directory */
 
2845
      if (selected_files.data != NULL)
 
2846
        thunar_component_set_selected_files (THUNAR_COMPONENT (window->view), &selected_files);
2622
2847
    }
2623
2848
}
2624
2849
 
2653
2878
                              ThunarZoomLevel zoom_level)
2654
2879
{
2655
2880
  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2656
 
  _thunar_return_if_fail (zoom_level >= 0 && zoom_level < THUNAR_ZOOM_N_LEVELS);
 
2881
  _thunar_return_if_fail (zoom_level < THUNAR_ZOOM_N_LEVELS);
2657
2882
 
2658
2883
  /* check if we have a new zoom level */
2659
2884
  if (G_LIKELY (window->zoom_level != zoom_level))