summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserentry.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-11-05 03:53:32 +0100
committerBenjamin Otte <otte@redhat.com>2011-12-16 20:09:12 +0100
commite2105c2befc3c0a10ccb5223714f1a68ee1b4c0b (patch)
tree64df6256a8087e1618b4a61693d3dfc64e1fb7d6 /gtk/gtkfilechooserentry.c
parent5c42972735d4819f32ee78141fed249e8366f154 (diff)
downloadgtk+-e2105c2befc3c0a10ccb5223714f1a68ee1b4c0b.tar.gz
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.
Diffstat (limited to 'gtk/gtkfilechooserentry.c')
-rw-r--r--gtk/gtkfilechooserentry.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 11d18382b7..14f9318166 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -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)));
}
/**