Skip to content

Commit 58e9876

Browse files
Sargasticraveit65
authored andcommitted
Add independent show/hide backup files
1 parent 040a897 commit 58e9876

20 files changed

+256
-21
lines changed

libcaja-private/caja-directory-async.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ static gboolean
904904
should_skip_file (CajaDirectory *directory, GFileInfo *info)
905905
{
906906
static gboolean show_hidden_files_changed_callback_installed = FALSE;
907-
907+
908908
/* Add the callback once for the life of our process */
909909
if (!show_hidden_files_changed_callback_installed)
910910
{
@@ -2457,7 +2457,8 @@ monitor_includes_file (const Monitor *monitor,
24572457
}
24582458
return caja_file_should_show (file,
24592459
monitor->monitor_hidden_files,
2460-
TRUE);
2460+
TRUE,
2461+
FALSE);
24612462
}
24622463

24632464
static gboolean

libcaja-private/caja-file-operations.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,7 @@ should_skip_file (CommonJob *common,
10321032
if (common->skip_files != NULL) {
10331033
return g_hash_table_lookup (common->skip_files, file) != NULL;
10341034
}
1035+
10351036
return FALSE;
10361037
}
10371038

libcaja-private/caja-file-private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ struct CajaFileDetails
208208
eel_boolean_bit is_symlink : 1;
209209
eel_boolean_bit is_mountpoint : 1;
210210
eel_boolean_bit is_hidden : 1;
211-
211+
eel_boolean_bit is_backup : 1;
212212
eel_boolean_bit has_permissions : 1;
213213

214214
eel_boolean_bit can_read : 1;

libcaja-private/caja-file.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105

106106
typedef enum {
107107
SHOW_HIDDEN = 1 << 0,
108+
SHOW_BACKUP = 1 << 1,
108109
} FilterOptions;
109110

110111
typedef void (* ModifyListFunction) (GList **list, CajaFile *file);
@@ -2094,7 +2095,7 @@ update_info_internal (CajaFile *file,
20942095
{
20952096
GList *node;
20962097
gboolean changed;
2097-
gboolean is_symlink, is_hidden, is_mountpoint;
2098+
gboolean is_symlink, is_hidden, is_backup, is_mountpoint;
20982099
gboolean has_permissions;
20992100
guint32 permissions;
21002101
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,
21852186
}
21862187
file->details->is_symlink = is_symlink;
21872188

2188-
is_hidden = g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info);
2189-
if (file->details->is_hidden != is_hidden) {
2189+
is_hidden = g_file_info_get_is_hidden (info);
2190+
is_backup = g_file_info_get_is_backup (info);
2191+
if (file->details->is_hidden != is_hidden ||
2192+
file->details->is_backup != is_backup) {
21902193
changed = TRUE;
21912194
}
21922195
file->details->is_hidden = is_hidden;
2193-
2196+
file->details->is_backup = is_backup;
2197+
21942198
is_mountpoint = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT);
21952199
if (file->details->is_mountpoint != is_mountpoint) {
21962200
changed = TRUE;
@@ -3627,6 +3631,7 @@ caja_file_is_hidden_file (CajaFile *file)
36273631
* caja_file_should_show:
36283632
* @file: the file to check.
36293633
* @show_hidden: whether we want to show hidden files or not.
3634+
* @show_backup: whether we want to show backup files or not.
36303635
*
36313636
* Determines if a #CajaFile should be shown. Note that when browsing
36323637
* a trash directory, this function will always return %TRUE.
@@ -3635,14 +3640,16 @@ caja_file_is_hidden_file (CajaFile *file)
36353640
*/
36363641
gboolean
36373642
caja_file_should_show (CajaFile *file,
3638-
gboolean show_hidden,
3639-
gboolean show_foreign)
3643+
gboolean show_hidden,
3644+
gboolean show_foreign,
3645+
gboolean show_backup)
36403646
{
36413647
/* Never hide any files in trash. */
36423648
if (caja_file_is_in_trash (file)) {
36433649
return TRUE;
36443650
} else {
36453651
return (show_hidden || !caja_file_is_hidden_file (file)) &&
3652+
(show_backup || !caja_file_is_backup_file (file)) &&
36463653
(show_foreign || !(caja_file_is_in_desktop (file) && caja_file_is_foreign_link (file)));
36473654
}
36483655
}
@@ -3671,6 +3678,12 @@ caja_file_is_in_desktop (CajaFile *file)
36713678

