[Nautilus-list] New show hidden/backup files patch



Hi,

Here is my updated patch for show hidden/backup files

This patch changes following things:

* The preference name in preference window is changed to:
  'Show hidden/backup files in new Nautilus windows'

* Only reads the preference at view creation time,
  and only listens to changes in actual window.

* Adds menu items to Window menu->Lay Out Items
  and Right click menu->Lay Out Items.

* Toolbar button added to Location Bar for hidden files.


Known issues: 
* Still needs a sexy icon for toolbar.


/Fredrik

diff -ru nautilus/ChangeLog nautilus.work/ChangeLog
--- nautilus/ChangeLog	Wed Feb 13 19:29:38 2002
+++ nautilus.work/ChangeLog	Wed Feb 13 21:23:28 2002
@@ -1,3 +1,36 @@
+2002-02-13  Fredrik Nilsson  <jymdman home se>
+	
+	Put show hidden/backup files toggles to menus and toolbar.
+	
+	* src/nautilus-preference-dialog.c: Rename preference
+	'Show hidden/backup files' to 
+	'Show hidden/backup files in new Nautilus windows'
+	
+	* src/nautilus-shell-ui.xml: Add placeholder to
+	Location Bar
+	
+	* src/file-manager/fm-directory-view.c:
+	(fm_directory_view_init): Get default preference
+	for hidden/backup files, remove unneeded listeners
+	to preference changes.
+	(fm_directory_view_finalize): Remove unneeded call to
+	fm_directory_view_ignore_hidden_file_preferences.
+	(show_hidden_files_state_change_callback): New.
+	(show_backup_files_state_change_callback): New.
+	check if user toggle show hidden/backup files
+	and reload directory.
+	(real_merge_menus): Update toggles, add listeners for toggles.
+	(filtering_change_callback): Remove, unneeded.
+	(fm_directory_view_ignore_hidden_file_preferences):
+	Unneeded calls to remove preferences callback removed.
+	
+	* src/file-manager/nautilus-directory-view-ui.xml:
+	Moved 'View->Lay Out Items' menus from nautilus-icon-view-ui.xml
+	and add new placeholders. Add Toolbarbutton to Location Bar.
+	
+	* src/file-manager/nautilus-icon-view-ui.xml:
+	Use new placeholders added to nautilus-directory-view-ui.xml.
+
 2002-02-11  Darin Adler  <darin bentspoon com>
 
 	* configure.in: Require at least libxml 2.4.7, since that's
diff -ru nautilus/src/file-manager/fm-directory-view.c nautilus.work/src/file-manager/fm-directory-view.c
--- nautilus/src/file-manager/fm-directory-view.c	Wed Feb  6 22:56:44 2002
+++ nautilus.work/src/file-manager/fm-directory-view.c	Wed Feb 13 20:50:09 2002
@@ -121,6 +121,8 @@
 #define FM_DIRECTORY_VIEW_COMMAND_CUT_FILES	    			"/commands/Cut Files"
 #define FM_DIRECTORY_VIEW_COMMAND_COPY_FILES				"/commands/Copy Files"
 #define FM_DIRECTORY_VIEW_COMMAND_PASTE_FILES	   			"/commands/Paste Files"
+#define FM_DIRECTORY_VIEW_COMMAND_SHOW_HIDDEN_FILES				"/commands/Show Hidden Files"
+#define FM_DIRECTORY_VIEW_COMMAND_SHOW_BACKUP_FILES				"/commands/Show Backup Files"
 
 #define FM_DIRECTORY_VIEW_MENU_PATH_OPEN_ALTERNATE        		"/menu/File/Open Placeholder/OpenAlternate"
 #define FM_DIRECTORY_VIEW_MENU_PATH_OPEN_WITH				"/menu/File/Open Placeholder/Open With"
@@ -150,6 +152,9 @@
 #define FM_DIRECTORY_VIEW_POPUP_PATH_OPEN_WITH				"/popups/selection/Open Placeholder/Open With"
 #define FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS				"/popups/selection/Open Placeholder/Scripts"
 
