[gspell] text-buffer: simplify code of constructor
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell] text-buffer: simplify code of constructor
- Date: Fri, 11 Mar 2016 15:38:52 +0000 (UTC)
commit 8e1dd019029b4eda41085bffd685de7c990871a8
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Mar 11 16:24:56 2016 +0100
text-buffer: simplify code of constructor
gspell/gspell-text-buffer.c | 30 +++++++++++-------------------
1 files changed, 11 insertions(+), 19 deletions(-)
---
diff --git a/gspell/gspell-text-buffer.c b/gspell/gspell-text-buffer.c
index 931434f..6bebe37 100644
--- a/gspell/gspell-text-buffer.c
+++ b/gspell/gspell-text-buffer.c
@@ -151,16 +151,6 @@ gspell_text_buffer_init (GspellTextBuffer *gspell_buffer)
{
}
-static GspellTextBuffer *
-gspell_text_buffer_new (GtkTextBuffer *gtk_buffer)
-{
- g_return_val_if_fail (GTK_IS_TEXT_BUFFER (gtk_buffer), NULL);
-
- return g_object_new (GSPELL_TYPE_TEXT_BUFFER,
- "buffer", gtk_buffer,
- NULL);
-}
-
/**
* gspell_text_buffer_get_from_gtk_text_buffer:
* @gtk_buffer: a #GtkTextBuffer.
@@ -183,18 +173,20 @@ gspell_text_buffer_get_from_gtk_text_buffer (GtkTextBuffer *gtk_buffer)
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (gtk_buffer), NULL);
gspell_buffer = g_object_get_data (G_OBJECT (gtk_buffer), GSPELL_TEXT_BUFFER_KEY);
- if (gspell_buffer != NULL)
+
+ if (gspell_buffer == NULL)
{
- g_return_val_if_fail (GSPELL_IS_TEXT_BUFFER (gspell_buffer), NULL);
- return gspell_buffer;
+ gspell_buffer = g_object_new (GSPELL_TYPE_TEXT_BUFFER,
+ "buffer", gtk_buffer,
+ NULL);
+
+ g_object_set_data_full (G_OBJECT (gtk_buffer),
+ GSPELL_TEXT_BUFFER_KEY,
+ gspell_buffer,
+ g_object_unref);
}
- gspell_buffer = gspell_text_buffer_new (gtk_buffer);
- g_object_set_data_full (G_OBJECT (gtk_buffer),
- GSPELL_TEXT_BUFFER_KEY,
- gspell_buffer,
- g_object_unref);
-
+ g_return_val_if_fail (GSPELL_IS_TEXT_BUFFER (gspell_buffer), NULL);
return gspell_buffer;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]