[nautilus] Changed the "event-after" signal to "changed" to update the "Location" / "Go to" label Change the se



commit f146e054849fef9300e9fc8786c11e2d9b7c91d7
Author: Marcus Carlson <marcus mejlamej nu>
Date:   Mon Oct 12 21:46:13 2009 +0200

    Changed the "event-after" signal to "changed" to update the "Location" / "Go to" label Change the secondary icon in the location to a "Go" (play) icon when the label is "Go to" otherwise a clear icon
    
    https://bugzilla.gnome.org/show_bug.cgi?id=163245

 src/nautilus-location-bar.c   |   20 ++++++++++++++----
 src/nautilus-location-entry.c |   42 +++++++++++++++++++++++++++++++++++++---
 src/nautilus-location-entry.h |    7 ++++++
 3 files changed, 60 insertions(+), 9 deletions(-)
---
diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c
index 63faf77..743c631 100644
--- a/src/nautilus-location-bar.c
+++ b/src/nautilus-location-bar.c
@@ -318,9 +318,8 @@ editable_activate_callback (GtkEntry *entry,
 }
 
 static void
-editable_event_after_callback (GtkEntry *entry,
-			       GdkEvent *event,
-			       gpointer user_data)
+editable_changed_callback (GtkEntry *entry,
+			   gpointer user_data)
 {
 	nautilus_location_bar_update_label (NAUTILUS_LOCATION_BAR (user_data));
 }
@@ -429,8 +428,8 @@ nautilus_location_bar_init (NautilusLocationBar *bar)
 	
 	g_signal_connect_object (entry, "activate",
 				 G_CALLBACK (editable_activate_callback), bar, 0);
-	g_signal_connect_object (entry, "event_after",
-				 G_CALLBACK (editable_event_after_callback), bar, G_CONNECT_AFTER);
+	g_signal_connect_object (entry, "changed",
+				 G_CALLBACK (editable_changed_callback), bar, 0);
 
 	gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
 
@@ -563,14 +562,25 @@ nautilus_location_bar_update_label (NautilusLocationBar *bar)
 	GFile *location;
 	GFile *last_location;
 	
+	if (bar->details->last_location == NULL){
+		gtk_label_set_text (GTK_LABEL (bar->details->label), GO_TO_LABEL);
+		nautilus_location_entry_set_secondary_action (NAUTILUS_LOCATION_ENTRY (bar->details->entry), 
+							      NAUTILUS_LOCATION_ENTRY_ACTION_GOTO);
+		return;
+	}
+
 	current_text = gtk_entry_get_text (GTK_ENTRY (bar->details->entry));
 	location = g_file_parse_name (current_text);
 	last_location = g_file_parse_name (bar->details->last_location);
 	
 	if (g_file_equal (last_location, location)) {
 		gtk_label_set_text (GTK_LABEL (bar->details->label), LOCATION_LABEL);
+		nautilus_location_entry_set_secondary_action (NAUTILUS_LOCATION_ENTRY (bar->details->entry), 
+							      NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR);
 	} else {		 
 		gtk_label_set_text (GTK_LABEL (bar->details->label), GO_TO_LABEL);
+		nautilus_location_entry_set_secondary_action (NAUTILUS_LOCATION_ENTRY (bar->details->entry), 
+							      NAUTILUS_LOCATION_ENTRY_ACTION_GOTO);
 	}
 
 	g_object_unref (location);
diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c
index 5f6392e..7e997a1 100644
--- a/src/nautilus-location-entry.c
+++ b/src/nautilus-location-entry.c
@@ -61,6 +61,7 @@ struct NautilusLocationEntryDetails {
 	gboolean has_special_text;
 	gboolean setting_special_text;
 	gchar *special_text;
+	NautilusLocationEntryAction secondary_action;
 };
 
 static void  nautilus_location_entry_class_init       (NautilusLocationEntryClass *class);
@@ -288,7 +289,16 @@ nautilus_location_entry_icon_release (GtkEntry *gentry,
 				      GdkEvent *event,
 				      gpointer unused)
 {
-	gtk_entry_set_text (gentry, "");
+	switch (NAUTILUS_LOCATION_ENTRY (gentry)->details->secondary_action) {
+	case NAUTILUS_LOCATION_ENTRY_ACTION_GOTO:
+		g_signal_emit_by_name (gentry, "activate", gentry);
+		break;
+	case NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR:
+		gtk_entry_set_text (gentry, "");
+		break;
+	default:
+		g_assert_not_reached ();
+	}
 }
 
 static gboolean
@@ -324,6 +334,30 @@ nautilus_location_entry_class_init (NautilusLocationEntryClass *class)
 	object_class->destroy = destroy;
 }
 
+void
+nautilus_location_entry_set_secondary_action (NautilusLocationEntry *entry,
+					      NautilusLocationEntryAction secondary_action)
+{
+	if (entry->details->secondary_action == secondary_action) {
+		return;
+	}
+	switch (secondary_action) {
+	case NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR:
+		gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), 
+					       GTK_ENTRY_ICON_SECONDARY,
+					       GTK_STOCK_CLEAR);
+		break;
+	case NAUTILUS_LOCATION_ENTRY_ACTION_GOTO:
+		gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+					       GTK_ENTRY_ICON_SECONDARY,
+					       GTK_STOCK_GO_FORWARD);
+		break;
+	default:
+		g_assert_not_reached ();
+	}
+	entry->details->secondary_action = secondary_action;
+}
+
 static void
 nautilus_location_entry_init (NautilusLocationEntry *entry)
 {
@@ -332,9 +366,9 @@ nautilus_location_entry_init (NautilusLocationEntry *entry)
 	entry->details->completer = g_filename_completer_new ();
 	g_filename_completer_set_dirs_only (entry->details->completer, TRUE);
 
-	gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY,
-				       GTK_STOCK_CLEAR);
-	
+	nautilus_location_entry_set_secondary_action (entry,
+						      NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR);
+
 	nautilus_entry_set_special_tab_handling (NAUTILUS_ENTRY (entry), TRUE);
 
 	g_signal_connect (entry, "event_after",
diff --git a/src/nautilus-location-entry.h b/src/nautilus-location-entry.h
index ada0cc3..9c5248d 100644
--- a/src/nautilus-location-entry.h
+++ b/src/nautilus-location-entry.h
@@ -52,9 +52,16 @@ typedef struct {
 	NautilusEntryClass parent_class;
 } NautilusLocationEntryClass;
 
+typedef enum {
+	NAUTILUS_LOCATION_ENTRY_ACTION_GOTO,
+	NAUTILUS_LOCATION_ENTRY_ACTION_CLEAR
+} 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);
 
 #endif /* NAUTILUS_LOCATION_ENTRY_H */



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