[Nautilus-list] Patch: Show hidden files toolbarbutton



Hi,

Sending a small patch to nautilus HEAD that adds a
'Show Hidden Files' toolbar-button in icon and listview.

A feature many wants (including me), by nobody implemented it...

Known issues: Needs a new toolbar-button....

/Fredrik




diff -ur nautilus/ChangeLog nautilus.copy/ChangeLog
--- nautilus/ChangeLog	Mon Feb 11 22:06:45 2002
+++ nautilus.copy/ChangeLog	Mon Feb 11 22:24:40 2002
@@ -1,3 +1,17 @@
+2002-02-11  Fredrik Nilsson <jymdman home se>
+
+	* src/file-manager/fm-directory-view.c:
+	(nautilus_bonobo_get_toggle_state), (show_hidden_files_callback),
+	(update_show_hidden_files_state): New functions
+	to handle 'Show Hidden Files' toolbar-button.
+	
+	* src/file-manager/fm-directory-view.c:
+	(real_merge_menu): Handle 'Show Hidden Files' toolbar-button.
+	(filtering_changed_callback): Ditto.
+	
+	* src/file-manager/nautilus-directory-view-ui.xml:
+	Add 'Show Hidden Files' toolbar-button.
+	
 2002-02-11  Jody Goldberg <jody gnome org>
 
 	* src/nautilus-bookmark-parsing.c : Include libxml/globals.h to get
diff -ur nautilus/src/file-manager/fm-directory-view.c nautilus.copy/src/file-manager/fm-directory-view.c
--- nautilus/src/file-manager/fm-directory-view.c	Wed Feb  6 22:56:44 2002
+++ nautilus.copy/src/file-manager/fm-directory-view.c	Mon Feb 11 22:24:45 2002
@@ -121,6 +121,7 @@
 #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_MENU_PATH_OPEN_ALTERNATE        		"/menu/File/Open Placeholder/OpenAlternate"
 #define FM_DIRECTORY_VIEW_MENU_PATH_OPEN_WITH				"/menu/File/Open Placeholder/Open With"
@@ -3999,6 +4000,60 @@
 			       gtk_get_current_event_time ());
 }
 
+/* Should be in libnautilus-private/bonobo-extensions.c ?? */
+static gboolean
+nautilus_bonobo_get_toggle_state (BonoboUIComponent *ui,
+				const char *path)
+{
+	char *value;
+	gboolean toggled;
+	CORBA_Environment ev;
+	
+	g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (ui), FALSE);
+	
+	CORBA_exception_init (&ev);
+	value = bonobo_ui_component_get_prop (ui, path, "state", &ev);
+	CORBA_exception_free (&ev);
+
+	if (value == NULL) {
+		toggled = FALSE;
+	} else {
+		/* Anything other than "0" counts as TRUE */
+		toggled = strcmp (value, "0") != 0;
+	}
+	
+	g_free (value);
+	
+	return toggled;
+}
+
+static void
+show_hidden_files_callback (BonoboUIComponent *component,
+				gpointer callback_data,
+				const char *verb)
+{
+	FMDirectoryView *view;
+	
+	g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+	
+	eel_preferences_set_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
+				nautilus_bonobo_get_toggle_state (view->details->ui, FM_DIRECTORY_VIEW_COMMAND_SHOW_HIDDEN_FILES));
+}
+
+static void
+update_show_hidden_files_state (FMDirectoryView *view)
+{
+	bonobo_ui_component_freeze (view->details->ui, NULL);
+
+	nautilus_bonobo_set_toggle_state (view->details->ui,
+						FM_DIRECTORY_VIEW_COMMAND_SHOW_HIDDEN_FILES,
+						eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES));
+	
+	bonobo_ui_component_thaw (view->details->ui, NULL);
+}
+
 static gboolean
 real_selection_clear_event (GtkWidget *widget,
 			    GdkEventSelection *event)
@@ -4144,6 +4199,7 @@
 		BONOBO_UI_VERB ("Show Properties", open_properties_window_callback),
 		BONOBO_UI_VERB ("Show Trash", show_trash_callback),
 		BONOBO_UI_VERB ("Trash", trash_callback),
+		BONOBO_UI_VERB ("Show Hidden Files", show_hidden_files_callback),
 		BONOBO_UI_VERB_END
 	};
 
@@ -4156,6 +4212,8 @@
 
 	bonobo_ui_component_add_verb_list_with_data (view->details->ui, verbs, view);
 
+	update_show_hidden_files_state (view);
+	
 	gtk_signal_connect_object (GTK_OBJECT (fm_directory_view_get_background (view)),
 			    	   "settings_changed",
 			    	   G_CALLBACK (schedule_update_menus),
@@ -5435,6 +5493,7 @@
 	if (new_show_hidden != directory_view->details->show_hidden_files) {
 		filtering_actually_changed = TRUE;
 		directory_view->details->show_hidden_files = new_show_hidden ;
+		update_show_hidden_files_state (directory_view);
 	}
 
 	new_show_backup = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
diff -ur nautilus/src/file-manager/nautilus-directory-view-ui.xml nautilus.copy/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.copy/src/file-manager/nautilus-directory-view-ui.xml	Mon Feb 11 22:11:17 2002
@@ -60,6 +60,9 @@
 	<cmd name="Trash"
          _label="Move to Trash"
 	 _tip="Move each selected item to the Trash"/>
+	<cmd name="Show Hidden Files"
+			_label="Show Hidden Files"
+	 _tip="Show Hidden Files"/>
 </commands>
 <keybindings>
 	<accel name="*Control*BackSpace" verb="Trash"/>
@@ -178,6 +181,16 @@
 		</placeholder>
 	</submenu>
 </menu>
+<dockitem name="Toolbar">
+	<placeholder name="Extra Buttons Placeholder">
+		<toolitem name="Show Hidden Files"
+				_label="Show Hidden Files"
+				verb="Show Hidden Files"
+				pixtype="stock"
+				pixname="gtk-yes"
+				type="toggle"/>
+	</placeholder>
+</dockitem>
 <popups>
 	<popup name="background">
 		<placeholder name="Before Zoom Items">


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