+#define ID_SHOW_HIDDEN_FILES		"Show Hidden Files"
+#define ID_SHOW_BACKUP_FILES		"Show Backup Files"
+
 #define MAX_MENU_LEVELS 5
 
 enum {
@@ -221,7 +226,6 @@
 
 	gboolean show_hidden_files;
 	gboolean show_backup_files;
-	gboolean ignore_hidden_file_preferences;
 
 	gboolean batching_selection_level;
 	gboolean selection_changed_while_batched;
@@ -313,7 +317,6 @@
 static void     disconnect_model_handlers                      (FMDirectoryView      *view);
 static void     remove_scripts_directory                       (FMDirectoryView      *view,
 								NautilusDirectory    *directory);
-static void     filtering_changed_callback                     (gpointer              callback_data);
 static void     metadata_for_directory_as_file_ready_callback  (NautilusFile         *file,
 								gpointer              callback_data);
 static void     metadata_for_files_in_directory_ready_callback (NautilusDirectory    *directory,
@@ -1204,6 +1207,12 @@
 	view->details->sort_directories_first = 
 		eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
 
+	view->details->show_hidden_files =
+		eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
+
+	view->details->show_backup_files =
+		eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
+		
 	g_signal_connect (view->details->nautilus_view, 
 			    "stop_loading",
 			    G_CALLBACK (stop_loading_callback),
@@ -1251,17 +1260,9 @@
 
 	gtk_widget_show (GTK_WIDGET (view));
 
-	filtering_changed_callback (view);
-	
 	eel_preferences_add_callback (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
 				      schedule_update_menus_callback,
 				      view);
-	eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
-				      filtering_changed_callback,
-				      view);
-	eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
-				      filtering_changed_callback,
-				      view);
 	eel_preferences_add_callback (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
 				      schedule_update_menus_callback,
 				      view);
@@ -1335,8 +1336,6 @@
 
 	remove_update_menus_timeout_callback (view);
 
-	fm_directory_view_ignore_hidden_file_preferences (view);
-
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
 					 schedule_update_menus_callback,
 					 view);
@@ -3999,6 +3998,66 @@
 			       gtk_get_current_event_time ());
 }
 
+static void
+show_hidden_files_state_changed_callback (BonoboUIComponent   *component,
+				       const char          *path,
+				       Bonobo_UIComponent_EventType type,
+				       const char          *state,
+				       gpointer            user_data)
+{
+	FMDirectoryView *view;
+	gboolean new_state;
+	
+	g_assert (strcmp (path, ID_SHOW_HIDDEN_FILES) == 0);
+	g_assert (FM_IS_DIRECTORY_VIEW (user_data));
+
+	if (strcmp (state, "") == 0) {
+		/* State goes blank when component is removed; ignore this. */
+		return;
+	}
+
+	view = FM_DIRECTORY_VIEW (user_data);
+
+	new_state = strcmp (state, "0") != 0;
+	
+	if (new_state != view->details->show_hidden_files) {
+		view->details->show_hidden_files = new_state;
+
+		load_directory (view,
+				view->details->model);
+	}
+}
+
+static void
+show_backup_files_state_changed_callback (BonoboUIComponent   *component,
+				       const char          *path,
+				       Bonobo_UIComponent_EventType type,
+				       const char          *state,
+				       gpointer            user_data)
+{
+	FMDirectoryView *view;
+	gboolean new_state;
+	
+	g_assert (strcmp (path, ID_SHOW_BACKUP_FILES) == 0);
+	g_assert (FM_IS_DIRECTORY_VIEW (user_data));
+
+	if (strcmp (state, "") == 0) {
+		/* State goes blank when component is removed; ignore this. */
+		return;
+	}
+
+	view = FM_DIRECTORY_VIEW (user_data);
+
+	new_state = strcmp (state, "0") != 0;
+
+	if (new_state != view->details->show_backup_files) {
+		view->details->show_backup_files = new_state;
+		
+		load_directory (view,
+				view->details->model);
+	}
+}
+
 static gboolean
 real_selection_clear_event (GtkWidget *widget,
 			    GdkEventSelection *event)
@@ -4154,8 +4213,19 @@
 	g_object_add_weak_pointer (G_OBJECT (view->details->ui),
                                    (gpointer *) &view->details->ui);
 
+	nautilus_bonobo_set_toggle_state (view->details->ui,
+						FM_DIRECTORY_VIEW_COMMAND_SHOW_HIDDEN_FILES,
+						view->details->show_hidden_files);
+
+	nautilus_bonobo_set_toggle_state (view->details->ui,
+						FM_DIRECTORY_VIEW_COMMAND_SHOW_BACKUP_FILES,
+						view->details->show_backup_files);
+
 	bonobo_ui_component_add_verb_list_with_data (view->details->ui, verbs, view);
 
