summaryrefslogtreecommitdiff
path: root/gtk/gtktreeselection.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2004-07-09 00:53:48 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2004-07-09 00:53:48 +0000
commitb3fbcef83159de5a109b9e72c7d139a45a7b11ee (patch)
treeb43f8da13f1886a6cc6d693f4d15abc3a9d3e584 /gtk/gtktreeselection.c
parent57e8c48a0cca13f4b71487f01f3e3545ee02d244 (diff)
downloadgtk+-b3fbcef83159de5a109b9e72c7d139a45a7b11ee.tar.gz
Fix #139290:
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.
Diffstat (limited to 'gtk/gtktreeselection.c')
-rw-r--r--gtk/gtktreeselection.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/gtk/gtktreeselection.c b/gtk/gtktreeselection.c
index b8ac48b8b8..b5e4272133 100644
--- a/gtk/gtktreeselection.c
+++ b/gtk/gtktreeselection.c
@@ -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;
}
-