[gtk+/gtk-2-24] filechooserentry: Add gtk_file_chooser_entry_get_completion_text()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] filechooserentry: Add gtk_file_chooser_entry_get_completion_text()
- Date: Thu, 10 Mar 2016 21:30:39 +0000 (UTC)
commit 87a67aa0e3be6e9b458a5cdf5a25957b97b1925f
Author: Benjamin Otte <otte redhat com>
Date: Mon Nov 7 03:09:22 2011 +0100
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.
gtk/gtkfilechooserentry.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 514ad99..d63cb52 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -130,13 +130,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);
@@ -154,12 +163,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);
@@ -512,7 +519,6 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
gboolean *prefix_expands_the_file_part_ret,
GError **error)
{
- GtkEditable *editable;
GtkTreeIter iter;
gboolean parsed;
gboolean valid;
@@ -525,9 +531,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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]