[gspell/wip/choose-language-context-menu] text-view: add :language-menu boolean property
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/choose-language-context-menu] text-view: add :language-menu boolean property
- Date: Sun, 8 May 2016 16:00:21 +0000 (UTC)
commit db260ae374f816e8bc031d4044fe3555b80c4268
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun May 8 17:59:25 2016 +0200
text-view: add :language-menu boolean property
https://bugzilla.gnome.org/show_bug.cgi?id=758415
gspell/gspell-text-view.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
gspell/gspell-text-view.h | 5 +++
2 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/gspell/gspell-text-view.c b/gspell/gspell-text-view.c
index 62386da..6fdab9d 100644
--- a/gspell/gspell-text-view.c
+++ b/gspell/gspell-text-view.c
@@ -53,6 +53,7 @@ struct _GspellTextViewPrivate
{
GtkTextView *view;
GspellInlineCheckerTextBuffer *inline_checker;
+ guint language_menu : 1;
};
enum
@@ -60,6 +61,7 @@ enum
PROP_0,
PROP_VIEW,
PROP_INLINE_SPELL_CHECKING,
+ PROP_LANGUAGE_MENU,
};
#define GSPELL_TEXT_VIEW_KEY "gspell-text-view-key"
@@ -248,6 +250,23 @@ gspell_text_view_class_init (GspellTextViewClass *klass)
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GspellTextView:language-menu:
+ *
+ * Whether to add a sub-menu to the context menu to select the language
+ * for the spell checking.
+ *
+ * Since: 1.2
+ */
+ g_object_class_install_property (object_class,
+ PROP_LANGUAGE_MENU,
+ g_param_spec_boolean ("language-menu",
+ "Language Menu",
+ "",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -355,4 +374,54 @@ gspell_text_view_set_inline_spell_checking (GspellTextView *gspell_view,
g_object_notify (G_OBJECT (gspell_view), "inline-spell-checking");
}
+/**
+ * gspell_text_view_get_language_menu:
+ * @gspell_view: a #GspellTextView.
+ *
+ * Returns: whether the language context menu is enabled.
+ * Since: 1.2
+ */
+gboolean
+gspell_text_view_get_language_menu (GspellTextView *gspell_view)
+{
+ GspellTextViewPrivate *priv;
+
+ g_return_val_if_fail (GSPELL_IS_TEXT_VIEW (gspell_view), FALSE);
+
+ priv = gspell_text_view_get_instance_private (gspell_view);
+ return priv->language_menu;
+}
+
+/**
+ * gspell_text_view_set_language_menu:
+ * @gspell_view: a #GspellTextView.
+ * @language_menu: whether to enable the language context menu.
+ *
+ * Sets whether to enable the language context menu. If enabled, doing a right
+ * click on the #GtkTextView will show a sub-menu to choose the language for the
+ * spell checking. If another language is chosen, it changes the
+ * #GspellChecker:language property of the #GspellTextBuffer:spell-checker of
+ * the #GtkTextView:buffer of the #GspellTextView:view.
+ *
+ * Since: 1.2
+ */
+void
+gspell_text_view_set_language_menu (GspellTextView *gspell_view,
+ gboolean language_menu)
+{
+ GspellTextViewPrivate *priv;
+
+ g_return_if_fail (GSPELL_IS_TEXT_VIEW (gspell_view));
+
+ priv = gspell_text_view_get_instance_private (gspell_view);
+
+ language_menu = language_menu != FALSE;
+
+ if (priv->language_menu != language_menu)
+ {
+ priv->language_menu = language_menu;
+ g_object_notify (G_OBJECT (gspell_view), "language-menu");
+ }
+}
+
/* ex:set ts=8 noet: */
diff --git a/gspell/gspell-text-view.h b/gspell/gspell-text-view.h
index b11e554..9cfc0ed 100644
--- a/gspell/gspell-text-view.h
+++ b/gspell/gspell-text-view.h
@@ -50,6 +50,11 @@ gboolean gspell_text_view_get_inline_spell_checking (GspellTextView
*gspell_vie
void gspell_text_view_set_inline_spell_checking (GspellTextView *gspell_view,
gboolean enable);
+gboolean gspell_text_view_get_language_menu (GspellTextView *gspell_view);
+
+void gspell_text_view_set_language_menu (GspellTextView *gspell_view,
+ gboolean language_menu);
+
G_END_DECLS
#endif /* GSPELL_TEXT_VIEW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]