gtk+ r21898 - in trunk: . gtk
- From: matthiasc svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r21898 - in trunk: . gtk
- Date: Sun, 14 Dec 2008 02:14:19 +0000 (UTC)
Author: matthiasc
Date: Sun Dec 14 02:14:19 2008
New Revision: 21898
URL: http://svn.gnome.org/viewvc/gtk+?rev=21898&view=rev
Log:
* 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.
Modified:
trunk/ChangeLog
trunk/gtk/gtkfilechooserbutton.c
trunk/gtk/gtkfilechooserdefault.c
trunk/gtk/gtkfilechooserentry.c
trunk/gtk/gtkfilesystem.c
trunk/gtk/gtkfilesystem.h
trunk/gtk/gtkfilesystemmodel.c
Modified: trunk/gtk/gtkfilechooserbutton.c
==============================================================================
--- trunk/gtk/gtkfilechooserbutton.c (original)
+++ trunk/gtk/gtkfilechooserbutton.c Sun Dec 14 02:14:19 2008
@@ -998,7 +998,7 @@
{
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 @@
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,
Modified: trunk/gtk/gtkfilechooserdefault.c
==============================================================================
--- trunk/gtk/gtkfilechooserdefault.c (original)
+++ trunk/gtk/gtkfilechooserdefault.c Sun Dec 14 02:14:19 2008
@@ -2771,7 +2771,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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))
Modified: trunk/gtk/gtkfilechooserentry.c
==============================================================================
--- trunk/gtk/gtkfilechooserentry.c (original)
+++ trunk/gtk/gtkfilechooserentry.c Sun Dec 14 02:14:19 2008
@@ -439,7 +439,7 @@
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 @@
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);
}
}
Modified: trunk/gtk/gtkfilesystem.c
==============================================================================
--- trunk/gtk/gtkfilesystem.c (original)
+++ trunk/gtk/gtkfilesystem.c Sun Dec 14 02:14:19 2008
@@ -959,6 +959,11 @@
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 @@
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);
+}
+
Modified: trunk/gtk/gtkfilesystem.h
==============================================================================
--- trunk/gtk/gtkfilesystem.h (original)
+++ trunk/gtk/gtkfilesystem.h Sun Dec 14 02:14:19 2008
@@ -172,6 +172,8 @@
GtkWidget *widget,
gint icon_size);
+gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
+
G_END_DECLS
#endif /* __GTK_FILE_SYSTEM_H__ */
Modified: trunk/gtk/gtkfilesystemmodel.c
==============================================================================
--- trunk/gtk/gtkfilesystemmodel.c (original)
+++ trunk/gtk/gtkfilesystemmodel.c Sun Dec 14 02:14:19 2008
@@ -444,7 +444,7 @@
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 @@
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 @@
{
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]