36723679
}
36733680

3681+
gboolean
3682+
caja_file_is_backup_file (CajaFile *file)
3683+
{
3684+
return file->details->is_backup;
3685+
}
3686+
36743687
static gboolean
36753688
filter_hidden_partition_callback (gpointer data,
36763689
gpointer callback_data)
@@ -3682,8 +3695,9 @@ filter_hidden_partition_callback (gpointer data,
36823695
options = GPOINTER_TO_INT (callback_data);
36833696

36843697
return caja_file_should_show (file,
3685-
options & SHOW_HIDDEN,
3686-
TRUE);
3698+
options & SHOW_HIDDEN,
3699+
TRUE,
3700+
options & SHOW_BACKUP);
36873701
}
36883702

36893703
GList *

libcaja-private/caja-file.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ int caja_file_compare_location (CajaFile
429429
gboolean caja_file_is_hidden_file (CajaFile *file);
430430
gboolean caja_file_should_show (CajaFile *file,
431431
gboolean show_hidden,
432-
gboolean show_foreign);
432+
gboolean show_foreign,
433+
gboolean show_backup);
433434
GList *caja_file_list_filter_hidden (GList *files,
434435
gboolean show_hidden);
435436

libcaja-private/caja-global-preferences.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ G_BEGIN_DECLS
6464

6565
/* Display */
6666
#define CAJA_PREFERENCES_SHOW_HIDDEN_FILES "show-hidden-files"
67+
#define CAJA_PREFERENCES_SHOW_BACKUP_FILES "show-backup-files"
6768
#define CAJA_PREFERENCES_SHOW_ADVANCED_PERMISSIONS "show-advanced-permissions"
6869
#define CAJA_PREFERENCES_DATE_FORMAT "date-format"
6970
#define CAJA_PREFERENCES_USE_IEC_UNITS "use-iec-units"

libcaja-private/caja-metadata.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static char *used_metadata_names[] =
4545
CAJA_METADATA_KEY_WINDOW_GEOMETRY,
4646
CAJA_METADATA_KEY_WINDOW_SCROLL_POSITION,
4747
CAJA_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES,
48+
CAJA_METADATA_KEY_WINDOW_SHOW_BACKUP_FILES,
4849
CAJA_METADATA_KEY_WINDOW_MAXIMIZED,
4950
CAJA_METADATA_KEY_WINDOW_STICKY,
5051
CAJA_METADATA_KEY_WINDOW_KEEP_ABOVE,

libcaja-private/caja-metadata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#define CAJA_METADATA_KEY_WINDOW_GEOMETRY "caja-window-geometry"
5959
#define CAJA_METADATA_KEY_WINDOW_SCROLL_POSITION "caja-window-scroll-position"
6060
#define CAJA_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES "caja-window-show-hidden-files"
61+
#define CAJA_METADATA_KEY_WINDOW_SHOW_BACKUP_FILES "caja-window-show-backup-files"
6162
#define CAJA_METADATA_KEY_WINDOW_MAXIMIZED "caja-window-maximized"
6263
#define CAJA_METADATA_KEY_WINDOW_STICKY "caja-window-sticky"
6364
#define CAJA_METADATA_KEY_WINDOW_KEEP_ABOVE "caja-window-keep-above"

libcaja-private/caja-window-info.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum
3131
SELECTION_CHANGED,
3232
TITLE_CHANGED,
3333
HIDDEN_FILES_MODE_CHANGED,
34+
BACKUP_FILES_MODE_CHANGED,
3435
LAST_SIGNAL
3536
};
3637

@@ -81,6 +82,15 @@ caja_window_info_base_init (gpointer g_class)
8182
g_cclosure_marshal_VOID__VOID,
8283
G_TYPE_NONE, 0);
8384

