diff options
21 files changed, 707 insertions, 524 deletions
@@ -1,3 +1,66 @@ +2000-08-02 Rebecca Schulman <rebecka@eazel.com> + Completed bug 1433, the interface to search by file + name and attribute. + + * libnautilus-extensions/nautilus-search-uri.c: + * libnautilus-extensions/nautilus-search-uri.h: + * libnautilus-extensions/Makefile.am: + removed the search uri files and placed their functionality + in the appropriate search bar classes. + + * libnautilus-extensions/nautilus-search-bar-criterion-private.h: + * libnautilus-extensions/nautilus-search-bar-criterion.h: + * libnautilus-extensions/nautilus-search-bar-criterion.c: + (nautilus_search_bar_criterion_new_from_values), + (nautilus_search_bar_criterion_next_new), + (nautilus_search_bar_criterion_get_location), + (get_next_default_search_criterion_type), + (nautilus_search_bar_criterion_show), + (nautilus_search_bar_criterion_hide), (get_name_location_for), + (get_content_location_for), (get_file_type_location_for), + (get_size_location_for), (get_emblem_location_for), + (get_date_modified_location_for), (get_owner_location_for): + added ability to turn the criteria state into a text + explanation for the search uri. It is slightly circuitous, + because search uris are not internationalized. + + + * libnautilus-extensions/nautilus-string.c: + * libnautilus-extensions/nautilus-string.h: + (nautilus_str_strip_trailing_str), (nautilus_self_check_string): + added new string function used by the search bar criterion code, + to strip a string off the end of an existing string. + + * src/nautilus-complex-search-bar.c: + (nautilus_complex_search_bar_initialize), + (nautilus_complex_search_bar_get_location), + (attach_criterion_to_search_bar), + (unattach_criterion_from_search_bar), + (load_find_them_pixmap_widget), (fewer_options_callback): + tweaks to make sizing an spacing on the bar better, and + added search pixmap to the find button. Moved the find + them button here from the switchable search bar + class for appearance reasons. + + * src/nautilus-simple-search-bar.c: + (nautilus_simple_search_bar_initialize), + (nautilus_simple_search_bar_set_location), + (nautilus_simple_search_bar_get_location), + (nautilus_search_uri_to_simple_search_criteria), + (nautilus_simple_search_criteria_to_search_uri): + moved search uri functionality and + find them button into the simple search bar class for + apprearance reasons. + + * src/nautilus-switchable-search-bar.c: + * src/nautilus-switchable-search-bar.h: + (nautilus_switchable_search_bar_initialize_class), + (nautilus_switchable_search_bar_initialize), + (nautilus_switchable_search_bar_set_mode), + (nautilus_search_uri_to_search_bar_mode), + (nautilus_search_uri_is_displayable_by_mode), (other_search_mode): + moved the find them button out of this class. + 2000-08-02 Darin Adler <darin@eazel.com> Finished task 222 "Don't look for metafile for some URIs for diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am index d2843e72f..d196dc2b3 100644 --- a/libnautilus-extensions/Makefile.am +++ b/libnautilus-extensions/Makefile.am @@ -90,7 +90,6 @@ libnautilus_extensions_la_SOURCES = \ nautilus-program-choosing.c \ nautilus-radio-button-group.c \ nautilus-search-bar-criterion.c \ - nautilus-search-uri.c \ nautilus-self-checks.c \ nautilus-stock-dialogs.c \ nautilus-string-list.c \ @@ -167,7 +166,6 @@ noinst_HEADERS = \ nautilus-program-choosing.h \ nautilus-radio-button-group.h \ nautilus-search-bar-criterion.h \ - nautilus-search-uri.h \ nautilus-self-checks.h \ nautilus-stock-dialogs.h \ nautilus-string-list.h \ diff --git a/libnautilus-extensions/nautilus-search-bar-criterion-private.h b/libnautilus-extensions/nautilus-search-bar-criterion-private.h index e243246d9..4de522d7c 100644 --- a/libnautilus-extensions/nautilus-search-bar-criterion-private.h +++ b/libnautilus-extensions/nautilus-search-bar-criterion-private.h @@ -24,12 +24,13 @@ Author: Rebecca Schulman <rebecka@eazel.com> */ + struct NautilusSearchBarCriterionDetails { NautilusSearchBarCriterionType type; /* various widgets hold by the criterion */ - GtkOptionMenu *available_option_menu; - GtkOptionMenu *operator_menu; + GtkOptionMenu *available_criteria; + GtkOptionMenu *relation_menu; gboolean use_value_entry; GtkEntry *value_entry; gboolean use_value_menu; diff --git a/libnautilus-extensions/nautilus-search-bar-criterion.c b/libnautilus-extensions/nautilus-search-bar-criterion.c index 3c987ab46..80f2aaa11 100644 --- a/libnautilus-extensions/nautilus-search-bar-criterion.c +++ b/libnautilus-extensions/nautilus-search-bar-criterion.c @@ -44,7 +44,6 @@ static char * criteria_titles [] = { N_("Type"), N_("Stored"), N_("Size"), - N_("With Note"), N_("With Emblem"), N_("Last Modified"), N_("Owned By"), @@ -74,7 +73,7 @@ static char *type_relations [] = { NULL }; -static char *type_options [] = { +static char *type_objects [] = { N_("regular file"), N_("text file"), N_("application"), @@ -88,7 +87,7 @@ static char *location_relations [] = { NULL }; -static char *location_options [] = { +static char *location_objects [] = { N_("on this computer"), N_("in my vault"), NULL @@ -100,7 +99,7 @@ static char *size_relations [] = { NULL }; -static char *size_options [] = { +static char *size_objects [] = { N_("1 KB"), N_("10 KB"), N_("100 KB"), @@ -111,11 +110,6 @@ static char *size_options [] = { }; -static char *notes_relations [] = { - N_("including"), - N_("not including"), - NULL -}; static char *emblem_relations [] = { N_("marked with"), @@ -123,7 +117,7 @@ static char *emblem_relations [] = { NULL }; -static char *emblem_options [] = { +static char *emblem_objects [] = { /* FIXME: add emblem possibilities here. likely to be icon filenames */ @@ -136,7 +130,7 @@ static char *modified_relations [] = { NULL }; -static char *modified_options [] = { +static char *modified_objects [] = { N_("today"), N_("this week"), N_("this month"), @@ -159,6 +153,22 @@ static NautilusSearchBarCriterion * nautilus_search_bar_criterion_new_from_value NautilusSearchBarCriterionType get_next_default_search_criterion_type (NautilusSearchBarCriterionType type) ; +static char * get_name_location_for (int relation_number, + char *name_text); +static char * get_content_location_for (int relation_number, + char *name_text); +static char * get_file_type_location_for (int relation_number, + int value_number); +static char * get_size_location_for (int relation_number, + char *size_text); +static char * get_emblem_location_for (int relation_number, + int value_number); +static char * get_date_modified_location_for (int relation_number, + int value_number); +static char * get_owner_location_for (int relation_number, + char *owner_number); + + void nautilus_search_bar_criterion_destroy (NautilusSearchBarCriterion *criterion) @@ -174,8 +184,6 @@ nautilus_search_bar_criterion_new (void) return g_new0 (NautilusSearchBarCriterion, 1); } -static void -option_menu_callback (GtkWidget *widget, gpointer data); static void option_menu_callback (GtkWidget *widget, gpointer data) @@ -207,14 +215,14 @@ nautilus_search_bar_criterion_set_callback (NautilusSearchBarCriterion *crit static NautilusSearchBarCriterion * nautilus_search_bar_criterion_new_from_values (NautilusSearchBarCriterionType type, - char *operator_options[], + char *relation_options[], gboolean use_value_entry, gboolean use_value_menu, char *value_options[]) { NautilusSearchBarCriterion *criterion; GtkWidget *search_criteria_option_menu, *search_criteria_menu; - GtkWidget *operator_option_menu, *operator_menu; + GtkWidget *relation_option_menu, *relation_menu; GtkWidget *value_option_menu, *value_menu; int i; @@ -239,24 +247,24 @@ nautilus_search_bar_criterion_new_from_values (NautilusSearchBarCriterionType ty gtk_menu_set_active (GTK_MENU (search_criteria_menu), type); gtk_option_menu_set_menu (GTK_OPTION_MENU (search_criteria_option_menu), search_criteria_menu); - criterion->details->available_option_menu = GTK_OPTION_MENU (search_criteria_option_menu); + criterion->details->available_criteria = GTK_OPTION_MENU (search_criteria_option_menu); gtk_widget_show_all (GTK_WIDGET(search_criteria_option_menu)); - operator_option_menu = gtk_option_menu_new (); - operator_menu = gtk_menu_new (); - for (i = 0; operator_options[i] != NULL; i++) { + relation_option_menu = gtk_option_menu_new (); + relation_menu = gtk_menu_new (); + for (i = 0; relation_options[i] != NULL; i++) { GtkWidget *item; - item = gtk_menu_item_new_with_label (_(operator_options[i])); + item = gtk_menu_item_new_with_label (_(relation_options[i])); gtk_object_set_data (GTK_OBJECT(item), "type", GINT_TO_POINTER(i)); - gtk_menu_append (GTK_MENU (operator_menu), + gtk_menu_append (GTK_MENU (relation_menu), item); } - gtk_option_menu_set_menu (GTK_OPTION_MENU (operator_option_menu), - operator_menu); - criterion->details->operator_menu = GTK_OPTION_MENU (operator_option_menu); - gtk_widget_show_all (GTK_WIDGET(operator_option_menu)); + gtk_option_menu_set_menu (GTK_OPTION_MENU (relation_option_menu), + relation_menu); + criterion->details->relation_menu = GTK_OPTION_MENU (relation_option_menu); + gtk_widget_show_all (GTK_WIDGET(relation_option_menu)); @@ -316,42 +324,35 @@ nautilus_search_bar_criterion_next_new (NautilusSearchBarCriterionType criterion type_relations, FALSE, TRUE, - type_options); + type_objects); break; case NAUTILUS_LOCATION_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_LOCATION_SEARCH_CRITERION, location_relations, FALSE, TRUE, - location_options); + location_objects); break; case NAUTILUS_SIZE_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_SIZE_SEARCH_CRITERION, size_relations, FALSE, TRUE, - size_options); - break; - case NAUTILUS_NOTES_SEARCH_CRITERION: - new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_NOTES_SEARCH_CRITERION, - notes_relations, - TRUE, - FALSE, - NULL); + size_objects); break; case NAUTILUS_EMBLEM_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_EMBLEM_SEARCH_CRITERION, emblem_relations, FALSE, TRUE, - emblem_options); + emblem_objects); break; case NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION, modified_relations, FALSE, TRUE, - modified_options); + modified_objects); break; case NAUTILUS_OWNER_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_OWNER_SEARCH_CRITERION, @@ -382,6 +383,11 @@ nautilus_search_bar_criterion_first_new (void) char * nautilus_search_bar_criterion_get_location (NautilusSearchBarCriterion *criterion) { + GtkWidget *menu; + GtkWidget *menu_item; + int name_number, relation_number, value_number; + char *value_text; + /* There is ONE thing you should be aware of while implementing this function. You have to make sure you use non-translated strings for building the uri. So, to implement this, you are supposed to: @@ -391,8 +397,49 @@ nautilus_search_bar_criterion_get_location (NautilusSearchBarCriterion *criterio menu_item = gtk_menu_get_active (optin_menu) number = gtk_object_get_data (menu_item, "type") */ + menu = gtk_option_menu_get_menu (criterion->details->available_criteria); + menu_item = gtk_menu_get_active (GTK_MENU (menu)); + name_number = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu_item), "type")); + menu = gtk_option_menu_get_menu (criterion->details->relation_menu); + menu_item = gtk_menu_get_active (GTK_MENU (menu)); + relation_number = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu_item), "type")); + if (criterion->details->use_value_menu) { + menu = gtk_option_menu_get_menu (criterion->details->value_menu); + menu_item = gtk_menu_get_active (GTK_MENU (menu)); + value_number = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu_item), "type")); + } + else { + value_text = gtk_entry_get_text (GTK_ENTRY (criterion->details->value_entry)); + } + + switch (name_number) { + case NAUTILUS_FILE_NAME_SEARCH_CRITERION: + return get_name_location_for (relation_number, + value_text); + case NAUTILUS_CONTENT_SEARCH_CRITERION: + return get_content_location_for (relation_number, + value_text); + case NAUTILUS_FILE_TYPE_SEARCH_CRITERION: + return get_file_type_location_for (relation_number, + value_number); + case NAUTILUS_SIZE_SEARCH_CRITERION: + return get_size_location_for (relation_number, + value_text); + case NAUTILUS_EMBLEM_SEARCH_CRITERION: + return get_emblem_location_for (relation_number, + value_number); + case NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION: + return get_date_modified_location_for (relation_number, + value_number); + case NAUTILUS_OWNER_SEARCH_CRITERION: + return get_owner_location_for (relation_number, + value_text); + default: + g_assert_not_reached (); + return NULL; + } return g_strdup ("file_name contains evolution "); } @@ -410,9 +457,7 @@ get_next_default_search_criterion_type (NautilusSearchBarCriterionType type) case NAUTILUS_LOCATION_SEARCH_CRITERION: return NAUTILUS_SIZE_SEARCH_CRITERION; case NAUTILUS_SIZE_SEARCH_CRITERION: - return NAUTILUS_NOTES_SEARCH_CRITERION; - case NAUTILUS_NOTES_SEARCH_CRITERION: - return NAUTILUS_EMBLEM_SEARCH_CRITERION; + return NAUTILUS_SIZE_SEARCH_CRITERION; case NAUTILUS_EMBLEM_SEARCH_CRITERION: return NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION; case NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION: @@ -430,8 +475,8 @@ void nautilus_search_bar_criterion_show (NautilusSearchBarCriterion *criterion) { - gtk_widget_show (GTK_WIDGET (criterion->details->available_option_menu)); - gtk_widget_show (GTK_WIDGET (criterion->details->operator_menu)); + gtk_widget_show (GTK_WIDGET (criterion->details->available_criteria)); + gtk_widget_show (GTK_WIDGET (criterion->details->relation_menu)); if (criterion->details->use_value_entry) { gtk_widget_show (GTK_WIDGET (criterion->details->value_entry)); @@ -447,8 +492,8 @@ void nautilus_search_bar_criterion_hide (NautilusSearchBarCriterion *criterion) { - gtk_widget_hide (GTK_WIDGET (criterion->details->available_option_menu)); - gtk_widget_hide (GTK_WIDGET (criterion->details->operator_menu)); + gtk_widget_hide (GTK_WIDGET (criterion->details->available_criteria)); + gtk_widget_hide (GTK_WIDGET (criterion->details->relation_menu)); if (criterion->details->use_value_entry) { gtk_widget_hide (GTK_WIDGET (criterion->details->value_entry)); @@ -458,6 +503,95 @@ nautilus_search_bar_criterion_hide (NautilusSearchBarCriterion *criterion) } } +static char * +get_name_location_for (int relation_number, char *name_text) +{ + const char *possible_relations[] = { "contains", + "starts_with", + "ends_with", + "matches_glob", + "matches_regexp" }; + + g_assert (relation_number >= 0); + g_assert (relation_number < 5); + + return g_strdup_printf ("file_name %s %s", possible_relations[relation_number], + name_text); + +} + +static char * +get_content_location_for (int relation_number, char *name_text) +{ + const char *possible_relations[] = { "includes", + "does_not_include" }; + + g_assert (relation_number == 0 || relation_number == 1); + + return g_strdup_printf ("content %s %s", possible_relations[relation_number], + name_text); +} + +static char * +get_file_type_location_for (int relation_number, + int value_number) +{ + const char *possible_relations[] = { "is", "is_not" }; + const char *possible_values[] = {"file", "text_file", "application", "directory", "music" }; + + g_assert (relation_number == 0 || relation_number == 1); + g_assert (value_number >= 0); + g_assert (value_number < 5); + return g_strdup_printf ("file_type %s %s", possible_relations[relation_number], + possible_values[value_number]); +} + + +static char * +get_size_location_for (int relation_number, + char *size_text) +{ + const char *possible_relations[] = { "larger_than", "smaller_than" }; + + g_assert (relation_number == 0 || relation_number == 1); + /* FIXME: Need checks for appropriate size here */ + return g_strdup_printf ("size %s %s", possible_relations[relation_number], size_text); + +} + +static char * +get_emblem_location_for (int relation_number, + int value_number) +{ + /* FIXME */ + return g_strdup (""); +} + +static char * +get_date_modified_location_for (int relation_number, + int value_number) +{ + const char *possible_relations[] = { "updated", "not_updated" }; + const char *possible_values[] = { "today", "this_week", "this_month" }; + + g_assert (relation_number == 0 || relation_number == 1); + g_assert (value_number >= 0); + g_assert (value_number < 3); + + return g_strdup_printf ("mod_time %s %s", possible_relations[relation_number], + possible_values[value_number]); + +} + +static char * +get_owner_location_for (int relation_number, + char *owner_text) +{ + const char *possible_relations[] = { "is", "is not" }; + g_assert (relation_number == 0 || relation_number == 1); + return g_strdup_printf ("owner %s %s", possible_relations[relation_number], owner_text); + +} diff --git a/libnautilus-extensions/nautilus-search-bar-criterion.h b/libnautilus-extensions/nautilus-search-bar-criterion.h index 1bcbcb7f6..f415e7919 100644 --- a/libnautilus-extensions/nautilus-search-bar-criterion.h +++ b/libnautilus-extensions/nautilus-search-bar-criterion.h @@ -37,7 +37,6 @@ typedef enum { NAUTILUS_FILE_TYPE_SEARCH_CRITERION, NAUTILUS_LOCATION_SEARCH_CRITERION, NAUTILUS_SIZE_SEARCH_CRITERION, - NAUTILUS_NOTES_SEARCH_CRITERION, NAUTILUS_EMBLEM_SEARCH_CRITERION, NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION, NAUTILUS_OWNER_SEARCH_CRITERION, diff --git a/libnautilus-extensions/nautilus-search-uri.c b/libnautilus-extensions/nautilus-search-uri.c deleted file mode 100644 index b3660c360..000000000 --- a/libnautilus-extensions/nautilus-search-uri.c +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-search-uri.c -- tools for creating - and parsing search uris - - Copyright (C) 2000 Eazel, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Rebecca Schulman <rebecka@eazel.com> -*/ - -#include <string.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include "nautilus-search-uri.h" - -static NautilusSearchBarMode other_search_mode (NautilusSearchBarMode mode); - -char * -nautilus_search_uri_to_simple_search_criteria (const char *uri) -{ - /* FIXME: Not yet implemented. */ - return g_strdup (""); -} - -char * -nautilus_simple_search_criteria_to_search_uri (const char *search_criteria) -{ - char **words; - char *search_uri; - char *fragment; - char *escaped_fragment; - int length, i; - - g_return_val_if_fail (search_criteria != NULL, NULL); - - words = g_new0 (char *, strlen (search_criteria)); - words = g_strsplit (search_criteria, " ", strlen (search_criteria)); - /* FIXME: this should eventually be: length = strlen ("[file%3A%2F%2F%2F]"); */ - length = strlen ("[file:///]"); - /* Count total length */ - for (i = 0; words[i] != NULL; i++) { - length += strlen (words[i]) + strlen ("file_name contains & "); - } - fragment = g_new0 (char, length); - /* FIXME: this should eventually be: sprintf (fragment, "[file%%3A%%2F%%2F%%2F]"); */ - sprintf (fragment, "[file:///]"); - if (words[0] != NULL) { - for (i = 0; words[i+1] != NULL; i++) { - strcat (fragment, "file_name contains "); - strcat (fragment, words[i]); - strcat (fragment, " & "); - } - strcat (fragment, "file_name contains "); - strcat (fragment, words[i]); - } - escaped_fragment = gnome_vfs_escape_string (fragment); - g_free (fragment); - search_uri = g_strconcat ("search:", escaped_fragment, NULL); - g_free (escaped_fragment); -#ifdef SEARCH_URI_DEBUG - printf ("Made uri %s from simple search criteria %s\n", - search_uri, search_criteria); -#endif - return search_uri; -} - - -NautilusSearchBarMode -nautilus_search_uri_to_search_bar_mode (const char *uri) -{ - NautilusSearchBarMode preferred_mode; - - preferred_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - NAUTILUS_SIMPLE_SEARCH_BAR); - if (nautilus_search_uri_is_displayable_by_mode (uri, preferred_mode)) { - return preferred_mode; - } - else { - return (other_search_mode (preferred_mode)); - } -} - - - -gboolean -nautilus_search_uri_is_displayable_by_mode (const char *uri, - NautilusSearchBarMode mode) -{ - /* FIXME */ - return TRUE; -} - - -static NautilusSearchBarMode -other_search_mode (NautilusSearchBarMode mode) -{ - switch (mode) { - case NAUTILUS_SIMPLE_SEARCH_BAR: - return NAUTILUS_COMPLEX_SEARCH_BAR; - break; - case NAUTILUS_COMPLEX_SEARCH_BAR: - return NAUTILUS_SIMPLE_SEARCH_BAR; - break; - default: - g_assert_not_reached (); - } - return NAUTILUS_COMPLEX_SEARCH_BAR; -} diff --git a/libnautilus-extensions/nautilus-search-uri.h b/libnautilus-extensions/nautilus-search-uri.h deleted file mode 100644 index 3f1ee58ca..000000000 --- a/libnautilus-extensions/nautilus-search-uri.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-search-uri.c -- tools for creating - and parsing search uris - - Copyright (C) 2000 Eazel, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Rebecca Schulman <rebecka@eazel.com> -*/ - -#include "nautilus-global-preferences.h" -#include "nautilus-search-bar-criterion.h" - - -char * nautilus_search_uri_to_simple_search_criteria (const char *location); -char * nautilus_simple_search_criteria_to_search_uri (const char *search_criteria); - -/* Translate a search criterion from the complex search bar into a search uri criterion */ -char * nautilus_search_uri_generate_criterion_from_widgets (NautilusSearchBarCriterion *criterion); -NautilusSearchBarMode nautilus_search_uri_to_search_bar_mode (const char *uri); -gboolean nautilus_search_uri_is_displayable_by_mode (const char *uri, - NautilusSearchBarMode mode); diff --git a/libnautilus-extensions/nautilus-string.c b/libnautilus-extensions/nautilus-string.c index ec10075f1..6081289ab 100644 --- a/libnautilus-extensions/nautilus-string.c +++ b/libnautilus-extensions/nautilus-string.c @@ -348,6 +348,26 @@ nautilus_str_strip_trailing_chr (const char *source, char remove_this) return g_strndup (source, end - source); } +char * +nautilus_str_strip_trailing_str (const char *source, const char *remove_this) +{ + const char *end; + if (source == NULL) { + return NULL; + } + if (remove_this == NULL) { + return g_strdup (source); + } + end = source + strlen (source); + if (strcmp (end - strlen (remove_this), remove_this) != 0) { + return g_strdup (source); + } + else { + return g_strndup (source, strlen (source) - strlen(remove_this)); + } + +} + gboolean nautilus_eat_str_to_int (char *source, int *integer) { @@ -561,6 +581,11 @@ nautilus_self_check_string (void) NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_chr ("foo_", '_'), "foo"); NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_chr ("_foo__", '_'), "_foo"); NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_chr ("_f_o__o_", '_'), "_f_o__o"); + + NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_str (NULL, "bar"), NULL); + NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_str ("foo", "bar"), "foo"); + NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_str ("foo bar", "bar"), "foo "); + NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_str ("bar", "bar"), "bar"); NAUTILUS_CHECK_STRING_RESULT (nautilus_str_double_underscores (NULL), NULL); NAUTILUS_CHECK_STRING_RESULT (nautilus_str_double_underscores (""), ""); diff --git a/libnautilus-extensions/nautilus-string.h b/libnautilus-extensions/nautilus-string.h index 18a15818c..72926e6cc 100644 --- a/libnautilus-extensions/nautilus-string.h +++ b/libnautilus-extensions/nautilus-string.h @@ -70,6 +70,8 @@ char * nautilus_str_strip_chr (const char *string, char remove_this); char * nautilus_str_strip_trailing_chr (const char *string, char remove_this); +char * nautilus_str_strip_trailing_str (const char *string, + const char *remove_this); /* Conversions to and from strings. */ gboolean nautilus_str_to_int (const char *string, diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index d2843e72f..d196dc2b3 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -90,7 +90,6 @@ libnautilus_extensions_la_SOURCES = \ nautilus-program-choosing.c \ nautilus-radio-button-group.c \ nautilus-search-bar-criterion.c \ - nautilus-search-uri.c \ nautilus-self-checks.c \ nautilus-stock-dialogs.c \ nautilus-string-list.c \ @@ -167,7 +166,6 @@ noinst_HEADERS = \ nautilus-program-choosing.h \ nautilus-radio-button-group.h \ nautilus-search-bar-criterion.h \ - nautilus-search-uri.h \ nautilus-self-checks.h \ nautilus-stock-dialogs.h \ nautilus-string-list.h \ diff --git a/libnautilus-private/nautilus-search-bar-criterion-private.h b/libnautilus-private/nautilus-search-bar-criterion-private.h index e243246d9..4de522d7c 100644 --- a/libnautilus-private/nautilus-search-bar-criterion-private.h +++ b/libnautilus-private/nautilus-search-bar-criterion-private.h @@ -24,12 +24,13 @@ Author: Rebecca Schulman <rebecka@eazel.com> */ + struct NautilusSearchBarCriterionDetails { NautilusSearchBarCriterionType type; /* various widgets hold by the criterion */ - GtkOptionMenu *available_option_menu; - GtkOptionMenu *operator_menu; + GtkOptionMenu *available_criteria; + GtkOptionMenu *relation_menu; gboolean use_value_entry; GtkEntry *value_entry; gboolean use_value_menu; diff --git a/libnautilus-private/nautilus-search-bar-criterion.c b/libnautilus-private/nautilus-search-bar-criterion.c index 3c987ab46..80f2aaa11 100644 --- a/libnautilus-private/nautilus-search-bar-criterion.c +++ b/libnautilus-private/nautilus-search-bar-criterion.c @@ -44,7 +44,6 @@ static char * criteria_titles [] = { N_("Type"), N_("Stored"), N_("Size"), - N_("With Note"), N_("With Emblem"), N_("Last Modified"), N_("Owned By"), @@ -74,7 +73,7 @@ static char *type_relations [] = { NULL }; -static char *type_options [] = { +static char *type_objects [] = { N_("regular file"), N_("text file"), N_("application"), @@ -88,7 +87,7 @@ static char *location_relations [] = { NULL }; -static char *location_options [] = { +static char *location_objects [] = { N_("on this computer"), N_("in my vault"), NULL @@ -100,7 +99,7 @@ static char *size_relations [] = { NULL }; -static char *size_options [] = { +static char *size_objects [] = { N_("1 KB"), N_("10 KB"), N_("100 KB"), @@ -111,11 +110,6 @@ static char *size_options [] = { }; -static char *notes_relations [] = { - N_("including"), - N_("not including"), - NULL -}; static char *emblem_relations [] = { N_("marked with"), @@ -123,7 +117,7 @@ static char *emblem_relations [] = { NULL }; -static char *emblem_options [] = { +static char *emblem_objects [] = { /* FIXME: add emblem possibilities here. likely to be icon filenames */ @@ -136,7 +130,7 @@ static char *modified_relations [] = { NULL }; -static char *modified_options [] = { +static char *modified_objects [] = { N_("today"), N_("this week"), N_("this month"), @@ -159,6 +153,22 @@ static NautilusSearchBarCriterion * nautilus_search_bar_criterion_new_from_value NautilusSearchBarCriterionType get_next_default_search_criterion_type (NautilusSearchBarCriterionType type) ; +static char * get_name_location_for (int relation_number, + char *name_text); +static char * get_content_location_for (int relation_number, + char *name_text); +static char * get_file_type_location_for (int relation_number, + int value_number); +static char * get_size_location_for (int relation_number, + char *size_text); +static char * get_emblem_location_for (int relation_number, + int value_number); +static char * get_date_modified_location_for (int relation_number, + int value_number); +static char * get_owner_location_for (int relation_number, + char *owner_number); + + void nautilus_search_bar_criterion_destroy (NautilusSearchBarCriterion *criterion) @@ -174,8 +184,6 @@ nautilus_search_bar_criterion_new (void) return g_new0 (NautilusSearchBarCriterion, 1); } -static void -option_menu_callback (GtkWidget *widget, gpointer data); static void option_menu_callback (GtkWidget *widget, gpointer data) @@ -207,14 +215,14 @@ nautilus_search_bar_criterion_set_callback (NautilusSearchBarCriterion *crit static NautilusSearchBarCriterion * nautilus_search_bar_criterion_new_from_values (NautilusSearchBarCriterionType type, - char *operator_options[], + char *relation_options[], gboolean use_value_entry, gboolean use_value_menu, char *value_options[]) { NautilusSearchBarCriterion *criterion; GtkWidget *search_criteria_option_menu, *search_criteria_menu; - GtkWidget *operator_option_menu, *operator_menu; + GtkWidget *relation_option_menu, *relation_menu; GtkWidget *value_option_menu, *value_menu; int i; @@ -239,24 +247,24 @@ nautilus_search_bar_criterion_new_from_values (NautilusSearchBarCriterionType ty gtk_menu_set_active (GTK_MENU (search_criteria_menu), type); gtk_option_menu_set_menu (GTK_OPTION_MENU (search_criteria_option_menu), search_criteria_menu); - criterion->details->available_option_menu = GTK_OPTION_MENU (search_criteria_option_menu); + criterion->details->available_criteria = GTK_OPTION_MENU (search_criteria_option_menu); gtk_widget_show_all (GTK_WIDGET(search_criteria_option_menu)); - operator_option_menu = gtk_option_menu_new (); - operator_menu = gtk_menu_new (); - for (i = 0; operator_options[i] != NULL; i++) { + relation_option_menu = gtk_option_menu_new (); + relation_menu = gtk_menu_new (); + for (i = 0; relation_options[i] != NULL; i++) { GtkWidget *item; - item = gtk_menu_item_new_with_label (_(operator_options[i])); + item = gtk_menu_item_new_with_label (_(relation_options[i])); gtk_object_set_data (GTK_OBJECT(item), "type", GINT_TO_POINTER(i)); - gtk_menu_append (GTK_MENU (operator_menu), + gtk_menu_append (GTK_MENU (relation_menu), item); } - gtk_option_menu_set_menu (GTK_OPTION_MENU (operator_option_menu), - operator_menu); - criterion->details->operator_menu = GTK_OPTION_MENU (operator_option_menu); - gtk_widget_show_all (GTK_WIDGET(operator_option_menu)); + gtk_option_menu_set_menu (GTK_OPTION_MENU (relation_option_menu), + relation_menu); + criterion->details->relation_menu = GTK_OPTION_MENU (relation_option_menu); + gtk_widget_show_all (GTK_WIDGET(relation_option_menu)); @@ -316,42 +324,35 @@ nautilus_search_bar_criterion_next_new (NautilusSearchBarCriterionType criterion type_relations, FALSE, TRUE, - type_options); + type_objects); break; case NAUTILUS_LOCATION_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_LOCATION_SEARCH_CRITERION, location_relations, FALSE, TRUE, - location_options); + location_objects); break; case NAUTILUS_SIZE_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_SIZE_SEARCH_CRITERION, size_relations, FALSE, TRUE, - size_options); - break; - case NAUTILUS_NOTES_SEARCH_CRITERION: - new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_NOTES_SEARCH_CRITERION, - notes_relations, - TRUE, - FALSE, - NULL); + size_objects); break; case NAUTILUS_EMBLEM_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_EMBLEM_SEARCH_CRITERION, emblem_relations, FALSE, TRUE, - emblem_options); + emblem_objects); break; case NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION, modified_relations, FALSE, TRUE, - modified_options); + modified_objects); break; case NAUTILUS_OWNER_SEARCH_CRITERION: new_criterion = nautilus_search_bar_criterion_new_from_values (NAUTILUS_OWNER_SEARCH_CRITERION, @@ -382,6 +383,11 @@ nautilus_search_bar_criterion_first_new (void) char * nautilus_search_bar_criterion_get_location (NautilusSearchBarCriterion *criterion) { + GtkWidget *menu; + GtkWidget *menu_item; + int name_number, relation_number, value_number; + char *value_text; + /* There is ONE thing you should be aware of while implementing this function. You have to make sure you use non-translated strings for building the uri. So, to implement this, you are supposed to: @@ -391,8 +397,49 @@ nautilus_search_bar_criterion_get_location (NautilusSearchBarCriterion *criterio menu_item = gtk_menu_get_active (optin_menu) number = gtk_object_get_data (menu_item, "type") */ + menu = gtk_option_menu_get_menu (criterion->details->available_criteria); + menu_item = gtk_menu_get_active (GTK_MENU (menu)); + name_number = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu_item), "type")); + menu = gtk_option_menu_get_menu (criterion->details->relation_menu); + menu_item = gtk_menu_get_active (GTK_MENU (menu)); + relation_number = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu_item), "type")); + if (criterion->details->use_value_menu) { + menu = gtk_option_menu_get_menu (criterion->details->value_menu); + menu_item = gtk_menu_get_active (GTK_MENU (menu)); + value_number = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu_item), "type")); + } + else { + value_text = gtk_entry_get_text (GTK_ENTRY (criterion->details->value_entry)); + } + + switch (name_number) { + case NAUTILUS_FILE_NAME_SEARCH_CRITERION: + return get_name_location_for (relation_number, + value_text); + case NAUTILUS_CONTENT_SEARCH_CRITERION: + return get_content_location_for (relation_number, + value_text); + case NAUTILUS_FILE_TYPE_SEARCH_CRITERION: + return get_file_type_location_for (relation_number, + value_number); + case NAUTILUS_SIZE_SEARCH_CRITERION: + return get_size_location_for (relation_number, + value_text); + case NAUTILUS_EMBLEM_SEARCH_CRITERION: + return get_emblem_location_for (relation_number, + value_number); + case NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION: + return get_date_modified_location_for (relation_number, + value_number); + case NAUTILUS_OWNER_SEARCH_CRITERION: + return get_owner_location_for (relation_number, + value_text); + default: + g_assert_not_reached (); + return NULL; + } return g_strdup ("file_name contains evolution "); } @@ -410,9 +457,7 @@ get_next_default_search_criterion_type (NautilusSearchBarCriterionType type) case NAUTILUS_LOCATION_SEARCH_CRITERION: return NAUTILUS_SIZE_SEARCH_CRITERION; case NAUTILUS_SIZE_SEARCH_CRITERION: - return NAUTILUS_NOTES_SEARCH_CRITERION; - case NAUTILUS_NOTES_SEARCH_CRITERION: - return NAUTILUS_EMBLEM_SEARCH_CRITERION; + return NAUTILUS_SIZE_SEARCH_CRITERION; case NAUTILUS_EMBLEM_SEARCH_CRITERION: return NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION; case NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION: @@ -430,8 +475,8 @@ void nautilus_search_bar_criterion_show (NautilusSearchBarCriterion *criterion) { - gtk_widget_show (GTK_WIDGET (criterion->details->available_option_menu)); - gtk_widget_show (GTK_WIDGET (criterion->details->operator_menu)); + gtk_widget_show (GTK_WIDGET (criterion->details->available_criteria)); + gtk_widget_show (GTK_WIDGET (criterion->details->relation_menu)); if (criterion->details->use_value_entry) { gtk_widget_show (GTK_WIDGET (criterion->details->value_entry)); @@ -447,8 +492,8 @@ void nautilus_search_bar_criterion_hide (NautilusSearchBarCriterion *criterion) { - gtk_widget_hide (GTK_WIDGET (criterion->details->available_option_menu)); - gtk_widget_hide (GTK_WIDGET (criterion->details->operator_menu)); + gtk_widget_hide (GTK_WIDGET (criterion->details->available_criteria)); + gtk_widget_hide (GTK_WIDGET (criterion->details->relation_menu)); if (criterion->details->use_value_entry) { gtk_widget_hide (GTK_WIDGET (criterion->details->value_entry)); @@ -458,6 +503,95 @@ nautilus_search_bar_criterion_hide (NautilusSearchBarCriterion *criterion) } } +static char * +get_name_location_for (int relation_number, char *name_text) +{ + const char *possible_relations[] = { "contains", + "starts_with", + "ends_with", + "matches_glob", + "matches_regexp" }; + + g_assert (relation_number >= 0); + g_assert (relation_number < 5); + + return g_strdup_printf ("file_name %s %s", possible_relations[relation_number], + name_text); + +} + +static char * +get_content_location_for (int relation_number, char *name_text) +{ + const char *possible_relations[] = { "includes", + "does_not_include" }; + + g_assert (relation_number == 0 || relation_number == 1); + + return g_strdup_printf ("content %s %s", possible_relations[relation_number], + name_text); +} + +static char * +get_file_type_location_for (int relation_number, + int value_number) +{ + const char *possible_relations[] = { "is", "is_not" }; + const char *possible_values[] = {"file", "text_file", "application", "directory", "music" }; + + g_assert (relation_number == 0 || relation_number == 1); + g_assert (value_number >= 0); + g_assert (value_number < 5); + return g_strdup_printf ("file_type %s %s", possible_relations[relation_number], + possible_values[value_number]); +} + + +static char * +get_size_location_for (int relation_number, + char *size_text) +{ + const char *possible_relations[] = { "larger_than", "smaller_than" }; + + g_assert (relation_number == 0 || relation_number == 1); + /* FIXME: Need checks for appropriate size here */ + return g_strdup_printf ("size %s %s", possible_relations[relation_number], size_text); + +} + +static char * +get_emblem_location_for (int relation_number, + int value_number) +{ + /* FIXME */ + return g_strdup (""); +} + +static char * +get_date_modified_location_for (int relation_number, + int value_number) +{ + const char *possible_relations[] = { "updated", "not_updated" }; + const char *possible_values[] = { "today", "this_week", "this_month" }; + + g_assert (relation_number == 0 || relation_number == 1); + g_assert (value_number >= 0); + g_assert (value_number < 3); + + return g_strdup_printf ("mod_time %s %s", possible_relations[relation_number], + possible_values[value_number]); + +} + +static char * +get_owner_location_for (int relation_number, + char *owner_text) +{ + const char *possible_relations[] = { "is", "is not" }; + g_assert (relation_number == 0 || relation_number == 1); + return g_strdup_printf ("owner %s %s", possible_relations[relation_number], owner_text); + +} diff --git a/libnautilus-private/nautilus-search-bar-criterion.h b/libnautilus-private/nautilus-search-bar-criterion.h index 1bcbcb7f6..f415e7919 100644 --- a/libnautilus-private/nautilus-search-bar-criterion.h +++ b/libnautilus-private/nautilus-search-bar-criterion.h @@ -37,7 +37,6 @@ typedef enum { NAUTILUS_FILE_TYPE_SEARCH_CRITERION, NAUTILUS_LOCATION_SEARCH_CRITERION, NAUTILUS_SIZE_SEARCH_CRITERION, - NAUTILUS_NOTES_SEARCH_CRITERION, NAUTILUS_EMBLEM_SEARCH_CRITERION, NAUTILUS_DATE_MODIFIED_SEARCH_CRITERION, NAUTILUS_OWNER_SEARCH_CRITERION, diff --git a/libnautilus-private/nautilus-search-uri.c b/libnautilus-private/nautilus-search-uri.c deleted file mode 100644 index b3660c360..000000000 --- a/libnautilus-private/nautilus-search-uri.c +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-search-uri.c -- tools for creating - and parsing search uris - - Copyright (C) 2000 Eazel, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Rebecca Schulman <rebecka@eazel.com> -*/ - -#include <string.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include "nautilus-search-uri.h" - -static NautilusSearchBarMode other_search_mode (NautilusSearchBarMode mode); - -char * -nautilus_search_uri_to_simple_search_criteria (const char *uri) -{ - /* FIXME: Not yet implemented. */ - return g_strdup (""); -} - -char * -nautilus_simple_search_criteria_to_search_uri (const char *search_criteria) -{ - char **words; - char *search_uri; - char *fragment; - char *escaped_fragment; - int length, i; - - g_return_val_if_fail (search_criteria != NULL, NULL); - - words = g_new0 (char *, strlen (search_criteria)); - words = g_strsplit (search_criteria, " ", strlen (search_criteria)); - /* FIXME: this should eventually be: length = strlen ("[file%3A%2F%2F%2F]"); */ - length = strlen ("[file:///]"); - /* Count total length */ - for (i = 0; words[i] != NULL; i++) { - length += strlen (words[i]) + strlen ("file_name contains & "); - } - fragment = g_new0 (char, length); - /* FIXME: this should eventually be: sprintf (fragment, "[file%%3A%%2F%%2F%%2F]"); */ - sprintf (fragment, "[file:///]"); - if (words[0] != NULL) { - for (i = 0; words[i+1] != NULL; i++) { - strcat (fragment, "file_name contains "); - strcat (fragment, words[i]); - strcat (fragment, " & "); - } - strcat (fragment, "file_name contains "); - strcat (fragment, words[i]); - } - escaped_fragment = gnome_vfs_escape_string (fragment); - g_free (fragment); - search_uri = g_strconcat ("search:", escaped_fragment, NULL); - g_free (escaped_fragment); -#ifdef SEARCH_URI_DEBUG - printf ("Made uri %s from simple search criteria %s\n", - search_uri, search_criteria); -#endif - return search_uri; -} - - -NautilusSearchBarMode -nautilus_search_uri_to_search_bar_mode (const char *uri) -{ - NautilusSearchBarMode preferred_mode; - - preferred_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - NAUTILUS_SIMPLE_SEARCH_BAR); - if (nautilus_search_uri_is_displayable_by_mode (uri, preferred_mode)) { - return preferred_mode; - } - else { - return (other_search_mode (preferred_mode)); - } -} - - - -gboolean -nautilus_search_uri_is_displayable_by_mode (const char *uri, - NautilusSearchBarMode mode) -{ - /* FIXME */ - return TRUE; -} - - -static NautilusSearchBarMode -other_search_mode (NautilusSearchBarMode mode) -{ - switch (mode) { - case NAUTILUS_SIMPLE_SEARCH_BAR: - return NAUTILUS_COMPLEX_SEARCH_BAR; - break; - case NAUTILUS_COMPLEX_SEARCH_BAR: - return NAUTILUS_SIMPLE_SEARCH_BAR; - break; - default: - g_assert_not_reached (); - } - return NAUTILUS_COMPLEX_SEARCH_BAR; -} diff --git a/libnautilus-private/nautilus-search-uri.h b/libnautilus-private/nautilus-search-uri.h deleted file mode 100644 index 3f1ee58ca..000000000 --- a/libnautilus-private/nautilus-search-uri.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-search-uri.c -- tools for creating - and parsing search uris - - Copyright (C) 2000 Eazel, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Rebecca Schulman <rebecka@eazel.com> -*/ - -#include "nautilus-global-preferences.h" -#include "nautilus-search-bar-criterion.h" - - -char * nautilus_search_uri_to_simple_search_criteria (const char *location); -char * nautilus_simple_search_criteria_to_search_uri (const char *search_criteria); - -/* Translate a search criterion from the complex search bar into a search uri criterion */ -char * nautilus_search_uri_generate_criterion_from_widgets (NautilusSearchBarCriterion *criterion); -NautilusSearchBarMode nautilus_search_uri_to_search_bar_mode (const char *uri); -gboolean nautilus_search_uri_is_displayable_by_mode (const char *uri, - NautilusSearchBarMode mode); diff --git a/libnautilus-private/nautilus-string.c b/libnautilus-private/nautilus-string.c index ec10075f1..6081289ab 100644 --- a/libnautilus-private/nautilus-string.c +++ b/libnautilus-private/nautilus-string.c @@ -348,6 +348,26 @@ nautilus_str_strip_trailing_chr (const char *source, char remove_this) return g_strndup (source, end - source); } +char * +nautilus_str_strip_trailing_str (const char *source, const char *remove_this) +{ + const char *end; + if (source == NULL) { + return NULL; + } + if (remove_this == NULL) { + return g_strdup (source); + } + end = source + strlen (source); + if (strcmp (end - strlen (remove_this), remove_this) != 0) { + return g_strdup (source); + } + else { + return g_strndup (source, strlen (source) - strlen(remove_this)); + } + +} + gboolean nautilus_eat_str_to_int (char *source, int *integer) { @@ -561,6 +581,11 @@ nautilus_self_check_string (void) NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_chr ("foo_", '_'), "foo"); NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_chr ("_foo__", '_'), "_foo"); NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_chr ("_f_o__o_", '_'), "_f_o__o"); + + NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_str (NULL, "bar"), NULL); + NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_str ("foo", "bar"), "foo"); + NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_str ("foo bar", "bar"), "foo "); + NAUTILUS_CHECK_STRING_RESULT (nautilus_str_strip_trailing_str ("bar", "bar"), "bar"); NAUTILUS_CHECK_STRING_RESULT (nautilus_str_double_underscores (NULL), NULL); NAUTILUS_CHECK_STRING_RESULT (nautilus_str_double_underscores (""), ""); diff --git a/libnautilus-private/nautilus-string.h b/libnautilus-private/nautilus-string.h index 18a15818c..72926e6cc 100644 --- a/libnautilus-private/nautilus-string.h +++ b/libnautilus-private/nautilus-string.h @@ -70,6 +70,8 @@ char * nautilus_str_strip_chr (const char *string, char remove_this); char * nautilus_str_strip_trailing_chr (const char *string, char remove_this); +char * nautilus_str_strip_trailing_str (const char *string, + const char *remove_this); /* Conversions to and from strings. */ gboolean nautilus_str_to_int (const char *string, diff --git a/src/nautilus-complex-search-bar.c b/src/nautilus-complex-search-bar.c index be21372e8..255696da6 100644 --- a/src/nautilus-complex-search-bar.c +++ b/src/nautilus-complex-search-bar.c @@ -26,14 +26,16 @@ #include "nautilus-complex-search-bar.h" -#include <glib.h> +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <glib.h> #include <gtk/gtkeventbox.h> +#include <libgnomevfs/gnome-vfs-utils.h> #include <libnautilus-extensions/nautilus-gtk-macros.h> -#include <libnautilus-extensions/nautilus-search-uri.h> #include <libnautilus-extensions/nautilus-search-bar-criterion.h> #include <libnautilus-extensions/nautilus-search-bar-criterion-private.h> +#include <libnautilus-extensions/nautilus-string.h> struct NautilusComplexSearchBarDetails { GtkVBox *bar_container; @@ -41,6 +43,7 @@ struct NautilusComplexSearchBarDetails { GtkWidget *more_options; GtkWidget *fewer_options; + GtkWidget *find_them; GSList *search_criteria; gchar *undo_text; @@ -64,7 +67,7 @@ static void fewer_options_callback (GtkObject static void criterion_callback (NautilusSearchBarCriterion *old_criterion, NautilusSearchBarCriterion *new_criterion, gpointer data); - +static GtkWidget * load_find_them_pixmap_widget (void); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusComplexSearchBar, nautilus_complex_search_bar, NAUTILUS_TYPE_SEARCH_BAR) @@ -118,12 +121,18 @@ nautilus_complex_search_bar_initialize (NautilusComplexSearchBar *bar) { NautilusSearchBarCriterion *file_name_criterion; GtkWidget *hbox; + GtkWidget *find_them_box, *find_them_pixmap_widget, *find_them_label; bar->details = g_new0 (NautilusComplexSearchBarDetails, 1); - bar->details->bar_container = GTK_VBOX (gtk_vbox_new (FALSE, 0)); + bar->details->bar_container = GTK_VBOX (gtk_vbox_new (FALSE, GNOME_PAD_SMALL)); - bar->details->table = GTK_TABLE (gtk_table_new (1, 1, FALSE)); + bar->details->table = GTK_TABLE (gtk_table_new (1, 3, TRUE)); + gtk_table_set_col_spacings (bar->details->table, + 1); + + gtk_container_set_resize_mode (GTK_CONTAINER (bar->details->table), + GTK_RESIZE_IMMEDIATE); file_name_criterion = nautilus_search_bar_criterion_first_new (); nautilus_search_bar_criterion_set_callback (file_name_criterion, criterion_callback, @@ -141,24 +150,55 @@ nautilus_complex_search_bar_initialize (NautilusComplexSearchBar *bar) 0); gtk_widget_show (GTK_WIDGET (bar->details->table)); - hbox = gtk_hbox_new (0, FALSE); + hbox = gtk_hbox_new (FALSE, 1); + + + bar->details->find_them = gtk_button_new (); + find_them_box = gtk_hbox_new (FALSE, 1); + find_them_pixmap_widget = load_find_them_pixmap_widget (); + gtk_box_pack_start (GTK_BOX (find_them_box), + find_them_pixmap_widget, + TRUE, + FALSE, + 1); + find_them_label = gtk_label_new ("Find Them!"); + gtk_box_pack_start (GTK_BOX (find_them_box), + find_them_label, + TRUE, + FALSE, + 1); + + gtk_container_add (GTK_CONTAINER (bar->details->find_them), find_them_box); + gtk_signal_connect_object (GTK_OBJECT (bar->details->find_them), "pressed", + nautilus_navigation_bar_location_changed, + GTK_OBJECT (bar)); + + gtk_box_pack_end (GTK_BOX (hbox), + bar->details->find_them, FALSE, FALSE, 0); + gtk_widget_show (bar->details->find_them); + - bar->details->more_options = gtk_button_new_with_label ("More Options"); - gtk_signal_connect (GTK_OBJECT (bar->details->more_options), "clicked", - more_options_callback, bar); - gtk_box_pack_start (GTK_BOX (hbox), - bar->details->more_options, - TRUE, FALSE, 0); - gtk_widget_show (bar->details->more_options); bar->details->fewer_options = gtk_button_new_with_label ("Fewer Options"); gtk_signal_connect (GTK_OBJECT (bar->details->fewer_options), "clicked", fewer_options_callback, bar); - gtk_box_pack_start (GTK_BOX (hbox), + + gtk_box_pack_end (GTK_BOX (hbox), bar->details->fewer_options, - TRUE, FALSE, 0); + FALSE, FALSE, 2 * GNOME_PAD_SMALL); + gtk_widget_show (bar->details->fewer_options); + bar->details->more_options = gtk_button_new_with_label ("More Options"); + gtk_signal_connect (GTK_OBJECT (bar->details->more_options), "clicked", + more_options_callback, bar); + + + gtk_box_pack_end (GTK_BOX (hbox), + bar->details->more_options, + FALSE, FALSE, 0); + gtk_widget_show (bar->details->more_options); + gtk_box_pack_start (GTK_BOX (bar->details->bar_container), hbox, TRUE, @@ -174,26 +214,31 @@ static char * nautilus_complex_search_bar_get_location (NautilusNavigationBar *navigation_bar) { NautilusComplexSearchBar *bar; - char *uri; + char *criteria_text, *trimmed_fragment, *escaped_fragment; + char *search_uri; GSList *list; bar = NAUTILUS_COMPLEX_SEARCH_BAR (navigation_bar); - uri = g_strdup ("search:[file:///]"); + criteria_text = g_strdup ("[file:///]"); for (list = bar->details->search_criteria; list != NULL; list = list->next) { - char *temp_uri, *criterion_uri; + char *temp_criterion, *criterion_text; NautilusSearchBarCriterion *criterion; criterion = (NautilusSearchBarCriterion *) list->data; - criterion_uri = nautilus_search_bar_criterion_get_location (criterion); - temp_uri = g_strconcat (uri, criterion_uri, NULL); - g_free (uri); - g_free (criterion_uri); - uri = temp_uri; + criterion_text = nautilus_search_bar_criterion_get_location (criterion); + temp_criterion = g_strconcat (criteria_text, criterion_text, " & ", NULL); + g_free (criteria_text); + g_free (criterion_text); + criteria_text = temp_criterion; } + trimmed_fragment = nautilus_str_strip_trailing_str (criteria_text, " & "); + g_free (criteria_text); - - return uri; + escaped_fragment = gnome_vfs_escape_string (trimmed_fragment); + search_uri = g_strconcat ("search:", escaped_fragment, NULL); + g_free (escaped_fragment); + return search_uri; } static void @@ -212,15 +257,16 @@ attach_criterion_to_search_bar (NautilusComplexSearchBar *bar, NautilusSearchBarCriterion *criterion, int row) { + g_return_if_fail (NAUTILUS_IS_COMPLEX_SEARCH_BAR (bar)); gtk_table_attach_defaults (bar->details->table, - GTK_WIDGET (criterion->details->available_option_menu), + GTK_WIDGET (criterion->details->available_criteria), 0, 1, row - 1, row); - gtk_table_attach_defaults (bar->details->table, - GTK_WIDGET (criterion->details->operator_menu), - 1, 2, row - 1, row); + gtk_table_attach_defaults (bar->details->table, + GTK_WIDGET (criterion->details->relation_menu), + 1, 2, row - 1, row); g_assert (criterion->details->use_value_entry + criterion->details->use_value_menu == 1); if (criterion->details->use_value_entry) { @@ -233,6 +279,8 @@ attach_criterion_to_search_bar (NautilusComplexSearchBar *bar, GTK_WIDGET (criterion->details->value_menu), 2, 3, row - 1, row); } + gtk_table_resize (bar->details->table, row, 3); + } static void @@ -240,10 +288,10 @@ unattach_criterion_from_search_bar (NautilusComplexSearchBar *bar, NautilusSearchBarCriterion *criterion) { gtk_container_remove (GTK_CONTAINER (bar->details->table), - GTK_WIDGET (criterion->details->available_option_menu)); + GTK_WIDGET (criterion->details->available_criteria)); gtk_container_remove (GTK_CONTAINER (bar->details->table), - GTK_WIDGET (criterion->details->operator_menu)); + GTK_WIDGET (criterion->details->relation_menu)); g_assert (criterion->details->use_value_entry + criterion->details->use_value_menu == 1); if (criterion->details->use_value_entry) { @@ -254,7 +302,24 @@ unattach_criterion_from_search_bar (NautilusComplexSearchBar *bar, gtk_container_remove (GTK_CONTAINER (bar->details->table), GTK_WIDGET (criterion->details->value_menu)); } + gtk_table_resize (bar->details->table, + g_slist_length (bar->details->search_criteria) - 1, + 3); + +} + +static GtkWidget * +load_find_them_pixmap_widget (void) +{ + GdkPixbuf *pixbuf; + GdkPixmap *pixmap; + GdkBitmap *mask; + + pixbuf = gdk_pixbuf_new_from_file ("/gnome/share/pixmaps/nautilus/search.png"); + gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128); + gdk_pixbuf_unref (pixbuf); + return gtk_pixmap_new (pixmap, mask); } @@ -320,8 +385,7 @@ fewer_options_callback (GtkObject *object, /* Assert that the old criteria got removed from the criteria list */ new_length = g_slist_length (bar->details->search_criteria); - g_assert ( new_length + 1 == old_length); - gtk_table_resize (bar->details->table, 3, new_length); + g_assert (new_length + 1 == old_length); /* FIXME: the folowing is pretty much evil since it relies on the run-time widget hierarchy of the nautilus toolbar. diff --git a/src/nautilus-simple-search-bar.c b/src/nautilus-simple-search-bar.c index 1130966ee..aefaad77b 100644 --- a/src/nautilus-simple-search-bar.c +++ b/src/nautilus-simple-search-bar.c @@ -25,18 +25,22 @@ #include <config.h> #include "nautilus-simple-search-bar.h" +#include <libgnomevfs/gnome-vfs-utils.h> #include <libnautilus-extensions/nautilus-gtk-macros.h> -#include <libnautilus-extensions/nautilus-search-uri.h> struct NautilusSimpleSearchBarDetails { GtkEntry *entry; }; -static char *nautilus_simple_search_bar_get_location (NautilusNavigationBar *bar); -static void nautilus_simple_search_bar_set_location (NautilusNavigationBar *bar, - const char *location); -static void nautilus_simple_search_bar_initialize_class (NautilusSimpleSearchBarClass *class); -static void nautilus_simple_search_bar_initialize (NautilusSimpleSearchBar *bar); +static char * nautilus_simple_search_bar_get_location (NautilusNavigationBar *bar); +static void nautilus_simple_search_bar_set_location (NautilusNavigationBar *bar, + const char *location); + +static char * nautilus_search_uri_to_simple_search_criteria (const char *location); +static char * nautilus_simple_search_criteria_to_search_uri (const char *search_criteria); + +static void nautilus_simple_search_bar_initialize_class (NautilusSimpleSearchBarClass *class); +static void nautilus_simple_search_bar_initialize (NautilusSimpleSearchBar *bar); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusSimpleSearchBar, nautilus_simple_search_bar, @@ -54,6 +58,7 @@ nautilus_simple_search_bar_initialize (NautilusSimpleSearchBar *bar) { GtkWidget *entry; GtkWidget *hbox; + GtkWidget *find_them, *find_them_label; hbox = gtk_hbox_new (0, FALSE); @@ -61,8 +66,19 @@ nautilus_simple_search_bar_initialize (NautilusSimpleSearchBar *bar) gtk_signal_connect_object (GTK_OBJECT (entry), "activate", nautilus_navigation_bar_location_changed, GTK_OBJECT (bar)); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); + + find_them = gtk_button_new (); + find_them_label = gtk_label_new ("Find Them!"); + gtk_container_add (GTK_CONTAINER (find_them), find_them_label); + gtk_signal_connect_object (GTK_OBJECT (find_them), "pressed", + nautilus_navigation_bar_location_changed, + GTK_OBJECT (bar)); + gtk_box_pack_start (GTK_BOX (hbox), find_them, FALSE, TRUE, 1); + gtk_container_add (GTK_CONTAINER (bar), hbox); + + gtk_widget_show_all (hbox); @@ -85,8 +101,6 @@ nautilus_simple_search_bar_set_location (NautilusNavigationBar *navigation_bar, /* We shouldn't have gotten here if the uri can't be displayed * using a simple search bar */ - g_return_if_fail (nautilus_search_uri_is_displayable_by_mode (location, NAUTILUS_SIMPLE_SEARCH_BAR)); - bar = NAUTILUS_SIMPLE_SEARCH_BAR (navigation_bar); /* Set the words in the box to be the words originally done in the search */ @@ -105,3 +119,54 @@ nautilus_simple_search_bar_get_location (NautilusNavigationBar *navigation_bar) search_entry_text = gtk_entry_get_text (bar->entry); return nautilus_simple_search_criteria_to_search_uri (search_entry_text); } + + + +char * +nautilus_search_uri_to_simple_search_criteria (const char *uri) +{ + /* FIXME: Not yet implemented. */ + return g_strdup (""); +} + +char * +nautilus_simple_search_criteria_to_search_uri (const char *search_criteria) +{ + char **words; + char *search_uri; + char *fragment; + char *escaped_fragment; + int length, i; + + g_return_val_if_fail (search_criteria != NULL, NULL); + + words = g_new0 (char *, strlen (search_criteria)); + words = g_strsplit (search_criteria, " ", strlen (search_criteria)); + /* FIXME: this should eventually be: length = strlen ("[file%3A%2F%2F%2F]"); */ + length = strlen ("[file:///]"); + /* Count total length */ + for (i = 0; words[i] != NULL; i++) { + length += strlen (words[i]) + strlen ("file_name contains & "); + } + fragment = g_new0 (char, length); + /* FIXME: this should eventually be: sprintf (fragment, "[file%%3A%%2F%%2F%%2F]"); */ + sprintf (fragment, "[file:///]"); + if (words[0] != NULL) { + for (i = 0; words[i+1] != NULL; i++) { + strcat (fragment, "file_name contains "); + strcat (fragment, words[i]); + strcat (fragment, " & "); + } + strcat (fragment, "file_name contains "); + strcat (fragment, words[i]); + } + escaped_fragment = gnome_vfs_escape_string (fragment); + g_free (fragment); + search_uri = g_strconcat ("search:", escaped_fragment, NULL); + g_free (escaped_fragment); +#ifdef SEARCH_URI_DEBUG + printf ("Made uri %s from simple search criteria %s\n", + search_uri, search_criteria); +#endif + return search_uri; +} diff --git a/src/nautilus-switchable-search-bar.c b/src/nautilus-switchable-search-bar.c index 3f6e039a2..90b9a111f 100644 --- a/src/nautilus-switchable-search-bar.c +++ b/src/nautilus-switchable-search-bar.c @@ -35,14 +35,17 @@ #include <libnautilus-extensions/nautilus-directory.h> #include <libnautilus-extensions/nautilus-global-preferences.h> #include <libnautilus-extensions/nautilus-gtk-macros.h> -#include <libnautilus-extensions/nautilus-search-uri.h> -static void nautilus_switchable_search_bar_set_location (NautilusNavigationBar *bar, - const char *location); -static char *nautilus_switchable_search_bar_get_location (NautilusNavigationBar *bar); -static void nautilus_switchable_search_bar_initialize_class (NautilusSwitchableSearchBarClass *class); -static void nautilus_switchable_search_bar_initialize (NautilusSwitchableSearchBar *bar); -static void nautilus_switchable_search_bar_destroy (GtkObject *object); +static void nautilus_switchable_search_bar_set_location (NautilusNavigationBar *bar, + const char *location); +static char * nautilus_switchable_search_bar_get_location (NautilusNavigationBar *bar); +static void nautilus_switchable_search_bar_initialize_class (NautilusSwitchableSearchBarClass *class); +static void nautilus_switchable_search_bar_initialize (NautilusSwitchableSearchBar *bar); + +static NautilusSearchBarMode other_search_mode (NautilusSearchBarMode mode); +static NautilusSearchBarMode nautilus_search_uri_to_search_bar_mode (const char *uri); +static gboolean nautilus_search_uri_is_displayable_by_mode (const char *uri, + NautilusSearchBarMode mode); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusSwitchableSearchBar, nautilus_switchable_search_bar, @@ -53,24 +56,6 @@ nautilus_switchable_search_bar_initialize_class (NautilusSwitchableSearchBarClas { NAUTILUS_NAVIGATION_BAR_CLASS (klass)->get_location = nautilus_switchable_search_bar_get_location; NAUTILUS_NAVIGATION_BAR_CLASS (klass)->set_location = nautilus_switchable_search_bar_set_location; - - GTK_OBJECT_CLASS (klass)->destroy = nautilus_switchable_search_bar_destroy; -} - -static void -search_bar_preference_changed_callback (gpointer user_data) -{ - g_assert (NAUTILUS_IS_SWITCHABLE_SEARCH_BAR (user_data)); - - /* Switch immediately as long as the current search_uri doesn't veto the switch. - * FIXME: Perhaps switch immediately anyway and blow away partially-formed - * search criteria? - */ - nautilus_switchable_search_bar_set_mode - (NAUTILUS_SWITCHABLE_SEARCH_BAR (user_data), - nautilus_search_uri_to_search_bar_mode - (nautilus_switchable_search_bar_get_location - (NAUTILUS_NAVIGATION_BAR (user_data)))); } static void @@ -81,7 +66,6 @@ nautilus_switchable_search_bar_initialize (NautilusSwitchableSearchBar *bar) GtkWidget *event_box; GtkWidget *vbox; GtkWidget *hbox; - GtkWidget *find_them, *find_them_label; hbox = gtk_hbox_new (0, FALSE); event_box = gtk_event_box_new (); @@ -100,46 +84,14 @@ nautilus_switchable_search_bar_initialize (NautilusSwitchableSearchBar *bar) 0); gtk_box_pack_start (GTK_BOX (hbox), bar->simple_search_bar, TRUE, TRUE, 0); - - find_them = gtk_button_new (); - find_them_label = gtk_label_new ("Find Them!"); - gtk_container_add (GTK_CONTAINER (find_them), find_them_label); - gtk_signal_connect_object (GTK_OBJECT (find_them), "pressed", - nautilus_navigation_bar_location_changed, - GTK_OBJECT (bar)); - - gtk_box_pack_start (GTK_BOX (hbox), find_them, FALSE, TRUE, 1); - gtk_container_add (GTK_CONTAINER (bar), hbox); - bar->label = GTK_LABEL (label); - bar->search_button = GTK_BUTTON (find_them); - gtk_widget_show_all (hbox); nautilus_switchable_search_bar_set_mode - (bar, + (bar, nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, NAUTILUS_SIMPLE_SEARCH_BAR)); - - /* React to future preference changes. */ - nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - search_bar_preference_changed_callback, - bar); -} - -static void -nautilus_switchable_search_bar_destroy (GtkObject *object) -{ - NautilusSwitchableSearchBar *bar; - - bar = NAUTILUS_SWITCHABLE_SEARCH_BAR (object); - - nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - search_bar_preference_changed_callback, - bar); - - NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); } GtkWidget * @@ -165,12 +117,7 @@ nautilus_switchable_search_bar_set_mode (NautilusSwitchableSearchBar *bar, return; } g_free (location); - - /* FIXME bugzilla.eazel.com 1860: - * Switching to the complex search bar, which is taller, leaves - * the navigation bar forever at the taller height, even after switching - * back to the simple search bar or the location bar. - */ + switch (mode) { case NAUTILUS_SIMPLE_SEARCH_BAR: gtk_widget_show (bar->simple_search_bar); @@ -227,3 +174,49 @@ nautilus_switchable_search_bar_set_location (NautilusNavigationBar *navigation_b nautilus_navigation_bar_set_location (NAUTILUS_NAVIGATION_BAR (bar->complex_search_bar), location); } + + + +NautilusSearchBarMode +nautilus_search_uri_to_search_bar_mode (const char *uri) +{ + NautilusSearchBarMode preferred_mode; + + preferred_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, + NAUTILUS_SIMPLE_SEARCH_BAR); + if (nautilus_search_uri_is_displayable_by_mode (uri, preferred_mode)) { + return preferred_mode; + } + else { + return (other_search_mode (preferred_mode)); + } +} + + + +gboolean +nautilus_search_uri_is_displayable_by_mode (const char *uri, + NautilusSearchBarMode mode) +{ + /* FIXME */ + return TRUE; +} + + +static NautilusSearchBarMode +other_search_mode (NautilusSearchBarMode mode) +{ + switch (mode) { + case NAUTILUS_SIMPLE_SEARCH_BAR: + return NAUTILUS_COMPLEX_SEARCH_BAR; + break; + case NAUTILUS_COMPLEX_SEARCH_BAR: + return NAUTILUS_SIMPLE_SEARCH_BAR; + break; + default: + g_assert_not_reached (); + } + return NAUTILUS_COMPLEX_SEARCH_BAR; +} + + diff --git a/src/nautilus-switchable-search-bar.h b/src/nautilus-switchable-search-bar.h index 5f2bf1fbc..e4130b5e0 100644 --- a/src/nautilus-switchable-search-bar.h +++ b/src/nautilus-switchable-search-bar.h @@ -41,8 +41,6 @@ typedef struct { NautilusSearchBarMode mode; GtkHBox *container; - GtkLabel *label; - GtkButton *search_button; GtkWidget *complex_search_bar; GtkWidget *simple_search_bar; } NautilusSwitchableSearchBar; |