Skip to content

Commit

Permalink
Add independent show/hide backup files
Browse files Browse the repository at this point in the history
  • Loading branch information
Sargastic authored and raveit65 committed Dec 27, 2018
1 parent 040a897 commit 58e9876
Show file tree
Hide file tree
Showing 20 changed files with 256 additions and 21 deletions.
5 changes: 3 additions & 2 deletions libcaja-private/caja-directory-async.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ static gboolean
should_skip_file (CajaDirectory *directory, GFileInfo *info)
{
static gboolean show_hidden_files_changed_callback_installed = FALSE;

/* Add the callback once for the life of our process */
if (!show_hidden_files_changed_callback_installed)
{
Expand Down Expand Up @@ -2457,7 +2457,8 @@ monitor_includes_file (const Monitor *monitor,
}
return caja_file_should_show (file,
monitor->monitor_hidden_files,
TRUE);
TRUE,
FALSE);
}

static gboolean
Expand Down
1 change: 1 addition & 0 deletions libcaja-private/caja-file-operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ should_skip_file (CommonJob *common,
if (common->skip_files != NULL) {
return g_hash_table_lookup (common->skip_files, file) != NULL;
}

return FALSE;
}

Expand Down
2 changes: 1 addition & 1 deletion libcaja-private/caja-file-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ struct CajaFileDetails
eel_boolean_bit is_symlink : 1;
eel_boolean_bit is_mountpoint : 1;
eel_boolean_bit is_hidden : 1;

eel_boolean_bit is_backup : 1;
eel_boolean_bit has_permissions : 1;

eel_boolean_bit can_read : 1;
Expand Down
30 changes: 22 additions & 8 deletions libcaja-private/caja-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@

typedef enum {
SHOW_HIDDEN = 1 << 0,
SHOW_BACKUP = 1 << 1,
} FilterOptions;

typedef void (* ModifyListFunction) (GList **list, CajaFile *file);
Expand Down Expand Up @@ -2094,7 +2095,7 @@ update_info_internal (CajaFile *file,
{
GList *node;
gboolean changed;
gboolean is_symlink, is_hidden, is_mountpoint;
gboolean is_symlink, is_hidden, is_backup, is_mountpoint;
gboolean has_permissions;
guint32 permissions;
gboolean can_read, can_write, can_execute, can_delete, can_trash, can_rename, can_mount, can_unmount, can_eject;
Expand Down Expand Up @@ -2185,12 +2186,15 @@ update_info_internal (CajaFile *file,
}
file->details->is_symlink = is_symlink;

is_hidden = g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info);
if (file->details->is_hidden != is_hidden) {
is_hidden = g_file_info_get_is_hidden (info);
is_backup = g_file_info_get_is_backup (info);
if (file->details->is_hidden != is_hidden ||
file->details->is_backup != is_backup) {
changed = TRUE;
}
file->details->is_hidden = is_hidden;

file->details->is_backup = is_backup;

is_mountpoint = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT);
if (file->details->is_mountpoint != is_mountpoint) {
changed = TRUE;
Expand Down Expand Up @@ -3627,6 +3631,7 @@ caja_file_is_hidden_file (CajaFile *file)
* caja_file_should_show:
* @file: the file to check.
* @show_hidden: whether we want to show hidden files or not.
* @show_backup: whether we want to show backup files or not.
*
* Determines if a #CajaFile should be shown. Note that when browsing
* a trash directory, this function will always return %TRUE.
Expand All @@ -3635,14 +3640,16 @@ caja_file_is_hidden_file (CajaFile *file)
*/
gboolean
caja_file_should_show (CajaFile *file,
gboolean show_hidden,
gboolean show_foreign)
gboolean show_hidden,
gboolean show_foreign,
gboolean show_backup)
{
/* Never hide any files in trash. */
if (caja_file_is_in_trash (file)) {
return TRUE;
} else {
return (show_hidden || !caja_file_is_hidden_file (file)) &&
(show_backup || !caja_file_is_backup_file (file)) &&
(show_foreign || !(caja_file_is_in_desktop (file) && caja_file_is_foreign_link (file)));
}
}
Expand Down Expand Up @@ -3671,6 +3678,12 @@ caja_file_is_in_desktop (CajaFile *file)

}

gboolean
caja_file_is_backup_file (CajaFile *file)
{
return file->details->is_backup;
}

static gboolean
filter_hidden_partition_callback (gpointer data,
gpointer callback_data)
Expand All @@ -3682,8 +3695,9 @@ filter_hidden_partition_callback (gpointer data,
options = GPOINTER_TO_INT (callback_data);

return caja_file_should_show (file,
options & SHOW_HIDDEN,
TRUE);
options & SHOW_HIDDEN,
TRUE,
options & SHOW_BACKUP);
}

