mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-17 23:01:59 +00:00
fbbaf80362
* Makefile.am: Remove librsvg. * librsvg/.cvsignore: * librsvg/Makefile.am: * librsvg/art_render.c: * librsvg/art_render.h: * librsvg/art_render_gradient.c: * librsvg/art_render_gradient.h: * librsvg/art_render_mask.c: * librsvg/art_render_mask.h: * librsvg/art_render_svp.c: * librsvg/art_render_svp.h: * librsvg/art_rgba.c: * librsvg/art_rgba.h: * librsvg/example-nested-transform.svg: * librsvg/makefile-simple: * librsvg/opacity.svg: * librsvg/rsvg-bpath-util.c: * librsvg/rsvg-bpath-util.h: * librsvg/rsvg-css.c: * librsvg/rsvg-css.h: * librsvg/rsvg-defs.c: * librsvg/rsvg-defs.h: * librsvg/rsvg-ft.c: * librsvg/rsvg-ft.h: * librsvg/rsvg-paint-server.c: * librsvg/rsvg-paint-server.h: * librsvg/rsvg-path.c: * librsvg/rsvg-path.h: * librsvg/rsvg.c: * librsvg/rsvg.h: * librsvg/subpixel-text-test: * librsvg/test-ft-gtk.c: * librsvg/test-ft.c: * librsvg/test-rsvg.c: * librsvg/test.svg: Move librsvg to its own top level GNOME CVS module. * configure.in: Add librsvg and eel dependencies. Remove librsvg and font entries. * nautilus.spec.in: Remove font entries. Add librsvg and eel requirements. * data/Makefile.am: * data/fonts/.cvsignore: * data/fonts/Makefile.am: * data/fonts/urw/.cvsignore: * data/fonts/urw/Makefile.am: * data/fonts/urw/README: * data/fonts/urw/fonts.dir: * data/fonts/urw/n019003l.afm: * data/fonts/urw/n019003l.pfb: * data/fonts/urw/n019003l.pfm: * data/fonts/urw/n019004l.afm: * data/fonts/urw/n019004l.pfb: * data/fonts/urw/n019004l.pfm: * data/fonts/urw/n019023l.afm: * data/fonts/urw/n019023l.pfb: * data/fonts/urw/n019023l.pfm: * data/fonts/urw/n019024l.afm: * data/fonts/urw/n019024l.pfb: * data/fonts/urw/n019024l.pfm: Retire default fonts. These now live in eel. * libnautilus/nautilus-undo-transaction.c: (nautilus_undo_transaction_destroy): * libnautilus/nautilus-view.c: (nautilus_view_destroy): Update for eel changes. Use eel-gtk-macros. * nautilus-installer/src/nautilus-druid-page-eazel.c: (nautilus_druid_page_eazel_destroy), (nautilus_druid_page_eazel_finalize), (nautilus_druid_page_eazel_size_allocate), (nautilus_druid_page_eazel_size_request): Update for eel changes. Use eel-gtk-macros. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-bonobo-extensions.c: * libnautilus-extensions/nautilus-bonobo-extensions.h: * libnautilus-extensions/nautilus-bookmark.c: * libnautilus-extensions/nautilus-ctree.c: * libnautilus-extensions/nautilus-customization-data.c: * libnautilus-extensions/nautilus-dateedit-extensions.c: * libnautilus-extensions/nautilus-dateedit-extensions.h: * libnautilus-extensions/nautilus-directory-async.c: * libnautilus-extensions/nautilus-directory-background.c: * libnautilus-extensions/nautilus-directory-background.h: * libnautilus-extensions/nautilus-directory-metafile-monitor.c: * libnautilus-extensions/nautilus-directory-metafile.c: * libnautilus-extensions/nautilus-directory.c: * libnautilus-extensions/nautilus-drag-window.c: * libnautilus-extensions/nautilus-drag.c: * libnautilus-extensions/nautilus-druid-page-eazel.c: * libnautilus-extensions/nautilus-druid.c: * libnautilus-extensions/nautilus-entry.c: * libnautilus-extensions/nautilus-file-changes-queue.c: * libnautilus-extensions/nautilus-file-operations-progress.c: * libnautilus-extensions/nautilus-file-operations.c: * libnautilus-extensions/nautilus-file-private.h: * libnautilus-extensions/nautilus-file-utilities.c: * libnautilus-extensions/nautilus-file.c: * libnautilus-extensions/nautilus-font-factory.c: * libnautilus-extensions/nautilus-gconf-extensions.c: * libnautilus-extensions/nautilus-generous-bin.c: * libnautilus-extensions/nautilus-global-preferences.c: * libnautilus-extensions/nautilus-global-preferences.h: * libnautilus-extensions/nautilus-horizontal-splitter.c: * libnautilus-extensions/nautilus-icon-canvas-item.c: * libnautilus-extensions/nautilus-icon-canvas-item.h: * libnautilus-extensions/nautilus-icon-container.c: * libnautilus-extensions/nautilus-icon-container.h: * libnautilus-extensions/nautilus-icon-dnd.c: * libnautilus-extensions/nautilus-icon-factory.c: * libnautilus-extensions/nautilus-icon-factory.h: * libnautilus-extensions/nautilus-icon-private.h: * libnautilus-extensions/nautilus-icon-text-item.c: * libnautilus-extensions/nautilus-keep-last-vertical-box.c: * libnautilus-extensions/nautilus-lib-self-check-functions.c: * libnautilus-extensions/nautilus-lib-self-check-functions.h: * libnautilus-extensions/nautilus-link-set.c: * libnautilus-extensions/nautilus-link.c: * libnautilus-extensions/nautilus-list-column-title.c: * libnautilus-extensions/nautilus-list.c: * libnautilus-extensions/nautilus-medusa-support.c: * libnautilus-extensions/nautilus-merged-directory.c: * libnautilus-extensions/nautilus-metafile-factory.c: * libnautilus-extensions/nautilus-metafile.c: * libnautilus-extensions/nautilus-mime-actions.c: * libnautilus-extensions/nautilus-preferences-box.c: * libnautilus-extensions/nautilus-preferences-dialog.c: * libnautilus-extensions/nautilus-preferences-group.c: * libnautilus-extensions/nautilus-preferences-item.c: * libnautilus-extensions/nautilus-preferences-pane.c: * libnautilus-extensions/nautilus-preferences.c: * libnautilus-extensions/nautilus-preferences.h: * libnautilus-extensions/nautilus-program-chooser.c: * libnautilus-extensions/nautilus-program-choosing.c: * libnautilus-extensions/nautilus-program-choosing.h: * libnautilus-extensions/nautilus-search-uri.c: * libnautilus-extensions/nautilus-sidebar-functions.c: * libnautilus-extensions/nautilus-tabs.c: * libnautilus-extensions/nautilus-theme.c: * libnautilus-extensions/nautilus-thumbnails.c: * libnautilus-extensions/nautilus-trash-directory.c: * libnautilus-extensions/nautilus-trash-file.c: * libnautilus-extensions/nautilus-trash-monitor.c: * libnautilus-extensions/nautilus-undo-context.c: * libnautilus-extensions/nautilus-undo-manager.c: * libnautilus-extensions/nautilus-undo-signal-handlers.c: * libnautilus-extensions/nautilus-vfs-directory.c: * libnautilus-extensions/nautilus-vfs-file.c: * libnautilus-extensions/nautilus-view-identifier.c: * libnautilus-extensions/nautilus-volume-monitor.c: Use new eel library. * libnautilus-extensions/nautilus-art-extensions.c: * libnautilus-extensions/nautilus-art-extensions.h: * libnautilus-extensions/nautilus-art-gtk-extensions.c: * libnautilus-extensions/nautilus-art-gtk-extensions.h: * libnautilus-extensions/nautilus-background-canvas-group.c: * libnautilus-extensions/nautilus-background-canvas-group.h: * libnautilus-extensions/nautilus-background.c: * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-caption-table.c: * libnautilus-extensions/nautilus-caption-table.h: * libnautilus-extensions/nautilus-caption.c: * libnautilus-extensions/nautilus-caption.h: * libnautilus-extensions/nautilus-clickable-image.c: * libnautilus-extensions/nautilus-clickable-image.h: * libnautilus-extensions/nautilus-debug-drawing.c: * libnautilus-extensions/nautilus-debug-drawing.h: * libnautilus-extensions/nautilus-debug.c: * libnautilus-extensions/nautilus-debug.h: * libnautilus-extensions/nautilus-ellipsizing-label.c: * libnautilus-extensions/nautilus-ellipsizing-label.h: * libnautilus-extensions/nautilus-enumeration.c: * libnautilus-extensions/nautilus-enumeration.h: * libnautilus-extensions/nautilus-font-manager.c: * libnautilus-extensions/nautilus-font-manager.h: * libnautilus-extensions/nautilus-font-picker.c: * libnautilus-extensions/nautilus-font-picker.h: * libnautilus-extensions/nautilus-gdk-extensions.c: * libnautilus-extensions/nautilus-gdk-extensions.h: * libnautilus-extensions/nautilus-gdk-font-extensions.c: * libnautilus-extensions/nautilus-gdk-font-extensions.h: * libnautilus-extensions/nautilus-gdk-pixbuf-extensions.c: * libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h: * libnautilus-extensions/nautilus-glib-extensions.c: * libnautilus-extensions/nautilus-glib-extensions.h: * libnautilus-extensions/nautilus-glyph.c: * libnautilus-extensions/nautilus-glyph.h: * libnautilus-extensions/nautilus-gnome-extensions.c: * libnautilus-extensions/nautilus-gnome-extensions.h: * libnautilus-extensions/nautilus-graphic-effects.c: * libnautilus-extensions/nautilus-graphic-effects.h: * libnautilus-extensions/nautilus-gtk-extensions.c: * libnautilus-extensions/nautilus-gtk-extensions.h: * libnautilus-extensions/nautilus-gtk-macros.h: * libnautilus-extensions/nautilus-image-table.c: * libnautilus-extensions/nautilus-image-table.h: * libnautilus-extensions/nautilus-image-with-background.c: * libnautilus-extensions/nautilus-image-with-background.h: * libnautilus-extensions/nautilus-image.c: * libnautilus-extensions/nautilus-image.h: * libnautilus-extensions/nautilus-label-with-background.c: * libnautilus-extensions/nautilus-label-with-background.h: * libnautilus-extensions/nautilus-label.c: * libnautilus-extensions/nautilus-label.h: * libnautilus-extensions/nautilus-labeled-image.c: * libnautilus-extensions/nautilus-labeled-image.h: * libnautilus-extensions/nautilus-lib-self-check-functions.c: * libnautilus-extensions/nautilus-lib-self-check-functions.h: * libnautilus-extensions/nautilus-password-dialog.c: * libnautilus-extensions/nautilus-password-dialog.h: * libnautilus-extensions/nautilus-radio-button-group.c: * libnautilus-extensions/nautilus-radio-button-group.h: * libnautilus-extensions/nautilus-region.c: * libnautilus-extensions/nautilus-region.h: * libnautilus-extensions/nautilus-scalable-font-private.h: * libnautilus-extensions/nautilus-scalable-font.c: * libnautilus-extensions/nautilus-scalable-font.h: * libnautilus-extensions/nautilus-self-checks.c: * libnautilus-extensions/nautilus-self-checks.h: * libnautilus-extensions/nautilus-smooth-text-layout-cache.c: * libnautilus-extensions/nautilus-smooth-text-layout-cache.h: * libnautilus-extensions/nautilus-smooth-text-layout.c: * libnautilus-extensions/nautilus-smooth-text-layout.h: * libnautilus-extensions/nautilus-smooth-widget.c: * libnautilus-extensions/nautilus-smooth-widget.h: * libnautilus-extensions/nautilus-stock-dialogs.c: * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-string-list.c: * libnautilus-extensions/nautilus-string-list.h: * libnautilus-extensions/nautilus-string-map.c: * libnautilus-extensions/nautilus-string-map.h: * libnautilus-extensions/nautilus-string-picker.c: * libnautilus-extensions/nautilus-string-picker.h: * libnautilus-extensions/nautilus-string.c: * libnautilus-extensions/nautilus-string.h: * libnautilus-extensions/nautilus-text-caption.c: * libnautilus-extensions/nautilus-text-caption.h: * libnautilus-extensions/nautilus-viewport.c: * libnautilus-extensions/nautilus-viewport.h: * libnautilus-extensions/nautilus-wrap-table.c: * libnautilus-extensions/nautilus-wrap-table.h: * libnautilus-extensions/nautilus-xml-extensions.c: * libnautilus-extensions/nautilus-xml-extensions.h: Remove these files. These are all part of eel now. * applets/launcher/nautilus-launcher-applet.c: * applets/preferences-applet/nautilus-preferences-applet.c: * components/adapter/Makefile.am: * components/adapter/main.c: * components/adapter/nautilus-adapter-control-embed-strategy.c: * components/adapter/nautilus-adapter-embed-strategy.c: * components/adapter/nautilus-adapter-embeddable-embed-strategy.c: * components/adapter/nautilus-adapter-factory-server.c: * components/adapter/nautilus-adapter-file-load-strategy.c: * components/adapter/nautilus-adapter-load-strategy.c: * components/adapter/nautilus-adapter-progressive-load-strategy.c: * components/adapter/nautilus-adapter-stream-load-strategy.c: * components/adapter/nautilus-adapter.c: * components/hardware/Makefile.am: * components/hardware/nautilus-hardware-view.c: * components/help/Makefile.am: * components/help/help-method.c: * components/help/hyperbola-filefmt.c: * components/help/hyperbola-nav-tree.c: * components/history/Makefile.am: * components/history/nautilus-history-view.c: * components/image-viewer/Makefile.am: * components/image-viewer/nautilus-image-view.c: * components/loser/content/Makefile.am: * components/loser/content/nautilus-content-loser.c: * components/loser/sidebar/Makefile.am: * components/loser/sidebar/nautilus-sidebar-loser.c: * components/mozilla/Makefile.am: * components/mozilla/bonobo-extensions.c: * components/mozilla/nautilus-mozilla-content-view.c: * components/music/Makefile.am: * components/music/nautilus-music-view.c: * components/notes/Makefile.am: * components/notes/nautilus-notes.c: * components/rpmview/Makefile.am: * components/rpmview/nautilus-rpm-verify-window.c: * components/rpmview/nautilus-rpm-view-install.c: * components/rpmview/nautilus-rpm-view.c: * components/sample/nautilus-sample-content-view.c: * components/services/install-view/Makefile.am: * components/services/install-view/callbacks.c: * components/services/install-view/forms.c: * components/services/install-view/nautilus-service-install-view.c: * components/services/install/lib/eazel-install-logic2.c: * components/services/install/server/main.c: * components/services/inventory-view/Makefile.am: * components/services/inventory-view/nautilus-inventory-config-page .c: * components/services/inventory-view/nautilus-inventory-disable-pag * components/services/inventory-view/nautilus-inventory-enable-page * components/services/inventory-view/nautilus-inventory-view.c: * components/services/inventory/Makefile.am: * components/services/inventory/eazel-inventory-upload-callback.c: * components/services/inventory/eazel-inventory.c: * components/services/inventory/main.c: * components/services/login/nautilus-view/Makefile.am: * components/services/login/nautilus-view/nautilus-change-password- view.c: * components/services/login/nautilus-view/password-box.c: * components/services/nautilus-dependent-shared/Makefile.am: * components/services/nautilus-dependent-shared/eazel-services-exte nsions.c: * components/services/nautilus-dependent-shared/eazel-services-exte nsions.h: * components/services/nautilus-dependent-shared/eazel-services-foot er.c: * components/services/nautilus-dependent-shared/eazel-services-head er.c: * components/services/nautilus-dependent-shared/test-footer-header. c: * components/services/summary/Makefile.am: * components/services/summary/nautilus-summary-callbacks.c: * components/services/summary/nautilus-summary-dialogs.c: * components/services/summary/nautilus-summary-dialogs.h: * components/services/summary/nautilus-summary-footer.c: * components/services/summary/nautilus-summary-menu-items.c: * components/services/summary/nautilus-summary-view-private.h: * components/services/summary/nautilus-summary-view.c: * components/services/time/nautilus-view/main.c: * components/services/time/nautilus-view/trilobite-eazel-time-view. c: * components/services/trilobite/sample/nautilus-view/Makefile.am: * components/text/Makefile.am: * components/text/nautilus-text-view.c: * components/throbber/Makefile.am: * components/throbber/main.c: * components/throbber/nautilus-throbber.c: * components/tree/Makefile.am: * components/tree/nautilus-tree-change-queue.c: * components/tree/nautilus-tree-expansion-state.c: * components/tree/nautilus-tree-model.c: * components/tree/nautilus-tree-node.c: * components/tree/nautilus-tree-view-dnd.c: * components/tree/nautilus-tree-view.c: * helper-utilities/authenticate/Makefile.am: * helper-utilities/authenticate/nautilus-authenticate.c: * nautilus-installer/src/nautilus-druid.c: * src/Makefile.am: * src/file-manager/fm-desktop-icon-view.c: * src/file-manager/fm-directory-view.c: * src/file-manager/fm-directory-view.h: * src/file-manager/fm-error-reporting.c: * src/file-manager/fm-icon-text-window.c: * src/file-manager/fm-icon-view.c: * src/file-manager/fm-list-view.c: * src/file-manager/fm-properties-window.c: * src/file-manager/fm-search-list-view.c: * src/file-manager/nautilus-indexing-info.c: * src/nautilus-about.c: * src/nautilus-application.c: * src/nautilus-bookmark-list.c: * src/nautilus-bookmark-parsing.c: * src/nautilus-bookmarks-window.c: * src/nautilus-complex-search-bar.c: * src/nautilus-component-adapter-factory.c: * src/nautilus-desktop-window.c: * src/nautilus-first-time-druid.c: * src/nautilus-link-set-window.c: * src/nautilus-location-bar.c: * src/nautilus-main.c: * src/nautilus-navigation-bar.c: * src/nautilus-profiler.c: * src/nautilus-property-browser.c: * src/nautilus-search-bar-criterion.c: * src/nautilus-search-bar.c: * src/nautilus-shell.c: * src/nautilus-sidebar-tabs.c: * src/nautilus-sidebar-title.c: * src/nautilus-sidebar.c: * src/nautilus-signaller.c: * src/nautilus-simple-search-bar.c: * src/nautilus-switchable-navigation-bar.c: * src/nautilus-switchable-search-bar.c: * src/nautilus-theme-selector.c: * src/nautilus-view-frame-corba.c: * src/nautilus-view-frame.c: * src/nautilus-window-manage-views.c: * src/nautilus-window-menus.c: * src/nautilus-window-toolbars.c: * src/nautilus-window.c: * src/nautilus-window.h: * src/nautilus-zoom-control.c: Update for new eel library usage. * test/test-nautilus-background.c: * test/test-nautilus-clickable-image.c: * test/test-nautilus-font-manager.c: * test/test-nautilus-font-picker.c: * test/test-nautilus-font-simple.c: * test/test-nautilus-font.c: * test/test-nautilus-glyph-simple.c: * test/test-nautilus-glyph.c: * test/test-nautilus-image-background.c: * test/test-nautilus-image-scrolled.c: * test/test-nautilus-image-simple.c: * test/test-nautilus-image-table.c: * test/test-nautilus-image-tile.c: * test/test-nautilus-image.c: * test/test-nautilus-label-background.c: * test/test-nautilus-label-flavorful.c: * test/test-nautilus-label-offset.c: * test/test-nautilus-label-scrolled.c: * test/test-nautilus-label-simple.c: * test/test-nautilus-label-wrapped.c: * test/test-nautilus-label.c: * test/test-nautilus-labeled-image.c: * test/test-nautilus-password-dialog.c: * test/test-nautilus-pixbuf-tile.c: * test/test-nautilus-smooth-text-layout.c: * test/test-nautilus-viewport-constraint.c: * test/test-nautilus-widgets.c: Remove these. They live in eel now. * test/vsignore: * test/kefile.am: * test/st-nautilus-preferences-change.c: * test/st-nautilus-preferences-display.c: * test/st-nautilus-wrap-table.c: * test/st.c: * test/st.h: Update for new eel library usage.
729 lines
26 KiB
C
729 lines
26 KiB
C
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
|
/* Code to generate human-readable strings from 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: Mathieu Lacage <mathieu@eazel.com>
|
|
*/
|
|
|
|
#include <config.h>
|
|
#include "nautilus-search-uri.h"
|
|
|
|
/* Must be included before other libgnome headers. */
|
|
#include <libgnome/gnome-defs.h>
|
|
|
|
#include "nautilus-lib-self-check-functions.h"
|
|
#include <eel/eel-glib-extensions.h>
|
|
#include <eel/eel-string.h>
|
|
#include <libgnome/gnome-i18n.h>
|
|
#include <libgnomevfs/gnome-vfs-utils.h>
|
|
|
|
static const char *strip_uri_beginning (const char *location_uri);
|
|
static GList * tokenize_uri (const char *string);
|
|
static char * get_translated_criterion (GList *criterion);
|
|
static char * get_nth_criterion_prefix (GList *criterion);
|
|
static char * parse_uri (const char *search_uri);
|
|
static void free_tokenized_uri (GList *list);
|
|
|
|
/**
|
|
* strip_uri_beginning:
|
|
* @location_uri: search uri.
|
|
*
|
|
* strips the search:[file:///...] part of the input uri.
|
|
*
|
|
*/
|
|
static const char *
|
|
strip_uri_beginning (const char *location_uri)
|
|
{
|
|
char **first_token;
|
|
char *ptr;
|
|
const char *ret_val;
|
|
|
|
first_token = g_strsplit (location_uri, " ", 1);
|
|
if (first_token[0] == NULL) {
|
|
g_strfreev (first_token);
|
|
return NULL;
|
|
}
|
|
|
|
/* parse the first token from the end to the beginning.
|
|
to extract the search:[] part.
|
|
*/
|
|
for (ptr = first_token[0]+strlen(first_token[0]);
|
|
ptr != first_token[0] && *ptr != ']';
|
|
ptr--) {}
|
|
|
|
ret_val = location_uri + (ptr - first_token[0]) + 1;
|
|
|
|
g_strfreev (first_token);
|
|
|
|
return ret_val;
|
|
}
|
|
|
|
/**
|
|
* free_tokenized_uri:
|
|
* @list: tokenized uri to free
|
|
*
|
|
*/
|
|
static void
|
|
free_tokenized_uri (GList *list)
|
|
{
|
|
GList *node;
|
|
|
|
for (node = list; node != NULL; node = node->next) {
|
|
eel_g_list_free_deep (node->data);
|
|
}
|
|
g_list_free (list);
|
|
}
|
|
|
|
|
|
/**
|
|
* tokenize_uri
|
|
* @string: string to parse
|
|
*
|
|
* This function tokenizes a subset of the grand medusa uri specification.
|
|
* If it cannot, it returns NULL. CHECK FOR NULL upon return.
|
|
*
|
|
* Return value: a Singly linked list of singly linked lists.
|
|
* each of the element of the root linked list is a complete criterion.
|
|
* each criterin sinlgly linked list is made of the different tokens
|
|
* of the criterion.
|
|
*/
|
|
static GList *
|
|
tokenize_uri (const char *string)
|
|
{
|
|
const char *temp_string;
|
|
char **criteria;
|
|
GList *criterion_list;
|
|
int i, j;
|
|
|
|
if (string == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
criterion_list = NULL;
|
|
|
|
string = strip_uri_beginning (string);
|
|
if (string == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
/* make sure we can handle this uri */
|
|
if ( strchr (string , '(') != NULL
|
|
|| strchr (string, ')') != NULL
|
|
|| strchr (string, '|') != NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
/* split the uri in different criteria */
|
|
criteria = g_strsplit (string, " & ", 0);
|
|
for (i = 0, temp_string = criteria[0];
|
|
temp_string != NULL;
|
|
i++, temp_string = criteria[i]) {
|
|
char **tokens;
|
|
char *token;
|
|
GList *token_list;
|
|
|
|
/* split a criterion in different tokens */
|
|
token_list = NULL;
|
|
tokens = g_strsplit (temp_string, " ", 2);
|
|
for (j = 0, token = tokens[0]; token != NULL; j++, token = tokens[j]) {
|
|
/* g_strstrip does not return a newly allocated string. */
|
|
token_list = g_list_append (token_list, g_strdup (g_strstrip (token)));
|
|
}
|
|
criterion_list = g_list_append (criterion_list, token_list);
|
|
g_strfreev (tokens);
|
|
}
|
|
g_strfreev (criteria);
|
|
|
|
return criterion_list;
|
|
}
|
|
|
|
typedef struct _value_criterion_item value_criterion_item;
|
|
typedef value_criterion_item *value_criterion_table;
|
|
|
|
typedef struct _operand_criterion_item operand_criterion_item;
|
|
typedef operand_criterion_item *operand_criterion_table;
|
|
|
|
typedef struct _field_criterion_item field_criterion_item;
|
|
typedef field_criterion_item *field_criterion_table;
|
|
|
|
/* toplevel structure each entry points to a level 2 structure */
|
|
struct _field_criterion_item {
|
|
char *id;
|
|
/* FIXME: This field is necessary so that
|
|
the size of this structure is the same
|
|
as the size of the other structures.
|
|
see the comment in the definition of "value_criterion_item"
|
|
to see what I mean. Yay, evil!
|
|
someone should make this go away. */
|
|
char *unused_field_for_hack_compatibility;
|
|
operand_criterion_table items;
|
|
};
|
|
/* second level structure. if items is NULL, the entry is a leaf
|
|
of our hierarchy. If it is not, it points to a level 3 leaf
|
|
*/
|
|
struct _operand_criterion_item {
|
|
char *id;
|
|
char *translation;
|
|
value_criterion_table items;
|
|
};
|
|
/* third level structure. leaf */
|
|
struct _value_criterion_item {
|
|
char *id;
|
|
char *translation;
|
|
/* this field is there only to make the 3 structures similar enough
|
|
so that you can safely cast between them it is a kind of evil hack
|
|
but i like it. It is guaranteed to be always NULL. */
|
|
value_criterion_table items;
|
|
};
|
|
|
|
|
|
/* -------------------------------------------------------
|
|
- file name -
|
|
-------------------------------------------------------
|
|
*/
|
|
|
|
static operand_criterion_item file_name2_table [] = {
|
|
{"contains",
|
|
/* Human readable description for a criterion in a search for
|
|
files. Bracketed items are context, and are message
|
|
strings elsewhere. You don't have to translate the whole
|
|
string, and only the translation for "containing '%s' will
|
|
be used. If you do translate the whole string, leave the
|
|
translations of the rest of the text in brackets, so it
|
|
will not be used.
|
|
"%s" here is a pattern the file name
|
|
matched, such as "nautilus" */
|
|
N_("[Items ]containing \"%s\" in their names"),
|
|
NULL},
|
|
{"starts_with",
|
|
/* "%s" here is a pattern the file name started with, such as
|
|
"nautilus" */
|
|
N_("[Items ]starting with \"%s\""),
|
|
NULL},
|
|
{"ends_with",
|
|
/* "%s" here is a pattern the file name ended with, such as
|
|
"mime" */
|
|
N_("[Items ]ending with %s"),
|
|
NULL},
|
|
{"does_not_contain",
|
|
/* "%s" here is a pattern the file name did not match, such
|
|
as "nautilus" */
|
|
N_("[Items ]not containing \"%s\" in their names"),
|
|
NULL},
|
|
{"regexp_matches",
|
|
/* "%s" is a regular expression string, for example "[abc]" */
|
|
N_("[Items ]matching the regular expression \"%s\""),
|
|
NULL},
|
|
{"matches",
|
|
/* "%s" is a file glob, for example "*.txt" */
|
|
N_("[Items ]matching the file pattern \"%s\""),
|
|
NULL},
|
|
{NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
/* -------------------------------------------------------
|
|
- file type -
|
|
-------------------------------------------------------
|
|
*/
|
|
static value_criterion_item file_type_options3_table [] = {
|
|
{"file",
|
|
N_("[Items that are ]regular files"),
|
|
NULL},
|
|
{"text_file",
|
|
N_("[Items that are ]text files"),
|
|
NULL},
|
|
{"application",
|
|
N_("[Items that are ]applications"),
|
|
NULL},
|
|
{"directory",
|
|
N_("[Items that are ]folders"),
|
|
NULL},
|
|
{"music",
|
|
N_("[Items that are ]music"),
|
|
NULL},
|
|
{NULL, NULL, NULL}
|
|
};
|
|
static operand_criterion_item file_type2_table [] = {
|
|
{"is_not",
|
|
/* "%s" here is a word describing a file type, for example
|
|
"folder" */
|
|
N_("[Items ]that are not %s"),
|
|
file_type_options3_table},
|
|
{"is",
|
|
/* "%s" here is a word describing a file type, for example
|
|
"folder" */
|
|
N_("[Items ]that are %s"),
|
|
file_type_options3_table},
|
|
{NULL, NULL, NULL}
|
|
};
|
|
|
|
|
|
/* -------------------------------------------------------
|
|
- owner -
|
|
-------------------------------------------------------
|
|
*/
|
|
static operand_criterion_item owner2_table [] = {
|
|
{"is_not",
|
|
/* "%s" here is the name of user on a Linux machine, such as
|
|
"root" */
|
|
N_("[Items ]not owned by \"%s\""),
|
|
NULL},
|
|
{"is",
|
|
/* "%s" here is the name of user on a Linux machine, such as
|
|
"root" */
|
|
N_("[Items ]owned by \"%s\""),
|
|
NULL},
|
|
{"has_uid",
|
|
N_("[Items ]with owner UID \"%s\""),
|
|
NULL},
|
|
{"does_not_have_uid",
|
|
N_("[Items ]with owner UID other than \"%s\""),
|
|
NULL},
|
|
{NULL, NULL, NULL}
|
|
};
|
|
|
|
/* -------------------------------------------------------
|
|
- size -
|
|
-------------------------------------------------------
|
|
*/
|
|
static operand_criterion_item size2_table [] = {
|
|
{"larger_than",
|
|
N_("[Items ]larger than %s bytes"),
|
|
NULL},
|
|
{"smaller_than",
|
|
N_("[Items ]smaller than %s bytes"),
|
|
NULL},
|
|
{"is",
|
|
N_("[Items ]of %s bytes"),
|
|
NULL},
|
|
{NULL, NULL, NULL}
|
|
};
|
|
|
|
/* -------------------------------------------------------
|
|
- modified time -
|
|
-------------------------------------------------------
|
|
*/
|
|
static operand_criterion_item mod_time2_table [] = {
|
|
{"is today",
|
|
N_("[Items ]modified today"),
|
|
NULL},
|
|
{"is yesterday",
|
|
N_("[Items ]modified yesterday"),
|
|
NULL},
|
|
{"is",
|
|
N_("[Items ]modified on %s"), NULL},
|
|
{"is_not",
|
|
N_("[Items ]not modified on %s"),
|
|
NULL},
|
|
{"is_before",
|
|
N_("[Items ]modified before %s"),
|
|
NULL},
|
|
{"is_after",
|
|
N_("[Items ]modified after %s"),
|
|
NULL},
|
|
{"is_within_a_week_of",
|
|
N_("[Items ]modified within a week of %s"),
|
|
NULL},
|
|
{"is_within_a_month_of",
|
|
N_("[Items ]modified within a month of %s"),
|
|
NULL},
|
|
{NULL, NULL, NULL}
|
|
};
|
|
|
|
/* -------------------------------------------------------
|
|
- emblems -
|
|
-------------------------------------------------------
|
|
*/
|
|
|
|
static operand_criterion_item emblem2_table [] = {
|
|
{ "include",
|
|
/* "%s" here is the name of an Emblem */
|
|
N_("[Items ]marked with \"%s\""),
|
|
NULL},
|
|
{ "do_not_include",
|
|
/* "%s" here is the name of an Emblem */
|
|
N_("[Items ]not marked with \"%s\""),
|
|
NULL},
|
|
{NULL, NULL, NULL}
|
|
};
|
|
|
|
|
|
/* -------------------------------------------------------
|
|
- contains -
|
|
-------------------------------------------------------
|
|
*/
|
|
|
|
|
|
static operand_criterion_item contains2_table [] = {
|
|
{"includes_all_of",
|
|
/* "%s" here is a word or words present in the file, for
|
|
example "nautilus" or "apple orange" */
|
|
N_("[Items ]with all the words \"%s\""),
|
|
NULL},
|
|
{"includes_any_of",
|
|
/* "%s" here is a word or words present in the file, for
|
|
example "nautilus" or "apple orange" */
|
|
N_("[Items ]containing one of the words \"%s\""),
|
|
NULL},
|
|
{"does_not_include_all_of",
|
|
/* "%s" here is a word or words present in the file, for
|
|
example "nautilus" or "apple orange" */
|
|
N_("[Items ]without all the words \"%s\""),
|
|
NULL},
|
|
{"does_not_include_any_of",
|
|
/* "%s" here is a word or words present in the file, for
|
|
example "nautilus" or "apple orange" */
|
|
N_("[Items ]without any of the words \"%s\""),
|
|
NULL},
|
|
{NULL, NULL, NULL},
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------------------
|
|
- main table -
|
|
------------------------------------------------------- */
|
|
static field_criterion_item main_table[] = {
|
|
{"file_name",
|
|
NULL,
|
|
file_name2_table},
|
|
{"file_type",
|
|
NULL,
|
|
file_type2_table},
|
|
{"owner",
|
|
NULL,
|
|
owner2_table},
|
|
{"size",
|
|
NULL,
|
|
size2_table},
|
|
{"content",
|
|
NULL,
|
|
contains2_table},
|
|
{"modified",
|
|
NULL,
|
|
mod_time2_table},
|
|
{"keywords",
|
|
NULL,
|
|
emblem2_table},
|
|
{NULL, NULL}
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
* get_item_number:
|
|
* @current_table: the table to parse.
|
|
* @item: the string to search into the table.
|
|
*
|
|
* Small helper function which allows whoich serches for @item
|
|
* into the @current_table.
|
|
* it returns -1 if it could not find it.
|
|
* Yes, I know it is wrong to use the normal function return value
|
|
* to pass error status. */
|
|
static int
|
|
get_item_number (field_criterion_item *current_table, char *item)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
while (strcmp (current_table[i].id,
|
|
item) != 0) {
|
|
i++;
|
|
if (current_table[i].id == NULL) {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
return i;
|
|
}
|
|
|
|
/**
|
|
* get_translated_criterion:
|
|
* @criterion: criterion uri to parse
|
|
*
|
|
* Returns a translated string for a given criterion uri.
|
|
*/
|
|
static char *
|
|
get_translated_criterion (GList *criterion)
|
|
{
|
|
|
|
int item_number, value_item_number;
|
|
operand_criterion_item *operand_table;
|
|
value_criterion_item *value_table;
|
|
char *ret_val;
|
|
char *context_stripped_operand, *context_stripped_value;
|
|
|
|
/* make sure we got a valid criterion */
|
|
if (g_list_length (criterion) != 3) {
|
|
return NULL;
|
|
}
|
|
|
|
|
|
/* get through begening of criterion structure */
|
|
item_number = get_item_number (main_table, (char *)criterion->data);
|
|
if (item_number == -1) {
|
|
return NULL;
|
|
}
|
|
operand_table = main_table[item_number].items;
|
|
criterion = criterion->next;
|
|
|
|
/* get through operanddle criterion structure */
|
|
item_number = get_item_number ((field_criterion_item *)operand_table,
|
|
(char *)criterion->data);
|
|
if (item_number == -1) {
|
|
return NULL;
|
|
}
|
|
value_table = operand_table[item_number].items;
|
|
criterion = criterion->next;
|
|
|
|
/* get through value criterion structure.
|
|
The fun begins NOW. */
|
|
|
|
if (value_table == NULL && operand_table[item_number].translation != NULL) {
|
|
/* simplest case: if the pointer to the value criterion
|
|
structure is NULL and we have a translation,
|
|
we output a concat of the translation and the
|
|
last part of the uri.
|
|
*/
|
|
context_stripped_operand = eel_str_remove_bracketed_text (_(operand_table[item_number].translation));
|
|
ret_val = g_strdup_printf (context_stripped_operand,
|
|
(char *) criterion->data);
|
|
g_free (context_stripped_operand);
|
|
return ret_val;
|
|
} else if (value_table != NULL) {
|
|
/* get through level 3 structure */
|
|
|
|
value_item_number = get_item_number ((field_criterion_item *) value_table,
|
|
(char *) criterion->data);
|
|
if (value_item_number == -1) {
|
|
return NULL;
|
|
}
|
|
|
|
if (operand_table[item_number].translation == NULL) {
|
|
/* if we had no translation in operand criterion table */
|
|
ret_val = eel_str_remove_bracketed_text (_(value_table[value_item_number].translation));
|
|
} else {
|
|
/* if we have both some translation in level 2 and level 3 */
|
|
context_stripped_operand = eel_str_remove_bracketed_text (_(operand_table[item_number].translation));
|
|
context_stripped_value = eel_str_remove_bracketed_text (_(value_table[value_item_number].translation));
|
|
ret_val = g_strdup_printf (context_stripped_operand, context_stripped_value);
|
|
g_free (context_stripped_operand);
|
|
g_free (context_stripped_value);
|
|
}
|
|
return ret_val;
|
|
}
|
|
|
|
return g_strdup ("");
|
|
}
|
|
|
|
|
|
/**
|
|
* get_nth_criterion_prefix:
|
|
* @criterion: The GList whose data field points to the criterion GList.
|
|
*
|
|
* calculates the "," or "and" prefix for any criterion.
|
|
*
|
|
* return value: the translated prefix.
|
|
*/
|
|
static char *
|
|
get_nth_criterion_prefix (GList *criterion)
|
|
{
|
|
/* if we are the last criterion, put it here. */
|
|
|
|
/* Human readable description for a criterion in a search for
|
|
files. Bracketed items are context, and are message
|
|
strings elsewhere. Translate only the words "and" here. */
|
|
if (criterion->next == NULL) {
|
|
|
|
return eel_str_remove_bracketed_text (_("[Items larger than 400K] and [without all the words \"apple orange\"]"));
|
|
}
|
|
/* Human readable description for a criterion in a search for
|
|
files. Bracketed items are context, and are message
|
|
strings elsewhere. Translate only the words "and" here. */
|
|
return eel_str_remove_bracketed_text (_("[Items larger than 400K], [owned by root and without all the words \"apple orange\"]"));
|
|
}
|
|
|
|
/**
|
|
* parse_uri:
|
|
* @search_uri: uri to translate.
|
|
*
|
|
* returns the translated version of the uri.
|
|
*/
|
|
static char *
|
|
parse_uri (const char *search_uri)
|
|
{
|
|
GList *criteria, *criterion;
|
|
char *translated_criterion, *translated_prefix;
|
|
char *ret_val, *temp;
|
|
|
|
criteria = tokenize_uri (search_uri);
|
|
if (criteria == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
/* processes the first criterion and add the necessary "whose" prefix */
|
|
translated_criterion = get_translated_criterion ((GList *)criteria->data);
|
|
if (translated_criterion == NULL) {
|
|
free_tokenized_uri (criteria);
|
|
return NULL;
|
|
}
|
|
/* The beginning of the description of a search that has just been
|
|
performed. The "%s" here is a description of a single criterion,
|
|
which in english might be "that contain the word 'foo'" */
|
|
ret_val = g_strdup_printf (_("Items %s"),
|
|
translated_criterion);
|
|
g_free (translated_criterion);
|
|
|
|
/* processes the other criteria and add the necessary "and" prefixes */
|
|
for (criterion = criteria->next; criterion != NULL; criterion = criterion->next) {
|
|
translated_criterion = get_translated_criterion (criterion->data);
|
|
if (translated_criterion == NULL) {
|
|
g_free (ret_val);
|
|
free_tokenized_uri (criteria);
|
|
return NULL;
|
|
}
|
|
translated_prefix = get_nth_criterion_prefix (criterion);
|
|
temp = g_strconcat (ret_val, translated_prefix,
|
|
translated_criterion, NULL);
|
|
g_free (ret_val);
|
|
ret_val = temp;
|
|
g_free (translated_criterion);
|
|
g_free (translated_prefix);
|
|
}
|
|
|
|
free_tokenized_uri (criteria);
|
|
|
|
return ret_val;
|
|
}
|
|
|
|
|
|
/**
|
|
* nautilus_search_uri_to_human:
|
|
* @search_uri: search uri to translate to human langage.
|
|
*
|
|
* The returned string is already localized.
|
|
*/
|
|
char *
|
|
nautilus_search_uri_to_human (const char *search_uri)
|
|
{
|
|
char *uri, *human;
|
|
|
|
g_return_val_if_fail (search_uri != NULL, NULL);
|
|
|
|
uri = gnome_vfs_unescape_string_for_display (search_uri);
|
|
human = parse_uri (uri);
|
|
if (human == NULL) {
|
|
return uri;
|
|
}
|
|
|
|
g_free (uri);
|
|
|
|
return human;
|
|
}
|
|
|
|
char *
|
|
nautilus_get_target_uri_from_search_result_name (const char *search_result_name)
|
|
{
|
|
return gnome_vfs_unescape_string (search_result_name, NULL);
|
|
}
|
|
|
|
gboolean
|
|
nautilus_is_search_uri (const char *uri)
|
|
{
|
|
g_return_val_if_fail (uri != NULL, FALSE);
|
|
|
|
return eel_istr_has_prefix (uri, "search:")
|
|
|| eel_istr_has_prefix (uri, "gnome-search:");
|
|
}
|
|
|
|
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
|
|
|
|
void
|
|
nautilus_self_check_search_uri (void)
|
|
{
|
|
/* search_uri_to_human */
|
|
|
|
/* make sure that it does not accept non-supported uris.*/
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (""), "");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("s"), "s");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (" "), " ");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (" "), " ");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (" s"), " s");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (" s "), " s ");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("xxx:yyy"), "xxx:yyy");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]"), "search:[][]");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]fi"), "search:[][]fi");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name"),
|
|
"search:[][]file_name");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name cont"),
|
|
"search:[][]file_name cont");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains"),
|
|
"search:[][]file_name contains");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name c stuff"),
|
|
"search:[][]file_name c stuff");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]&"),
|
|
"search:[][]&");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]f & s"),
|
|
"search:[][]f & s");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & f"),
|
|
"search:[][]file_name contains stuff & f");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & file_type i"),
|
|
"search:[][]file_name contains stuff & file_type i");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & file_type is f"),
|
|
"search:[][]file_name contains stuff & file_type is f");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stu)ff & file_type is file"),
|
|
"search:[][]file_name contains stu)ff & file_type is file");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stu(ff & file_type is file"),
|
|
"search:[][]file_name contains stu(ff & file_type is file");
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stu|ff & file_type is file"),
|
|
"search:[][]file_name contains stu|ff & file_type is file");
|
|
|
|
/* make sure all the code paths work */
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff"),
|
|
_("Items containing \"stuff\" in their names"));
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_type is file"),
|
|
_("Items that are regular files"));
|
|
/* FIXME bugzilla.eazel.com 5088: This may be what the function calls "human", but it's bad grammar. */
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & file_type is file"),
|
|
_("Items containing \"stuff\" in their names and that are regular files"));
|
|
/* FIXME bugzilla.eazel.com 5088: This may be what the function calls "human", but it's bad grammar. */
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & file_type is file"
|
|
" & size smaller_than 2000"),
|
|
_("Items containing \"stuff\" in their names, that are regular files and "
|
|
"smaller than 2000 bytes"));
|
|
/* FIXME bugzilla.eazel.com 5088: This may be what the function calls "human", but it's bad grammar. */
|
|
EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains medusa & file_type is directory"),
|
|
_("Items containing \"medusa\" in their names and that are "
|
|
"folders"));
|
|
|
|
/* is_search_uri */
|
|
EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri (""), FALSE);
|
|
EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("search:"), TRUE);
|
|
EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("gnome-search:"), TRUE);
|
|
EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("xxx-search:"), FALSE);
|
|
EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("search:xxx"), TRUE);
|
|
EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("gnome-search:xxx"), TRUE);
|
|
EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("xxx-search:xxx"), FALSE);
|
|
}
|
|
|
|
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
|
|
|