+	bonobo_ui_component_add_listener (view->details->ui, ID_SHOW_HIDDEN_FILES, show_hidden_files_state_changed_callback, view);
+	bonobo_ui_component_add_listener (view->details->ui, ID_SHOW_BACKUP_FILES, show_backup_files_state_changed_callback, view);
+
 	gtk_signal_connect_object (GTK_OBJECT (fm_directory_view_get_background (view)),
 			    	   "settings_changed",
 			    	   G_CALLBACK (schedule_update_menus),
@@ -5421,54 +5491,13 @@
 	schedule_update_menus (FM_DIRECTORY_VIEW (callback_data));
 }
 
-static void
-filtering_changed_callback (gpointer callback_data)
-{
-	FMDirectoryView	*directory_view;
-	gboolean new_show_hidden, new_show_backup;
-	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 ;
-	}
-
-	new_show_backup = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
-	if (new_show_backup != directory_view->details->show_backup_files) {
-		filtering_actually_changed = TRUE;
-		directory_view->details->show_backup_files = new_show_backup;
-	}
-
-	/* Reload the current uri so that the filtering changes take place. */
-	if (filtering_actually_changed && directory_view->details->model != NULL) {
-		load_directory (directory_view,
-				directory_view->details->model);
-	}
-}
-
 void
 fm_directory_view_ignore_hidden_file_preferences (FMDirectoryView *view)
 {
 	g_return_if_fail (view->details->model == NULL);
 
-	if (view->details->ignore_hidden_file_preferences) {
-		return;
-	}
-
-	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
-					      filtering_changed_callback,
-					      view);
-	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
-					      filtering_changed_callback,
-					      view);
-
 	view->details->show_hidden_files = FALSE;
 	view->details->show_backup_files = FALSE;
-	view->details->ignore_hidden_file_preferences = TRUE;
 }
 
 char *
diff -ru nautilus/src/file-manager/nautilus-directory-view-ui.xml nautilus.work/src/file-manager/nautilus-directory-view-ui.xml
--- nautilus/src/file-manager/nautilus-directory-view-ui.xml	Wed May 23 02:03:03 2001
+++ nautilus.work/src/file-manager/nautilus-directory-view-ui.xml	Wed Feb 13 20:52:34 2002
@@ -60,6 +60,10 @@
 	<cmd name="Trash"
          _label="Move to Trash"
 	 _tip="Move each selected item to the Trash"/>
+	<cmd name="Show Hidden Files"
+	 _tip="Toggle show hidden files in active Nautilus window"/>
+	<cmd name="Show Backup Files"
+	 _tip="Toggle show backup files in active Nautilus window"/>
 </commands>
 <keybindings>
 	<accel name="*Control*BackSpace" verb="Trash"/>
@@ -176,15 +180,51 @@
 				  _label="Reset View to Match _Preferences"
 				  verb="Reset to Defaults"/>
 		</placeholder>
+		<placeholder name="View Items Placeholder">
+			<submenu name="Lay Out" _label="_Lay Out Items">
+				<placeholder name="Before Hidden Files Placeholder" delimit="none"/>
+				<menuitem name="Show Hidden Files"
+						_label="Show Hidden Files"
+						id="Show Hidden Files"
+						type="toggle"/>
+				<menuitem name="Show Backup Files"
+						_label="Show Backup Files"
+						id="Show Backup Files"
+						type="toggle"/>
+				<placeholder name="After Hidden Files Placeholder" delimit="top"/>
+			</submenu>
+		</placeholder>			
 	</submenu>
 </menu>
+<dockitem name="Location Bar">
+	<placeholder name="Location Bar Placeholder">
+		<toolitem name="Show Hidden Files"
+				id="Show Hidden Files"
+				pixtype="stock"
+				pixname="gtk-yes"
+				type="toggle"/>
+	</placeholder>
+</dockitem>
 <popups>
 	<popup name="background">
 		<placeholder name="Before Zoom Items">
 			<placeholder name="New Items">
 				<menuitem name="New Folder" verb="New Folder"/>
 			</placeholder>