GList *
Expand Down
3 changes: 2 additions & 1 deletion libcaja-private/caja-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ int caja_file_compare_location (CajaFile
gboolean caja_file_is_hidden_file (CajaFile *file);
gboolean caja_file_should_show (CajaFile *file,
gboolean show_hidden,
gboolean show_foreign);
gboolean show_foreign,
gboolean show_backup);
GList *caja_file_list_filter_hidden (GList *files,
gboolean show_hidden);

Expand Down
1 change: 1 addition & 0 deletions libcaja-private/caja-global-preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ G_BEGIN_DECLS

/* Display */
#define CAJA_PREFERENCES_SHOW_HIDDEN_FILES "show-hidden-files"
#define CAJA_PREFERENCES_SHOW_BACKUP_FILES "show-backup-files"
#define CAJA_PREFERENCES_SHOW_ADVANCED_PERMISSIONS "show-advanced-permissions"
#define CAJA_PREFERENCES_DATE_FORMAT "date-format"
#define CAJA_PREFERENCES_USE_IEC_UNITS "use-iec-units"
Expand Down
1 change: 1 addition & 0 deletions libcaja-private/caja-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static char *used_metadata_names[] =
CAJA_METADATA_KEY_WINDOW_GEOMETRY,
CAJA_METADATA_KEY_WINDOW_SCROLL_POSITION,
CAJA_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES,
CAJA_METADATA_KEY_WINDOW_SHOW_BACKUP_FILES,
CAJA_METADATA_KEY_WINDOW_MAXIMIZED,
CAJA_METADATA_KEY_WINDOW_STICKY,
CAJA_METADATA_KEY_WINDOW_KEEP_ABOVE,
Expand Down
1 change: 1 addition & 0 deletions libcaja-private/caja-metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#define CAJA_METADATA_KEY_WINDOW_GEOMETRY "caja-window-geometry"
#define CAJA_METADATA_KEY_WINDOW_SCROLL_POSITION "caja-window-scroll-position"
#define CAJA_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES "caja-window-show-hidden-files"
#define CAJA_METADATA_KEY_WINDOW_SHOW_BACKUP_FILES "caja-window-show-backup-files"
#define CAJA_METADATA_KEY_WINDOW_MAXIMIZED "caja-window-maximized"
#define CAJA_METADATA_KEY_WINDOW_STICKY "caja-window-sticky"
#define CAJA_METADATA_KEY_WINDOW_KEEP_ABOVE "caja-window-keep-above"
Expand Down
28 changes: 28 additions & 0 deletions libcaja-private/caja-window-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum
SELECTION_CHANGED,
TITLE_CHANGED,
HIDDEN_FILES_MODE_CHANGED,
BACKUP_FILES_MODE_CHANGED,
LAST_SIGNAL
};

Expand Down Expand Up @@ -81,6 +82,15 @@ caja_window_info_base_init (gpointer g_class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);

caja_window_info_signals[BACKUP_FILES_MODE_CHANGED] =
g_signal_new ("backup_files_mode_changed",
CAJA_TYPE_WINDOW_INFO,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CajaWindowInfoIface, backup_files_mode_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);

initialized = TRUE;
}
}
Expand Down Expand Up @@ -248,6 +258,24 @@ caja_window_info_set_hidden_files_mode (CajaWindowInfo *window,
mode);
}

CajaWindowShowBackupFilesMode
caja_window_info_get_backup_files_mode (CajaWindowInfo *window)
{
g_return_val_if_fail (CAJA_IS_WINDOW_INFO (window), CAJA_WINDOW_SHOW_BACKUP_FILES_DEFAULT);

return (* CAJA_WINDOW_INFO_GET_IFACE (window)->get_backup_files_mode) (window);
}

void
caja_window_info_set_backup_files_mode (CajaWindowInfo *window,
CajaWindowShowBackupFilesMode mode)
{
g_return_if_fail (CAJA_IS_WINDOW_INFO (window));

(* CAJA_WINDOW_INFO_GET_IFACE (window)->set_backup_files_mode) (window,
mode);
}

