2004-07-08  Federico Mena Quintero  <federico@ximian.com>

	Fix #139290:

	* gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Add a
	GError argument.  Do check for errors when getting the
	GtkFileFolder:  get the folder and read the children before
	actually creating the model.  Removed obsolete code that handled
	roots-changed on the file system.
	(file_model_node_get_info): Assert that we don't reach the old
	case to display file system roots.
	(roots_changed_callback): Removed.

	* gtk/gtkfilechooserdefault.c (set_list_model): Add a GError
	argument, and a boolean return value.  Return an error if we
	cannot create the file system model.  On error, set a NULL model
	on the tree.
	(gtk_file_chooser_default_set_current_folder): Use the error value
	from set_list_model().
	(gtk_file_chooser_default_set_property): Set the show_hidden
	property only if the browse_files_model exists.
	(gtk_file_chooser_default_unselect_path): Only operate if the
	browse_files_model exists.
	(check_preview_change): Check whether we have the sort_model.
	(change_folder_and_display_error): Copy the path we get passed
	before using it.  There's a comment in there that explains why we
	need to copy it; basically, if the passed path belongs to the
	model, the model may go away in the middle of this function and
	we'll be left with a dangling pointer.
	(install_list_model_filter): Assert that the model is not NULL.
	(set_current_filter): Check whether the model exists.

	* gtk/gtktreeselection.c (gtk_tree_selection_get_selected): Don't
	g_return_if_fail if the model is NULL.
	(gtk_tree_selection_get_selected_rows): Likewise.
	(gtk_tree_selection_count_selected_rows): Likewise.
	(gtk_tree_selection_selected_foreach): Likewise.
	(gtk_tree_selection_path_is_selected): Likewise; rather just
	return FALSE.
	(gtk_tree_selection_select_all): Likewise.
	(gtk_tree_selection_unselect_all): Likewise.
	(gtk_tree_selection_select_range): Do g_return_if_fail() if the
	model is NULL.
	(gtk_tree_selection_unselect_range): Likewise.

	* gtk/gtkfilesystemunix.c (fill_in_names): Return immediately if
	g_dir_open() fails:  there is no need to set the error ourselves,
	as g_dir_open() already does it.
This commit is contained in:
Federico Mena Quintero 2004-07-09 00:53:48 +00:00 committed by Federico Mena Quintero
parent 57e8c48a0c
commit b3fbcef831
9 changed files with 312 additions and 198 deletions

View File

@ -1,3 +1,52 @@
2004-07-08 Federico Mena Quintero <federico@ximian.com>
Fix #139290:
* gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Add a
GError argument. Do check for errors when getting the
GtkFileFolder: get the folder and read the children before
actually creating the model. Removed obsolete code that handled
roots-changed on the file system.
(file_model_node_get_info): Assert that we don't reach the old
case to display file system roots.
(roots_changed_callback): Removed.
* gtk/gtkfilechooserdefault.c (set_list_model): Add a GError
argument, and a boolean return value. Return an error if we
cannot create the file system model. On error, set a NULL model
on the tree.
(gtk_file_chooser_default_set_current_folder): Use the error value
from set_list_model().
(gtk_file_chooser_default_set_property): Set the show_hidden
property only if the browse_files_model exists.
(gtk_file_chooser_default_unselect_path): Only operate if the
browse_files_model exists.
(check_preview_change): Check whether we have the sort_model.
(change_folder_and_display_error): Copy the path we get passed
before using it. There's a comment in there that explains why we
need to copy it; basically, if the passed path belongs to the
model, the model may go away in the middle of this function and
we'll be left with a dangling pointer.
(install_list_model_filter): Assert that the model is not NULL.
(set_current_filter): Check whether the model exists.
* gtk/gtktreeselection.c (gtk_tree_selection_get_selected): Don't
g_return_if_fail if the model is NULL.
(gtk_tree_selection_get_selected_rows): Likewise.
(gtk_tree_selection_count_selected_rows): Likewise.
(gtk_tree_selection_selected_foreach): Likewise.
(gtk_tree_selection_path_is_selected): Likewise; rather just
return FALSE.
(gtk_tree_selection_select_all): Likewise.
(gtk_tree_selection_unselect_all): Likewise.
(gtk_tree_selection_select_range): Do g_return_if_fail() if the
model is NULL.
(gtk_tree_selection_unselect_range): Likewise.
* gtk/gtkfilesystemunix.c (fill_in_names): Return immediately if
g_dir_open() fails: there is no need to set the error ourselves,
as g_dir_open() already does it.
2004-07-08 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Allow

