Re: Patch and feature request for toggling display of hidden files
- From: Jamie McCracken <jamiemcc blueyonder co uk>
- To: Alexander Larsson <alexl redhat com>
- Cc: Nautilus <nautilus-list gnome org>
- Subject: Re: Patch and feature request for toggling display of hidden files
- Date: Fri, 28 May 2004 16:21:21 +0100
On Thu, 2004-05-27 at 15:29, Alexander Larsson wrote:
> > (I think the default should be to hide all hidden stuff and let users
> > override this on an individual folder basis if they want - please
> > confirm if thats acceptable)
>
> I'd prefer if the global prefs was used for the initial setting for new
> windowd, and changing it later would change the setting for all windows
> that haven't made a local change.
>
> The question is if we should store the hidden setting for spatial
> windows for each directory, or maybe we should do something like inherit
> the setting from the launching directory.
>
> > > Also, we probably want to group the show backup prefs with the hidden
> > > toggle, like we do for the prefs dialog.
> > >
> >
> > So backup files should always be shown when hidden files are shown and
> > vice versa?
>
> Yes.
Patch updated and attached for this.
Also updated bugzilla -
http://bugzilla.gnome.org/show_bug.cgi?id=43472
I have implemented it as you wanted so the global pref acts as a default
setting for any uri (in both browser and spatial modes) that has not had
its toggle state locally set.
I have not changed the global pref dialog but I do think the option
"Show hidden and backup files" should have the words "by default"
appended to make it clear that it wont override folders that have been
locally changed.
Hope thats now acceptable to be committed.
jamie.
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Alexander Larsson Red Hat, Inc
> alexl redhat com alla lysator liu se
> He's a gun-slinging zombie cat burglar haunted by memories of 'Nam. She's an
> orphaned junkie socialite with the power to bend men's minds. They fight
> crime!
>
>
Index: libnautilus-private/nautilus-metadata.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metadata.h,v
retrieving revision 1.28
diff -u -r1.28 nautilus-metadata.h
--- a/libnautilus-private/nautilus-metadata.h 11 Jan 2004 20:34:32 -0000 1.28
+++ b/libnautilus-private/nautilus-metadata.h 28 May 2004 15:02:35 -0000
@@ -64,6 +64,7 @@
#define NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY "window_geometry"
#define NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION "window_scroll_position"
+#define NAUTILUS_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES "window_show_hidden_files"
#define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR "sidebar_background_color"
#define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE "sidebar_background_tile_image"
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.620
diff -u -r1.620 fm-directory-view.c
--- a/src/file-manager/fm-directory-view.c 22 May 2004 01:40:58 -0000 1.620
+++ b/src/file-manager/fm-directory-view.c 28 May 2004 15:02:50 -0000
@@ -1093,6 +1093,43 @@
fm_directory_view_reset_to_defaults (callback_data);
}
+
+static void
+show_hidden_files_toggle_callback (BonoboUIComponent *component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ gpointer callback_data)
+{
+ FMDirectoryView *directory_view;
+ NautilusFile *file;
+ char *window_uri;
+
+ g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
+ directory_view = FM_DIRECTORY_VIEW (callback_data);
+
+ if (strcmp (state, "") == 0) {
+ /* State goes blank when component is removed; ignore this. */
+ return;
+ }
+
+ directory_view->details->show_hidden_files = (!strcmp (state, "1"));
+
+ if (directory_view->details->model != NULL) {
+ window_uri = fm_directory_view_get_uri(directory_view);
+ file = nautilus_file_get (window_uri);
+ nautilus_file_set_metadata (file,
+ NAUTILUS_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES,
+ NULL,
+ state);
+
+ g_free(window_uri);
+ nautilus_file_unref (file);
+ load_directory (directory_view,
+ directory_view->details->model);
+ }
+}
+
static void
bonobo_menu_empty_trash_callback (BonoboUIComponent *component,
gpointer callback_data,
@@ -5205,6 +5242,42 @@
bonobo_ui_component_add_verb_list_with_data (view->details->ui, verbs, view);
+ bonobo_ui_component_add_listener
+ (view->details->ui,
+ "Show Hidden Files",
+ show_hidden_files_toggle_callback,
+ view);
+
+ NautilusFile *file;
+ char *window_uri;
+ char *show_hidden_file_setting;
+ gboolean show_all_files;
+
+ window_uri = fm_directory_view_get_uri(view);
+ file = nautilus_file_get (window_uri);
+
+ show_hidden_file_setting = nautilus_file_get_metadata
+ (file,
+ NAUTILUS_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES,
+ NULL);
+
+ /* set toggle to default if show/hide state for current uri has not been previously set */
+ if (show_hidden_file_setting == NULL) {
+ nautilus_bonobo_set_toggle_state (view->details->ui,
+ "/commands/Show Hidden Files",
+ view->details->show_hidden_files);
+ } else {
+ show_all_files = !strcmp (show_hidden_file_setting, "1");
+ view->details->show_hidden_files = show_all_files;
+ view->details->show_backup_files = show_all_files;
+ nautilus_bonobo_set_toggle_state (view->details->ui,
+ "/commands/Show Hidden Files",
+ show_all_files);
+ }
+
+ g_free(window_uri);
+ g_free(show_hidden_file_setting);
+ nautilus_file_unref (file);
g_signal_connect_object (fm_directory_view_get_background (view), "settings_changed",
G_CALLBACK (schedule_update_menus), G_OBJECT (view),
G_CONNECT_SWAPPED);
@@ -6888,28 +6961,42 @@
filtering_changed_callback (gpointer callback_data)
{
FMDirectoryView *directory_view;
- gboolean new_show_hidden, new_show_backup;
+ gboolean new_show_hidden;
gboolean filtering_actually_changed;
directory_view = FM_DIRECTORY_VIEW (callback_data);
filtering_actually_changed = FALSE;
new_show_hidden = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
- if (new_show_hidden != directory_view->details->show_hidden_files) {
- filtering_actually_changed = TRUE;
- directory_view->details->show_hidden_files = new_show_hidden ;
- }
+
+ NautilusFile *file;
+ char *window_uri;
+ char *show_hidden_file_setting;
- new_show_backup = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
- if (new_show_backup != directory_view->details->show_backup_files) {
+ window_uri = fm_directory_view_get_uri(directory_view);
+ file = nautilus_file_get (window_uri);
+
+ show_hidden_file_setting = nautilus_file_get_metadata
+ (file, NAUTILUS_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES, NULL);
+
+ /* only apply global show hidden files pref if local setting has not been set for this uri */
+ if ((new_show_hidden != directory_view->details->show_hidden_files) && (show_hidden_file_setting == NULL)) {
filtering_actually_changed = TRUE;
- directory_view->details->show_backup_files = new_show_backup;
+ directory_view->details->show_hidden_files = new_show_hidden;
+ directory_view->details->show_backup_files = new_show_hidden;
}
+
+ g_free(window_uri);
+ g_free(show_hidden_file_setting);
+ nautilus_file_unref (file);
/* Reload the current uri so that the filtering changes take place. */
- if (filtering_actually_changed && directory_view->details->model != NULL) {
+ if ((filtering_actually_changed) && directory_view->details->model != NULL) {
load_directory (directory_view,
directory_view->details->model);
+ nautilus_bonobo_set_toggle_state (directory_view->details->ui,
+ "/commands/Show Hidden Files",
+ directory_view->details->show_hidden_files);
}
}
Index: src/file-manager/nautilus-directory-view-ui.xml
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/nautilus-directory-view-ui.xml,v
retrieving revision 1.63
diff -u -r1.63 nautilus-directory-view-ui.xml
--- a/src/file-manager/nautilus-directory-view-ui.xml 28 Jan 2004 07:36:16 -0000 1.63
+++ b/src/file-manager/nautilus-directory-view-ui.xml 28 May 2004 15:02:50 -0000
@@ -39,6 +39,9 @@
<cmd name="OtherApplication"
_label="Other _Application..."
_tip="Choose another application with which to open the selected item"/>
+ <cmd name="Show Hidden Files"
+ _label="Show _Hidden Files"
+ _tip="Toggles the display of hidden files in the current window"/>
<cmd name="Reset to Defaults"
_label="Reset View to _Defaults"
_tip="Reset sorting order and zoom level to match preferences for this view"/>
@@ -205,6 +208,10 @@
<placeholder name="View Preferences Placeholder">
<menuitem name="Reset to Defaults"
verb="Reset to Defaults"/>
+ <menuitem name="Show Hidden Files"
+ type="toggle"
+ accel="*Control*h"
+ verb="Show Hidden Files"/>
</placeholder>
</submenu>
</menu>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]