GtkUIManager *
caja_window_info_get_ui_manager (CajaWindowInfo *window)
{
Expand Down
17 changes: 16 additions & 1 deletion libcaja-private/caja-window-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ extern "C" {
}
CajaWindowShowHiddenFilesMode;

typedef enum
{
CAJA_WINDOW_SHOW_BACKUP_FILES_DEFAULT,
CAJA_WINDOW_SHOW_BACKUP_FILES_ENABLE,
CAJA_WINDOW_SHOW_BACKUP_FILES_DISABLE
}
CajaWindowShowBackupFilesMode;

typedef enum
{
Expand Down Expand Up @@ -105,6 +112,7 @@ extern "C" {
void (* title_changed) (CajaWindowInfo *window,
const char *title);
void (* hidden_files_mode_changed)(CajaWindowInfo *window);
void (* backup_files_mode_changed)(CajaWindowInfo *window);

/* VTable: */
/* A view calls this once after a load_location, once it starts loading the
Expand Down Expand Up @@ -142,7 +150,11 @@ extern "C" {
(* get_hidden_files_mode) (CajaWindowInfo *window);
void (* set_hidden_files_mode) (CajaWindowInfo *window,
CajaWindowShowHiddenFilesMode mode);

CajaWindowShowBackupFilesMode
(* get_backup_files_mode) (CajaWindowInfo *window);
void (* set_backup_files_mode) (CajaWindowInfo *window,
CajaWindowShowBackupFilesMode mode);

CajaWindowSlotInfo * (* get_active_slot) (CajaWindowInfo *window);
CajaWindowSlotInfo * (* get_extra_slot) (CajaWindowInfo *window);

Expand Down Expand Up @@ -180,6 +192,9 @@ extern "C" {
CajaWindowShowHiddenFilesMode caja_window_info_get_hidden_files_mode (CajaWindowInfo *window);
void caja_window_info_set_hidden_files_mode (CajaWindowInfo *window,
CajaWindowShowHiddenFilesMode mode);
void caja_window_info_set_backup_files_mode (CajaWindowInfo *window,
CajaWindowShowBackupFilesMode mode);

gboolean caja_window_info_get_initiated_unmount (CajaWindowInfo *window);
void caja_window_info_set_initiated_unmount (CajaWindowInfo *window,
gboolean initiated_unmount);
Expand Down
8 changes: 7 additions & 1 deletion libcaja-private/org.mate.caja.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,14 @@
<key name="show-hidden-files" type="b">
<default>false</default>
<summary>Whether to show hidden files</summary>
<description>If set to true, then hidden files are shown by default in the file manager. Hidden files are either dotfiles, listed in the folder's .hidden file or backup files ending with a tilde (~).</description>
<description>If set to true, then hidden files are shown by default in the file manager. Hidden files are either dotfiles or listed in the folder's .hidden file.</description>
</key>
<key name="show-backup-files" type="b">
<default>false</default>
<summary>Whether to show backup files</summary>
<description>If set to true, then backup files are shown by default in the file manager. Backup files are either backup files ending with a tilde (~).</description>
</key>

<key name="use-iec-units" type="b">
<default>false</default>
<summary>Whether to show file sizes with IEC units</summary>
Expand Down
1 change: 1 addition & 0 deletions src/caja-actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#define CAJA_ACTION_ZOOM_OUT "Zoom Out"
#define CAJA_ACTION_ZOOM_NORMAL "Zoom Normal"
#define CAJA_ACTION_SHOW_HIDDEN_FILES "Show Hidden Files"
#define CAJA_ACTION_SHOW_BACKUP_FILES "Show Backup Files"
#define CAJA_ACTION_CLOSE "Close"
#define CAJA_ACTION_SEARCH "Search"
#define CAJA_ACTION_FOLDER_WINDOW "Folder Window"
Expand Down
4 changes: 4 additions & 0 deletions src/caja-file-management-properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#define CAJA_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_TRASH_WIDGET "trash_confirm_trash_checkbutton"
#define CAJA_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET "trash_delete_checkbutton"
#define CAJA_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET "hidden_files_checkbutton"
#define CAJA_FILE_MANAGEMENT_PROPERTIES_SHOW_BACKUP_WIDGET "backup_files_checkbutton"
#define CAJA_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET "treeview_folders_checkbutton"
#define CAJA_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTOMOUNT_OPEN "media_automount_open_checkbutton"
#define CAJA_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTORUN_NEVER "media_autorun_never_checkbutton"
Expand Down Expand Up @@ -1178,6 +1179,9 @@ caja_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *wi
bind_builder_bool (builder, caja_preferences,
CAJA_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET,
CAJA_PREFERENCES_SHOW_HIDDEN_FILES);
bind_builder_bool (builder, caja_preferences,
CAJA_FILE_MANAGEMENT_PROPERTIES_SHOW_BACKUP_WIDGET,
CAJA_PREFERENCES_SHOW_BACKUP_FILES);
bind_builder_bool (builder, caja_tree_sidebar_preferences,
CAJA_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET,
CAJA_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES);
Expand Down
17 changes: 16 additions & 1 deletion src/caja-file-management-properties.ui
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
</child>
<child>
<object class="GtkCheckButton" id="hidden_files_checkbutton">
<property name="label" translatable="yes">Show hidden and _backup files</property>
<property name="label" translatable="yes">Show hidden files</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
Expand All @@ -503,6 +503,21 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="backup_files_checkbutton">
<property name="label" translatable="yes">Show backup files</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
Loading

0 comments on commit 58e9876

Please sign in to comment.