View File

@ -1,3 +1,52 @@
2004-07-08 Federico Mena Quintero <federico@ximian.com>
Fix #139290:
* gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Add a
GError argument. Do check for errors when getting the
GtkFileFolder: get the folder and read the children before
actually creating the model. Removed obsolete code that handled
roots-changed on the file system.
(file_model_node_get_info): Assert that we don't reach the old
case to display file system roots.
(roots_changed_callback): Removed.
* gtk/gtkfilechooserdefault.c (set_list_model): Add a GError
argument, and a boolean return value. Return an error if we
cannot create the file system model. On error, set a NULL model
on the tree.
(gtk_file_chooser_default_set_current_folder): Use the error value
from set_list_model().
(gtk_file_chooser_default_set_property): Set the show_hidden
property only if the browse_files_model exists.
(gtk_file_chooser_default_unselect_path): Only operate if the
browse_files_model exists.
(check_preview_change): Check whether we have the sort_model.
(change_folder_and_display_error): Copy the path we get passed
before using it. There's a comment in there that explains why we
need to copy it; basically, if the passed path belongs to the
model, the model may go away in the middle of this function and
we'll be left with a dangling pointer.
(install_list_model_filter): Assert that the model is not NULL.
(set_current_filter): Check whether the model exists.
* gtk/gtktreeselection.c (gtk_tree_selection_get_selected): Don't
g_return_if_fail if the model is NULL.
(gtk_tree_selection_get_selected_rows): Likewise.
(gtk_tree_selection_count_selected_rows): Likewise.
(gtk_tree_selection_selected_foreach): Likewise.
(gtk_tree_selection_path_is_selected): Likewise; rather just
return FALSE.
(gtk_tree_selection_select_all): Likewise.
(gtk_tree_selection_unselect_all): Likewise.
(gtk_tree_selection_select_range): Do g_return_if_fail() if the
model is NULL.
(gtk_tree_selection_unselect_range): Likewise.
* gtk/gtkfilesystemunix.c (fill_in_names): Return immediately if
g_dir_open() fails: there is no need to set the error ourselves,
as g_dir_open() already does it.
2004-07-08 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Allow

View File

@ -1,3 +1,52 @@
2004-07-08 Federico Mena Quintero <federico@ximian.com>
Fix #139290:
* gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Add a
GError argument. Do check for errors when getting the
GtkFileFolder: get the folder and read the children before
actually creating the model. Removed obsolete code that handled
roots-changed on the file system.
(file_model_node_get_info): Assert that we don't reach the old
case to display file system roots.
(roots_changed_callback): Removed.
* gtk/gtkfilechooserdefault.c (set_list_model): Add a GError
argument, and a boolean return value. Return an error if we
cannot create the file system model. On error, set a NULL model
on the tree.
(gtk_file_chooser_default_set_current_folder): Use the error value
from set_list_model().
(gtk_file_chooser_default_set_property): Set the show_hidden
property only if the browse_files_model exists.
(gtk_file_chooser_default_unselect_path): Only operate if the
browse_files_model exists.
(check_preview_change): Check whether we have the sort_model.
(change_folder_and_display_error): Copy the path we get passed
before using it. There's a comment in there that explains why we
need to copy it; basically, if the passed path belongs to the
model, the model may go away in the middle of this function and
we'll be left with a dangling pointer.
(install_list_model_filter): Assert that the model is not NULL.
(set_current_filter): Check whether the model exists.
* gtk/gtktreeselection.c (gtk_tree_selection_get_selected): Don't
g_return_if_fail if the model is NULL.
(gtk_tree_selection_get_selected_rows): Likewise.
(gtk_tree_selection_count_selected_rows): Likewise.
(gtk_tree_selection_selected_foreach): Likewise.
(gtk_tree_selection_path_is_selected): Likewise; rather just
return FALSE.
(gtk_tree_selection_select_all): Likewise.
(gtk_tree_selection_unselect_all): Likewise.
(gtk_tree_selection_select_range): Do g_return_if_fail() if the
model is NULL.
(gtk_tree_selection_unselect_range): Likewise.
* gtk/gtkfilesystemunix.c (fill_in_names): Return immediately if
g_dir_open() fails: there is no need to set the error ourselves,
as g_dir_open() already does it.
2004-07-08 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Allow

