diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/caja-actions.h | 1 | ||||
-rw-r--r-- | src/caja-file-management-properties.c | 4 | ||||
-rw-r--r-- | src/caja-file-management-properties.ui | 17 | ||||
-rw-r--r-- | src/caja-window-menus.c | 67 | ||||
-rw-r--r-- | src/caja-window-private.h | 1 | ||||
-rw-r--r-- | src/caja-window.c | 19 | ||||
-rw-r--r-- | src/file-manager/caja-directory-view-ui.xml | 1 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.c | 63 | ||||
-rw-r--r-- | src/file-manager/fm-tree-model.c | 7 |
9 files changed, 173 insertions, 7 deletions
diff --git a/src/caja-actions.h b/src/caja-actions.h index c8a0dffd..75fbd72c 100644 --- a/src/caja-actions.h +++ b/src/caja-actions.h @@ -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" diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c index 29039add..7f540707 100644 --- a/src/caja-file-management-properties.c +++ b/src/caja-file-management-properties.c @@ -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" @@ -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); diff --git a/src/caja-file-management-properties.ui b/src/caja-file-management-properties.ui index 20d36c08..77fdd7ee 100644 --- a/src/caja-file-management-properties.ui +++ b/src/caja-file-management-properties.ui @@ -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> @@ -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> diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c index 66012627..d1b65df9 100644 --- a/src/caja-window-menus.c +++ b/src/caja-window-menus.c @@ -405,6 +405,27 @@ action_show_hidden_files_callback (GtkAction *action, } static void +action_show_backup_files_callback (GtkAction *action, + gpointer callback_data) +{ + CajaWindow *window; + CajaWindowShowBackupFilesMode mode; + + window = CAJA_WINDOW (callback_data); + + if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) + { + mode = CAJA_WINDOW_SHOW_BACKUP_FILES_ENABLE; + } + else + { + mode = CAJA_WINDOW_SHOW_BACKUP_FILES_DISABLE; + } + + caja_window_info_set_backup_files_mode (window, mode); +} + +static void show_hidden_files_preference_callback (gpointer callback_data) { CajaWindow *window; @@ -430,6 +451,30 @@ show_hidden_files_preference_callback (gpointer callback_data) } static void +show_backup_files_preference_callback (gpointer callback_data) +{ + CajaWindow *window; + GtkAction *action; + + window = CAJA_WINDOW (callback_data); + + if (window->details->show_backup_files_mode == CAJA_WINDOW_SHOW_BACKUP_FILES_DEFAULT) + { + action = gtk_action_group_get_action (window->details->main_action_group, CAJA_ACTION_SHOW_BACKUP_FILES); + g_assert (GTK_IS_ACTION (action)); + + /* update button */ + g_signal_handlers_block_by_func (action, action_show_backup_files_callback, window); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_SHOW_BACKUP_FILES)); + g_signal_handlers_unblock_by_func (action, action_show_backup_files_callback, window); + + /* inform views */ + caja_window_info_set_backup_files_mode (window, CAJA_WINDOW_SHOW_BACKUP_FILES_DEFAULT); + } +} + +static void preferences_respond_callback (GtkDialog *dialog, gint response_id) { @@ -922,6 +967,13 @@ static const GtkToggleActionEntry main_toggle_entries[] = G_CALLBACK (action_show_hidden_files_callback), TRUE }, + /* name, stock id */ { "Show Backup Files", NULL, + /* label, accelerator */ N_("Show _Backup Files"), NULL, + /* tooltip */ N_("Toggle the display of backup files in the current window"), + G_CALLBACK (action_show_backup_files_callback), + TRUE + }, + }; /** @@ -959,12 +1011,20 @@ caja_window_initialize_menus (CajaWindow *window) gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_SHOW_HIDDEN_FILES)); g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window); - - g_signal_connect_swapped (caja_preferences, "changed::" CAJA_PREFERENCES_SHOW_HIDDEN_FILES, G_CALLBACK(show_hidden_files_preference_callback), window); + action = gtk_action_group_get_action (action_group, CAJA_ACTION_SHOW_BACKUP_FILES); + g_signal_handlers_block_by_func (action, action_show_backup_files_callback, window); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_SHOW_BACKUP_FILES)); + g_signal_handlers_unblock_by_func (action, action_show_backup_files_callback, window); + + g_signal_connect_swapped (caja_preferences, "changed::" CAJA_PREFERENCES_SHOW_BACKUP_FILES, + G_CALLBACK(show_backup_files_preference_callback), + window); + window->details->ui_manager = gtk_ui_manager_new (); ui_manager = window->details->ui_manager; gtk_window_add_accel_group (GTK_WINDOW (window), @@ -996,6 +1056,9 @@ caja_window_finalize_menus (CajaWindow *window) g_signal_handlers_disconnect_by_func (caja_preferences, show_hidden_files_preference_callback, window); + + g_signal_handlers_disconnect_by_func (caja_preferences, + show_backup_files_preference_callback, window); } static GList * diff --git a/src/caja-window-private.h b/src/caja-window-private.h index 7afcb497..f02e73c8 100644 --- a/src/caja-window-private.h +++ b/src/caja-window-private.h @@ -60,6 +60,7 @@ struct CajaWindowDetails CajaBookmarkList *bookmark_list; CajaWindowShowHiddenFilesMode show_hidden_files_mode; + CajaWindowShowBackupFilesMode show_backup_files_mode; /* View As menu */ GList *short_list_viewers; diff --git a/src/caja-window.c b/src/caja-window.c index 52676dd5..a0c1d06a 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -1975,6 +1975,21 @@ caja_window_set_hidden_files_mode (CajaWindowInfo *window, g_signal_emit_by_name (window, "hidden_files_mode_changed"); } +static CajaWindowShowBackupFilesMode +caja_window_get_backup_files_mode (CajaWindowInfo *window) +{ + return window->details->show_backup_files_mode; +} + +static void +caja_window_set_backup_files_mode (CajaWindowInfo *window, + CajaWindowShowBackupFilesMode mode) +{ + window->details->show_backup_files_mode = mode; + + g_signal_emit_by_name (window, "backup_files_mode_changed"); +} + static gboolean caja_window_get_initiated_unmount (CajaWindowInfo *window) { @@ -2076,6 +2091,10 @@ caja_window_info_iface_init (CajaWindowInfoIface *iface) iface->get_selection = caja_window_get_selection; iface->get_hidden_files_mode = caja_window_get_hidden_files_mode; iface->set_hidden_files_mode = caja_window_set_hidden_files_mode; + + iface->get_backup_files_mode = caja_window_get_backup_files_mode; + iface->set_backup_files_mode = caja_window_set_backup_files_mode; + iface->get_active_slot = caja_window_get_active_slot; iface->get_extra_slot = caja_window_get_extra_slot; iface->get_initiated_unmount = caja_window_get_initiated_unmount; diff --git a/src/file-manager/caja-directory-view-ui.xml b/src/file-manager/caja-directory-view-ui.xml index 4e926fa0..4eba3e63 100644 --- a/src/file-manager/caja-directory-view-ui.xml +++ b/src/file-manager/caja-directory-view-ui.xml @@ -93,6 +93,7 @@ <placeholder name="View Preferences Placeholder"> <menuitem name="Reset to Defaults" action="Reset to Defaults"/> <menuitem name="Show Hidden Files" action="Show Hidden Files"/> + <menuitem name="Show Backup Files" action="Show Backup Files"/> </placeholder> </menu> </menubar> diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 90a0d594..65a0976b 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -237,6 +237,8 @@ struct FMDirectoryViewDetails gboolean show_foreign_files; gboolean show_hidden_files; gboolean ignore_hidden_file_preferences; + + gboolean show_backup_files; gboolean batching_selection_level; gboolean selection_changed_while_batched; @@ -291,6 +293,7 @@ static void load_directory (FMDirectoryView static void fm_directory_view_merge_menus (FMDirectoryView *view); static void fm_directory_view_unmerge_menus (FMDirectoryView *view); static void fm_directory_view_init_show_hidden_files (FMDirectoryView *view); +static void fm_directory_view_init_show_backup_files (FMDirectoryView *view); static void fm_directory_view_load_location (CajaView *caja_view, const char *location); static void fm_directory_view_stop_loading (CajaView *caja_view); @@ -1292,6 +1295,17 @@ hidden_files_mode_changed (CajaWindow *window, } static void +backup_files_mode_changed (CajaWindow *window, + gpointer callback_data) +{ + FMDirectoryView *directory_view; + + directory_view = FM_DIRECTORY_VIEW (callback_data); + + fm_directory_view_init_show_backup_files (directory_view); +} + +static void action_save_search_callback (GtkAction *action, gpointer callback_data) { @@ -7266,6 +7280,44 @@ fm_directory_view_init_show_hidden_files (FMDirectoryView *view) } +static void +fm_directory_view_init_show_backup_files (FMDirectoryView *view) +{ + CajaWindowShowBackupFilesMode mode; + gboolean show_backup_changed; + gboolean show_backup_default_setting; + + /* + if (view->details->ignore_hidden_file_preferences) { + return; + } + */ + + show_backup_changed = FALSE; + mode = caja_window_info_get_backup_files_mode (view->details->window); + + if (mode == CAJA_WINDOW_SHOW_BACKUP_FILES_DEFAULT) { + show_backup_default_setting = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_SHOW_BACKUP_FILES); + if (show_backup_default_setting != view->details->show_backup_files) { + view->details->show_backup_files = show_backup_default_setting; + show_backup_changed = TRUE; + } + } else { + if (mode == CAJA_WINDOW_SHOW_BACKUP_FILES_ENABLE) { + show_backup_changed = !view->details->show_backup_files; + view->details->show_backup_files = TRUE; + } else { + show_backup_changed = view->details->show_backup_files; + view->details->show_backup_files = FALSE; + } + } + + if (show_backup_changed && (view->details->model != NULL)) { + load_directory (view, view->details->model); + } + +} + static const GtkActionEntry directory_view_entries[] = { /* name, icon name, label */ { "New Documents", "document-new", N_("Create _Document") }, /* name, icon name, label */ { "Open With", NULL, N_("Open Wit_h"), @@ -9974,8 +10026,9 @@ gboolean fm_directory_view_should_show_file (FMDirectoryView *view, CajaFile *file) { return caja_file_should_show (file, - view->details->show_hidden_files, - view->details->show_foreign_files); + view->details->show_hidden_files, + view->details->show_foreign_files, + view->details->show_backup_files); } static gboolean @@ -10801,6 +10854,12 @@ fm_directory_view_set_property (GObject *object, "hidden-files-mode-changed", G_CALLBACK (hidden_files_mode_changed), directory_view, 0); fm_directory_view_init_show_hidden_files (directory_view); + + g_signal_connect_object (directory_view->details->window, + "backup-files-mode-changed", G_CALLBACK (backup_files_mode_changed), + directory_view, 0); + fm_directory_view_init_show_backup_files (directory_view); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c index fd9bf074..3ca02fd7 100644 --- a/src/file-manager/fm-tree-model.c +++ b/src/file-manager/fm-tree-model.c @@ -100,8 +100,9 @@ struct FMTreeModelDetails guint monitoring_update_idle_id; gboolean show_hidden_files; + gboolean show_backup_files; gboolean show_only_directories; - + GList *highlighted_files; }; @@ -956,7 +957,9 @@ should_show_file (FMTreeModel *model, CajaFile *file) should = caja_file_should_show (file, model->details->show_hidden_files, - TRUE); + /* TODO details->show_backup_files */ + TRUE, + model->details->show_backup_files); if (should && model->details->show_only_directories |