[nautilus] Add an icon to the location entry and drop use of location bar



commit cbcb055eb2867c2b69cf2f8f504983ce4d715410
Author: William Jon McCann <jmccann redhat com>
Date:   Fri Sep 7 16:25:42 2012 -0400

    Add an icon to the location entry and drop use of location bar
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683598

 src/Makefile.am                    |    2 -
 src/nautilus-application.c         |    2 +-
 src/nautilus-location-bar.c        |  556 ------------------------------------
 src/nautilus-location-bar.h        |   70 -----
 src/nautilus-location-entry.c      |  403 ++++++++++++++++++++++++---
 src/nautilus-location-entry.h      |    8 +-
 src/nautilus-toolbar.c             |   14 +-
 src/nautilus-toolbar.h             |    4 +-
 src/nautilus-window-manage-views.c |    1 -
 src/nautilus-window.c              |   53 ++--
 src/nautilus-window.h              |    2 +-
 11 files changed, 410 insertions(+), 705 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3319877..71279b5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -160,8 +160,6 @@ nautilus_SOURCES = \
 	nautilus-list-view-private.h 		\
 	nautilus-list-view.c			\
 	nautilus-list-view.h 			\
-	nautilus-location-bar.c         	\
-	nautilus-location-bar.h			\
 	nautilus-location-entry.c               \
 	nautilus-location-entry.h               \
 	nautilus-main.c 			\
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 49be84d..f9fb29f 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -826,7 +826,7 @@ action_enter_location (GSimpleAction *action,
 
 	cur_window = get_focus_window (application);
 	window = NAUTILUS_WINDOW (cur_window);
-	nautilus_window_ensure_location_bar (window);
+	nautilus_window_ensure_location_entry (window);
 }
 
 static void
diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c
index ded9545..887f176 100644
--- a/src/nautilus-location-entry.c
+++ b/src/nautilus-location-entry.c
@@ -33,6 +33,7 @@
 #include <config.h>
 #include "nautilus-location-entry.h"
 
+#include "nautilus-application.h"
 #include "nautilus-window-private.h"
 #include "nautilus-window.h"
 #include <gtk/gtk.h>
@@ -42,25 +43,307 @@
 #include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-entry.h>
 #include <libnautilus-private/nautilus-clipboard.h>
+#include <eel/eel-stock-dialogs.h>
+#include <eel/eel-string.h>
+#include <eel/eel-vfs-extensions.h>
 #include <stdio.h>
 #include <string.h>
 
+#define NAUTILUS_DND_URI_LIST_TYPE 	  "text/uri-list"
+#define NAUTILUS_DND_TEXT_PLAIN_TYPE 	  "text/plain"
+
+enum {
+	NAUTILUS_DND_URI_LIST,
+	NAUTILUS_DND_TEXT_PLAIN,
+	NAUTILUS_DND_NTARGETS
+};
+
+static const GtkTargetEntry drag_types [] = {
+	{ NAUTILUS_DND_URI_LIST_TYPE,   0, NAUTILUS_DND_URI_LIST },
+	{ NAUTILUS_DND_TEXT_PLAIN_TYPE, 0, NAUTILUS_DND_TEXT_PLAIN },
+};
+
+static const GtkTargetEntry drop_types [] = {
+	{ NAUTILUS_DND_URI_LIST_TYPE,   0, NAUTILUS_DND_URI_LIST },
+	{ NAUTILUS_DND_TEXT_PLAIN_TYPE, 0, NAUTILUS_DND_TEXT_PLAIN },
+};
+
 struct NautilusLocationEntryDetails {
-	GtkLabel *label;
-	
 	char *current_directory;
 	GFilenameCompleter *completer;
-	
+
 	guint idle_id;
 
+	char *last_uri;
+
 	gboolean has_special_text;
 	gboolean setting_special_text;
 	gchar *special_text;
 	NautilusLocationEntryAction secondary_action;
 };
 
+enum {
+	CANCEL,
+	LOCATION_CHANGED,
+	LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
 G_DEFINE_TYPE (NautilusLocationEntry, nautilus_location_entry, NAUTILUS_TYPE_ENTRY);
 
+void
+nautilus_location_entry_focus (NautilusLocationEntry *entry)
+{
+	/* Put the keyboard focus in the text field when switching to this mode,
+	 * and select all text for easy overtyping
+	 */
+	gtk_widget_grab_focus (GTK_WIDGET (entry));
+	nautilus_entry_select_all (NAUTILUS_ENTRY (entry));
+}
+
+static GFile *
+nautilus_location_entry_get_location (NautilusLocationEntry *entry)
+{
+	char *user_location;
+	GFile *location;
+
+	user_location = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+	location = g_file_parse_name (user_location);
+	g_free (user_location);
+
+	return location;
+}
+
+static void
+emit_location_changed (NautilusLocationEntry *entry)
+{
+	GFile *location;
+
+	location = nautilus_location_entry_get_location (entry);
+	g_signal_emit (entry, signals[LOCATION_CHANGED], 0, location);
+	g_object_unref (location);
+}
+
+static void
+nautilus_location_entry_update_action (NautilusLocationEntry *entry)
+{
+	const char *current_text;
+	GFile *location;
+	GFile *last_location;
+
+	if (entry->details->last_uri == NULL){
+		nautilus_location_entry_set_secondary_action (entry,
+							      NAUTILUS_LOCATION_ENTRY_ACTION_GOTO);
+		return;
+	}
+
+	current_text = gtk_entry_get_text (GTK_ENTRY (entry));
+	location = g_file_parse_name (current_text);
+	last_location = g_file_parse_name (entry->details->last_uri);
+
+	if (g_file_equal (last_location, location)) {
+		nautilus_location_entry_set_secondary_action (entry,
+							      NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR);
+	} else {
+		nautilus_location_entry_set_secondary_action (entry,
+							      NAUTILUS_LOCATION_ENTRY_ACTION_GOTO);
+	}
+
+	g_object_unref (location);
+	g_object_unref (last_location);
+}
+
+static int
+get_editable_number_of_chars (GtkEditable *editable)
+{
+	char *text;
+	int length;
+
+	text = gtk_editable_get_chars (editable, 0, -1);
+	length = g_utf8_strlen (text, -1);
+	g_free (text);
+	return length;
+}
+
+static void
+set_position_and_selection_to_end (GtkEditable *editable)
+{
+	int end;
+
+	end = get_editable_number_of_chars (editable);
+	gtk_editable_select_region (editable, end, end);
+	gtk_editable_set_position (editable, end);
+}
+
+static void
+nautilus_location_entry_update_current_uri (NautilusLocationEntry *entry,
+					    const char *uri)
+{
+	g_free (entry->details->current_directory);
+	entry->details->current_directory = g_strdup (uri);
+
+	nautilus_entry_set_text (NAUTILUS_ENTRY (entry), uri);
+	set_position_and_selection_to_end (GTK_EDITABLE (entry));
+}
+
+void
+nautilus_location_entry_set_uri (NautilusLocationEntry *entry,
+				 const char            *uri)
+{
+	char *formatted_uri;
+	GFile *file;
+
+	g_assert (uri != NULL);
+
+	/* Note: This is called in reaction to external changes, and
+	 * thus should not emit the LOCATION_CHANGED signal. */
+
+	if (eel_uri_is_search (uri)) {
+		nautilus_location_entry_set_special_text (entry,
+							  "");
+	} else {
+		file = g_file_new_for_uri (uri);
+		formatted_uri = g_file_get_parse_name (file);
+		g_object_unref (file);
+		nautilus_location_entry_update_current_uri (entry,
+								 formatted_uri);
+		g_free (formatted_uri);
+	}
+
+	/* remember the original uri for later comparison */
+
+	if (entry->details->last_uri != uri) {
+		g_free (entry->details->last_uri);
+		entry->details->last_uri = g_strdup (uri);
+	}
+
+	nautilus_location_entry_update_action (entry);
+}
+
+static void
+drag_data_received_callback (GtkWidget *widget,
+			     GdkDragContext *context,
+			     int x,
+			     int y,
+			     GtkSelectionData *data,
+			     guint info,
+			     guint32 time,
+			     gpointer callback_data)
+{
+	char **names;
+	NautilusApplication *application;
+	int name_count;
+	NautilusWindow *new_window;
+	GtkWidget *window;
+	GdkScreen      *screen;
+	gboolean new_windows_for_extras;
+	char *prompt;
+	char *detail;
+	GFile *location;
+	NautilusLocationEntry *self = NAUTILUS_LOCATION_ENTRY (widget);
+
+	g_assert (data != NULL);
+	g_assert (callback_data == NULL);
+
+	names = g_uri_list_extract_uris ((const gchar *) gtk_selection_data_get_data (data));
+
+	if (names == NULL || *names == NULL) {
+		g_warning ("No D&D URI's");
+		gtk_drag_finish (context, FALSE, FALSE, time);
+		return;
+	}
+
+	window = gtk_widget_get_toplevel (widget);
+	new_windows_for_extras = FALSE;
+	/* Ask user if they really want to open multiple windows
+	 * for multiple dropped URIs. This is likely to have been
+	 * a mistake.
+	 */
+	name_count = g_strv_length (names);
+	if (name_count > 1) {
+		prompt = g_strdup_printf (ngettext("Do you want to view %d location?",
+						   "Do you want to view %d locations?",
+						   name_count),
+					  name_count);
+		detail = g_strdup_printf (ngettext("This will open %d separate window.",
+						   "This will open %d separate windows.",
+						   name_count),
+					  name_count);
+		/* eel_run_simple_dialog should really take in pairs
+		 * like gtk_dialog_new_with_buttons() does. */
+		new_windows_for_extras = eel_run_simple_dialog (GTK_WIDGET (window),
+								TRUE,
+								GTK_MESSAGE_QUESTION,
+								prompt,
+								detail,
+								GTK_STOCK_CANCEL, GTK_STOCK_OK,
+								NULL) != 0 /* GNOME_OK */;
+
+		g_free (prompt);
+		g_free (detail);
+
+		if (!new_windows_for_extras) {
+			gtk_drag_finish (context, FALSE, FALSE, time);
+			return;
+		}
+	}
+
+	nautilus_location_entry_set_uri (self, names[0]);
+	emit_location_changed (self);
+
+	if (new_windows_for_extras) {
+		int i;
+
+		application = NAUTILUS_APPLICATION (g_application_get_default ());
+		screen = gtk_window_get_screen (GTK_WINDOW (window));
+
+		for (i = 1; names[i] != NULL; ++i) {
+			new_window = nautilus_application_create_window (application, screen);
+			location = g_file_new_for_uri (names[i]);
+			nautilus_window_go_to (new_window, location);
+			g_object_unref (location);
+		}
+	}
+
+	g_strfreev (names);
+
+	gtk_drag_finish (context, TRUE, FALSE, time);
+}
+
+static void
+drag_data_get_callback (GtkWidget *widget,
+			GdkDragContext *context,
+			GtkSelectionData *selection_data,
+			guint info,
+			guint32 time,
+			gpointer callback_data)
+{
+	NautilusLocationEntry *self;
+	GFile *location;
+	gchar *uri;
+
+	g_assert (selection_data != NULL);
+	self = callback_data;
+
+	location = nautilus_location_entry_get_location (self);
+	uri = g_file_get_uri (location);
+
+	switch (info) {
+	case NAUTILUS_DND_URI_LIST:
+	case NAUTILUS_DND_TEXT_PLAIN:
+		gtk_selection_data_set (selection_data,
+					gtk_selection_data_get_target (selection_data),
+					8, (guchar *) uri,
+					strlen (uri));
+		break;
+	default:
+		g_assert_not_reached ();
+	}
+	g_free (uri);
+	g_object_unref (location);
+}
+
 /* routine that performs the tab expansion.  Extract the directory name and
    incomplete basename, then iterate through the directory trying to complete it.  If we
    find something, add it to the entry */
@@ -144,28 +427,6 @@ entry_would_have_inserted_characters (const GdkEventKey *event)
 	}
 }
 
-static int
-get_editable_number_of_chars (GtkEditable *editable)
-{
-	char *text;
-	int length;
-
-	text = gtk_editable_get_chars (editable, 0, -1);
-	length = g_utf8_strlen (text, -1);
-	g_free (text);
-	return length;
-}
-
-static void
-set_position_and_selection_to_end (GtkEditable *editable)
-{
-	int end;
-
-	end = get_editable_number_of_chars (editable);
-	gtk_editable_select_region (editable, end, end);
-	gtk_editable_set_position (editable, end);
-}
-
 static gboolean
 position_and_selection_are_at_end (GtkEditable *editable)
 {
@@ -250,6 +511,9 @@ finalize (GObject *object)
 	g_object_unref (entry->details->completer);
 	g_free (entry->details->special_text);
 
+	g_free (entry->details->last_uri);
+	entry->details->last_uri = NULL;
+
 	G_OBJECT_CLASS (nautilus_location_entry_parent_class)->finalize (object);
 }
 
@@ -343,11 +607,21 @@ nautilus_location_entry_activate (GtkEntry *entry)
 }
 
 static void
+nautilus_location_entry_cancel (NautilusLocationEntry *entry)
+{
+	char *last_uri;
+
+	last_uri = entry->details->last_uri;
+	nautilus_location_entry_set_uri (entry, last_uri);
+}
+
+static void
 nautilus_location_entry_class_init (NautilusLocationEntryClass *class)
 {
 	GtkWidgetClass *widget_class;
 	GObjectClass *gobject_class;
 	GtkEntryClass *entry_class;
+	GtkBindingSet *binding_set;
 
 	widget_class = GTK_WIDGET_CLASS (class);
 	widget_class->focus_in_event = nautilus_location_entry_focus_in;
@@ -359,18 +633,30 @@ nautilus_location_entry_class_init (NautilusLocationEntryClass *class)
 	entry_class = GTK_ENTRY_CLASS (class);
 	entry_class->activate = nautilus_location_entry_activate;
 
-	g_type_class_add_private (class, sizeof (NautilusLocationEntryDetails));
-}
-
-void
-nautilus_location_entry_update_current_location (NautilusLocationEntry *entry,
-						 const char *location)
-{
-	g_free (entry->details->current_directory);
-	entry->details->current_directory = g_strdup (location);
+	class->cancel = nautilus_location_entry_cancel;
+
+	signals[CANCEL] = g_signal_new
+		("cancel",
+		 G_TYPE_FROM_CLASS (class),
+		 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+		 G_STRUCT_OFFSET (NautilusLocationEntryClass,
+				  cancel),
+		 NULL, NULL,
+		 g_cclosure_marshal_VOID__VOID,
+		 G_TYPE_NONE, 0);
+
+	signals[LOCATION_CHANGED] = g_signal_new
+		("location-changed",
+		 G_TYPE_FROM_CLASS (class),
+		 G_SIGNAL_RUN_LAST, 0,
+		 NULL, NULL,
+		 g_cclosure_marshal_generic,
+		 G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
+	binding_set = gtk_binding_set_by_class (class);
+	gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
 
-	nautilus_entry_set_text (NAUTILUS_ENTRY (entry), location);
-	set_position_and_selection_to_end (GTK_EDITABLE (entry));
+	g_type_class_add_private (class, sizeof (NautilusLocationEntryDetails));
 }
 
 void
@@ -398,14 +684,42 @@ nautilus_location_entry_set_secondary_action (NautilusLocationEntry *entry,
 }
 
 static void
+editable_activate_callback (GtkEntry *entry,
+			    gpointer user_data)
+{
+	NautilusLocationEntry *self = user_data;
+	const char *entry_text;
+
+	entry_text = gtk_entry_get_text (entry);
+	if (entry_text != NULL && *entry_text != '\0') {
+		emit_location_changed (self);
+	}
+}
+
+static void
+editable_changed_callback (GtkEntry *entry,
+			   gpointer user_data)
+{
+	nautilus_location_entry_update_action (NAUTILUS_LOCATION_ENTRY (entry));
+}
+
+static void
 nautilus_location_entry_init (NautilusLocationEntry *entry)
 {
+	GtkTargetList *targetlist;
+
 	entry->details = G_TYPE_INSTANCE_GET_PRIVATE (entry, NAUTILUS_TYPE_LOCATION_ENTRY,
 						      NautilusLocationEntryDetails);
 
 	entry->details->completer = g_filename_completer_new ();
 	g_filename_completer_set_dirs_only (entry->details->completer, TRUE);
 
+	gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, "folder-symbolic");
+	gtk_entry_set_icon_activatable (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, FALSE);
+	targetlist = gtk_target_list_new (drag_types, G_N_ELEMENTS (drag_types));
+	gtk_entry_set_icon_drag_source (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, targetlist, GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
+	gtk_target_list_unref (targetlist);
+
 	nautilus_location_entry_set_secondary_action (entry,
 						      NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR);
 
@@ -422,6 +736,23 @@ nautilus_location_entry_init (NautilusLocationEntry *entry)
 
 	g_signal_connect (entry->details->completer, "got_completion_data",
 		          G_CALLBACK (got_completion_data_callback), entry);
+
+	/* Drag source */
+	g_signal_connect_object (entry, "drag_data_get",
+				 G_CALLBACK (drag_data_get_callback), entry, 0);
+
+	/* Drag dest. */
+	gtk_drag_dest_set (GTK_WIDGET (entry),
+			   GTK_DEST_DEFAULT_ALL,
+			   drop_types, G_N_ELEMENTS (drop_types),
+			   GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
+	g_signal_connect (entry, "drag_data_received",
+			  G_CALLBACK (drag_data_received_callback), NULL);
+
+	g_signal_connect_object (entry, "activate",
+				 G_CALLBACK (editable_activate_callback), entry, G_CONNECT_AFTER);
+	g_signal_connect_object (entry, "changed",
+				 G_CALLBACK (editable_changed_callback), entry, 0);
 }
 
 GtkWidget *
diff --git a/src/nautilus-location-entry.h b/src/nautilus-location-entry.h
index 460d698..31e4c29 100644
--- a/src/nautilus-location-entry.h
+++ b/src/nautilus-location-entry.h
@@ -50,6 +50,8 @@ typedef struct NautilusLocationEntry {
 
 typedef struct {
 	NautilusEntryClass parent_class;
+	/* for GtkBindingSet */
+	void         (* cancel)           (NautilusLocationEntry *entry);
 } NautilusLocationEntryClass;
 
 typedef enum {
@@ -58,12 +60,14 @@ typedef enum {
 } NautilusLocationEntryAction;
 
 GType      nautilus_location_entry_get_type     	(void);
+
 GtkWidget* nautilus_location_entry_new          	(void);
 void       nautilus_location_entry_set_special_text     (NautilusLocationEntry *entry,
 							 const char            *special_text);
 void       nautilus_location_entry_set_secondary_action (NautilusLocationEntry *entry,
 							 NautilusLocationEntryAction secondary_action);
-void       nautilus_location_entry_update_current_location (NautilusLocationEntry *entry,
-							    const char *path);
+void       nautilus_location_entry_set_uri              (NautilusLocationEntry *entry,
+							 const char            *location);
+void       nautilus_location_entry_focus                (NautilusLocationEntry *entry);
 
 #endif /* NAUTILUS_LOCATION_ENTRY_H */
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 56ce4cc..d1f63cf 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -27,7 +27,7 @@
 
 #include "nautilus-toolbar.h"
 
-#include "nautilus-location-bar.h"
+#include "nautilus-location-entry.h"
 #include "nautilus-pathbar.h"
 #include "nautilus-actions.h"
 
@@ -47,7 +47,7 @@ struct _NautilusToolbarPriv {
 	NautilusWindow *window;
 
 	GtkWidget *path_bar;
-	GtkWidget *location_bar;
+	GtkWidget *location_entry;
 
 	GtkToolItem *back_forward;
 
@@ -76,7 +76,7 @@ toolbar_update_appearance (NautilusToolbar *self)
 	show_location_entry = self->priv->show_location_entry ||
 		g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY);
 
-	gtk_widget_set_visible (self->priv->location_bar,
+	gtk_widget_set_visible (self->priv->location_entry,
 				show_location_entry);
 	gtk_widget_set_visible (self->priv->path_bar,
 				!show_location_entry);
@@ -383,8 +383,8 @@ nautilus_toolbar_constructed (GObject *obj)
 	gtk_box_pack_start (GTK_BOX (hbox), self->priv->path_bar, TRUE, TRUE, 0);
 
 	/* entry-like location bar */
-	self->priv->location_bar = nautilus_location_bar_new ();
-	gtk_box_pack_start (GTK_BOX (hbox), self->priv->location_bar, TRUE, TRUE, 0);
+	self->priv->location_entry = nautilus_location_entry_new ();
+	gtk_box_pack_start (GTK_BOX (hbox), self->priv->location_entry, TRUE, TRUE, 0);
 
 	tool_item = gtk_tool_item_new ();
 	gtk_tool_item_set_expand (tool_item, TRUE);
@@ -546,9 +546,9 @@ nautilus_toolbar_get_path_bar (NautilusToolbar *self)
 }
 
 GtkWidget *
-nautilus_toolbar_get_location_bar (NautilusToolbar *self)
+nautilus_toolbar_get_location_entry (NautilusToolbar *self)
 {
-	return self->priv->location_bar;
+	return self->priv->location_entry;
 }
 
 void
diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h
index 79ec18b..b3f6a5e 100644
--- a/src/nautilus-toolbar.h
+++ b/src/nautilus-toolbar.h
@@ -48,7 +48,7 @@ typedef struct _NautilusToolbarClass NautilusToolbarClass;
 
 typedef enum {
 	NAUTILUS_TOOLBAR_MODE_PATH_BAR,
-	NAUTILUS_TOOLBAR_MODE_LOCATION_BAR,
+	NAUTILUS_TOOLBAR_MODE_LOCATION_ENTRY,
 } NautilusToolbarMode;
 
 struct _NautilusToolbar {
@@ -67,7 +67,7 @@ GType nautilus_toolbar_get_type (void);
 GtkWidget *nautilus_toolbar_new (NautilusWindow *window);
 
 GtkWidget *nautilus_toolbar_get_path_bar (NautilusToolbar *self);
-GtkWidget *nautilus_toolbar_get_location_bar (NautilusToolbar *self);
+GtkWidget *nautilus_toolbar_get_location_entry (NautilusToolbar *self);
 
 void nautilus_toolbar_set_show_main_bar (NautilusToolbar *self,
 					 gboolean show_main_bar);
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 9be4df0..836d34c 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -31,7 +31,6 @@
 #include "nautilus-actions.h"
 #include "nautilus-application.h"
 #include "nautilus-floating-bar.h"
-#include "nautilus-location-bar.h"
 #include "nautilus-pathbar.h"
 #include "nautilus-window-private.h"
 #include "nautilus-window-slot.h"
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index d058eca..f7606e4 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -35,7 +35,7 @@
 #include "nautilus-application.h"
 #include "nautilus-bookmarks-window.h"
 #include "nautilus-desktop-window.h"
-#include "nautilus-location-bar.h"
+#include "nautilus-location-entry.h"
 #include "nautilus-mime-actions.h"
 #include "nautilus-notebook.h"
 #include "nautilus-places-sidebar.h"
@@ -226,7 +226,7 @@ restore_focus_widget (NautilusWindow *window)
 }
 
 static void
-navigation_bar_cancel_callback (GtkWidget      *widget,
+location_entry_cancel_callback (GtkWidget      *widget,
 				NautilusWindow *window)
 {
 	nautilus_toolbar_set_show_location_entry (NAUTILUS_TOOLBAR (window->details->toolbar), FALSE);
@@ -235,7 +235,7 @@ navigation_bar_cancel_callback (GtkWidget      *widget,
 }
 
 static void
-navigation_bar_location_changed_callback (GtkWidget      *widget,
+location_entry_location_changed_callback (GtkWidget      *widget,
 					  GFile          *location,
 					  NautilusWindow *window)
 {
@@ -444,15 +444,15 @@ void
 nautilus_window_prompt_for_location (NautilusWindow *window,
 				     const char     *initial)
 {
-	GtkWidget *bar;
+	GtkWidget *entry;
 
 	g_return_if_fail (NAUTILUS_IS_WINDOW (window));
 
-	bar = nautilus_window_ensure_location_bar (window);
+	entry = nautilus_window_ensure_location_entry (window);
 
 	if (initial) {
-		nautilus_location_bar_set_location (NAUTILUS_LOCATION_BAR (bar),
-						    initial);
+		nautilus_location_entry_set_uri (NAUTILUS_LOCATION_ENTRY (entry),
+						 initial);
 	}
 }
 
@@ -722,15 +722,15 @@ nautilus_window_sync_location_widgets (NautilusWindow *window)
 	/* Change the location bar and path bar to match the current location. */
 	if (slot->location != NULL) {
 		char *uri;
-		GtkWidget *location_bar;
+		GtkWidget *location_entry;
 		GtkWidget *path_bar;
 
-		location_bar = nautilus_toolbar_get_location_bar (NAUTILUS_TOOLBAR (window->details->toolbar));
+		location_entry = nautilus_toolbar_get_location_entry (NAUTILUS_TOOLBAR (window->details->toolbar));
 		path_bar = nautilus_toolbar_get_path_bar (NAUTILUS_TOOLBAR (window->details->toolbar));
 
 		/* this may be NULL if we just created the slot */
 		uri = nautilus_window_slot_get_location_uri (slot);
-		nautilus_location_bar_set_location (NAUTILUS_LOCATION_BAR (location_bar), uri);
+		nautilus_location_entry_set_uri (NAUTILUS_LOCATION_ENTRY (location_entry), uri);
 		g_free (uri);
 		nautilus_path_bar_set_path (NAUTILUS_PATH_BAR (path_bar), slot->location);
 	}
@@ -749,18 +749,18 @@ nautilus_window_sync_location_widgets (NautilusWindow *window)
 }
 
 GtkWidget *
-nautilus_window_ensure_location_bar (NautilusWindow *window)
+nautilus_window_ensure_location_entry (NautilusWindow *window)
 {
-	GtkWidget *location_bar;
+	GtkWidget *location_entry;
 
 	remember_focus_widget (window);
 
 	nautilus_toolbar_set_show_location_entry (NAUTILUS_TOOLBAR (window->details->toolbar), TRUE);
 
-	location_bar = nautilus_toolbar_get_location_bar (NAUTILUS_TOOLBAR (window->details->toolbar));
-	nautilus_location_bar_activate (NAUTILUS_LOCATION_BAR (location_bar));
+	location_entry = nautilus_toolbar_get_location_entry (NAUTILUS_TOOLBAR (window->details->toolbar));
+	nautilus_location_entry_focus (NAUTILUS_LOCATION_ENTRY (location_entry));
 
-	return location_bar;
+	return location_entry;
 }
 
 static void
@@ -969,7 +969,7 @@ create_toolbar (NautilusWindow *window)
 	GtkSizeGroup *header_size_group;
 	GtkWidget *toolbar;
 	GtkWidget *path_bar;
-	GtkWidget *location_bar;
+	GtkWidget *location_entry;
 
 	header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
 	gtk_size_group_set_ignore_hidden (header_size_group, FALSE);
@@ -990,19 +990,18 @@ create_toolbar (NautilusWindow *window)
 	g_signal_connect_object (path_bar, "path-event",
 				 G_CALLBACK (path_bar_path_event_callback), window, 0);
 
-	/* connect to the location bar signals */
-	location_bar = nautilus_toolbar_get_location_bar (NAUTILUS_TOOLBAR (toolbar));
-	gtk_size_group_add_widget (header_size_group, location_bar);
+	/* connect to the location entry signals */
+	location_entry = nautilus_toolbar_get_location_entry (NAUTILUS_TOOLBAR (toolbar));
+	gtk_size_group_add_widget (header_size_group, location_entry);
 
-	nautilus_clipboard_set_up_editable
-		(GTK_EDITABLE (nautilus_location_bar_get_entry (NAUTILUS_LOCATION_BAR (location_bar))),
-		 nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)),
-		 TRUE);
+	nautilus_clipboard_set_up_editable (GTK_EDITABLE (location_entry),
+					    nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)),
+					    TRUE);
 
-	g_signal_connect_object (location_bar, "location-changed",
-				 G_CALLBACK (navigation_bar_location_changed_callback), window, 0);
-	g_signal_connect_object (location_bar, "cancel",
-				 G_CALLBACK (navigation_bar_cancel_callback), window, 0);
+	g_signal_connect_object (location_entry, "location-changed",
+				 G_CALLBACK (location_entry_location_changed_callback), window, 0);
+	g_signal_connect_object (location_entry, "cancel",
+				 G_CALLBACK (location_entry_cancel_callback), window, 0);
 
 	g_object_unref (header_size_group);
 
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 406fb64..b914896 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -120,7 +120,7 @@ NautilusWindowSlot * nautilus_window_open_slot             (NautilusWindow *wind
 void                 nautilus_window_slot_close            (NautilusWindow *window,
                                                             NautilusWindowSlot *slot);
 
-GtkWidget *          nautilus_window_ensure_location_bar   (NautilusWindow *window);
+GtkWidget *          nautilus_window_ensure_location_entry (NautilusWindow *window);
 void                 nautilus_window_sync_location_widgets (NautilusWindow *window);
 void                 nautilus_window_grab_focus            (NautilusWindow *window);
 void                 nautilus_window_sync_search_widgets   (NautilusWindow *window);



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