diff options
author | John Sullivan <sullivan@src.gnome.org> | 2000-09-12 17:16:59 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2000-09-12 17:16:59 +0000 |
commit | 7a6d8a28f9f03a742965d43ff16a1ade1f2514a5 (patch) | |
tree | 3eb756ff18f1889b2508f490f01485d23fab103f /src/nautilus-complex-search-bar.c | |
parent | e8d3b4590332148edfdee58cf9fddba80c4f4e11 (diff) | |
download | nautilus-7a6d8a28f9f03a742965d43ff16a1ade1f2514a5.tar.gz |
Fixed bug 2668 (Switching to Search mode should move the
focus to the search text field).
* src/nautilus-navigation-bar.h: Added signal and public
function for nautilus_navigation_bar_activate.
* src/nautilus-navigation-bar.c:
(nautilus_navigation_bar_initialize_class): Wire up
activate signal; default function is NULL.
(nautilus_navigation_bar_activate): New function, emits
signal.
* src/nautilus-switchable-navigation-bar.h:
* src/nautilus-switchable-navigation-bar.c:
Defined a NautilusSwitchableNavigationBarDetails struct,
and moved implementation details into it. Set the types
of the fields in this struct to reflect actual needs,
instead of using GtkWidget and casting up to other
classes.
(nautilus_switchable_navigation_bar_initialize): Create
details struct.
(nautilus_switchable_navigation_bar_destroy): New function,
free details struct.
(nautilus_switchable_navigation_bar_initialize_class):
Wire up destroy handler.
(nautilus_switchable_navigation_bar_set_mode): Call
nautilus_navigation_bar_activate on switched-to bar.
(nautilus_switchable_navigation_bar_get_mode),
(nautilus_switchable_navigation_bar_get_location),
(nautilus_switchable_navigation_bar_set_location): Updated
to use bar->details.
* src/nautilus-switchable-search-bar.c:
(nautilus_switchable_search_bar_initialize_class):
Wire up activate signal to real_activate.
(real_activate): Call nautilus_navigation_bar_activate
on the current search bar.
* src/nautilus-simple-search-bar.c:
(nautilus_simple_search_bar_initialize_class): Wire up
activate signal to real_activate.
(real_activate): Set focus to text field.
* src/nautilus-complex-search-bar.c:
(nautilus_complex_search_bar_initialize_class): Wire up
activate signal to real_activate.
(get_first_text_field): New helper function to find the
first text field in a search criterion (or NULL).
(real_activate): Set focus to first text field.
Diffstat (limited to 'src/nautilus-complex-search-bar.c')
-rw-r--r-- | src/nautilus-complex-search-bar.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nautilus-complex-search-bar.c b/src/nautilus-complex-search-bar.c index f1a31cc2d..f526e0f5f 100644 --- a/src/nautilus-complex-search-bar.c +++ b/src/nautilus-complex-search-bar.c @@ -53,6 +53,7 @@ struct NautilusComplexSearchBarDetails { }; +static void real_activate (NautilusNavigationBar *bar); static char *nautilus_complex_search_bar_get_location (NautilusNavigationBar *bar); static void nautilus_complex_search_bar_set_location (NautilusNavigationBar *bar, const char *location); @@ -149,6 +150,7 @@ nautilus_complex_search_bar_initialize_class (NautilusComplexSearchBarClass *kla { GTK_OBJECT_CLASS (klass)->destroy = nautilus_complex_search_bar_destroy; + NAUTILUS_NAVIGATION_BAR_CLASS (klass)->activate = real_activate; NAUTILUS_NAVIGATION_BAR_CLASS (klass)->get_location = nautilus_complex_search_bar_get_location; NAUTILUS_NAVIGATION_BAR_CLASS (klass)->set_location = nautilus_complex_search_bar_set_location; } @@ -262,6 +264,37 @@ nautilus_complex_search_bar_destroy (GtkObject *object) NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); } +static GtkWidget * +get_first_text_field (NautilusComplexSearchBar *bar) +{ + GSList *node; + NautilusSearchBarCriterion *criterion; + + for (node = bar->details->search_criteria; node != NULL; node = node->next) { + criterion = NAUTILUS_SEARCH_BAR_CRITERION (node->data); + if (criterion->details->use_value_entry) { + return GTK_WIDGET (criterion->details->value_entry); + } + } + + return NULL; +} + +static void +real_activate (NautilusNavigationBar *navigation_bar) +{ + NautilusComplexSearchBar *bar; + GtkWidget *initial_focus_widget; + + bar = NAUTILUS_COMPLEX_SEARCH_BAR (navigation_bar); + + /* Put the keyboard focus in a text field when switching to search mode */ + initial_focus_widget = get_first_text_field (bar); + if (initial_focus_widget != NULL) { + gtk_widget_grab_focus (initial_focus_widget); + } +} + /* returned string should be g_freed by the caller */ static char * nautilus_complex_search_bar_get_location (NautilusNavigationBar *navigation_bar) |