Commit 85e1e3dd authored by James Willcox's avatar James Willcox Committed by James Willcox

Add a "Edit->Select Pattern" menu entry


2003-09-25  James Willcox  <james@ximian.com>

	* libnautilus-private/nautilus-directory.c:
	(nautilus_directory_match_glob):
	* libnautilus-private/nautilus-directory.h:
	* src/file-manager/fm-directory-view.c: (get_pattern_selection),
	(bonobo_menu_select_pattern_callback), (real_merge_menus):
	* src/file-manager/nautilus-directory-view-ui.xml:
	* src/nautilus-shell-ui.xml:

 	Add a "Edit->Select Pattern" menu entry
parent 6a263ae1
2003-09-25 James Willcox <james@ximian.com>
* libnautilus-private/nautilus-directory.c:
(nautilus_directory_match_glob):
* libnautilus-private/nautilus-directory.h:
* src/file-manager/fm-directory-view.c: (get_pattern_selection),
(bonobo_menu_select_pattern_callback), (real_merge_menus):
* src/file-manager/nautilus-directory-view-ui.xml:
* src/nautilus-shell-ui.xml:
Add a "Edit->Select Pattern" menu entry
2003-09-25 Ettore Perazzoli <ettore@ximian.com>
* src/file-manager/fm-directory-view.c
......
......@@ -1630,6 +1630,37 @@ nautilus_directory_get_file_list (NautilusDirectory *directory)
return non_tentative_files;
}
GList *
nautilus_directory_match_pattern (NautilusDirectory *directory, const char *pattern)
{
GList *files, *l, *ret;
GPatternSpec *spec;
ret = NULL;
spec = g_pattern_spec_new (pattern);
files = nautilus_directory_get_file_list (directory);
for (l = files; l; l = l->next) {
NautilusFile *file;
char *name;
file = NAUTILUS_FILE (l->data);
name = nautilus_file_get_display_name (file);
if (g_pattern_match_string (spec, name)) {
ret = g_list_prepend(ret, nautilus_file_ref (file));
}
g_free (name);
}
g_pattern_spec_free (spec);
nautilus_file_list_free (files);
return ret;
}
/**
* nautilus_directory_list_ref
*
......
......@@ -188,6 +188,10 @@ void nautilus_directory_force_reload (NautilusDirector
/* Get a list of all files currently known in the directory. */
GList * nautilus_directory_get_file_list (NautilusDirectory *directory);
GList * nautilus_directory_match_pattern (NautilusDirectory *directory,
const char *glob);
/* Return true if the directory has information about all the files.
* This will be false until the directory has been read at least once.
*/
......
......@@ -55,6 +55,8 @@
#include <gtk/gtksignal.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkentry.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-uidefs.h>
......@@ -952,6 +954,79 @@ bonobo_menu_select_all_callback (BonoboUIComponent *component,
fm_directory_view_select_all (callback_data);
}
static void
pattern_select_response_cb (GtkWidget *dialog, int response, gpointer user_data)
{
FMDirectoryView *view;
GtkWidget *entry;
view = FM_DIRECTORY_VIEW (user_data);
if (response == GTK_RESPONSE_OK) {
NautilusDirectory *directory;
GList *selection;
entry = g_object_get_data (G_OBJECT (dialog), "entry");
directory = fm_directory_view_get_model (view);
selection = nautilus_directory_match_pattern (directory,
gtk_entry_get_text (GTK_ENTRY (entry)));
if (selection) {
fm_directory_view_set_selection(view, selection);
nautilus_file_list_free (selection);
}
}
gtk_widget_destroy (dialog);
}
static void
select_pattern (FMDirectoryView *view)
{
GtkWidget *dialog;
GtkWidget *box;
GtkWidget *entry;
GList *ret;
ret = NULL;
dialog = gtk_dialog_new_with_buttons (_("Select Pattern"),
fm_directory_view_get_containing_window (view),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OK,
GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_OK);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
box = gtk_hbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (box), 6);
entry = gtk_entry_new ();
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
gtk_box_pack_start_defaults (GTK_BOX (box),
gtk_label_new (_("Pattern:")));
gtk_box_pack_start_defaults (GTK_BOX (box), entry);
gtk_widget_show_all (box);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
g_object_set_data (G_OBJECT (dialog), "entry", entry);
g_signal_connect (dialog, "response",
G_CALLBACK (pattern_select_response_cb),
view);
gtk_widget_show_all (dialog);
}
static void
bonobo_menu_select_pattern_callback (BonoboUIComponent *component,
gpointer callback_data,
const char *verb)
{
g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
select_pattern(callback_data);
}
static void
reset_to_defaults_callback (BonoboUIComponent *component,
gpointer callback_data,
......@@ -4615,6 +4690,7 @@ real_merge_menus (FMDirectoryView *view)
BONOBO_UI_VERB ("Reset Background", reset_background_callback),
BONOBO_UI_VERB ("Reset to Defaults", reset_to_defaults_callback),
BONOBO_UI_VERB ("Select All", bonobo_menu_select_all_callback),
BONOBO_UI_VERB ("Select Pattern", bonobo_menu_select_pattern_callback),
BONOBO_UI_VERB ("Properties", open_properties_window_callback),
BONOBO_UI_VERB ("Trash", trash_callback),
BONOBO_UI_VERB_END
......
......@@ -60,6 +60,9 @@
<cmd name="Select All"
_label="Select _All Files"
_tip="Select all items in this window"/>
<cmd name="Select Pattern"
_label="Select _Pattern"
_tip="Select items in this window matching a given pattern"/>
<cmd name="Properties"
_label="_Properties"
_tip="View or modify the properties of each selected item"/>
......@@ -142,9 +145,14 @@
accel="*Control*v"
pixtype="stock" pixname="gtk-paste"
verb="Paste Files"/>
<placeholder name="Select Items">
<menuitem name="Select All"
accel="*Control*a"
verb="Select All"/>
<menuitem name="Select Pattern"
verb="Select Pattern"/>
</placeholder>
<placeholder name="File Items Placeholder">
<menuitem name="Duplicate"
......
......@@ -128,9 +128,12 @@
<separator/>
<placeholder name="Select Items">
<menuitem name="Select All"
_label="Select _All"
verb="Select All"/>
</placeholder>
<placeholder name="File Items Placeholder" delimit="top"/>
<placeholder name="Dangerous File Items Placeholder" delimit="top"/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment