Commit 50329fa7 authored by Matthias Clasen's avatar Matthias Clasen

Privately export this method. It classifies directories and mountables the

        * gtk/gtkfilesystem.[hc] (_gtk_file_info_consider_as_directory):
        Privately export this method. It classifies directories and mountables
        the same.

        * gtk/gtkfilesystem.c (enclosing_volume_mount_cb): Silently drop
        G_IO_ERROR_ALREADY_MOUNTED error for gvfs backends without visible
        mounts.

        * gtk/gtkfilesystemmodel.c:
        * gtk/gtkfilechooserbutton.c:
        * gtk/gtkfilechooserentry.c:
        * gtk/gtkfilechooserdefault.c: Use the new function instead of
        direct checks for G_FILE_TYPE_DIRECTORY throughout.


svn path=/trunk/; revision=21898
parent d68d9790
2008-12-13 Matthias Clasen <mclasen@redhat.com>
Bug 561494 – FileChooser network browsing and authentication support
* gtk/gtkfilesystem.[hc] (_gtk_file_info_consider_as_directory):
Privately export this method. It classifies directories and mountables
the same.
* gtk/gtkfilesystem.c (enclosing_volume_mount_cb): Silently drop
G_IO_ERROR_ALREADY_MOUNTED error for gvfs backends without visible
mounts.
* gtk/gtkfilesystemmodel.c:
* gtk/gtkfilechooserbutton.c:
* gtk/gtkfilechooserentry.c:
* gtk/gtkfilechooserdefault.c: Use the new function instead of
direct checks for G_FILE_TYPE_DIRECTORY throughout.
2008-12-13 Matthias Clasen <mclasen@redhat.com>
Bug 562579 – Remove error dialog when directory does not exist
......
......@@ -998,7 +998,7 @@ dnd_select_folder_get_info_cb (GCancellable *cancellable,
{
gboolean is_folder;
is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
is_folder = _gtk_file_info_consider_as_directory (info);
data->selected =
(((data->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER && is_folder) ||
......@@ -1455,7 +1455,7 @@ set_info_get_info_cb (GCancellable *cancellable,
if (!data->label)
data->label = g_strdup (g_file_info_get_display_name (info));
is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
is_folder = _gtk_file_info_consider_as_directory (info);
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
ICON_COLUMN, pixbuf,
......
......@@ -2771,7 +2771,7 @@ selection_check_foreach_cb (GtkTreeModel *model,
case OPERATION_MODE_BROWSE:
gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
info = _gtk_file_system_model_get_info (closure->impl->browse_files_model, &child_iter);
is_folder = info ? (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) : FALSE;
is_folder = info ? (_gtk_file_info_consider_as_directory (info)) : FALSE;
break;
case OPERATION_MODE_SEARCH:
......@@ -4177,8 +4177,7 @@ file_list_drag_data_received_get_info_cb (GCancellable *cancellable,
if ((data->impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
data->impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) &&
data->uris[1] == 0 && !error &&
g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
data->uris[1] == 0 && !error && _gtk_file_info_consider_as_directory (info))
change_folder_and_display_error (data->impl, data->file, FALSE);
else
{
......@@ -6127,7 +6126,7 @@ list_model_filter_func (GtkFileSystemModel *model,
if (!impl->current_filter)
return TRUE;
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
if (_gtk_file_info_consider_as_directory (file_info))
return TRUE;
return !get_is_file_filtered (impl, file, file_info);
......@@ -6164,12 +6163,12 @@ install_list_model_filter (GtkFileChooserDefault *impl)
gboolean dir_a, dir_b; \
\
if (info_a) \
dir_a = (g_file_info_get_file_type (info_a) == G_FILE_TYPE_DIRECTORY); \
dir_a = _gtk_file_info_consider_as_directory (info_a); \
else \
return impl->list_sort_ascending ? -1 : 1; \
\
if (info_b) \
dir_b = (g_file_info_get_file_type (info_b) == G_FILE_TYPE_DIRECTORY); \
dir_b = _gtk_file_info_consider_as_directory (info_b); \
else \
return impl->list_sort_ascending ? 1 : -1; \
\
......@@ -6451,9 +6450,9 @@ show_and_select_files_finished_loading (GtkFolder *folder,
have_hidden = g_file_info_get_is_hidden (info);
if (!have_filtered)
have_filtered = (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY) &&
have_filtered = (! _gtk_file_info_consider_as_directory (info)) &&
get_is_file_filtered (data->impl, file, info);
g_object_unref (info);
if (have_hidden && have_filtered)
......@@ -6786,7 +6785,7 @@ update_chooser_entry (GtkFileChooserDefault *impl)
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
{
/* We don't want the name to change when clicking on a folder... */
change_entry = (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY);
change_entry = (! _gtk_file_info_consider_as_directory (info));
}
else
change_entry = TRUE; /* ... unless we are in SELECT_FOLDER mode */
......@@ -6946,7 +6945,7 @@ update_current_folder_get_info_cb (GCancellable *cancellable,
g_object_unref (data->original_file);
}
if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY)
if (! _gtk_file_info_consider_as_directory (info))
goto out;
if (!_gtk_path_bar_set_file (GTK_PATH_BAR (impl->browse_path_bar), data->file, data->keep_trail, NULL))
......@@ -7229,7 +7228,7 @@ maybe_select (GtkTreeModel *model,
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
info = get_list_file_info (impl, iter);
is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
is_folder = _gtk_file_info_consider_as_directory (info);
if ((is_folder && impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) ||
(!is_folder && impl->action == GTK_FILE_CHOOSER_ACTION_OPEN))
......@@ -7627,7 +7626,7 @@ add_shortcut_get_info_cb (GCancellable *cancellable,
data->impl->loading_shortcuts = g_slist_remove (data->impl->loading_shortcuts, cancellable);
if (cancelled || error || g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY)
if (cancelled || error || (! _gtk_file_info_consider_as_directory (info)))
goto out;
pos = shortcuts_get_pos_for_shortcut_folder (data->impl, data->impl->num_shortcuts);
......@@ -8175,7 +8174,7 @@ save_entry_get_info_cb (GCancellable *cancellable,
if (!info)
parent_is_folder = FALSE;
else
parent_is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
parent_is_folder = _gtk_file_info_consider_as_directory (info);
if (parent_is_folder)
{
......@@ -8245,7 +8244,7 @@ file_exists_get_info_cb (GCancellable *cancellable,
if (cancelled)
goto out;
file_exists_and_is_not_folder = info && (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY);
file_exists_and_is_not_folder = info && (! _gtk_file_info_consider_as_directory (info));
if (data->impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
/* user typed a filename; we are done */
......@@ -8665,7 +8664,7 @@ search_hit_get_info_cb (GCancellable *cancellable,
g_file_info_get_modification_time (info, &mtime);
modification_time = (guint64) mtime.tv_sec;
size = g_file_info_get_size (info);
is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
is_folder = _gtk_file_info_consider_as_directory (info);
pixbuf = _gtk_file_info_render_icon (info, GTK_WIDGET (request->impl),
request->impl->icon_size);
......@@ -9755,7 +9754,7 @@ recent_item_get_info_cb (GCancellable *cancellable,
goto out;
}
is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
is_folder = _gtk_file_info_consider_as_directory (info);
gtk_list_store_set (request->impl->recent_model, &iter,
RECENT_MODEL_COL_IS_FOLDER, is_folder,
......@@ -10323,7 +10322,7 @@ shortcuts_activate_get_info_cb (GCancellable *cancellable,
if (cancelled)
goto out;
if (!error && g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
if (!error && _gtk_file_info_consider_as_directory (info))
change_folder_and_display_error (data->impl, data->file, FALSE);
else
gtk_file_chooser_default_select_file (GTK_FILE_CHOOSER (data->impl),
......@@ -10545,7 +10544,7 @@ list_select_func (GtkTreeSelection *selection,
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &iter);
info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
if (info && g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY)
if (info && (! _gtk_file_info_consider_as_directory (info)))
return FALSE;
}
break;
......@@ -10657,11 +10656,27 @@ list_row_activated (GtkTreeView *tree_view,
info = _gtk_file_system_model_get_info (impl->browse_files_model,
&child_iter);
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
if (_gtk_file_info_consider_as_directory (info))
{
GFile *file;
GFile *file, *target_file;
const gchar *target_uri;
file = _gtk_file_system_model_get_file (impl->browse_files_model, &child_iter);
if (g_file_info_get_file_type (info) == G_FILE_TYPE_MOUNTABLE)
{
target_uri = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
if (target_uri)
{
target_file = g_file_new_for_uri (target_uri);
if (target_file)
{
g_object_unref (file);
file = target_file;
}
}
}
change_folder_and_display_error (impl, file, FALSE);
return;
}
......@@ -10789,7 +10804,7 @@ list_icon_data_func (GtkTreeViewColumn *tree_column,
if (info &&
(impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
sensitive = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
sensitive = _gtk_file_info_consider_as_directory (info);
}
break;
}
......@@ -10893,7 +10908,7 @@ list_name_data_func (GtkTreeViewColumn *tree_column,
if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
{
sensitive = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
sensitive = _gtk_file_info_consider_as_directory (info);
}
g_object_set (cell,
......@@ -10951,7 +10966,7 @@ list_size_data_func (GtkTreeViewColumn *tree_column,
info = get_list_file_info (impl, iter);
if (!info || g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
if (!info || _gtk_file_info_consider_as_directory (info))
{
g_object_set (cell,
"text", NULL,
......@@ -11055,7 +11070,7 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column,
if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
sensitive = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
sensitive = _gtk_file_info_consider_as_directory (info);
}
if (G_UNLIKELY (time_mtime == 0))
......
......@@ -439,7 +439,7 @@ maybe_append_separator_to_file (GtkFileChooserEntry *chooser_entry,
if (info)
{
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
if (_gtk_file_info_consider_as_directory (info))
{
gchar *tmp = display_name;
display_name = g_strconcat (tmp, G_DIR_SEPARATOR_S, NULL);
......@@ -1812,7 +1812,7 @@ _gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
if (file_info)
{
retval = (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY);
retval = _gtk_file_info_consider_as_directory (file_info);
g_object_unref (file_info);
}
}
......
......@@ -959,6 +959,11 @@ enclosing_volume_mount_cb (GObject *source_object,
g_file_mount_enclosing_volume_finish (G_FILE (source_object), result, &error);
volume = _gtk_file_system_get_volume_for_file (async_data->file_system, G_FILE (source_object));
/* Silently drop G_IO_ERROR_ALREADY_MOUNTED error for gvfs backends without visible mounts. */
/* Better than doing query_info with additional I/O every time. */
if (error && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED))
g_clear_error (&error);
gdk_threads_enter ();
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable, volume,
error, async_data->data);
......@@ -1791,3 +1796,13 @@ _gtk_file_info_render_icon (GFileInfo *info,
return pixbuf;
}
gboolean
_gtk_file_info_consider_as_directory (GFileInfo *info)
{
GFileType type = g_file_info_get_file_type (info);
return (type == G_FILE_TYPE_DIRECTORY ||
type == G_FILE_TYPE_MOUNTABLE);
}
......@@ -172,6 +172,8 @@ GdkPixbuf * _gtk_file_info_render_icon (GFileInfo *info,
GtkWidget *widget,
gint icon_size);
gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
G_END_DECLS
#endif /* __GTK_FILE_SYSTEM_H__ */
......@@ -444,7 +444,7 @@ gtk_file_system_model_iter_has_child (GtkTreeModel *tree_model,
else
{
GFileInfo *info = file_model_node_get_info (model, node);
return (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
return _gtk_file_info_consider_as_directory (info);
}
}
......@@ -1330,7 +1330,7 @@ file_model_node_is_visible (GtkFileSystemModel *model,
return FALSE;
}
is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
is_folder = _gtk_file_info_consider_as_directory (info);
if (model->show_folders != model->show_files &&
model->show_folders != is_folder)
......@@ -1553,7 +1553,7 @@ file_model_node_get_children (GtkFileSystemModel *model,
{
GFileInfo *info = file_model_node_get_info (model, node);
gboolean has_children = FALSE;
gboolean is_folder = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
gboolean is_folder = _gtk_file_info_consider_as_directory (info);
file_model_node_idle_clear_cancel (node);
......
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