Do not allow setting select_multiple when in Save mode. (set_list_model):

2004-01-16  Federico Mena Quintero  <federico@ximian.com>

	* gtk/gtkfilechooserdefault.c
	(gtk_file_chooser_default_set_property): Do not allow setting
	select_multiple when in Save mode.
	(set_list_model): No need to nullify the list_model and
	sort_model.
	(gtk_file_chooser_default_get_paths): Handle folder mode as well.
	(get_paths_foreach): Likewise.

	* gtk/gtkfilechooser.c (gtk_file_chooser_get_filename): Clarify
	documentation about folder mode.
	(gtk_file_chooser_get_uri): Likewise.
This commit is contained in:
Federico Mena Quintero 2004-01-16 05:12:21 +00:00 committed by Federico Mena Quintero
parent f2f12b9aae
commit c6860c111b
7 changed files with 132 additions and 39 deletions

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Do not allow setting
select_multiple when in Save mode.
(set_list_model): No need to nullify the list_model and
sort_model.
(gtk_file_chooser_default_get_paths): Handle folder mode as well.
(get_paths_foreach): Likewise.
* gtk/gtkfilechooser.c (gtk_file_chooser_get_filename): Clarify
documentation about folder mode.
(gtk_file_chooser_get_uri): Likewise.
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Do not allow setting
select_multiple when in Save mode.
(set_list_model): No need to nullify the list_model and
sort_model.
(gtk_file_chooser_default_get_paths): Handle folder mode as well.
(get_paths_foreach): Likewise.
* gtk/gtkfilechooser.c (gtk_file_chooser_get_filename): Clarify
documentation about folder mode.
(gtk_file_chooser_get_uri): Likewise.
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Do not allow setting
select_multiple when in Save mode.
(set_list_model): No need to nullify the list_model and
sort_model.
(gtk_file_chooser_default_get_paths): Handle folder mode as well.
(get_paths_foreach): Likewise.
* gtk/gtkfilechooser.c (gtk_file_chooser_get_filename): Clarify
documentation about folder mode.
(gtk_file_chooser_get_uri): Likewise.
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Do not allow setting
select_multiple when in Save mode.
(set_list_model): No need to nullify the list_model and
sort_model.
(gtk_file_chooser_default_get_paths): Handle folder mode as well.
(get_paths_foreach): Likewise.
* gtk/gtkfilechooser.c (gtk_file_chooser_get_filename): Clarify
documentation about folder mode.
(gtk_file_chooser_get_uri): Likewise.
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Do not allow setting
select_multiple when in Save mode.
(set_list_model): No need to nullify the list_model and
sort_model.
(gtk_file_chooser_default_get_paths): Handle folder mode as well.
(get_paths_foreach): Likewise.
* gtk/gtkfilechooser.c (gtk_file_chooser_get_filename): Clarify
documentation about folder mode.
(gtk_file_chooser_get_uri): Likewise.
2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New

View File

@ -362,6 +362,9 @@ gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
* the file selector. If multiple files are selected,
* one of the filenames will be returned at random.
*
* If the file chooser is in folder mode, this function returns the selected
* folder.
*
* Return value: The currently selected filename, or %NULL
* if no file is selected, or the selected file can't
* be represented with a local filename. Free with g_free().
@ -629,6 +632,9 @@ gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
* the file selector. If multiple files are selected,
* one of the filenames will be returned at random.
*
* If the file chooser is in folder mode, this function returns the selected
* folder.
*
* Return value: The currently selected URI, or %NULL
* if no file is selected. Free with g_free()
*

View File

@ -1615,6 +1615,12 @@ gtk_file_chooser_default_set_property (GObject *object,
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
{
gboolean select_multiple = g_value_get_boolean (value);
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE && select_multiple)
{
g_warning ("Multiple selection mode is not allowed in Save mode");
return;
}
if (select_multiple != impl->select_multiple)
{
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
@ -1855,10 +1861,7 @@ set_list_model (GtkFileChooserDefault *impl)
if (impl->list_model)
{
g_object_unref (impl->list_model);
impl->list_model = NULL;
g_object_unref (impl->sort_model);
impl->sort_model = NULL;
}
impl->list_model = _gtk_file_system_model_new (impl->file_system,
@ -2121,18 +2124,25 @@ get_paths_foreach (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
GtkTreePath *child_path;
GtkTreeIter child_iter;
const GtkFilePath *file_path;
struct get_paths_closure *info;
const GtkFilePath *file_path;
GtkFileSystemModel *fs_model;
GtkTreeIter sel_iter;
info = data;
child_path = gtk_tree_model_sort_convert_path_to_child_path (info->impl->sort_model, path);
gtk_tree_model_get_iter (GTK_TREE_MODEL (info->impl->list_model), &child_iter, child_path);
gtk_tree_path_free (child_path);
if (info->impl->folder_mode)
{
fs_model = info->impl->tree_model;
sel_iter = *iter;
}
else
{
fs_model = info->impl->list_model;
gtk_tree_model_sort_convert_iter_to_child_iter (info->impl->sort_model, &sel_iter, iter);
}
file_path = _gtk_file_system_model_get_path (info->impl->list_model, &child_iter);
file_path = _gtk_file_system_model_get_path (fs_model, &sel_iter);
info->result = g_slist_prepend (info->result, gtk_file_path_copy (file_path));
}
@ -2144,8 +2154,6 @@ gtk_file_chooser_default_get_paths (GtkFileChooser *chooser)
struct get_paths_closure info;
if (gtk_file_chooser_get_action (chooser) == GTK_FILE_CHOOSER_ACTION_SAVE)
{
if (!gtk_file_chooser_get_select_multiple (chooser))
{
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (impl->entry);
const GtkFilePath *folder_path = _gtk_file_chooser_entry_get_current_folder (chooser_entry);
@ -2174,12 +2182,21 @@ gtk_file_chooser_default_get_paths (GtkFileChooser *chooser)
return g_slist_append (NULL, selected);
}
}
}
if (impl->folder_mode)
{
if (!impl->tree_model)
return NULL;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->tree));
}
else
{
if (!impl->sort_model)
return NULL;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
}
info.result = NULL;
info.impl = impl;