forked from AuroraMiddleware/gtk
filechooserentry: Modify _gtk_file_chooser_entry_get_current_folder()
The new version does not need to muck with the entry, it just extracts the required information. It returns a reference to the folder though, as we extract the information now instead of returning something stored.
This commit is contained in:
parent
5c42972735
commit
e2105c2bef
@ -7640,7 +7640,7 @@ check_save_entry (GtkFileChooserDefault *impl,
|
||||
|
||||
if (!file_part || file_part[0] == '\0')
|
||||
{
|
||||
*file_ret = g_object_ref (current_folder);
|
||||
*file_ret = current_folder;
|
||||
*is_well_formed_ret = TRUE;
|
||||
*is_file_part_empty_ret = TRUE;
|
||||
*is_folder = TRUE;
|
||||
@ -7652,6 +7652,7 @@ check_save_entry (GtkFileChooserDefault *impl,
|
||||
|
||||
error = NULL;
|
||||
file = g_file_get_child_for_display_name (current_folder, file_part, &error);
|
||||
g_object_unref (current_folder);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
@ -8953,7 +8954,7 @@ gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
|
||||
data = g_new0 (struct FileExistsData, 1);
|
||||
data->impl = g_object_ref (impl);
|
||||
data->file = g_object_ref (file);
|
||||
data->parent_file = g_object_ref (_gtk_file_chooser_entry_get_current_folder (entry));
|
||||
data->parent_file = _gtk_file_chooser_entry_get_current_folder (entry);
|
||||
|
||||
if (impl->file_exists_get_info_cancellable)
|
||||
g_cancellable_cancel (impl->file_exists_get_info_cancellable);
|
||||
|
@ -440,6 +440,23 @@ gtk_file_chooser_get_file_for_text (GtkFileChooserEntry *chooser_entry,
|
||||
return file;
|
||||
}
|
||||
|
||||
static GFile *
|
||||
gtk_file_chooser_get_directory_for_text (GtkFileChooserEntry *chooser_entry,
|
||||
const char * text)
|
||||
{
|
||||
GFile *file, *parent;
|
||||
|
||||
file = gtk_file_chooser_get_file_for_text (chooser_entry, text);
|
||||
|
||||
if (text[0] == 0 || text[strlen (text) - 1] == G_DIR_SEPARATOR)
|
||||
return file;
|
||||
|
||||
parent = g_file_get_parent (file);
|
||||
g_object_unref (file);
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_file_chooser_entry_parse (GtkFileChooserEntry *chooser_entry,
|
||||
const gchar *str,
|
||||
@ -1675,14 +1692,16 @@ _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
|
||||
* be different. If the user has entered unparsable text, or text which
|
||||
* the entry cannot handle, this will return %NULL.
|
||||
*
|
||||
* Return value: the file for the current folder - this value is owned by the
|
||||
* chooser entry and must not be modified or freed.
|
||||
* Return value: the file for the current folder - you must g_object_unref()
|
||||
* the value after use.
|
||||
**/
|
||||
GFile *
|
||||
_gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
commit_completion_and_refresh (chooser_entry);
|
||||
return chooser_entry->current_folder_file;
|
||||
g_return_val_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry), NULL);
|
||||
|
||||
return gtk_file_chooser_get_directory_for_text (chooser_entry,
|
||||
gtk_entry_get_text (GTK_ENTRY (chooser_entry)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user