Commit e83213d0 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen
Browse files

Apply a patch to reset the filter if an otherwise invisible file is

2004-12-09  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkfilechooserdefault.c: Apply a patch to reset the
	filter if an otherwise invisible file is selected via the
	location popup.  (#159896, Carlos Garnacho Parro)
parent 788bec83
2004-12-09 Matthias Clasen <mclasen@redhat.com> 2004-12-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c: Apply a patch to reset the
filter if an otherwise invisible file is selected via the
location popup. (#159896, Carlos Garnacho Parro)
Fix #145463, reported by Michael Natterer. Fix #145463, reported by Michael Natterer.
* gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an
......
2004-12-09 Matthias Clasen <mclasen@redhat.com> 2004-12-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c: Apply a patch to reset the
filter if an otherwise invisible file is selected via the
location popup. (#159896, Carlos Garnacho Parro)
Fix #145463, reported by Michael Natterer. Fix #145463, reported by Michael Natterer.
* gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an
......
2004-12-09 Matthias Clasen <mclasen@redhat.com> 2004-12-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c: Apply a patch to reset the
filter if an otherwise invisible file is selected via the
location popup. (#159896, Carlos Garnacho Parro)
Fix #145463, reported by Michael Natterer. Fix #145463, reported by Michael Natterer.
* gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an
......
2004-12-09 Matthias Clasen <mclasen@redhat.com> 2004-12-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c: Apply a patch to reset the
filter if an otherwise invisible file is selected via the
location popup. (#159896, Carlos Garnacho Parro)
Fix #145463, reported by Michael Natterer. Fix #145463, reported by Michael Natterer.
* gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an * gtk/gtkcellrenderer.h (struct _GtkCellRenderer): Add an
......
...@@ -3994,22 +3994,14 @@ gtk_file_chooser_default_screen_changed (GtkWidget *widget, ...@@ -3994,22 +3994,14 @@ gtk_file_chooser_default_screen_changed (GtkWidget *widget,
} }
static gboolean static gboolean
list_model_filter_func (GtkFileSystemModel *model, get_is_file_filtered (GtkFileChooserDefault *impl,
GtkFilePath *path, GtkFilePath *path,
const GtkFileInfo *file_info, GtkFileInfo *file_info)
gpointer user_data)
{ {
GtkFileChooserDefault *impl = user_data;
GtkFileFilterInfo filter_info; GtkFileFilterInfo filter_info;
GtkFileFilterFlags needed; GtkFileFilterFlags needed;
gboolean result; gboolean result;
if (!impl->current_filter)
return TRUE;
if (gtk_file_info_get_is_folder (file_info))
return TRUE;
filter_info.contains = GTK_FILE_FILTER_DISPLAY_NAME | GTK_FILE_FILTER_MIME_TYPE; filter_info.contains = GTK_FILE_FILTER_DISPLAY_NAME | GTK_FILE_FILTER_MIME_TYPE;
needed = gtk_file_filter_get_needed (impl->current_filter); needed = gtk_file_filter_get_needed (impl->current_filter);
...@@ -4042,18 +4034,48 @@ list_model_filter_func (GtkFileSystemModel *model, ...@@ -4042,18 +4034,48 @@ list_model_filter_func (GtkFileSystemModel *model,
if (filter_info.uri) if (filter_info.uri)
g_free ((gchar *)filter_info.uri); g_free ((gchar *)filter_info.uri);
return result; return !result;
}
static gboolean
list_model_filter_func (GtkFileSystemModel *model,
GtkFilePath *path,
const GtkFileInfo *file_info,
gpointer user_data)
{
GtkFileChooserDefault *impl = user_data;
if (!impl->current_filter)
return TRUE;
if (gtk_file_info_get_is_folder (file_info))
return TRUE;
return !get_is_file_filtered (impl, path, (GtkFileInfo *) file_info);
} }
static void static void
install_list_model_filter (GtkFileChooserDefault *impl) install_list_model_filter (GtkFileChooserDefault *impl)
{ {
GtkFileSystemModelFilter filter;
gpointer data;
g_assert (impl->browse_files_model != NULL); g_assert (impl->browse_files_model != NULL);
if (impl->current_filter) if (impl->current_filter)
{
filter = list_model_filter_func;
data = impl;
}
else
{
filter = NULL;
data = NULL;
}
_gtk_file_system_model_set_filter (impl->browse_files_model, _gtk_file_system_model_set_filter (impl->browse_files_model,
list_model_filter_func, filter,
impl); data);
} }
#define COMPARE_DIRECTORIES \ #define COMPARE_DIRECTORIES \
...@@ -4535,7 +4557,7 @@ gtk_file_chooser_default_select_path (GtkFileChooser *chooser, ...@@ -4535,7 +4557,7 @@ gtk_file_chooser_default_select_path (GtkFileChooser *chooser,
gboolean result; gboolean result;
GtkFileFolder *folder; GtkFileFolder *folder;
GtkFileInfo *info; GtkFileInfo *info;
gboolean is_hidden; gboolean is_hidden, is_filtered;
result = _gtk_file_chooser_set_current_folder_path (chooser, parent_path, error); result = _gtk_file_chooser_set_current_folder_path (chooser, parent_path, error);
...@@ -4558,11 +4580,15 @@ gtk_file_chooser_default_select_path (GtkFileChooser *chooser, ...@@ -4558,11 +4580,15 @@ gtk_file_chooser_default_select_path (GtkFileChooser *chooser,
return FALSE; return FALSE;
is_hidden = gtk_file_info_get_is_hidden (info); is_hidden = gtk_file_info_get_is_hidden (info);
is_filtered = get_is_file_filtered (impl, (GtkFilePath *) path, info);
gtk_file_info_free (info); gtk_file_info_free (info);
if (is_hidden) if (is_hidden)
g_object_set (impl, "show-hidden", TRUE, NULL); g_object_set (impl, "show-hidden", TRUE, NULL);
if (is_filtered)
set_current_filter (impl, NULL);
pending_op_queue (impl, PENDING_OP_SELECT_PATH, path); pending_op_queue (impl, PENDING_OP_SELECT_PATH, path);
return TRUE; return TRUE;
} }
...@@ -5285,10 +5311,10 @@ set_current_filter (GtkFileChooserDefault *impl, ...@@ -5285,10 +5311,10 @@ set_current_filter (GtkFileChooserDefault *impl,
{ {
int filter_index; int filter_index;
/* If we have filters, new filter must be one of them /* NULL filters are allowed to reset to non-filtered status
*/ */
filter_index = g_slist_index (impl->filters, filter); filter_index = g_slist_index (impl->filters, filter);
if (impl->filters && filter_index < 0) if (impl->filters && filter && filter_index < 0)
return; return;
if (impl->current_filter) if (impl->current_filter)
......
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