[devhelp] Settings: add freeze/thaw_books_disabled_changed()



commit 6e268b99750668321a8f55fd992f70ecc35e5754
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Apr 29 10:20:15 2018 +0200

    Settings: add freeze/thaw_books_disabled_changed()

 devhelp/dh-settings.c               |   51 +++++++++++++++++++++++++++++++++++
 devhelp/dh-settings.h               |    4 +++
 docs/reference/devhelp-sections.txt |    2 +
 3 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/devhelp/dh-settings.c b/devhelp/dh-settings.c
index fab7344..23916f9 100644
--- a/devhelp/dh-settings.c
+++ b/devhelp/dh-settings.c
@@ -515,3 +515,54 @@ dh_settings_set_book_enabled (DhSettings *settings,
         else
                 disable_book (settings, book_id);
 }
+
+/**
+ * dh_settings_freeze_books_disabled_changed:
+ * @settings: a #DhSettings.
+ *
+ * Tells @settings to not emit the #DhSettings::books-disabled-changed signal
+ * until dh_settings_thaw_books_disabled_changed() is called.
+ *
+ * A bit like g_object_freeze_notify(), except that there is no freeze count.
+ *
+ * This function is useful if you call dh_settings_set_book_enabled() several
+ * times in a row.
+ *
+ * Since: 3.30
+ */
+void
+dh_settings_freeze_books_disabled_changed (DhSettings *settings)
+{
+        g_return_if_fail (DH_IS_SETTINGS (settings));
+
+        g_signal_handlers_block_by_func (settings->priv->gsettings_contents,
+                                         books_disabled_changed_cb,
+                                         settings);
+}
+
+/**
+ * dh_settings_thaw_books_disabled_changed:
+ * @settings: a #DhSettings.
+ *
+ * Stops the effect of dh_settings_freeze_books_disabled_changed(), and emits
+ * the #DhSettings::books-disabled-changed signal.
+ *
+ * A bit like g_object_thaw_notify(), except that there is no freeze count.
+ *
+ * Since: 3.30
+ */
+void
+dh_settings_thaw_books_disabled_changed (DhSettings *settings)
+{
+        g_return_if_fail (DH_IS_SETTINGS (settings));
+
+        g_signal_handlers_unblock_by_func (settings->priv->gsettings_contents,
+                                           books_disabled_changed_cb,
+                                           settings);
+
+        /* Emit the signal in any case, the implementation is simpler and good
+         * enough, it doesn't hurt to emit the signal even if the GSettings key
+         * didn't change.
+         */
+        g_signal_emit (settings, signals[SIGNAL_BOOKS_DISABLED_CHANGED], 0);
+}
diff --git a/devhelp/dh-settings.h b/devhelp/dh-settings.h
index 2d39a87..ad2b8e9 100644
--- a/devhelp/dh-settings.h
+++ b/devhelp/dh-settings.h
@@ -79,6 +79,10 @@ void            dh_settings_set_book_enabled                    (DhSettings *set
                                                                  DhBook     *book,
                                                                  gboolean    enabled);
 
+void            dh_settings_freeze_books_disabled_changed       (DhSettings *settings);
+
+void            dh_settings_thaw_books_disabled_changed         (DhSettings *settings);
+
 G_END_DECLS
 
 #endif /* DH_SETTINGS_H */
diff --git a/docs/reference/devhelp-sections.txt b/docs/reference/devhelp-sections.txt
index d744bb1..e7ef396 100644
--- a/docs/reference/devhelp-sections.txt
+++ b/docs/reference/devhelp-sections.txt
@@ -254,6 +254,8 @@ dh_settings_set_group_books_by_language
 dh_settings_bind_group_books_by_language
 dh_settings_is_book_enabled
 dh_settings_set_book_enabled
+dh_settings_freeze_books_disabled_changed
+dh_settings_thaw_books_disabled_changed
 <SUBSECTION Standard>
 DH_IS_SETTINGS
 DH_IS_SETTINGS_CLASS


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