void nautilus_entry_set_text (NautilusEntry *entry, const gchar *text) { g_return_if_fail (NAUTILUS_IS_ENTRY (entry)); gtk_entry_set_text (GTK_ENTRY (entry), text); g_signal_emit (entry, signals[SELECTION_CHANGED], 0); }
/** * nautilus_entry_select_all * * Select all text, leaving the text cursor position at the end. * * @entry: A NautilusEntry **/ void nautilus_entry_select_all (NautilusEntry *entry) { g_return_if_fail (NAUTILUS_IS_ENTRY (entry)); gtk_editable_set_position (GTK_EDITABLE (entry), -1); gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); }
static void name_or_uri_field_activate (NautilusEntry *entry) { g_assert (NAUTILUS_IS_ENTRY (entry)); update_bookmark_from_text (); nautilus_entry_select_all_at_idle (entry); }
static gboolean on_text_field_focus_out_event (GtkWidget *widget, GdkEventFocus *event, gpointer user_data) { g_assert (NAUTILUS_IS_ENTRY (widget)); update_bookmark_from_text (); return FALSE; }
/* Overridden to work around GTK bug. The selection_clear_event is queued * when the selection changes. Changing the selection to NULL and then * back to the original selection owner still sends the event, so the * selection owner then gets the selection ripped away from it. We ran into * this with type-completion behavior in NautilusLocationBar (see bug 5313). * There's a FIXME comment that seems to be about this same issue in * gtk+/gtkselection.c, gtk_selection_clear. */ static gboolean nautilus_entry_selection_clear (GtkWidget *widget, GdkEventSelection *event) { g_assert (NAUTILUS_IS_ENTRY (widget)); if (gdk_selection_owner_get (event->selection) == gtk_widget_get_window (widget)) { return FALSE; } return GTK_WIDGET_CLASS (nautilus_entry_parent_class)->selection_clear_event (widget, event); }
/** * nautilus_entry_select_all_at_idle * * Select all text at the next idle, not immediately. * This is useful when reacting to a key press, because * changing the selection and the text cursor position doesn't * work in a key_press signal handler. * * @entry: A NautilusEntry **/ void nautilus_entry_select_all_at_idle (NautilusEntry *entry) { g_return_if_fail (NAUTILUS_IS_ENTRY (entry)); /* If the text cursor position changes in this routine * then gtk_entry_key_press will unselect (and we want * to move the text cursor position to the end). */ if (entry->details->select_idle_id == 0) { entry->details->select_idle_id = g_idle_add (select_all_at_idle, entry); } }