-			<placeholder name="View Items" delimit="top"/>
+			<placeholder name="View Items" delimit="top">
+				<submenu name="Lay Out" _label="Lay Out Items" tearoff="0">
+					<placeholder name="Before Hidden Files Placeholder" delimit="none"/>
+					<menuitem name="Show Hidden Files"
+							_label="Show Hidden Files"
+							id="Show Hidden Files"
+							type="toggle"/>
+					<menuitem name="Show Backup Files"
+							_label="Show Backup Files"
+							id="Show Backup Files"
+							type="toggle"/>
+					<placholder name="After Hidden Files Placeholder" delimit="top"/>
+				</submenu>
+			</placeholder>
 			<placeholder name="File Clipboard Actions" delimit="top">
 				<menuitem name="Cut Files" verb="Cut Files"/>
 				<menuitem name="Copy Files" verb="Copy Files"/>
diff -ru nautilus/src/file-manager/nautilus-icon-view-ui.xml nautilus.work/src/file-manager/nautilus-icon-view-ui.xml
--- nautilus/src/file-manager/nautilus-icon-view-ui.xml	Mon Feb  4 19:04:07 2002
+++ nautilus.work/src/file-manager/nautilus-icon-view-ui.xml	Wed Feb 13 20:42:07 2002
@@ -61,42 +61,46 @@
 
 	<submenu name="View">
 		<placeholder name="View Items Placeholder">
-			<submenu name="Lay Out" _label="_Lay Out Items">
-				<menuitem name="Manual Layout"
-					  _label="_Manually"
-					  type="radio" group="layout group"
-					  id="Manual Layout"/>
-				<placeholder name="Auto Layout" delimit="top">
-					<menuitem name="Sort by Name"
-						  _label="By _Name"
-						  type="radio" group="layout group"
-						  id="Sort by Name"/>
-					<menuitem name="Sort by Size"
-						  _label="By _Size"
-						  type="radio" group="layout group"
-						  id="Sort by Size"/>
-					<menuitem name="Sort by Type"
-						  _label="By _Type"
-						  type="radio" group="layout group"
-						  id="Sort by Type"/>
-					<menuitem name="Sort by Modification Date" 
-						  _label="By Modification _Date"
-						  type="radio" group="layout group"
-						  id="Sort by Modification Date"/>
-					<menuitem name="Sort by Emblems"
-						  _label="By _Emblems"
-						  type="radio" group="layout group"
-						  id="Sort by Emblems"/>
+			<submenu name="Lay Out">
+				<placeholder name="Before Hidden Files Placeholder">
+					<menuitem name="Manual Layout"
+						  _label="_Manually"
+ 						  type="radio" group="layout group"
+						  id="Manual Layout"/>
+					<placeholder name="Auto Layout" delimit="top">
+						<menuitem name="Sort by Name"
+							  _label="By _Name"
+							  type="radio" group="layout group"
+							  id="Sort by Name"/>
+						<menuitem name="Sort by Size"
+							  _label="By _Size"
+							  type="radio" group="layout group"
+							  id="Sort by Size"/>
+						<menuitem name="Sort by Type"
+							  _label="By _Type"
+							  type="radio" group="layout group"
+							  id="Sort by Type"/>
+						<menuitem name="Sort by Modification Date" 
+							  _label="By Modification _Date"
+							  type="radio" group="layout group"
+							  id="Sort by Modification Date"/>
+						<menuitem name="Sort by Emblems"
+							  _label="By _Emblems"
+							  type="radio" group="layout group"
+						 	 id="Sort by Emblems"/>
+					</placeholder>
+					<separator/>
+				</placeholder>
+				<placeholder name="After Hidden Files Placeholder">
+					<menuitem name="Tighter Layout"
+						  _label="Tighter _Layout"
+  	                                        id="Tighter Layout"
+   	                                       type="toggle"/>
+					<menuitem name="Reversed Order"
+						  _label="Re_versed Order"
+      	                                    id="Reversed Order"
+       	                                   type="toggle"/>
 				</placeholder>
-				<separator/>
-				<menuitem name="Tighter Layout"
-					  _label="Tighter _Layout"
-                                          id="Tighter Layout"
-                                          type="toggle"/>
-				<menuitem name="Reversed Order"
-					  _label="Re_versed Order"
-                                          id="Reversed Order"
-                                          type="toggle"/>
 			</submenu>
 			<menuitem name="Clean Up"
 				  _label="_Clean Up by Name"
