mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-19 15:51:40 +00:00
936e97a0de
2000-06-28 Rebecca Schulman <rebecka@eazel.com> * libnautilus-extensions/nautilus-search-uri.c: (nautilus_simple_search_criteria_to_search_uri): (add facility to make search uri's from simple search queries ) * src/nautilus-complex-search-bar.c: (nautilus_complex_search_bar_initialize_class), (nautilus_complex_search_bar_initialize), (more_options_callback), (add_file_type_search_criterion_callback), (add_file_name_search_criterion_callback), (add_file_location_search_criterion_callback), (add_content_search_criterion_callback), (add_size_search_criterion_callback), (add_date_modified_search_criterion_callback), (add_notes_search_criterion_callback), (nautilus_complex_search_bar_get_location): added ability to add more criterion (still incomplete) * src/nautilus-complex-search-bar.h: * src/nautilus-search-bar-criterion.c: (nautilus_search_bar_criterion_file_type_new), (nautilus_search_bar_criterion_file_name_new), (nautilus_search_bar_criterion_location_new), (nautilus_search_bar_criterion_content_new), (nautilus_search_bar_criterion_size_new), (nautilus_search_bar_criterion_add_to_search_bar), (nautilus_search_bar_criterion_show): added code to actually create various search button criterion sets. * src/nautilus-search-bar-criterion.h: * src/nautilus-simple-search-bar.c: (nautilus_simple_search_bar_initialize_class), (nautilus_simple_search_bar_get_location), (editable_activated_callback): * src/nautilus-simple-search-bar.h: Updated so that the search location is done correctly. Adjustments to the nautilus-directory should be all that is needed to make all of this stuff work. * src/nautilus-switchable-search-bar.c: (nautilus_switchable_search_bar_initialize), (nautilus_switchable_search_bar_get_location), (nautilus_switchable_search_bar_set_search_controls): Some widget changes, and search get_location calls respective simple or complex search bar get_location functions
115 lines
3 KiB
C
115 lines
3 KiB
C
/* -*- 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 "nautilus-search-uri.h"
|
|
|
|
static NautilusSearchBarMode other_search_mode (NautilusSearchBarMode mode);
|
|
|
|
char*
|
|
nautilus_search_uri_to_simple_search_criteria (const char *uri)
|
|
{
|
|
return "";
|
|
|
|
}
|
|
|
|
char *
|
|
nautilus_simple_search_criteria_to_search_uri (const char *search_criteria)
|
|
{
|
|
char **words;
|
|
char *search_uri;
|
|
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));
|
|
length = strlen ("gnome-search:[file:///]");
|
|
/* Count total length */
|
|
for (i = 0; words[i] != NULL; i++) {
|
|
length += strlen (words[i]) + strlen ("file_name contains & ");
|
|
}
|
|
search_uri = g_new0 (char, length);
|
|
sprintf (search_uri, "gnome-search:[file:///]");
|
|
if (words[0] != NULL) {
|
|
for (i = 0; words[i+1] != NULL; i++) {
|
|
strcat (search_uri, "file_name contains ");
|
|
strcat (search_uri, words[i]);
|
|
strcat (search_uri, " & ");
|
|
}
|
|
strcat (search_uri, "file_name contains ");
|
|
strcat (search_uri, words[i]);
|
|
}
|
|
#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;
|
|
}
|