Commit ce64cbc6 authored by William Jon McCann's avatar William Jon McCann
parent 7b280cb7
......@@ -46,6 +46,12 @@ eel_uri_is_trash (const char *uri)
return g_str_has_prefix (uri, "trash:");
}
gboolean
eel_uri_is_recent (const char *uri)
{
return g_str_has_prefix (uri, "recent:");
}
gboolean
eel_uri_is_search (const char *uri)
{
......
......@@ -42,6 +42,7 @@ gboolean eel_uri_is_trash_folder (const char *
gboolean eel_uri_is_in_trash (const char *uri);
gboolean eel_uri_is_desktop (const char *uri);
gboolean eel_uri_is_search (const char *uri);
gboolean eel_uri_is_recent (const char *uri);
char * eel_make_valid_utf8 (const char *name);
......
......@@ -538,6 +538,18 @@ nautilus_directory_is_in_trash (NautilusDirectory *directory)
return g_file_has_uri_scheme (directory->details->location, "trash");
}
gboolean
nautilus_directory_is_in_recent (NautilusDirectory *directory)
{
g_assert (NAUTILUS_IS_DIRECTORY (directory));
if (directory->details->location == NULL) {
return FALSE;
}
return g_file_has_uri_scheme (directory->details->location, "recent");
}
gboolean
nautilus_directory_are_all_files_seen (NautilusDirectory *directory)
{
......
......@@ -216,6 +216,7 @@ gboolean nautilus_directory_are_all_files_seen (NautilusDirector
gboolean nautilus_directory_is_local (NautilusDirectory *directory);
gboolean nautilus_directory_is_in_trash (NautilusDirectory *directory);
gboolean nautilus_directory_is_in_recent (NautilusDirectory *directory);
/* Return false if directory contains anything besides a Nautilus metafile.
* Only valid if directory is monitored. Used by the Trash monitor.
......
......@@ -1023,6 +1023,7 @@ static gboolean
can_delete_without_confirm (GFile *file)
{
if (g_file_has_uri_scheme (file, "burn") ||
g_file_has_uri_scheme (file, "recent") ||
g_file_has_uri_scheme (file, "x-nautilus-desktop")) {
return TRUE;
}
......
......@@ -6763,6 +6763,23 @@ nautilus_file_is_in_trash (NautilusFile *file)
return nautilus_directory_is_in_trash (file->details->directory);
}
/**
* nautilus_file_is_in_recent
*
* Check if this file is a file in Recent.
* @file: NautilusFile representing the file in question.
*
* Returns: TRUE if @file is in Recent.
*
**/
gboolean
nautilus_file_is_in_recent (NautilusFile *file)
{
g_assert (NAUTILUS_IS_FILE (file));
return nautilus_directory_is_in_recent (file->details->directory);
}
GError *
nautilus_file_get_file_info_error (NautilusFile *file)
{
......
......@@ -188,6 +188,7 @@ gboolean nautilus_file_is_user_special_directory (Nautilu
GUserDirectory special_directory);
gboolean nautilus_file_is_archive (NautilusFile *file);
gboolean nautilus_file_is_in_trash (NautilusFile *file);
gboolean nautilus_file_is_in_recent (NautilusFile *file);
gboolean nautilus_file_is_in_desktop (NautilusFile *file);
gboolean nautilus_file_is_home (NautilusFile *file);
gboolean nautilus_file_is_desktop_directory (NautilusFile *file);
......
......@@ -52,6 +52,7 @@ nautilus_recent_add_file (NautilusFile *file,
/* do not add trash:// etc */
if (eel_uri_is_trash (uri) ||
eel_uri_is_search (uri) ||
eel_uri_is_recent (uri) ||
eel_uri_is_desktop (uri)) {
g_free (uri);
return;
......
......@@ -425,6 +425,21 @@ special_directory_get_gicon (GUserDirectory directory)
#undef ICON_CASE
}
static gboolean
recent_is_supported (void)
{
const char * const *supported;
int i;
supported = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
for (i = 0; supported[i] != NULL; i++) {
if (strcmp ("recent", supported[i]) == 0) {
return TRUE;
}
}
return FALSE;
}
static void
update_places (NautilusPlacesSidebar *sidebar)
{
......@@ -476,6 +491,17 @@ update_places (NautilusPlacesSidebar *sidebar)
add_heading (sidebar, SECTION_COMPUTER,
_("Places"));
if (recent_is_supported ()) {
mount_uri = "recent:///"; /* No need to strdup */
icon = g_themed_icon_new ("document-open-recent-symbolic");
add_place (sidebar, PLACES_BUILT_IN,
SECTION_COMPUTER,
_("Recent"), icon, mount_uri,
NULL, NULL, NULL, 0,
_("Recent files"));
g_object_unref (icon);
}
/* home folder */
mount_uri = nautilus_get_home_directory_uri ();
icon = g_themed_icon_new (NAUTILUS_ICON_HOME);
......
......@@ -2392,6 +2392,19 @@ is_burn_directory (NautilusFile *file)
return result;
}
static gboolean
is_recent_directory (NautilusFile *file)
{
char *file_uri;
gboolean result;
file_uri = nautilus_file_get_uri (file);
result = strcmp (file_uri, "recent:///") == 0;
g_free (file_uri);
return result;
}
static gboolean
should_show_custom_icon_buttons (NautilusPropertiesWindow *window)
{
......@@ -2456,6 +2469,15 @@ should_show_link_target (NautilusPropertiesWindow *window)
return FALSE;
}
static gboolean
location_show_original (NautilusPropertiesWindow *window)
{
NautilusFile *file;
file = get_original_file (window);
return !nautilus_file_is_in_recent (file);
}
static gboolean
should_show_free_space (NautilusPropertiesWindow *window)
{
......@@ -2464,6 +2486,7 @@ should_show_free_space (NautilusPropertiesWindow *window)
&& (is_merged_trash_directory (get_target_file (window)) ||
is_computer_directory (get_target_file (window)) ||
is_network_directory (get_target_file (window)) ||
is_recent_directory (get_target_file (window)) ||
is_burn_directory (get_target_file (window)))) {
return FALSE;
}
......@@ -3083,7 +3106,7 @@ create_basic_page (NautilusPropertiesWindow *window)
append_title_and_ellipsizing_value (window, grid, _("Location:"),
"where",
INCONSISTENT_STATE_STRING,
TRUE);
location_show_original (window));
append_title_and_ellipsizing_value (window, grid,
_("Volume:"),
......@@ -4576,6 +4599,7 @@ should_show_permissions (NautilusPropertiesWindow *window)
*/
if (!is_multi_file_window (window)
&& (is_merged_trash_directory (file) ||
is_recent_directory (file) ||
is_computer_directory (file))) {
return FALSE;
}
......
......@@ -522,12 +522,26 @@ showing_trash_directory (NautilusView *view)
return FALSE;
}
static gboolean
showing_recent_directory (NautilusView *view)
{
NautilusFile *file;
file = nautilus_view_get_directory_as_file (view);
if (file != NULL) {
return nautilus_file_is_in_recent (file);
}
return FALSE;
}
static gboolean
nautilus_view_supports_creating_files (NautilusView *view)
{
g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE);
return !nautilus_view_is_read_only (view) && !showing_trash_directory (view);
return !nautilus_view_is_read_only (view)
&& !showing_trash_directory (view)
&& !showing_recent_directory (view);
}
static gboolean
......@@ -8281,22 +8295,26 @@ real_update_paste_menu (NautilusView *view,
{
gboolean can_paste_files_into;
gboolean selection_is_read_only;
gboolean selection_contains_recent;
gboolean is_read_only;
GtkAction *action;
selection_is_read_only = selection_count == 1 &&
(!nautilus_file_can_write (NAUTILUS_FILE (selection->data)) &&
!nautilus_file_has_activation_uri (NAUTILUS_FILE (selection->data)));
is_read_only = nautilus_view_is_read_only (view);
can_paste_files_into = (selection_count == 1 &&
selection_contains_recent = showing_recent_directory (view);
can_paste_files_into = (!selection_contains_recent &&
selection_count == 1 &&
can_paste_into_file (NAUTILUS_FILE (selection->data)));
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_PASTE);
gtk_action_set_sensitive (action, !is_read_only);
gtk_action_set_visible (action, !selection_contains_recent);
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_PASTE_FILES_INTO);
gtk_action_set_visible (action, can_paste_files_into);
......@@ -8316,6 +8334,7 @@ real_update_location_menu (NautilusView *view)
NautilusFile *file;
gboolean is_special_link;
gboolean is_desktop_or_home_dir;
gboolean is_recent;
gboolean can_delete_file, show_delete;
gboolean show_separate_delete_command;
gboolean show_open_in_new_tab;
......@@ -8354,6 +8373,7 @@ real_update_location_menu (NautilusView *view)
is_special_link = NAUTILUS_IS_DESKTOP_ICON_FILE (file);
is_desktop_or_home_dir = nautilus_file_is_home (file)
|| nautilus_file_is_desktop_directory (file);
is_recent = nautilus_file_is_in_recent (file);
can_delete_file =
nautilus_file_can_delete (file) &&
......@@ -8362,7 +8382,8 @@ real_update_location_menu (NautilusView *view)
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_LOCATION_CUT);
gtk_action_set_sensitive (action, can_delete_file);
gtk_action_set_sensitive (action, !is_recent && can_delete_file);
gtk_action_set_visible (action, !is_recent);
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_LOCATION_PASTE_FILES_INTO);
......@@ -8370,10 +8391,12 @@ real_update_location_menu (NautilusView *view)
"can-paste-according-to-destination",
GINT_TO_POINTER (can_paste_into_file (file)));
gtk_action_set_sensitive (action,
!is_recent &&
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),
"can-paste-according-to-clipboard")) &&
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),
"can-paste-according-to-destination")));
gtk_action_set_visible (action, !is_recent);
show_delete = TRUE;
......@@ -8483,6 +8506,7 @@ real_update_menus (NautilusView *view)
char *label_with_underscore;
gboolean selection_contains_special_link;
gboolean selection_contains_desktop_or_home_dir;
gboolean selection_contains_recent;
gboolean can_create_files;
gboolean can_delete_files;
gboolean can_trash_files;
......@@ -8508,6 +8532,7 @@ real_update_menus (NautilusView *view)
selection_contains_special_link = special_link_in_selection (view);
selection_contains_desktop_or_home_dir = desktop_or_home_dir_in_selection (view);
selection_contains_recent = showing_recent_directory (view);
can_create_files = nautilus_view_supports_creating_files (view);
can_delete_files =
......@@ -8521,11 +8546,12 @@ real_update_menus (NautilusView *view)
!selection_contains_special_link &&
!selection_contains_desktop_or_home_dir;
can_copy_files = selection_count != 0
&& !selection_contains_special_link;
&& !selection_contains_recent
&& !selection_contains_special_link;
can_duplicate_files = can_create_files && can_copy_files;
can_link_files = can_create_files && can_copy_files;
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_RENAME);
/* rename sensitivity depending on selection */
......@@ -8537,15 +8563,17 @@ real_update_menus (NautilusView *view)
selection_count == 1 &&
nautilus_view_can_rename_file (view, selection->data));
}
gtk_action_set_visible (action, !selection_contains_recent);
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_NEW_FOLDER);
gtk_action_set_sensitive (action, can_create_files);
gtk_action_set_visible (action, !selection_contains_recent);
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_NEW_FOLDER_WITH_SELECTION);
gtk_action_set_sensitive (action, can_create_files && can_delete_files && (selection_count > 1));
gtk_action_set_visible (action, selection_count > 1);
gtk_action_set_visible (action, !selection_contains_recent && (selection_count > 1));
label_with_underscore = g_strdup_printf (ngettext("New Folder with Selection (%'d Item)",
"New Folder with Selection (%'d Items)",
selection_count),
......@@ -8724,10 +8752,12 @@ real_update_menus (NautilusView *view)
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_DUPLICATE);
gtk_action_set_sensitive (action, can_duplicate_files);
gtk_action_set_visible (action, !selection_contains_recent);
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_CREATE_LINK);
gtk_action_set_sensitive (action, can_link_files);
gtk_action_set_visible (action, !selection_contains_recent);
g_object_set (action, "label",
ngettext ("Ma_ke Link",
"Ma_ke Links",
......@@ -8801,6 +8831,7 @@ real_update_menus (NautilusView *view)
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_CUT);
gtk_action_set_sensitive (action, can_delete_files);
gtk_action_set_visible (action, !selection_contains_recent);
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_COPY);
......@@ -8821,6 +8852,7 @@ real_update_menus (NautilusView *view)
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_NEW_DOCUMENTS);
gtk_action_set_sensitive (action, can_create_files);
gtk_action_set_visible (action, !selection_contains_recent);
if (can_create_files && view->details->templates_invalid) {
update_templates_menu (view);
......@@ -8829,9 +8861,11 @@ real_update_menus (NautilusView *view)
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_COPY_TO);
gtk_action_set_sensitive (action, can_copy_files);
gtk_action_set_visible (action, !selection_contains_recent);
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_MOVE_TO);
gtk_action_set_sensitive (action, can_delete_files);
gtk_action_set_visible (action, !selection_contains_recent);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment