[nautilus] location-bar: use a GFile in location-changed signal
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] location-bar: use a GFile in location-changed signal
- Date: Mon, 23 Apr 2012 14:19:20 +0000 (UTC)
commit ce16451d1d7f384ca296ca7ce824938606b21af0
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sun Apr 22 16:50:13 2012 -0400
location-bar: use a GFile in location-changed signal
Avoids GFile->URI->GFile roundtrips
src/nautilus-location-bar.c | 44 +++++++++++++++++-------------------------
src/nautilus-window-pane.c | 6 +----
2 files changed, 19 insertions(+), 31 deletions(-)
---
diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c
index 2a77655..18a6882 100644
--- a/src/nautilus-location-bar.c
+++ b/src/nautilus-location-bar.c
@@ -66,7 +66,6 @@ struct NautilusLocationBarDetails {
};
enum {
- NAUTILUS_DND_MC_DESKTOP_ICON,
NAUTILUS_DND_URI_LIST,
NAUTILUS_DND_TEXT_PLAIN,
NAUTILUS_DND_NTARGETS
@@ -102,39 +101,29 @@ nautilus_location_bar_get_window (GtkWidget *bar)
/**
* nautilus_location_bar_get_location
*
- * Get the "URI" represented by the text in the location bar.
- *
- * @bar: A NautilusLocationBar.
- *
- * returns a newly allocated "string" containing the mangled
- * (by g_file_parse_name) text that the user typed in...maybe a URI
- * but not guaranteed.
- *
+ * Get the GFile represented by the text in the location bar.
**/
-static char *
+static GFile *
nautilus_location_bar_get_location (NautilusLocationBar *bar)
{
- char *user_location, *uri;
+ char *user_location;
GFile *location;
user_location = gtk_editable_get_chars (GTK_EDITABLE (bar->details->entry), 0, -1);
location = g_file_parse_name (user_location);
g_free (user_location);
- uri = g_file_get_uri (location);
- g_object_unref (location);
- return uri;
+
+ return location;
}
static void
emit_location_changed (NautilusLocationBar *bar)
{
- char *location;
+ GFile *location;
location = nautilus_location_bar_get_location (bar);
- g_signal_emit (bar,
- signals[LOCATION_CHANGED], 0,
- location);
- g_free (location);
+ g_signal_emit (bar, signals[LOCATION_CHANGED], 0, location);
+ g_object_unref (location);
}
static void
@@ -236,25 +225,28 @@ drag_data_get_callback (GtkWidget *widget,
gpointer callback_data)
{
NautilusLocationBar *self;
- char *entry_text;
+ GFile *location;
+ gchar *uri;
g_assert (selection_data != NULL);
self = callback_data;
- entry_text = nautilus_location_bar_get_location (self);
+ location = nautilus_location_bar_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 *) entry_text,
- strlen (entry_text));
+ 8, (guchar *) uri,
+ strlen (uri));
break;
default:
g_assert_not_reached ();
}
- g_free (entry_text);
+ g_free (uri);
+ g_object_unref (location);
}
/* routine that determines the usize for the label widget as larger
@@ -441,8 +433,8 @@ nautilus_location_bar_class_init (NautilusLocationBarClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0,
NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index e34dd81..e2818d5 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -269,20 +269,16 @@ nautilus_window_pane_hide_search_bar (NautilusWindowPane *pane)
static void
navigation_bar_location_changed_callback (GtkWidget *widget,
- const char *uri,
+ GFile *location,
NautilusWindowPane *pane)
{
- GFile *location;
-
nautilus_toolbar_set_show_location_entry (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
nautilus_window_pane_hide_search_bar (pane);
nautilus_window_pane_hide_temporary_bars (pane);
restore_focus_widget (pane);
- location = g_file_new_for_uri (uri);
nautilus_window_slot_open_location (pane->active_slot, location, 0);
- g_object_unref (location);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]