Revision: 5543 http://geany.svn.sourceforge.net/geany/?rev=5543&view=rev Author: eht16 Date: 2011-02-21 19:09:34 +0000 (Mon, 21 Feb 2011)
Log Message: ----------- Add support for multiple file filters, separated by semicolon (based on a patch by Grigory Javadyan, thanks).
Modified Paths: -------------- trunk/ChangeLog trunk/plugins/filebrowser.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-02-07 17:23:41 UTC (rev 5542) +++ trunk/ChangeLog 2011-02-21 19:09:34 UTC (rev 5543) @@ -1,3 +1,10 @@ +2011-02-21 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * plugins/filebrowser.c: + Add support for multiple file filters, separated by semicolon + (based on a patch by Grigory Javadyan, thanks). + + 2011-02-07 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* data/filetype_extensions.conf:
Modified: trunk/plugins/filebrowser.c =================================================================== --- trunk/plugins/filebrowser.c 2011-02-07 17:23:41 UTC (rev 5542) +++ trunk/plugins/filebrowser.c 2011-02-21 19:09:34 UTC (rev 5543) @@ -80,7 +80,7 @@ static gchar *current_dir = NULL; /* in locale-encoding */ static gchar *open_cmd; /* in locale-encoding */ static gchar *config_file; -static gchar *filter = NULL; +static gchar **filter = NULL;
static gint page_number = 0;
@@ -158,14 +158,21 @@ /* Returns: whether filename should be removed. */ static gboolean check_filtered(const gchar *base_name) { + gchar **filter_item; + guint len; + if (filter == NULL) return FALSE; - - if (! utils_str_equal(base_name, "*") && ! g_pattern_match_simple(filter, base_name)) + + len = g_strv_length(filter); + foreach_c_array(filter_item, filter, len) { - return TRUE; + if (utils_str_equal(base_name, "*") || g_pattern_match_simple(*filter_item, base_name)) + { + return FALSE; + } } - return FALSE; + return TRUE; }
@@ -728,9 +735,19 @@ }
+static void clear_filter(void) +{ + if (filter != NULL) + { + g_strfreev(filter); + filter = NULL; + } +} + + static void on_clear_filter(GtkEntry *entry, gpointer user_data) { - setptr(filter, NULL); + clear_filter();
gtk_entry_set_text(GTK_ENTRY(filter_entry), "");
@@ -777,13 +794,11 @@
static void on_filter_activate(GtkEntry *entry, gpointer user_data) { - setptr(filter, g_strdup(gtk_entry_get_text(entry))); - - if (! NZV(filter)) + filter = g_strsplit(gtk_entry_get_text(entry), ";", -1); + if (filter == NULL || g_strv_length(filter) == 0) { - setptr(filter, g_strdup("*")); + clear_filter(); } - refresh(); }
@@ -791,8 +806,7 @@ static void on_filter_clear(GtkEntry *entry, gint icon_pos, GdkEvent *event, gpointer data) { - setptr(filter, g_strdup("*")); - + clear_filter(); refresh(); }
@@ -896,7 +910,7 @@ g_signal_connect(filter_entry, "icon-release", G_CALLBACK(on_filter_clear), NULL); } ui_widget_set_tooltip_text(filter_entry, - _("Filter your files with usual wildcards")); + _("Filter your files with usual wildcards, separate multiple filters with ";"")); g_signal_connect(filter_entry, "activate", G_CALLBACK(on_filter_activate), NULL);
gtk_box_pack_start(GTK_BOX(filterbar), label, FALSE, FALSE, 0); @@ -1080,7 +1094,7 @@ GtkWidget *scrollwin, *toolbar, *filterbar;
filter = NULL; - + file_view_vbox = gtk_vbox_new(FALSE, 0); toolbar = make_toolbar(); gtk_box_pack_start(GTK_BOX(file_view_vbox), toolbar, FALSE, FALSE, 0); @@ -1252,7 +1266,7 @@
g_free(config_file); g_free(open_cmd); - g_free(filter); + clear_filter(); gtk_widget_destroy(file_view_vbox); g_object_unref(G_OBJECT(entry_completion)); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.