[gspell] Entry: add basic_setup()



commit 9c5045d55b5c3ec1d1f0f13d771678d5dd690d6d
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Nov 26 18:38:43 2016 +0100

    Entry: add basic_setup()
    
    Like gspell_text_view_basic_setup().

 docs/reference/gspell-1.0-sections.txt |    1 +
 gspell/gspell-entry.c                  |   56 ++++++++++++++++++++++++++++++++
 gspell/gspell-entry.h                  |    2 +
 3 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gspell-1.0-sections.txt b/docs/reference/gspell-1.0-sections.txt
index 44042c3..0880d9f 100644
--- a/docs/reference/gspell-1.0-sections.txt
+++ b/docs/reference/gspell-1.0-sections.txt
@@ -150,6 +150,7 @@ GSPELL_TYPE_ENTRY_BUFFER
 <TITLE>GspellEntry</TITLE>
 GspellEntry
 gspell_entry_get_from_gtk_entry
+gspell_entry_basic_setup
 gspell_entry_get_entry
 gspell_entry_get_inline_spell_checking
 gspell_entry_set_inline_spell_checking
diff --git a/gspell/gspell-entry.c b/gspell/gspell-entry.c
index 3dfeb04..f8becb3 100644
--- a/gspell/gspell-entry.c
+++ b/gspell/gspell-entry.c
@@ -815,6 +815,62 @@ gspell_entry_get_from_gtk_entry (GtkEntry *gtk_entry)
 }
 
 /**
+ * gspell_entry_basic_setup:
+ * @gspell_entry: a #GspellEntry.
+ *
+ * This function is a convenience function that does the following:
+ * - Set a spell checker. The language chosen is the one returned by
+ *   gspell_language_get_default().
+ * - Set the #GspellEntry:inline-spell-checking property to %TRUE.
+ *
+ * Example:
+ * |[
+ * GtkEntry *gtk_entry;
+ * GspellEntry *gspell_entry;
+ *
+ * gspell_entry = gspell_entry_get_from_gtk_entry (gtk_entry);
+ * gspell_entry_basic_setup (gspell_entry);
+ * ]|
+ *
+ * This is equivalent to:
+ * |[
+ * GtkEntry *gtk_entry;
+ * GspellEntry *gspell_entry;
+ * GspellChecker *checker;
+ * GtkEntryBuffer *gtk_buffer;
+ * GspellEntryBuffer *gspell_buffer;
+ *
+ * checker = gspell_checker_new (NULL);
+ * gtk_buffer = gtk_entry_get_buffer (gtk_entry);
+ * gspell_buffer = gspell_entry_buffer_get_from_gtk_entry_buffer (gtk_buffer);
+ * gspell_entry_buffer_set_spell_checker (gspell_buffer, checker);
+ * g_object_unref (checker);
+ *
+ * gspell_entry = gspell_entry_get_from_gtk_entry (gtk_entry);
+ * gspell_entry_set_inline_spell_checking (gspell_entry, TRUE);
+ * ]|
+ *
+ * Since: 1.4
+ */
+void
+gspell_entry_basic_setup (GspellEntry *gspell_entry)
+{
+       GspellChecker *checker;
+       GtkEntryBuffer *gtk_buffer;
+       GspellEntryBuffer *gspell_buffer;
+
+       g_return_if_fail (GSPELL_IS_ENTRY (gspell_entry));
+
+       checker = gspell_checker_new (NULL);
+       gtk_buffer = gtk_entry_get_buffer (gspell_entry->entry);
+       gspell_buffer = gspell_entry_buffer_get_from_gtk_entry_buffer (gtk_buffer);
+       gspell_entry_buffer_set_spell_checker (gspell_buffer, checker);
+       g_object_unref (checker);
+
+       gspell_entry_set_inline_spell_checking (gspell_entry, TRUE);
+}
+
+/**
  * gspell_entry_get_entry:
  * @gspell_entry: a #GspellEntry.
  *
diff --git a/gspell/gspell-entry.h b/gspell/gspell-entry.h
index ee2ccb7..d7f1671 100644
--- a/gspell/gspell-entry.h
+++ b/gspell/gspell-entry.h
@@ -35,6 +35,8 @@ G_DECLARE_FINAL_TYPE (GspellEntry, gspell_entry,
 
 GspellEntry *  gspell_entry_get_from_gtk_entry         (GtkEntry *gtk_entry);
 
+void           gspell_entry_basic_setup                (GspellEntry *gspell_entry);
+
 GtkEntry *     gspell_entry_get_entry                  (GspellEntry *gspell_entry);
 
 gboolean       gspell_entry_get_inline_spell_checking  (GspellEntry *gspell_entry);


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