85+
caja_window_info_signals[BACKUP_FILES_MODE_CHANGED] =
86+
g_signal_new ("backup_files_mode_changed",
87+
CAJA_TYPE_WINDOW_INFO,
88+
G_SIGNAL_RUN_LAST,
89+
G_STRUCT_OFFSET (CajaWindowInfoIface, backup_files_mode_changed),
90+
NULL, NULL,
91+
g_cclosure_marshal_VOID__VOID,
92+
G_TYPE_NONE, 0);
93+
8494
initialized = TRUE;
8595
}
8696
}
@@ -248,6 +258,24 @@ caja_window_info_set_hidden_files_mode (CajaWindowInfo *window,
248258
mode);
249259
}
250260

261+
CajaWindowShowBackupFilesMode
262+
caja_window_info_get_backup_files_mode (CajaWindowInfo *window)
263+
{
264+
g_return_val_if_fail (CAJA_IS_WINDOW_INFO (window), CAJA_WINDOW_SHOW_BACKUP_FILES_DEFAULT);
265+
266+
return (* CAJA_WINDOW_INFO_GET_IFACE (window)->get_backup_files_mode) (window);
267+
}
268+
269+
void
270+
caja_window_info_set_backup_files_mode (CajaWindowInfo *window,
271+
CajaWindowShowBackupFilesMode mode)
272+
{
273+
g_return_if_fail (CAJA_IS_WINDOW_INFO (window));
274+
275+
(* CAJA_WINDOW_INFO_GET_IFACE (window)->set_backup_files_mode) (window,
276+
mode);
277+
}
278+
251279
GtkUIManager *
252280
caja_window_info_get_ui_manager (CajaWindowInfo *window)
253281
{

libcaja-private/caja-window-info.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ extern "C" {
4141
}
4242
CajaWindowShowHiddenFilesMode;
4343

44+
typedef enum
45+
{
46+
CAJA_WINDOW_SHOW_BACKUP_FILES_DEFAULT,
47+
CAJA_WINDOW_SHOW_BACKUP_FILES_ENABLE,
48+
CAJA_WINDOW_SHOW_BACKUP_FILES_DISABLE
49+
}
50+
CajaWindowShowBackupFilesMode;
4451

4552
typedef enum
4653
{
@@ -105,6 +112,7 @@ extern "C" {
105112
void (* title_changed) (CajaWindowInfo *window,
106113
const char *title);
107114
void (* hidden_files_mode_changed)(CajaWindowInfo *window);
115+
void (* backup_files_mode_changed)(CajaWindowInfo *window);
108116

109117
/* VTable: */
110118
/* A view calls this once after a load_location, once it starts loading the
@@ -142,7 +150,11 @@ extern "C" {
142150
(* get_hidden_files_mode) (CajaWindowInfo *window);
143151
void (* set_hidden_files_mode) (CajaWindowInfo *window,
144152
CajaWindowShowHiddenFilesMode mode);
145-
153+
CajaWindowShowBackupFilesMode
154+
(* get_backup_files_mode) (CajaWindowInfo *window);
155+
void (* set_backup_files_mode) (CajaWindowInfo *window,
156+
CajaWindowShowBackupFilesMode mode);
157+
146158
CajaWindowSlotInfo * (* get_active_slot) (CajaWindowInfo *window);
147159
CajaWindowSlotInfo * (* get_extra_slot) (CajaWindowInfo *window);
148160

@@ -180,6 +192,9 @@ extern "C" {
180192
CajaWindowShowHiddenFilesMode caja_window_info_get_hidden_files_mode (CajaWindowInfo *window);
181193
void caja_window_info_set_hidden_files_mode (CajaWindowInfo *window,
182194
CajaWindowShowHiddenFilesMode mode);
195+
void caja_window_info_set_backup_files_mode (CajaWindowInfo *window,
196+
CajaWindowShowBackupFilesMode mode);
197+
183198
gboolean caja_window_info_get_initiated_unmount (CajaWindowInfo *window);
184199
void caja_window_info_set_initiated_unmount (CajaWindowInfo *window,
185200
gboolean initiated_unmount);

0 commit comments

Comments
 (0)