PATCH for Search in folders (was Re: [Usability] Some usability feedback)
- From: Jamie McCracken <jamiemcc blueyonder co uk>
- To: Alan Horkan <horkana maths tcd ie>
- Cc: Gnome Usability <usability gnome org>, Nautilus <nautilus-list gnome org>
- Subject: PATCH for Search in folders (was Re: [Usability] Some usability feedback)
- Date: Tue, 30 Nov 2004 01:33:07 +0000
> On Mon, 2004-11-29 at 16:05 +0000, Alan Horkan wrote:
> > > It could of course be in the edit menu as well.
> >
> > Would definately be useful to have it in the menus.
> >
> > Thanks
> >
> > - Alan H.
Attached is a patch for Nautilus which implements search in folders via
the gnome-search-tool. Its accessible in both the main edit menu and in
the selection context menu for a folder.
Theres a keyboard shortcut of Shift+Ctlr+S to open the search tool too.
The ability to launch the search tool is limited to when either a folder
is selected or no item is selected (search tool defaults to current
folder in that case).
jamie.
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.643
diff -u -r1.643 fm-directory-view.c
--- src/file-manager/fm-directory-view.c 11 Oct 2004 11:49:00 -0000 1.643
+++ src/file-manager/fm-directory-view.c 30 Nov 2004 01:20:30 -0000
@@ -120,6 +120,7 @@
#define FM_DIRECTORY_VIEW_COMMAND_RENAME "/commands/Rename"
#define FM_DIRECTORY_VIEW_COMMAND_OPEN "/commands/Open"
#define FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE "/commands/OpenAlternate"
+#define FM_DIRECTORY_VIEW_COMMAND_SEARCH "/commands/Search"
#define FM_DIRECTORY_VIEW_COMMAND_OPEN_WITH "/commands/Open With"
#define FM_DIRECTORY_VIEW_COMMAND_NEW_FOLDER "/commands/New Folder"
#define FM_DIRECTORY_VIEW_COMMAND_NEW_LAUNCHER "/commands/New Launcher"
@@ -5586,6 +5587,42 @@
}
+static void
+search_folder_callback (BonoboUIComponent *component,
+ gpointer user_data,
+ const char *verb)
+{
+ char *uri, *displayname, *command;
+ GnomeVFSURI *uri_vfs;
+ GList *selection;
+ const GList *node;
+ FMDirectoryView *view;
+
+ view = FM_DIRECTORY_VIEW (user_data);
+
+ selection = fm_directory_view_get_selection (view);
+ if (selection == NULL) {
+ uri = nautilus_file_get_uri (view->details->directory_as_file);
+ } else {
+ node = g_list_first (selection);
+ uri = nautilus_file_get_uri ((NautilusFile *) node->data);
+ nautilus_file_list_free (selection);
+ }
+ uri_vfs = gnome_vfs_uri_new (uri);
+ displayname = gnome_vfs_uri_to_string (uri_vfs, GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD);
+ gnome_vfs_uri_unref (uri_vfs);
+ g_free (uri);
+ if (view->details->show_hidden_files) {
+ command = g_strconcat ("gnome-search-tool --path=", displayname, " --hidden", NULL);
+ } else {
+ command = g_strconcat ("gnome-search-tool --path=", displayname, NULL);
+ }
+ g_free (displayname);
+ eel_gnome_shell_execute_on_screen (command, gtk_widget_get_screen (GTK_WIDGET (view)));
+ g_free (command);
+
+}
+
static void
real_merge_menus (FMDirectoryView *view)
{
@@ -5605,6 +5642,7 @@
BONOBO_UI_VERB ("OpenCloseParent", open_close_parent_callback),
BONOBO_UI_VERB ("OpenAlternate", open_alternate_callback),
BONOBO_UI_VERB ("OtherApplication", other_application_callback),
+ BONOBO_UI_VERB ("Search", search_folder_callback),
BONOBO_UI_VERB ("Edit Launcher", edit_launcher_callback),
BONOBO_UI_VERB ("Paste Files", paste_files_callback),
BONOBO_UI_VERB ("Paste Files Into", paste_files_into_callback),
@@ -5917,6 +5955,7 @@
gboolean show_separate_delete_command;
gboolean vfolder_directory;
gboolean show_open_alternate;
+ gboolean show_search;
gboolean can_open;
ActivationAction action;
EelBackground *background;
@@ -6019,7 +6058,18 @@
nautilus_bonobo_set_hidden (view->details->ui,
FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE,
!show_open_alternate);
-
+
+ nautilus_bonobo_set_sensitive (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_SEARCH,
+ selection_count <= 1);
+
+ show_search = file_list_all_are_folders (selection);
+
+ nautilus_bonobo_set_hidden (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_SEARCH,
+ !show_search);
+
+
/* Broken into its own function just for convenience */
reset_bonobo_open_with_menu (view, selection);
reset_extension_actions_menu (view, selection);
Index: src/file-manager/nautilus-directory-view-ui.xml
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/nautilus-directory-view-ui.xml,v
retrieving revision 1.69
diff -u -r1.69 nautilus-directory-view-ui.xml
--- src/file-manager/nautilus-directory-view-ui.xml 4 Oct 2004 11:36:14 -0000 1.69
+++ src/file-manager/nautilus-directory-view-ui.xml 30 Nov 2004 01:20:30 -0000
@@ -33,6 +33,9 @@
<cmd name="OpenAlternate"
_label="Open in Navigation Window"
_tip="Open each selected item in a navigation window"/>
+ <cmd name="Search"
+ _label="Search In Folder..."
+ _tip="Open Search tool with current or selected folder"/>
<cmd name="Open Scripts Folder"
_label="_Open Scripts Folder"
_tip="Show the folder containing the scripts that appear in this menu"/>
@@ -200,6 +203,9 @@
<menuitem name="Select Pattern"
accel="*Control*s"
verb="Select Pattern"/>
+ <menuitem name="Search Folder..."
+ accel="*Control**Shift*s"
+ verb="Search"/>
</placeholder>
<placeholder name="File Items Placeholder">
@@ -285,6 +291,8 @@
verb="Open"/>
<menuitem name="OpenAlternate"
verb="OpenAlternate"/>
+ <menuitem name="Search Folder"
+ verb="Search"/>
<placeholder name="Applications Placeholder" delimit="top"/>
<submenu name="Open With"
_label="Open Wit_h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]