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), },
328
static GObjectClass *thunar_window_parent_class;
329
static guint window_signals[LAST_SIGNAL];
334
thunar_window_get_type (void)
336
static GType type = G_TYPE_INVALID;
338
if (G_UNLIKELY (type == G_TYPE_INVALID))
340
static const GTypeInfo info =
342
sizeof (ThunarWindowClass),
345
(GClassInitFunc) thunar_window_class_init,
348
sizeof (ThunarWindow),
350
(GInstanceInitFunc) thunar_window_init,
354
type = g_type_register_static (GTK_TYPE_WINDOW, I_("ThunarWindow"), &info, 0);
337
static guint window_signals[LAST_SIGNAL];
341
G_DEFINE_TYPE_WITH_CODE (ThunarWindow, thunar_window, GTK_TYPE_WINDOW,
342
G_IMPLEMENT_INTERFACE (THUNAR_TYPE_BROWSER, NULL))
611
592
thunar_window_setup_user_dir_menu_entries (ThunarWindow *window)
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"
619
#if !GLIB_CHECK_VERSION(2, 14, 0)
621
for (i = 0; i < G_N_ELEMENTS(callback_names); i++)
623
GtkAction *action = gtk_action_group_get_action (window->action_group,
625
gtk_action_set_visible (GTK_ACTION (action), FALSE);
628
#else /* GLIB_CHECK_VERSION(2, 14, 0) */
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;
636
614
bindtextdomain (XDG_USER_DIRS_PACKAGE, PACKAGE_LOCALE_DIR);
637
615
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
646
624
setlocale (LC_MESSAGES, locale);
649
home_dir = xfce_get_homedir ();
627
home_dir = thunar_g_file_new_for_home ();
651
for (i = 0; i < THUNAR_USER_N_DIRECTORIES; i++)
629
for (i = 0; i < G_USER_N_DIRECTORIES; i++)
653
gboolean visible = FALSE;
654
GtkAction *action = gtk_action_group_get_action (window->action_group,
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);
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);
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);
666
if (G_LIKELY(vfs_path != NULL))
669
thunar_vfs_path_unref (vfs_path);
673
gtk_action_set_visible (GTK_ACTION (action), visible);
675
/* if an entry is invisible don't waste time translating it */
676
if (G_UNLIKELY (visible == FALSE)) {
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);
643
if (G_LIKELY (path != NULL && !g_file_equal (dir, home_dir)))
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);
650
gtk_action_set_visible (GTK_ACTION (action), FALSE);
652
g_object_unref (dir);
655
g_object_unref (home_dir);
688
657
setlocale (LC_MESSAGES, old_locale);
690
#endif /* GLIB_CHECK_VERSION(2,14,0) */
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);
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);
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));
805
767
g_signal_connect_swapped (G_OBJECT (window->launcher), "change-directory", G_CALLBACK (thunar_window_set_current_directory), window);
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);
773
/* restore the maxized state of the window */
774
if (G_UNLIKELY (maximized))
775
gtk_window_maximize (GTK_WINDOW (window));
811
777
window->table = gtk_table_new (6, 1, FALSE);
812
778
gtk_container_add (GTK_CONTAINER (window), window->table);
968
941
g_closure_unref (window->menu_item_deselected_closure);
969
942
g_closure_unref (window->menu_item_selected_closure);
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);
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);
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);
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);
987
960
/* release the preferences reference */
988
g_object_unref (G_OBJECT (window->preferences));
961
g_object_unref (window->preferences);
990
963
/* release the scroll_to_files hash table */
991
964
g_hash_table_destroy (window->scroll_to_files);
1396
thunar_window_merge_go_actions (ThunarWindow *window)
1400
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
1401
_thunar_return_if_fail (window->go_items_actions_merge_id == 0);
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);
1406
/* setup the "open-trash" action */
1407
if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
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);
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);
1422
g_object_unref (action);
1425
/* add the file system action to the UI manager */
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);
1436
/* setup the "open-network" action */
1437
if (thunar_g_vfs_is_uri_scheme_supported ("network"))
1439
/* create the network action */
1440
action = gtk_action_new ("open-network", _("Network"), _("Browse the network"),
1442
g_signal_connect (action, "activate", G_CALLBACK (thunar_window_action_open_network), window);
1444
/* add the network action to the action group */
1445
gtk_action_group_add_action (window->action_group, action);
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);
1455
g_object_unref (action);
1462
thunar_window_open_or_launch (ThunarWindow *window,
1465
GError *error = NULL;
1467
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
1468
_thunar_return_if_fail (THUNAR_IS_FILE (file));
1470
if (thunar_file_is_directory (file))
1472
/* open the new directory */
1473
thunar_window_set_current_directory (window, file);
1477
/* try to launch the selected file */
1478
if (!thunar_file_launch (file, window, NULL, &error))
1480
thunar_dialogs_show_error (window, error, _("Failed to launch \"%s\""),
1481
thunar_file_get_display_name (file));
1482
g_error_free (error);
1490
thunar_window_poke_file_finish (ThunarBrowser *browser,
1492
ThunarFile *target_file,
1496
_thunar_return_if_fail (THUNAR_IS_WINDOW (browser));
1497
_thunar_return_if_fail (THUNAR_IS_FILE (file));
1501
thunar_window_open_or_launch (THUNAR_WINDOW (browser), target_file);
1505
thunar_dialogs_show_error (GTK_WIDGET (browser), error,
1506
_("Failed to open \"%s\""),
1507
thunar_file_get_display_name (file));
1423
1514
thunar_window_start_open_location (ThunarWindow *window,
1424
1515
const gchar *initial_text)
1426
1517
ThunarFile *selected_file;
1427
1518
GtkWidget *dialog;
1428
GError *error = NULL;
1520
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
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)
1547
/* be sure to hide the location dialog first */
1548
gtk_widget_hide (dialog);
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))
1459
/* open the new directory */
1460
thunar_window_set_current_directory (window, selected_file);
1464
/* be sure to hide the location dialog first */
1465
gtk_widget_hide (dialog);
1467
/* try to launch the selected file */
1468
if (!thunar_file_launch (selected_file, GTK_WIDGET (window), &error))
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);
1552
if (selected_file != NULL)
1554
thunar_browser_poke_file (THUNAR_BROWSER (window), selected_file, window,
1555
thunar_window_poke_file_finish, NULL);
1878
1961
thunar_window_action_open_home (GtkAction *action,
1879
1962
ThunarWindow *window)
1881
ThunarVfsPath *home_path;
1882
1965
ThunarFile *home_file;
1883
1966
GError *error = NULL;
1885
_thunar_return_if_fail (GTK_IS_ACTION (action));
1886
1968
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
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 ();
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))
1895
1977
/* display an error to the user */
1906
1988
/* release our reference on the home path */
1907
thunar_vfs_path_unref (home_path);
1989
g_object_unref (home);
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)
1916
2000
ThunarFile *user_file = NULL;
1917
GError *error = NULL;
1918
gchar *user_dir = NULL;
1919
gboolean result = FALSE;
1921
#if GLIB_CHECK_VERSION(2, 14, 0)
1922
user_dir = g_strdup (g_get_user_special_dir (thunar_user_dir));
1925
if (G_UNLIKELY (user_dir == NULL))
2001
gboolean result = FALSE;
2002
GError *error = NULL;
2007
path = g_strdup (g_get_user_special_dir (thunar_user_dir));
2009
if (G_UNLIKELY (path == NULL))
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);
2017
user_dir = g_file_new_for_path (path);
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))
1934
2022
g_error_free (error);
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);
1942
2030
if (G_LIKELY (user_file != NULL))
1956
2044
g_error_free (error);
2047
g_object_unref (user_dir);
1965
2056
thunar_window_action_open_desktop (GtkAction *action,
1966
2057
ThunarWindow *window)
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));
1972
2062
thunar_window_open_user_folder (action, window,
1973
2063
THUNAR_USER_DIRECTORY_DESKTOP,
1979
2070
thunar_window_action_open_documents (GtkAction *action,
1980
2071
ThunarWindow *window)
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));
1986
2076
thunar_window_open_user_folder (action, window,
1987
2077
THUNAR_USER_DIRECTORY_DOCUMENTS,
1993
2084
thunar_window_action_open_downloads (GtkAction *action,
1994
2085
ThunarWindow *window)
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));
2000
2090
thunar_window_open_user_folder (action, window,
2001
2091
THUNAR_USER_DIRECTORY_DOWNLOAD,
2007
2098
thunar_window_action_open_music (GtkAction *action,
2008
2099
ThunarWindow *window)
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));
2014
2104
thunar_window_open_user_folder (action, window,
2015
2105
THUNAR_USER_DIRECTORY_MUSIC,
2021
2112
thunar_window_action_open_pictures (GtkAction *action,
2022
2113
ThunarWindow *window)
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));
2028
2118
thunar_window_open_user_folder (action, window,
2029
2119
THUNAR_USER_DIRECTORY_PICTURES,
2035
2126
thunar_window_action_open_public (GtkAction *action,
2036
2127
ThunarWindow *window)
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));
2042
2132
thunar_window_open_user_folder (action, window,
2043
2133
THUNAR_USER_DIRECTORY_PUBLIC_SHARE,
2049
2140
thunar_window_action_open_templates (GtkAction *action,
2050
2141
ThunarWindow *window)
2129
2221
thunar_window_action_open_videos (GtkAction *action,
2130
2222
ThunarWindow *window)
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));
2136
2227
thunar_window_open_user_folder (action, window,
2137
2228
THUNAR_USER_DIRECTORY_VIDEOS,
2235
thunar_window_action_open_file_system (GtkAction *action,
2236
ThunarWindow *window)
2239
ThunarFile *root_file;
2240
GError *error = NULL;
2242
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2244
/* determine the path to the root directory */
2245
root = thunar_g_file_new_for_root ();
2247
/* determine the file for the root directory */
2248
root_file = thunar_file_get (root, &error);
2249
if (G_UNLIKELY (root_file == NULL))
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);
2257
/* open the root folder */
2258
thunar_window_set_current_directory (window, root_file);
2259
g_object_unref (G_OBJECT (root_file));
2262
/* release our reference on the home path */
2263
g_object_unref (root);
2144
2269
thunar_window_action_open_trash (GtkAction *action,
2145
2270
ThunarWindow *window)
2147
ThunarVfsPath *trash_bin_path;
2148
ThunarFile *trash_bin;
2149
GError *error = NULL;
2273
ThunarFile *trash_bin_file;
2274
GError *error = NULL;
2151
2276
_thunar_return_if_fail (GTK_IS_ACTION (action));
2152
2277
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
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 ();
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))
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"));
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));
2172
2297
/* release our reference on the trash bin path */
2173
thunar_vfs_path_unref (trash_bin_path);
2298
g_object_unref (trash_bin);
2304
thunar_window_action_open_network (GtkAction *action,
2305
ThunarWindow *window)
2307
ThunarFile *network_file;
2308
GError *error = NULL;
2311
_thunar_return_if_fail (GTK_IS_ACTION (action));
2312
_thunar_return_if_fail (THUNAR_IS_WINDOW (window));
2314
/* determine the network root location */
2315
network = g_file_new_for_uri ("network://");
2317
/* determine the file for this location */
2318
network_file = thunar_file_get (network, &error);
2319
if (G_UNLIKELY (network_file == NULL))
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);
2327
/* open the network root location */
2328
thunar_window_set_current_directory (window, network_file);
2329
g_object_unref (G_OBJECT (network_file));
2332
/* release our reference on the location itself */
2333
g_object_unref (network);
2254
2414
thunar_window_current_directory_destroy (ThunarFile *current_directory,
2255
2415
ThunarWindow *window)
2257
ThunarVfsPath *path;
2258
ThunarVfsInfo *info;
2259
ThunarFile *file = NULL;
2417
ThunarFile *new_directory = NULL;
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);
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));
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)
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))
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);
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))
2434
/* it does, try to load the file */
2435
new_directory = thunar_file_get (path, NULL);
2437
/* fall back to $HOME if loading the file failed */
2438
if (new_directory == NULL)
2443
/* determine the parent of the directory */
2444
tmp = g_file_get_parent (path);
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 */
2451
/* free the old directory */
2452
g_object_unref (path);
2454
/* check the parent next */
2459
/* make sure we don't leak */
2461
g_object_unref (path);
2284
2463
/* check if we have a new folder */
2285
if (G_LIKELY (file != NULL))
2464
if (G_LIKELY (new_directory != NULL))
2287
2466
/* enter the new folder */
2288
thunar_window_set_current_directory (window, file);
2467
thunar_window_set_current_directory (window, new_directory);
2290
2469
/* release the file reference */
2291
g_object_unref (G_OBJECT (file));
2470
g_object_unref (new_directory);
2474
/* enter the home folder */
2475
thunar_window_action_open_home (NULL, window);
2405
thunar_window_volume_pre_unmount (ThunarVfsVolumeManager *volume_manager,
2406
ThunarVfsVolume *volume,
2407
ThunarWindow *window)
2589
thunar_window_mount_pre_unmount (GVolumeMonitor *volume_monitor,
2591
ThunarWindow *window)
2409
ThunarVfsPath *path;
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));
2417
2602
/* nothing to do if we don't have a current directory */
2418
2603
if (G_UNLIKELY (window->current_directory == NULL))
2421
/* determine the mount point for the volume */
2422
path = thunar_vfs_volume_get_mount_point (volume);
2423
if (G_UNLIKELY (path == NULL))
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);
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))
2491
2675
gtk_window_get_size (GTK_WINDOW (window), &width, &height);
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);
2683
/* only store that the window is full screen */
2684
g_object_set (G_OBJECT (window->preferences), "last-window-maximized", TRUE, NULL);
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);
2815
/* reset the selected files list */
2816
selected_files.data = NULL;
2817
selected_files.prev = NULL;
2818
selected_files.next = NULL;
2820
/* determine the next file in the history */
2821
selected_file = thunar_history_peek_forward (window->history);
2822
if (selected_file != NULL)
2824
/* mark the file from history for selection if it is inside the new
2826
if (thunar_file_is_parent (window->current_directory, selected_file))
2827
selected_files.data = selected_file;
2830
/* do the same with the previous file in the history */
2831
if (selected_files.data == NULL)
2833
selected_file = thunar_history_peek_back (window->history);
2834
if (selected_file != NULL)
2836
/* mark the file from history for selection if it is inside the
2838
if (thunar_file_is_parent (window->current_directory, selected_file))
2839
selected_files.data = selected_file;
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);