Re: [patch] select pattern
- From: James Willcox <jwillcox gnome org>
- To: Dave Camp <dave ximian com>
- Cc: nautilus-list gnome org
- Subject: Re: [patch] select pattern
- Date: Sun, 21 Sep 2003 14:41:17 -0500
On Sun, 2003-09-21 at 13:45, Dave Camp wrote:
> > --- src/nautilus-shell-ui.xml 15 Sep 2003 02:46:00
> > -0000 1.107.6.1
> > +++ src/nautilus-shell-ui.xml 21 Sep 2003 03:07:42 -0000
> > @@ -19,6 +19,7 @@
> > <cmd name="Stop"
> > _tip="Stop loading this location"/>
> > <cmd name="Select All" accel="*Control*a" sensitive="0"/>
> > + <cmd name="Select Pattern"/>
>
> I think this was left in on accident, nautilus-shell-ui.xml shouldn't
> need any changes.
>
Hmm, turns out it was needed....
>
> > + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
> > box);
> > + response = gtk_dialog_run (GTK_DIALOG (dialog));
> > +
> > + if (response == GTK_RESPONSE_OK) {
>
> This dialog probably shouldn't be modal (correct me if I'm wrong).
Oops, it was still blocking the main loop. New patch attached.
James
? nautilus-snap-2.patch
? nautilus_jwillcox_emblem_refresh_v1.diff
? nautilus_jwillcox_select_pattern_v1.diff
? nautilus_jwillcox_select_pattern_v2.diff
? nautilus_jwillcox_select_pattern_v3.diff
? nautilus_jwillcox_select_pattern_v4.diff
? libnautilus-private/.nautilus-directory.c.swp
? libnautilus-private/nautilus-dot-hidden.diff
? src/file-manager/.fm-directory-view.c.swp
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5926.2.2
diff -u -r1.5926.2.2 ChangeLog
--- ChangeLog 18 Sep 2003 19:11:15 -0000 1.5926.2.2
+++ ChangeLog 21 Sep 2003 19:38:50 -0000
@@ -1,3 +1,15 @@
+2003-09-21 James Willcox <jwillcox gnome org>
+
+ * 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-18 Dave Camp <dcamp novell com>
* libnautilus-private/nautilus-global-preferences.c:
Index: libnautilus-private/nautilus-directory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-directory.c,v
retrieving revision 1.249
diff -u -r1.249 nautilus-directory.c
--- libnautilus-private/nautilus-directory.c 29 Aug 2003 12:03:52 -0000 1.249
+++ libnautilus-private/nautilus-directory.c 21 Sep 2003 19:38:51 -0000
@@ -1630,6 +1630,37 @@
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
*
Index: libnautilus-private/nautilus-directory.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-directory.h,v
retrieving revision 1.65
diff -u -r1.65 nautilus-directory.h
--- libnautilus-private/nautilus-directory.h 29 Aug 2003 12:03:52 -0000 1.65
+++ libnautilus-private/nautilus-directory.h 21 Sep 2003 19:38:51 -0000
@@ -188,6 +188,10 @@
/* 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.
*/
Index: src/nautilus-shell-ui.xml
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-shell-ui.xml,v
retrieving revision 1.107.6.1
diff -u -r1.107.6.1 nautilus-shell-ui.xml
--- src/nautilus-shell-ui.xml 15 Sep 2003 02:46:00 -0000 1.107.6.1
+++ src/nautilus-shell-ui.xml 21 Sep 2003 19:38:52 -0000
@@ -120,6 +120,9 @@
<menuitem name="Select All"
_label="Select _All"
verb="Select All"/>
+ <menuitem name="Select Pattern"
+ _label="Select _Pattern"
+ verb="Select Pattern"/>
<placeholder name="File Items Placeholder" delimit="top"/>
<placeholder name="Dangerous File Items Placeholder" delimit="top"/>
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.580.6.1
diff -u -r1.580.6.1 fm-directory-view.c
--- src/file-manager/fm-directory-view.c 15 Sep 2003 02:46:31 -0000 1.580.6.1
+++ src/file-manager/fm-directory-view.c 21 Sep 2003 19:38:54 -0000
@@ -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>
@@ -938,6 +940,79 @@
}
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,
const char *verb)
@@ -4652,6 +4727,7 @@
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
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.53.6.1
diff -u -r1.53.6.1 nautilus-directory-view-ui.xml
--- src/file-manager/nautilus-directory-view-ui.xml 15 Sep 2003 02:46:33 -0000 1.53.6.1
+++ src/file-manager/nautilus-directory-view-ui.xml 21 Sep 2003 19:38:55 -0000
@@ -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"/>
@@ -146,6 +149,8 @@
<menuitem name="Select All"
accel="*Control*a"
verb="Select All"/>
+ <menuitem name="Select Pattern"
+ verb="Select Pattern"/>
<placeholder name="File Items Placeholder">
<menuitem name="Duplicate"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]