[gtk+/gtk-2-24] filechooserentry: Redo _gtk_file_chooser_entry_get_file_part()



commit a0ee779cc23fb5037c8681a84bd4e03499e4a366
Author: Benjamin Otte <otte redhat com>
Date:   Sat Nov 5 03:56:36 2011 +0100

    filechooserentry: Redo _gtk_file_chooser_entry_get_file_part()
    
    The new version does not need to update any text, it just strips the
    last part of the existing entry.

 gtk/gtkfilechooserentry.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 455e239..3861601 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -1717,8 +1717,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;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]