[gtk+/filechooserentry: 28/51] entrycompletion: Export gtk_entry_completion_compute_prefix()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/filechooserentry: 28/51] entrycompletion: Export gtk_entry_completion_compute_prefix()
- Date: Mon, 7 Nov 2011 04:45:23 +0000 (UTC)
commit 0c863e4066cdb5b25babe11e3fe5b6ba6b1942b0
Author: Benjamin Otte <otte redhat com>
Date: Sat Nov 5 20:38:28 2011 +0100
entrycompletion: Export gtk_entry_completion_compute_prefix()
I want to use it in the file chooser entry autocomplete code.
docs/reference/gtk/gtk3-sections.txt | 1 +
gtk/gtk.symbols | 1 +
gtk/gtkentrycompletion.c | 27 +++++++++++++++++++++------
gtk/gtkentrycompletion.h | 2 ++
4 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index b9c9fb8..838cff7 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -1132,6 +1132,7 @@ gtk_entry_completion_get_model
gtk_entry_completion_set_match_func
gtk_entry_completion_set_minimum_key_length
gtk_entry_completion_get_minimum_key_length
+gtk_entry_completion_compute_prefix
gtk_entry_completion_complete
gtk_entry_completion_get_completion_prefix
gtk_entry_completion_insert_prefix
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 2f34a4a..d9d5f76 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -820,6 +820,7 @@ gtk_entry_buffer_new
gtk_entry_buffer_set_max_length
gtk_entry_buffer_set_text
gtk_entry_completion_complete
+gtk_entry_completion_compute_prefix
gtk_entry_completion_delete_action
gtk_entry_completion_get_completion_prefix
gtk_entry_completion_get_entry
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 4847b9d..b7e9b6b 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -1693,19 +1693,32 @@ gtk_entry_completion_cursor_on_match (GtkEntryCompletion *completion,
return TRUE;
}
-static gchar *
-gtk_entry_completion_compute_prefix (GtkEntryCompletion *completion)
+/**
+ * gtk_entry_completion_compute_prefix:
+ * @completion: the entry completion
+ * @key: The text to complete for
+ *
+ * Computes the common prefix that is shared by all rows in @completion
+ * that start with @key. If no row matches @key, %NULL will be returned.
+ * Note that a text column must have been set for this function to work,
+ * see gtk_entry_completion_set_text_column() for details.
+ *
+ * Returns: (transfer: full): The common prefix all rows starting with @key
+ * or %NULL if no row matches @key.
+ *
+ * Since: 3.4
+ **/
+gchar *
+gtk_entry_completion_compute_prefix (GtkEntryCompletion *completion,
+ const char *key)
{
GtkTreeIter iter;
gchar *prefix = NULL;
gboolean valid;
- const gchar *key;
if (completion->priv->text_column < 0)
return NULL;
- key = gtk_entry_get_text (GTK_ENTRY (completion->priv->entry));
-
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (completion->priv->filter_model),
&iter);
@@ -1874,7 +1887,9 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
g_signal_handler_block (completion->priv->entry,
completion->priv->insert_text_id);
- prefix = gtk_entry_completion_compute_prefix (completion);
+ prefix = gtk_entry_completion_compute_prefix (completion,
+ gtk_entry_get_text (GTK_ENTRY (completion->priv->entry)));
+
if (prefix)
{
g_signal_emit (completion, entry_completion_signals[INSERT_PREFIX],
diff --git a/gtk/gtkentrycompletion.h b/gtk/gtkentrycompletion.h
index 368b944..0b19e6d 100644
--- a/gtk/gtkentrycompletion.h
+++ b/gtk/gtkentrycompletion.h
@@ -114,6 +114,8 @@ void gtk_entry_completion_set_match_func (GtkEntryComplet
void gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion,
gint length);
gint gtk_entry_completion_get_minimum_key_length (GtkEntryCompletion *completion);
+gchar * gtk_entry_completion_compute_prefix (GtkEntryCompletion *completion,
+ const char *key);
void gtk_entry_completion_complete (GtkEntryCompletion *completion);
void gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]