[patch] take advantage of nautilus_get_home_directory_uri()



Hi,

	here is a small cleanup I stumbled across by chance: nautilus has a
small util that does get the home directory uri, however most of the
places that need to get the home uri do not use it. This patch addresses
that and also removes the nautilus_navigation_window_go_home method
since it's parent (NautilusWindow) has the exact same method with the
same code.

(the patch also includes some cleanup of not needed includes and the use
of g_signal_emit instead of g_signal_emit_by_name in a place).

Paolo
Index: libnautilus-private/nautilus-desktop-link.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-link.c,v
retrieving revision 1.14
diff -u -p -u -p -r1.14 nautilus-desktop-link.c
--- libnautilus-private/nautilus-desktop-link.c	18 Mar 2006 07:13:49 -0000	1.14
+++ libnautilus-private/nautilus-desktop-link.c	7 Dec 2006 16:34:42 -0000
@@ -34,6 +34,7 @@
 #include <gtk/gtksignal.h>
 #include <glib/gi18n.h>
 #include <libgnomevfs/gnome-vfs.h>
+#include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-trash-monitor.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
 #include <string.h>
@@ -130,10 +131,8 @@ nautilus_desktop_link_new (NautilusDeskt
 	switch (type) {
 	case NAUTILUS_DESKTOP_LINK_HOME:
 		link->details->filename = g_strdup ("home");
-
 		link->details->display_name = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_HOME_NAME);
-		
-		link->details->activation_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+		link->details->activation_uri = nautilus_get_home_directory_uri ();
 		link->details->icon = g_strdup ("gnome-fs-home");
 
 		eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_HOME_NAME,
Index: libnautilus-private/nautilus-file-utilities.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-utilities.c,v
retrieving revision 1.135
diff -u -p -u -p -r1.135 nautilus-file-utilities.c
--- libnautilus-private/nautilus-file-utilities.c	19 Oct 2006 13:27:21 -0000	1.135
+++ libnautilus-private/nautilus-file-utilities.c	7 Dec 2006 16:34:42 -0000
@@ -323,7 +323,7 @@ nautilus_is_home_directory_file_escaped 
 	GnomeVFSURI *vfs_uri;
 	
 	if (escaped_home_dir_dirname == NULL) {
-		uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+		uri = nautilus_get_home_directory_uri ();
 		vfs_uri = gnome_vfs_uri_new (uri);
 		g_free (uri);
 
Index: libnautilus-private/nautilus-query.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-query.c,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 nautilus-query.c
--- libnautilus-private/nautilus-query.c	18 Mar 2006 07:13:49 -0000	1.3
+++ libnautilus-private/nautilus-query.c	7 Dec 2006 16:34:42 -0000
@@ -25,10 +25,10 @@
 #include <string.h>
 
 #include "nautilus-query.h"
-#include <libgnomevfs/gnome-vfs-utils.h>
 #include <eel/eel-gtk-macros.h>
 #include <eel/eel-glib-extensions.h>
 #include <glib/gi18n.h>
+#include <libnautilus-private/nautilus-file-utilities.h>
 
 struct NautilusQueryDetails {
 	char *text;
@@ -143,9 +143,9 @@ encode_home_uri (const char *uri)
 {
 	char *home_uri;
 	const char *encoded_uri;
-	
-	home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-	
+
+	home_uri = nautilus_get_home_directory_uri ();
+
 	if (g_str_has_prefix (uri, home_uri)) {
 		encoded_uri = uri + strlen (home_uri);
 		if (*encoded_uri == '/') {
@@ -169,7 +169,7 @@ decode_home_uri (const char *uri)
 	if (g_str_has_prefix (uri, "file:")) {
 		decoded_uri = g_strdup (uri);
 	} else {
-		home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+		home_uri = nautilus_get_home_directory_uri ();
 
 		decoded_uri = g_strconcat (home_uri, "/", uri, NULL);
 		
Index: src/nautilus-navigation-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-window.c,v
retrieving revision 1.450
diff -u -p -u -p -r1.450 nautilus-navigation-window.c
--- src/nautilus-navigation-window.c	2 Oct 2006 10:53:58 -0000	1.450
+++ src/nautilus-navigation-window.c	7 Dec 2006 16:34:42 -0000
@@ -49,7 +49,6 @@
 #include <eel/eel-gtk-macros.h>
 #include <eel/eel-stock-dialogs.h>
 #include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gdk/gdkx.h>
 #include <gtk/gtkmain.h>
@@ -63,12 +62,7 @@
 #include <gtk/gtkliststore.h>
 #include <glib/gi18n.h>
 #include <libgnome/gnome-macros.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomeui/gnome-messagebox.h>
 #include <libgnomeui/gnome-uidefs.h>
-#include <libgnomeui/gnome-window-icon.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-file-attributes.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
@@ -762,18 +756,6 @@ void
 nautilus_navigation_window_go_forward (NautilusNavigationWindow *window)
 {
 	nautilus_navigation_window_back_or_forward (window, FALSE, 0);
-}
-
-void
-nautilus_navigation_window_go_home (NautilusNavigationWindow *window)
-{
-	char *home_uri;
-
-	home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-	
-	g_assert (home_uri != NULL);
-	nautilus_window_go_to (NAUTILUS_WINDOW (window), home_uri);
-	g_free (home_uri);
 }
 
 void
Index: src/nautilus-navigation-window.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-window.h,v
retrieving revision 1.115
diff -u -p -u -p -r1.115 nautilus-navigation-window.h
--- src/nautilus-navigation-window.h	25 Jul 2006 00:39:38 -0000	1.115
+++ src/nautilus-navigation-window.h	7 Dec 2006 16:34:42 -0000
@@ -82,7 +82,6 @@ struct _NautilusNavigationWindowClass {
 };
 
 GType    nautilus_navigation_window_get_type             (void);
-void     nautilus_navigation_window_go_home              (NautilusNavigationWindow *window);
 void     nautilus_navigation_window_allow_back           (NautilusNavigationWindow *window,
                                                           gboolean                  allow);
 void     nautilus_navigation_window_allow_forward        (NautilusNavigationWindow *window,
Index: src/nautilus-pathbar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-pathbar.c,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 nautilus-pathbar.c
--- src/nautilus-pathbar.c	8 Jul 2006 08:38:17 -0000	1.6
+++ src/nautilus-pathbar.c	7 Dec 2006 16:34:43 -0000
@@ -189,7 +189,7 @@ desktop_location_changed_callback (gpoin
 	g_free (path_bar->desktop_path);
 	g_free (path_bar->home_path);
 	path_bar->desktop_path = nautilus_get_desktop_directory_uri ();
-	path_bar->home_path = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+	path_bar->home_path = nautilus_get_home_directory_uri ();
 	desktop_is_home = (strcmp (path_bar->home_path, path_bar->desktop_path) == 0);
 
         if (path_bar->home_icon) {
@@ -212,7 +212,7 @@ nautilus_path_bar_init (NautilusPathBar 
         path_bar->icon_size = NAUTILUS_PATH_BAR_ICON_SIZE;
 
         path_bar->desktop_path = nautilus_get_desktop_directory_uri ();
-	path_bar->home_path = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+	path_bar->home_path = nautilus_get_home_directory_uri ();
 	path_bar->root_path = g_strdup ("file:///");
 	desktop_is_home = (strcmp (path_bar->home_path, path_bar->desktop_path) == 0);
 
Index: src/nautilus-places-sidebar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-places-sidebar.c,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 nautilus-places-sidebar.c
--- src/nautilus-places-sidebar.c	23 Nov 2006 13:56:54 -0000	1.26
+++ src/nautilus-places-sidebar.c	7 Dec 2006 16:34:43 -0000
@@ -233,7 +233,7 @@ update_places (NautilusPlacesSidebar *si
 	if (strcmp (g_get_home_dir(), desktop_path) != 0) {
 		char *display_name;
 
-		mount_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+		mount_uri = nautilus_get_home_directory_uri ();
 		display_name = g_filename_display_basename (g_get_home_dir ());
 		last_iter = add_place (sidebar, PLACES_BUILT_IN,
 				       display_name, "gnome-fs-home",
Index: src/nautilus-shell.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-shell.c,v
retrieving revision 1.65
diff -u -p -u -p -r1.65 nautilus-shell.c
--- src/nautilus-shell.c	7 Nov 2006 10:50:33 -0000	1.65
+++ src/nautilus-shell.c	7 Dec 2006 16:34:43 -0000
@@ -149,8 +149,9 @@ open_window (NautilusShell *shell, const
 		}
 	} else {
 		home_uri = NULL;
+
 		if (uri == NULL) {
-			home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+			home_uri = nautilus_get_home_directory_uri ();
 			uri = home_uri;
 		}
 		
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.369
diff -u -p -u -p -r1.369 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	23 Nov 2006 13:56:54 -0000	1.369
+++ src/nautilus-window-manage-views.c	7 Dec 2006 16:34:44 -0000
@@ -942,7 +942,7 @@ got_file_info_for_view_selection_callbac
 				   better test for that */
 				
 				if (!gnome_vfs_uris_match (location, "file:///")) {
-					home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+					home_uri = nautilus_get_home_directory_uri ();
 					if (!gnome_vfs_uris_match (home_uri, location)) {	
 						nautilus_window_go_home (NAUTILUS_WINDOW (window));
 					} else {
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.465
diff -u -p -u -p -r1.465 nautilus-window.c
--- src/nautilus-window.c	21 Jun 2006 16:26:23 -0000	1.465
+++ src/nautilus-window.c	7 Dec 2006 16:34:44 -0000
@@ -59,13 +59,7 @@
 #include <gtk/gtktogglebutton.h>
 #include <gtk/gtkvbox.h>
 #include <glib/gi18n.h>
-#include <libgnome/gnome-macros.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomeui/gnome-messagebox.h>
-#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomeui/gnome-window-icon.h>
 #include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-file-attributes.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
@@ -366,7 +360,6 @@ nautilus_window_allow_reload (NautilusWi
 	action = gtk_action_group_get_action (window->details->main_action_group,
 					      NAUTILUS_ACTION_RELOAD);
 	gtk_action_set_sensitive (action, allow);
-
 }
 
 void
@@ -374,12 +367,8 @@ nautilus_window_go_home (NautilusWindow 
 {
 	char *home_uri;
 
-	g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
-	home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-	
-	g_assert (home_uri != NULL);
-	nautilus_window_go_to (window, home_uri);
+	home_uri = nautilus_get_home_directory_uri ();
+	nautilus_window_open_location (window, home_uri, FALSE);
 	g_free (home_uri);
 }
 
Index: src/file-manager/fm-tree-model.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-tree-model.c,v
retrieving revision 1.13
diff -u -p -u -p -r1.13 fm-tree-model.c
--- src/file-manager/fm-tree-model.c	1 Nov 2006 09:47:46 -0000	1.13
+++ src/file-manager/fm-tree-model.c	7 Dec 2006 16:34:44 -0000
@@ -1023,9 +1023,11 @@ done_loading_callback (NautilusDirectory
 	}
 	set_done_loading (root->model, node, TRUE);
 	nautilus_file_unref (file);
-	
+
 	make_iter_for_node (node, &iter, root->model->details->stamp);
-	g_signal_emit_by_name (root->model, "row_loaded", &iter);
+	g_signal_emit (root->model,
+		       tree_model_signals[ROW_LOADED], 0,
+		       &iter);
 }
 
 static NautilusFileAttributes
Index: src/file-manager/fm-tree-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-tree-view.c,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 fm-tree-view.c
--- src/file-manager/fm-tree-view.c	28 Nov 2006 10:04:19 -0000	1.30
+++ src/file-manager/fm-tree-view.c	7 Dec 2006 16:34:45 -0000
@@ -34,11 +34,11 @@
 
 #include "fm-tree-model.h"
 #include "fm-properties-window.h"
+#include <string.h>
 #include <eel/eel-alert-dialog.h>
 #include <eel/eel-glib-extensions.h>
 #include <eel/eel-gtk-extensions.h>
 #include <eel/eel-preferences.h>
-#include <eel/eel-string.h>
 #include <eel/eel-stock-dialogs.h>
 #include <eel/eel-vfs-extensions.h>
 #include <gtk/gtkmain.h>
@@ -66,6 +66,7 @@
 #include <libnautilus-private/nautilus-debug-log.h>
 #include <libnautilus-private/nautilus-file-attributes.h>
 #include <libnautilus-private/nautilus-file-operations.h>
+#include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
 #include <libnautilus-private/nautilus-program-choosing.h>
 #include <libnautilus-private/nautilus-tree-view-drag-dest.h>
@@ -346,7 +347,7 @@ got_activation_uri_callback (NautilusFil
 
 	uri = nautilus_file_get_activation_uri (file);
 	if (uri != NULL
-	    && eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
+	    && g_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
 
 		uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
 		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
@@ -355,8 +356,8 @@ got_activation_uri_callback (NautilusFil
 		nautilus_launch_application_from_command (screen, NULL, uri, NULL, FALSE);
 
 	} else if (uri != NULL
-	    	   && eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
-		   
+		   && g_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+
 		file_uri = nautilus_file_get_uri (file);
 		nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
 				    "tree view launch_desktop_file window=%p: %s",
@@ -1388,7 +1389,7 @@ create_tree (FMTreeView *view)
 		(view->details->child_model, "row_loaded",
 		 G_CALLBACK (row_loaded_callback),
 		 view, G_CONNECT_AFTER);
-	home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+	home_uri = nautilus_get_home_directory_uri ();
 	fm_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home Folder"), "gnome-fs-home", NULL);
 	g_free (home_uri);
 	fm_tree_model_add_root_uri (view->details->child_model, "file:///", _("File System"), "gnome-fs-directory", NULL);


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