diff options
author | Sargastic <[email protected]> | 2018-08-11 21:40:02 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-12-27 13:11:09 +0100 |
commit | 58e987622a1d4ff137b9e5475880376dd60ac18b (patch) | |
tree | 9eefd32199ba49d8500074b2a087ebc009431ae7 /libcaja-private | |
parent | 040a897fe879e949f4e11be4b0d065486c677e97 (diff) | |
download | caja-58e987622a1d4ff137b9e5475880376dd60ac18b.tar.bz2 caja-58e987622a1d4ff137b9e5475880376dd60ac18b.tar.xz |
Add independent show/hide backup files
Diffstat (limited to 'libcaja-private')
-rw-r--r-- | libcaja-private/caja-directory-async.c | 5 | ||||
-rw-r--r-- | libcaja-private/caja-file-operations.c | 1 | ||||
-rw-r--r-- | libcaja-private/caja-file-private.h | 2 | ||||
-rw-r--r-- | libcaja-private/caja-file.c | 30 | ||||
-rw-r--r-- | libcaja-private/caja-file.h | 3 | ||||
-rw-r--r-- | libcaja-private/caja-global-preferences.h | 1 | ||||
-rw-r--r-- | libcaja-private/caja-metadata.c | 1 | ||||
-rw-r--r-- | libcaja-private/caja-metadata.h | 1 | ||||
-rw-r--r-- | libcaja-private/caja-window-info.c | 28 | ||||
-rw-r--r-- | libcaja-private/caja-window-info.h | 17 | ||||
-rw-r--r-- | libcaja-private/org.mate.caja.gschema.xml | 8 |
11 files changed, 83 insertions, 14 deletions
diff --git a/libcaja-private/caja-directory-async.c b/libcaja-private/caja-directory-async.c index 069f5523..e3513cc8 100644 --- a/libcaja-private/caja-directory-async.c +++ b/libcaja-private/caja-directory-async.c @@ -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) { @@ -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 diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c index 41e4f129..51481db0 100644 --- a/libcaja-private/caja-file-operations.c +++ b/libcaja-private/caja-file-operations.c @@ -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; } diff --git a/libcaja-private/caja-file-private.h b/libcaja-private/caja-file-private.h index 71beac72..1130862a 100644 --- a/libcaja-private/caja-file-private.h +++ b/libcaja-private/caja-file-private.h @@ -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; diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c index 0d13ff5f..74cbe988 100644 --- a/libcaja-private/caja-file.c +++ b/libcaja-private/caja-file.c @@ -105,6 +105,7 @@ typedef enum { SHOW_HIDDEN = 1 << 0, + SHOW_BACKUP = 1 << 1, } FilterOptions; typedef void (* ModifyListFunction) (GList **list, CajaFile *file); @@ -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; @@ -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; @@ -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. @@ -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))); } } @@ -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) @@ -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 * diff --git a/libcaja-private/caja-file.h b/libcaja-private/caja-file.h index 949c77e9..9d5a1f62 100644 --- a/libcaja-private/caja-file.h +++ b/libcaja-private/caja-file.h @@ -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); diff --git a/libcaja-private/caja-global-preferences.h b/libcaja-private/caja-global-preferences.h index 7a0da287..d3e4b7ce 100644 --- a/libcaja-private/caja-global-preferences.h +++ b/libcaja-private/caja-global-preferences.h @@ -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" diff --git a/libcaja-private/caja-metadata.c b/libcaja-private/caja-metadata.c index b4a315c8..2b12962f 100644 --- a/libcaja-private/caja-metadata.c +++ b/libcaja-private/caja-metadata.c @@ -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, diff --git a/libcaja-private/caja-metadata.h b/libcaja-private/caja-metadata.h index 02384c60..72eb4789 100644 --- a/libcaja-private/caja-metadata.h +++ b/libcaja-private/caja-metadata.h @@ -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" diff --git a/libcaja-private/caja-window-info.c b/libcaja-private/caja-window-info.c index f55e6803..cce05f7d 100644 --- a/libcaja-private/caja-window-info.c +++ b/libcaja-private/caja-window-info.c @@ -31,6 +31,7 @@ enum SELECTION_CHANGED, TITLE_CHANGED, HIDDEN_FILES_MODE_CHANGED, + BACKUP_FILES_MODE_CHANGED, LAST_SIGNAL }; @@ -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; } } @@ -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) { diff --git a/libcaja-private/caja-window-info.h b/libcaja-private/caja-window-info.h index 7cced147..20ecc414 100644 --- a/libcaja-private/caja-window-info.h +++ b/libcaja-private/caja-window-info.h @@ -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 { @@ -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 @@ -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); @@ -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); diff --git a/libcaja-private/org.mate.caja.gschema.xml b/libcaja-private/org.mate.caja.gschema.xml index 8555d5f7..34ae2e5a 100644 --- a/libcaja-private/org.mate.caja.gschema.xml +++ b/libcaja-private/org.mate.caja.gschema.xml @@ -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> |