]> Pileus Git - ~andy/gtk/commitdiff
filechooserentry: Redo _gtk_file_chooser_entry_get_file_part()
authorBenjamin Otte <otte@redhat.com>
Sat, 5 Nov 2011 02:56:36 +0000 (03:56 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 16 Dec 2011 19:09:12 +0000 (20:09 +0100)
The new version does not need to update any text, it just strips the
last part of the existing entry.

gtk/gtkfilechooserentry.c

index 14f9318166676f8407905dbd3ff0e21fbcb403e6..a14116e90757797d4411296fca0d0796af9d13d6 100644 (file)
@@ -1719,8 +1719,16 @@ _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
 const gchar *
 _gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry)
 {
-  commit_completion_and_refresh (chooser_entry);
-  return chooser_entry->file_part;
+  const char *last_slash, *text;
+
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry), NULL);
+
+  text = gtk_entry_get_text (GTK_ENTRY (chooser_entry));
+  last_slash = strrchr (text, G_DIR_SEPARATOR);
+  if (last_slash)
+    return last_slash + 1;
+  else
+    return text;
 }
 
 /**