summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserentry.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-11-07 03:09:22 +0100
committerBenjamin Otte <otte@redhat.com>2011-12-16 20:09:13 +0100
commitd3fd759f779e10419f8b2aa5e9b43393178ca67b (patch)
tree21d97f54a4a7c5c895f31db0245c6510efba409c /gtk/gtkfilechooserentry.c
parentf6f2a78d3ec1303a26f5992cbcfd3204f4b1221d (diff)
downloadgtk+-d3fd759f779e10419f8b2aa5e9b43393178ca67b.tar.gz
filechooserentry: Add gtk_file_chooser_entry_get_completion_text()
This returns the text that should be completed on. As this is somewhat tricky to compute (and in fact one place did it wrong), let's make it a function.
Diffstat (limited to 'gtk/gtkfilechooserentry.c')
-rw-r--r--gtk/gtkfilechooserentry.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index af73ab18b8..65968f8ba6 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -127,13 +127,22 @@ static void finished_loading_cb (GtkFileSystemModel *model,
G_DEFINE_TYPE (GtkFileChooserEntry, _gtk_file_chooser_entry, GTK_TYPE_ENTRY)
+static char *
+gtk_file_chooser_entry_get_completion_text (GtkFileChooserEntry *chooser_entry)
+{
+ GtkEditable *editable = GTK_EDITABLE (chooser_entry);
+ int start, end;
+
+ gtk_editable_get_selection_bounds (editable, &start, &end);
+ return gtk_editable_get_chars (editable, 0, MIN (start, end));
+}
+
static void
gtk_file_chooser_entry_dispatch_properties_changed (GObject *object,
guint n_pspecs,
GParamSpec **pspecs)
{
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object);
- GtkEditable *editable = GTK_EDITABLE (object);
guint i;
G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs);
@@ -151,12 +160,10 @@ gtk_file_chooser_entry_dispatch_properties_changed (GObject *object,
pspecs[i]->name == I_("text"))
{
char *text;
- int start, end;
chooser_entry->load_complete_action = LOAD_COMPLETE_NOTHING;
- gtk_editable_get_selection_bounds (editable, &start, &end);
- text = gtk_editable_get_chars (editable, 0, MIN (start, end));
+ text = gtk_file_chooser_entry_get_completion_text (chooser_entry);
refresh_current_folder_and_file_part (chooser_entry, text);
g_free (text);
@@ -509,7 +516,6 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
gboolean *prefix_expands_the_file_part_ret,
GError **error)
{
- GtkEditable *editable;
GtkTreeIter iter;
gboolean parsed;
gboolean valid;
@@ -522,9 +528,7 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
*is_complete_not_unique_ret = FALSE;
*prefix_expands_the_file_part_ret = FALSE;
- editable = GTK_EDITABLE (chooser_entry);
-
- text_up_to_cursor = gtk_editable_get_chars (editable, 0, gtk_editable_get_position (editable));
+ text_up_to_cursor = gtk_file_chooser_entry_get_completion_text (chooser_entry);
parsed = gtk_file_chooser_entry_parse (chooser_entry,
text_up_to_cursor,