View File

@ -1,3 +1,52 @@
2004-07-08 Federico Mena Quintero <federico@ximian.com>
Fix #139290:
* gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Add a
GError argument. Do check for errors when getting the
GtkFileFolder: get the folder and read the children before
actually creating the model. Removed obsolete code that handled
roots-changed on the file system.
(file_model_node_get_info): Assert that we don't reach the old
case to display file system roots.
(roots_changed_callback): Removed.
* gtk/gtkfilechooserdefault.c (set_list_model): Add a GError
argument, and a boolean return value. Return an error if we
cannot create the file system model. On error, set a NULL model
on the tree.
(gtk_file_chooser_default_set_current_folder): Use the error value
from set_list_model().
(gtk_file_chooser_default_set_property): Set the show_hidden
property only if the browse_files_model exists.
(gtk_file_chooser_default_unselect_path): Only operate if the
browse_files_model exists.
(check_preview_change): Check whether we have the sort_model.
(change_folder_and_display_error): Copy the path we get passed
before using it. There's a comment in there that explains why we
need to copy it; basically, if the passed path belongs to the
model, the model may go away in the middle of this function and
we'll be left with a dangling pointer.
(install_list_model_filter): Assert that the model is not NULL.
(set_current_filter): Check whether the model exists.
* gtk/gtktreeselection.c (gtk_tree_selection_get_selected): Don't
g_return_if_fail if the model is NULL.
(gtk_tree_selection_get_selected_rows): Likewise.
(gtk_tree_selection_count_selected_rows): Likewise.
(gtk_tree_selection_selected_foreach): Likewise.
(gtk_tree_selection_path_is_selected): Likewise; rather just
return FALSE.
(gtk_tree_selection_select_all): Likewise.
(gtk_tree_selection_unselect_all): Likewise.
(gtk_tree_selection_select_range): Do g_return_if_fail() if the
model is NULL.
(gtk_tree_selection_unselect_range): Likewise.
* gtk/gtkfilesystemunix.c (fill_in_names): Return immediately if
g_dir_open() fails: there is no need to set the error ourselves,
as g_dir_open() already does it.
2004-07-08 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Allow

View File

