[gspell] navigator: GInitiallyUnowned



commit 72fdd0af8c4d77c70d769825a9c3a352b5bfdd10
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Mar 12 13:26:48 2016 +0100

    navigator: GInitiallyUnowned
    
    To use the full possibilities of GObject, when it makes sense.

 gspell/gspell-checker-dialog.c      |    6 +-----
 gspell/gspell-navigator-text-view.c |    2 +-
 gspell/gspell-navigator-text-view.h |    4 ++--
 gspell/gspell-navigator.c           |    4 ++--
 gspell/gspell-navigator.h           |    4 ++--
 tests/test-spell.c                  |    1 -
 6 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/gspell/gspell-checker-dialog.c b/gspell/gspell-checker-dialog.c
index e63fa8e..4e49059 100644
--- a/gspell/gspell-checker-dialog.c
+++ b/gspell/gspell-checker-dialog.c
@@ -100,7 +100,7 @@ set_navigator (GspellCheckerDialog *dialog,
        priv = gspell_checker_dialog_get_instance_private (dialog);
 
        g_return_if_fail (priv->navigator == NULL);
-       priv->navigator = g_object_ref (navigator);
+       priv->navigator = g_object_ref_sink (navigator);
 
        g_object_notify (G_OBJECT (dialog), "spell-navigator");
 }
@@ -703,10 +703,6 @@ gspell_checker_dialog_init (GspellCheckerDialog *dialog)
  * @parent: transient parent of the dialog.
  * @navigator: the #GspellNavigator to use.
  *
- * Creates a new #GspellCheckerDialog. The #GspellCheckerDialog will own a
- * reference to @navigator, so you can release your reference if you no longer
- * need it.
- *
  * Returns: a new #GspellCheckerDialog widget.
  */
 GtkWidget *
diff --git a/gspell/gspell-navigator-text-view.c b/gspell/gspell-navigator-text-view.c
index 5e6778a..1052181 100644
--- a/gspell/gspell-navigator-text-view.c
+++ b/gspell/gspell-navigator-text-view.c
@@ -73,7 +73,7 @@ static void gspell_navigator_iface_init (gpointer g_iface, gpointer iface_data);
 
 G_DEFINE_TYPE_WITH_CODE (GspellNavigatorTextView,
                         gspell_navigator_text_view,
-                        G_TYPE_OBJECT,
+                        G_TYPE_INITIALLY_UNOWNED,
                         G_ADD_PRIVATE (GspellNavigatorTextView)
                         G_IMPLEMENT_INTERFACE (GSPELL_TYPE_NAVIGATOR,
                                                gspell_navigator_iface_init))
diff --git a/gspell/gspell-navigator-text-view.h b/gspell/gspell-navigator-text-view.h
index 052d8bd..405b499 100644
--- a/gspell/gspell-navigator-text-view.h
+++ b/gspell/gspell-navigator-text-view.h
@@ -33,11 +33,11 @@ G_BEGIN_DECLS
 #define GSPELL_TYPE_NAVIGATOR_TEXT_VIEW (gspell_navigator_text_view_get_type ())
 G_DECLARE_DERIVABLE_TYPE (GspellNavigatorTextView, gspell_navigator_text_view,
                          GSPELL, NAVIGATOR_TEXT_VIEW,
-                         GObject)
+                         GInitiallyUnowned)
 
 struct _GspellNavigatorTextViewClass
 {
-       GObjectClass parent_class;
+       GInitiallyUnownedClass parent_class;
 
        /* Padding for future expansion */
        gpointer padding[8];
diff --git a/gspell/gspell-navigator.c b/gspell/gspell-navigator.c
index a9cfa8c..3dc00b6 100644
--- a/gspell/gspell-navigator.c
+++ b/gspell/gspell-navigator.c
@@ -1,7 +1,7 @@
 /*
  * This file is part of gspell, a spell-checking library.
  *
- * Copyright 2015 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright 2015, 2016 - Sébastien Wilmet <swilmet gnome org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -39,7 +39,7 @@
  * interface.
  */
 
-G_DEFINE_INTERFACE (GspellNavigator, gspell_navigator, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE (GspellNavigator, gspell_navigator, G_TYPE_INITIALLY_UNOWNED)
 
 static gboolean
 gspell_navigator_goto_next_default (GspellNavigator  *navigator,
diff --git a/gspell/gspell-navigator.h b/gspell/gspell-navigator.h
index 5c87f43..e03106d 100644
--- a/gspell/gspell-navigator.h
+++ b/gspell/gspell-navigator.h
@@ -1,7 +1,7 @@
 /*
  * This file is part of gspell, a spell-checking library.
  *
- * Copyright 2015 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright 2015, 2016 - Sébastien Wilmet <swilmet gnome org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
 #define GSPELL_TYPE_NAVIGATOR (gspell_navigator_get_type ())
 G_DECLARE_INTERFACE (GspellNavigator, gspell_navigator,
                     GSPELL, NAVIGATOR,
-                    GObject)
+                    GInitiallyUnowned)
 
 struct _GspellNavigatorInterface
 {
diff --git a/tests/test-spell.c b/tests/test-spell.c
index 4a12e05..d079021 100644
--- a/tests/test-spell.c
+++ b/tests/test-spell.c
@@ -66,7 +66,6 @@ checker_button_clicked_cb (GtkButton *checker_button,
 
        navigator = gspell_navigator_text_view_new (spell->view);
        checker_dialog = gspell_checker_dialog_new (GTK_WINDOW (window), navigator);
-       g_object_unref (navigator);
 
        gtk_widget_show (checker_dialog);
 }


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