@@ -109,34 +113,38 @@
 	<popup name="background">
 		<placeholder name="Before Zoom Items">
 			<placeholder name="View Items">
-				<submenu name="Lay Out" _label="Lay Out Items" tearoff="0">
-					<menuitem name="Manual Layout"
-						  type="radio" group="context menu layout group"
-						  id="Manual Layout"/>
-					<placeholder name="Auto Layout" delimit="top">
-						<menuitem name="Sort by Name"
-							  type="radio" group="context menu layout group"
-							  id="Sort by Name"/>
-						<menuitem name="Sort by Size"
-							  type="radio" group="context menu layout group"
-							  id="Sort by Size"/>
-						<menuitem name="Sort by Type"
+				<submenu name="Lay Out">
+					<placeholder name="Before Hidden Files Placeholder">
+						<menuitem name="Manual Layout"
 							  type="radio" group="context menu layout group"
-							  id="Sort by Type"/>
-						<menuitem name="Sort by Modification Date" 
-							  type="radio" group="context menu layout group"
-							  id="Sort by Modification Date"/>
-						<menuitem name="Sort by Emblems"
-							  type="radio" group="context menu layout group"
-							  id="Sort by Emblems"/>
+							  id="Manual Layout"/>
+						<placeholder name="Auto Layout" delimit="top">
+							<menuitem name="Sort by Name"
+								  type="radio" group="context menu layout group"
+								  id="Sort by Name"/>
+							<menuitem name="Sort by Size"
+								  type="radio" group="context menu layout group"
+								  id="Sort by Size"/>
+							<menuitem name="Sort by Type"
+								  type="radio" group="context menu layout group"
+								  id="Sort by Type"/>
+							<menuitem name="Sort by Modification Date" 
+								  type="radio" group="context menu layout group"
+							 	 id="Sort by Modification Date"/>
+							<menuitem name="Sort by Emblems"
+								  type="radio" group="context menu layout group"
+								  id="Sort by Emblems"/>
+						</placeholder>
+						<separator/>
+					</placeholder>
+					<placeholder name="After Hidden Files Placeholder">
+						<menuitem name="Tighter Layout" 
+		                                          id="Tighter Layout"
+	 	                                         type="toggle"/>
+						<menuitem name="Reversed Order" 
+	   	                                       id="Reversed Order"
+	    	                                      type="toggle"/>
 					</placeholder>
-					<separator/>
-					<menuitem name="Tighter Layout" 
-	                                          id="Tighter Layout"
-	                                          type="toggle"/>
-					<menuitem name="Reversed Order" 
-	                                          id="Reversed Order"
-	                                          type="toggle"/>
 				</submenu>
 				<menuitem name="Clean Up" verb="Clean Up"/>
 			</placeholder>
diff -ru nautilus/src/nautilus-preferences-dialog.c nautilus.work/src/nautilus-preferences-dialog.c
--- nautilus/src/nautilus-preferences-dialog.c	Wed Jan 30 17:37:14 2002
+++ nautilus.work/src/nautilus-preferences-dialog.c	Wed Feb 13 20:44:25 2002
@@ -139,12 +139,12 @@
 	},
 	{ N_("Show/Hide Options"),
 	  NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
-	  N_("Show hidden files (file names start with \".\")"),
+	  N_("Show hidden files in new Nautilus windows (file names start with \".\")"),
 	  EEL_PREFERENCE_ITEM_BOOLEAN
 	},
 	{ N_("Show/Hide Options"),
 	  NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
-	  N_("Show backup files (file names end with \"~\")"),
+	  N_("Show backup files in new Nautilus windows (file names end with \"~\")"),
 	  EEL_PREFERENCE_ITEM_BOOLEAN
 	},
 	{ N_("Show/Hide Options"),
diff -ru nautilus/src/nautilus-shell-ui.xml nautilus.work/src/nautilus-shell-ui.xml
--- nautilus/src/nautilus-shell-ui.xml	Thu Feb  7 22:29:24 2002
+++ nautilus.work/src/nautilus-shell-ui.xml	Wed Feb 13 20:50:47 2002
@@ -279,6 +279,7 @@
 
 <dockitem name="Location Bar" behavior="exclusive,never vertical">
 	<control name="Wrapper" behavior="expandable"/>
+	<placeholder name="Location Bar Placeholder" delimit="top"/>
 </dockitem>
 
 <dockitem name="Toolbar" behavior="exclusive">


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]