@ -785,12 +785,26 @@ change_folder_and_display_error (GtkFileChooserDefault *impl,
{
GError *error;
gboolean result;
GtkFilePath *path_copy;
/* We copy the path because of this case:
*
* list_row_activated()
* fetches path from model; path belongs to the model (*)
* calls change_folder_and_display_error()
* calls _gtk_file_chooser_set_current_folder_path()
* changing folders fails, sets model to NULL, thus freeing the path in (*)
*/
path_copy = gtk_file_path_copy (path);
error = NULL;
result = _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path, &error);
result = _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path_copy, &error);
if (!result)
error_changing_folder_dialog (impl, path, error);
error_changing_folder_dialog (impl, path_copy, error);
gtk_file_path_free (path_copy);
return result;
}
@ -1473,6 +1487,9 @@ new_folder_button_clicked (GtkButton *button,
GtkTreeIter iter;
GtkTreePath *path;
if (!impl->browse_files_model)
return; /* FIXME: this sucks. Disable the New Folder button or something. */
_gtk_file_system_model_add_editable (impl->browse_files_model, &iter);
path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->browse_files_model), &iter);
@ -1878,10 +1895,8 @@ selection_check (GtkFileChooserDefault *impl,
static void
bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl)
{
GtkTreeSelection *selection;
gboolean active;
/* Check selection */
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
@ -2725,13 +2740,13 @@ popup_position_func (GtkMenu *menu,
GtkRequisition req;
gint monitor_num;
GdkRectangle monitor;
g_return_if_fail (GTK_WIDGET_REALIZED (widget));
gdk_window_get_origin (widget->window, x, y);
gdk_window_get_origin (widget->window, x, y);
gtk_widget_size_request (GTK_WIDGET (menu), &req);
*x += (widget->allocation.width - req.width) / 2;
*y += (widget->allocation.height - req.height) / 2;
@ -2757,10 +2772,10 @@ file_list_popup_menu (GtkFileChooserDefault *impl,
else
{
gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
NULL, NULL,
NULL, NULL,
popup_position_func, impl->browse_files_tree_view,
0, GDK_CURRENT_TIME);
gtk_menu_shell_select_first (GTK_MENU_SHELL (impl->browse_files_popup_menu),
gtk_menu_shell_select_first (GTK_MENU_SHELL (impl->browse_files_popup_menu),
FALSE);
}
@ -3481,7 +3496,9 @@ gtk_file_chooser_default_set_property (GObject *object,
if (show_hidden != impl->show_hidden)
{
impl->show_hidden = show_hidden;
_gtk_file_system_model_set_show_hidden (impl->browse_files_model, show_hidden);
if (impl->browse_files_model)
_gtk_file_system_model_set_show_hidden (impl->browse_files_model, show_hidden);
}
}
break;
@ -3723,6 +3740,8 @@ list_model_filter_func (GtkFileSystemModel *model,
static void
install_list_model_filter (GtkFileChooserDefault *impl)
{
g_assert (impl->browse_files_model != NULL);
if (impl->current_filter)
_gtk_file_system_model_set_filter (impl->browse_files_model,
list_model_filter_func,
@ -3842,20 +3861,32 @@ browse_files_model_finished_loading_cb (GtkFileSystemModel *model,
}
/* Gets rid of the old list model and creates a new one for the current folder */
static void
set_list_model (GtkFileChooserDefault *impl)
static gboolean
set_list_model (GtkFileChooserDefault *impl,
GError **error)
{
if (impl->browse_files_model)
{
g_object_unref (impl->browse_files_model);
impl->browse_files_model = NULL;
g_object_unref (impl->sort_model);
impl->sort_model = NULL;
}
set_busy_cursor (impl, TRUE);
impl->browse_files_model = _gtk_file_system_model_new (impl->file_system,
impl->current_folder, 0,
GTK_FILE_INFO_ALL);
GTK_FILE_INFO_ALL,
error);
if (!impl->browse_files_model)
{
set_busy_cursor (impl, FALSE);
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view), NULL);
return FALSE;
}
g_signal_connect (impl->browse_files_model, "finished-loading",
G_CALLBACK (browse_files_model_finished_loading_cb), impl);
@ -3891,6 +3922,8 @@ set_list_model (GtkFileChooserDefault *impl)
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (impl->browse_files_tree_view));
gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->browse_files_tree_view),
GTK_FILE_SYSTEM_MODEL_DISPLAY_NAME);
return TRUE;
}
static void
@ -3927,6 +3960,7 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
GError **error)
{
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
gboolean result;
if (impl->local_only &&
!gtk_file_system_path_is_local (impl->file_system, path))
@ -3965,8 +3999,11 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
impl->changing_folder = FALSE;
}
/* Create a new list model */
set_list_model (impl);
/* Create a new list model. This is slightly evil; we store the result value
* but perform more actions rather than returning immediately even if it
* generates an error.
*/
result = set_list_model (impl, error);
/* Refresh controls */
@ -3979,7 +4016,7 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
g_signal_emit_by_name (impl, "selection-changed", 0);
return TRUE;
return result;
}
static GtkFilePath *
@ -4100,6 +4137,9 @@ gtk_file_chooser_default_unselect_path (GtkFileChooser *chooser,
{
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
if (!impl->browse_files_model)
return;
_gtk_file_system_model_path_do (impl->browse_files_model, path,
unselect_func, impl);
}
@ -4719,7 +4759,8 @@ set_current_filter (GtkFileChooserDefault *impl,
gtk_combo_box_set_active (GTK_COMBO_BOX (impl->filter_combo),
filter_index);
install_list_model_filter (impl);
if (impl->browse_files_model)
install_list_model_filter (impl);
g_object_notify (G_OBJECT (impl), "filter");
}
@ -4743,7 +4784,7 @@ check_preview_change (GtkFileChooserDefault *impl)
const GtkFileInfo *new_info;
gtk_tree_view_get_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), &cursor_path, NULL);
if (cursor_path)
if (cursor_path && impl->sort_model)
{
GtkTreeIter iter;
GtkTreeIter child_iter;

View File

@ -161,11 +161,6 @@ static void file_model_node_clear (GtkFileSystemModel *mode
static FileModelNode * file_model_node_get_children (GtkFileSystemModel *model,
FileModelNode *node);
#if 0
static void roots_changed_callback (GtkFileSystem *file_system,
GtkFileSystemModel *model);
#endif
static void deleted_callback (GtkFileFolder *folder,
FileModelNode *node);
static void files_added_callback (GtkFileFolder *folder,
@ -722,26 +717,48 @@ queue_finished_loading (GtkFileSystemModel *model)
* that is desired about the files. This will
* determine what information is returned by
* _gtk_file_system_model_get_info().
* @error: location to store error, or %NULL.
*
* Creates a new #GtkFileSystemModel object. The #GtkFileSystemModel
* object wraps a #GtkFileSystem interface as a #GtkTreeModel.
* Using the @root_path and @max_depth parameters, the tree model
* can be restricted to a subportion of the entire file system.
*
* Return value: the newly created #GtkFileSystemModel object.
* Return value: the newly created #GtkFileSystemModel object, or NULL if there
* was an error.
**/
GtkFileSystemModel *
_gtk_file_system_model_new (GtkFileSystem *file_system,
const GtkFilePath *root_path,
gint max_depth,
GtkFileInfoType types)
GtkFileInfoType types,
GError **error)
{
GtkFileSystemModel *model;
GSList *roots = NULL;
GtkFileFolder *root_folder;
GSList *roots;
GSList *tmp_list;
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
g_return_val_if_fail (root_path != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
/* First, try to load the folder */
types |= GTK_FILE_INFO_IS_FOLDER | GTK_FILE_INFO_IS_HIDDEN;
root_folder = gtk_file_system_get_folder (file_system, root_path, types, error);
if (!root_folder)
return NULL;
if (!gtk_file_folder_list_children (root_folder, &roots, error))
{
g_object_unref (root_folder);
return NULL;
}
/* Then, actually create the model and the root nodes */
model = g_object_new (GTK_TYPE_FILE_SYSTEM_MODEL, NULL);
model->file_system = g_object_ref (file_system);
@ -749,48 +766,25 @@ _gtk_file_system_model_new (GtkFileSystem *file_system,
model->max_depth = G_MAXUSHORT;
else
model->max_depth = MIN (max_depth, G_MAXUSHORT);
model->types = types | GTK_FILE_INFO_IS_FOLDER | GTK_FILE_INFO_IS_HIDDEN;
if (root_path)
{
GSList *child_paths;
model->types = types;
model->root_folder = root_folder;
model->root_path = gtk_file_path_copy (root_path);
model->root_path = gtk_file_path_copy (root_path);
model->root_folder = gtk_file_system_get_folder (file_system, root_path,
model->types,
NULL); /* NULL-GError */
if (model->root_folder)
{
if (gtk_file_folder_list_children (model->root_folder,
&child_paths,
NULL)) /* NULL-GError */
roots = child_paths;
if (gtk_file_folder_is_finished_loading (model->root_folder))
queue_finished_loading (model); /* done in an idle because we are being created */
else
g_signal_connect_object (model->root_folder, "finished-loading",
G_CALLBACK (root_folder_finished_loading_cb), model, 0);
g_signal_connect_object (model->root_folder, "deleted",
G_CALLBACK (root_deleted_callback), model, 0);
g_signal_connect_object (model->root_folder, "files-added",
G_CALLBACK (root_files_added_callback), model, 0);
g_signal_connect_object (model->root_folder, "files-changed",
G_CALLBACK (root_files_changed_callback), model, 0);
g_signal_connect_object (model->root_folder, "files-removed",
G_CALLBACK (root_files_removed_callback), model, 0);
}
}
#if 0
if (gtk_file_folder_is_finished_loading (model->root_folder))
queue_finished_loading (model); /* done in an idle because we are being created */
else
{
roots = gtk_file_system_list_roots (file_system);
g_signal_connect_object (file_system, "roots-changed",
G_CALLBACK (roots_changed_callback), model, 0);
}
#endif
g_signal_connect_object (model->root_folder, "finished-loading",
G_CALLBACK (root_folder_finished_loading_cb), model, 0);
g_signal_connect_object (model->root_folder, "deleted",
G_CALLBACK (root_deleted_callback), model, 0);
g_signal_connect_object (model->root_folder, "files-added",
G_CALLBACK (root_files_added_callback), model, 0);
g_signal_connect_object (model->root_folder, "files-changed",
G_CALLBACK (root_files_changed_callback), model, 0);
g_signal_connect_object (model->root_folder, "files-removed",
G_CALLBACK (root_files_removed_callback), model, 0);
roots = gtk_file_paths_sort (roots);
@ -805,7 +799,7 @@ _gtk_file_system_model_new (GtkFileSystem *file_system,
}
g_slist_free (roots);
model->roots = (FileModelNode *)g_slist_reverse ((GSList *)model->roots);
model->roots = (FileModelNode *) g_slist_reverse ((GSList *)model->roots);
return model;
}
@ -1277,15 +1271,8 @@ file_model_node_get_info (GtkFileSystemModel *model,
node->path,
NULL); /* NULL-GError */
}
#if 0
else
{
node->info = gtk_file_system_get_root_info (model->file_system,
node->path,
model->types,
NULL); /* NULL-GError */
}
#endif
g_assert_not_reached ();
}
return node->info;
@ -1822,105 +1809,6 @@ do_files_removed (GtkFileSystemModel *model,
g_slist_free (sorted_paths);
}
#if 0
static void
roots_changed_callback (GtkFileSystem *file_system,
GtkFileSystemModel *model)
{
GtkTreeModel *tree_model = GTK_TREE_MODEL (model);
GSList *new_roots;
GSList *tmp_list;
FileModelNode *children;
FileModelNode *prev = NULL;
GtkTreePath *path;
new_roots = gtk_file_system_list_roots (file_system);
new_roots = gtk_file_paths_sort (new_roots);
children = model->roots;
tmp_list = new_roots;
path = gtk_tree_path_new ();
gtk_tree_path_down (path);
while (children || tmp_list)
{
FileModelNode *next = NULL;
int cmp;
if (tmp_list && children)
cmp = gtk_file_path_compare (children->path, tmp_list->data);
else if (children)
cmp = -1;
else
cmp = 1;
if (cmp < 0)
{
next = children->next;
if (prev)
prev->next = children->next;
else
model->roots = children->next;
if (children->is_visible)
gtk_tree_model_row_deleted (tree_model, path);
file_model_node_free (children);
}
else if (cmp == 0)
{
/* Already there
*/
next = children->next;
prev = children;
if (children->is_visible)
gtk_tree_path_next (path);
}
else
{
GtkTreeIter iter;
FileModelNode *node = file_model_node_new (model, tmp_list->data);
node->is_visible = file_model_node_is_visible (model, node);
node->next = children;
node->depth = 0;
if (prev)
prev->next = node;
else
model->roots = node;
if (node->is_visible)
{
iter.user_data = node;
gtk_tree_model_row_inserted (tree_model, path, &iter);
if (gtk_file_system_model_iter_has_child (tree_model, &iter))
gtk_tree_model_row_has_child_toggled (tree_model, path, &iter);
gtk_tree_path_next (path);
}
prev = node;
}
if (cmp <= 0)
{
children = next;
}
if (cmp >= 0)
{
gtk_file_path_free (tmp_list->data);
tmp_list = tmp_list->next;
}
}
g_slist_free (new_roots);
gtk_tree_path_free (path);
}
#endif
static void
deleted_callback (GtkFileFolder *folder,
FileModelNode *node)

View File

@ -44,7 +44,8 @@ typedef enum {
GtkFileSystemModel *_gtk_file_system_model_new (GtkFileSystem *file_system,
const GtkFilePath *root_path,
gint max_depth,
GtkFileInfoType types);
GtkFileInfoType types,
GError **error);
const GtkFileInfo * _gtk_file_system_model_get_info (GtkFileSystemModel *model,
GtkTreeIter *iter);
const GtkFilePath * _gtk_file_system_model_get_path (GtkFileSystemModel *model,

View File

@ -1732,18 +1732,7 @@ fill_in_names (GtkFileFolderUnix *folder_unix, GError **error)
(GDestroyNotify)free_stat_info_entry);
dir = g_dir_open (folder_unix->filename, 0, error);
if (!dir)
{
int save_errno = errno;
gchar *filename_utf8 = g_filename_to_utf8 (folder_unix->filename, -1, NULL, NULL, NULL);
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
_("error getting information for '%s': %s"),
filename_utf8 ? filename_utf8 : "???",
g_strerror (save_errno));
g_free (filename_utf8);
return FALSE;
}
return FALSE;
while (TRUE)
{

View File

@ -362,7 +362,6 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection,
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
g_return_val_if_fail (selection->type != GTK_SELECTION_MULTIPLE, FALSE);
g_return_val_if_fail (selection->tree_view != NULL, FALSE);
g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
if (model)
*model = selection->tree_view->priv->model;
@ -437,7 +436,6 @@ gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection,
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), NULL);
g_return_val_if_fail (selection->tree_view != NULL, NULL);
g_return_val_if_fail (selection->tree_view->priv->model != NULL, NULL);
if (selection->tree_view->priv->tree == NULL ||
selection->tree_view->priv->tree->root == NULL)
@ -560,7 +558,6 @@ gtk_tree_selection_count_selected_rows (GtkTreeSelection *selection)
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), 0);
g_return_val_if_fail (selection->tree_view != NULL, 0);
g_return_val_if_fail (selection->tree_view->priv->model != NULL, 0);
if (selection->tree_view->priv->tree == NULL ||
selection->tree_view->priv->tree->root == NULL)
@ -621,7 +618,6 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
g_return_if_fail (selection->tree_view->priv->model != NULL);
if (func == NULL ||
selection->tree_view->priv->tree == NULL ||
@ -915,7 +911,9 @@ gtk_tree_selection_path_is_selected (GtkTreeSelection *selection,
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
g_return_val_if_fail (selection->tree_view != NULL, FALSE);
g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
if (selection->tree_view->priv->model == NULL)
return FALSE;
ret = _gtk_tree_view_find_node (selection->tree_view,
path,
@ -1029,8 +1027,10 @@ gtk_tree_selection_select_all (GtkTreeSelection *selection)
{
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
if (selection->tree_view->priv->tree == NULL)
if (selection->tree_view->priv->tree == NULL || selection->tree_view->priv->model == NULL)
return;
g_return_if_fail (selection->type == GTK_SELECTION_MULTIPLE);
if (gtk_tree_selection_real_select_all (selection))
@ -1130,12 +1130,10 @@ gtk_tree_selection_unselect_all (GtkTreeSelection *selection)
{
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
if (selection->tree_view->priv->tree == NULL)
if (selection->tree_view->priv->tree == NULL || selection->tree_view->priv->model == NULL)
return;
if (selection->tree_view->priv->tree == NULL)
return;
if (gtk_tree_selection_real_unselect_all (selection))
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
}
@ -1253,6 +1251,7 @@ gtk_tree_selection_select_range (GtkTreeSelection *selection,
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
g_return_if_fail (selection->type == GTK_SELECTION_MULTIPLE);
g_return_if_fail (selection->tree_view->priv->model != NULL);
if (gtk_tree_selection_real_modify_range (selection, RANGE_SELECT, start_path, end_path))
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
@ -1276,6 +1275,7 @@ gtk_tree_selection_unselect_range (GtkTreeSelection *selection,
{
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
g_return_if_fail (selection->tree_view->priv->model != NULL);
if (gtk_tree_selection_real_modify_range (selection, RANGE_UNSELECT, start_path, end_path))
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
@ -1537,4 +1537,3 @@ gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
return FALSE;
}