[devhelp/wip/swilmet/misc-improvements: 12/18] book-tree: use g_signal_connect_object()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/wip/swilmet/misc-improvements: 12/18] book-tree: use g_signal_connect_object()
- Date: Sun, 24 May 2015 15:35:34 +0000 (UTC)
commit 3d1aadf4f42baac05e20e4810704486ee022176d
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun May 24 15:22:31 2015 +0200
book-tree: use g_signal_connect_object()
It simplifies the code.
https://bugzilla.gnome.org/show_bug.cgi?id=749797
src/dh-book-tree.c | 95 ++++++++++++++++++---------------------------------
1 files changed, 34 insertions(+), 61 deletions(-)
---
diff --git a/src/dh-book-tree.c b/src/dh-book-tree.c
index 4423396..5e11469 100644
--- a/src/dh-book-tree.c
+++ b/src/dh-book-tree.c
@@ -34,13 +34,6 @@ typedef struct {
GtkTreeStore *store;
DhBookManager *book_manager;
DhLink *selected_link;
-
- /* Signals */
- guint book_created_id;
- guint book_deleted_id;
- guint book_enabled_id;
- guint book_disabled_id;
- guint group_by_language_id;
} DhBookTreePrivate;
static void dh_book_tree_class_init (DhBookTreeClass *klass);
@@ -82,37 +75,6 @@ dh_book_tree_dispose (GObject *object)
{
DhBookTreePrivate *priv = dh_book_tree_get_instance_private (DH_BOOK_TREE (object));
- /* Disconnect signals */
- if (priv->book_created_id != 0 &&
- g_signal_handler_is_connected (priv->book_manager, priv->book_created_id)) {
- g_signal_handler_disconnect (priv->book_manager, priv->book_created_id);
- priv->book_created_id = 0;
- }
-
- if (priv->book_deleted_id &&
- g_signal_handler_is_connected (priv->book_manager, priv->book_deleted_id)) {
- g_signal_handler_disconnect (priv->book_manager, priv->book_deleted_id);
- priv->book_deleted_id = 0;
- }
-
- if (priv->book_enabled_id != 0 &&
- g_signal_handler_is_connected (priv->book_manager, priv->book_enabled_id)) {
- g_signal_handler_disconnect (priv->book_manager, priv->book_enabled_id);
- priv->book_enabled_id = 0;
- }
-
- if (priv->book_disabled_id != 0 &&
- g_signal_handler_is_connected (priv->book_manager, priv->book_disabled_id)) {
- g_signal_handler_disconnect (priv->book_manager, priv->book_disabled_id);
- priv->book_disabled_id = 0;
- }
-
- if (priv->group_by_language_id != 0 &&
- g_signal_handler_is_connected (priv->book_manager, priv->group_by_language_id)) {
- g_signal_handler_disconnect (priv->book_manager, priv->group_by_language_id);
- priv->group_by_language_id = 0;
- }
-
g_clear_object (&priv->store);
g_clear_object (&priv->book_manager);
@@ -211,9 +173,11 @@ book_tree_setup_selection (DhBookTree *tree)
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
- g_signal_connect (selection, "changed",
- G_CALLBACK (book_tree_selection_changed_cb),
- tree);
+ g_signal_connect_object (selection,
+ "changed",
+ G_CALLBACK (book_tree_selection_changed_cb),
+ tree,
+ 0);
}
/* Tries to find:
@@ -720,26 +684,35 @@ dh_book_tree_constructed (GObject *object)
DhBookTree *tree = DH_BOOK_TREE (object);
DhBookTreePrivate *priv = dh_book_tree_get_instance_private (tree);
- priv->book_created_id = g_signal_connect (priv->book_manager,
- "book-created",
- G_CALLBACK (book_tree_book_created_or_enabled_cb),
- tree);
- priv->book_deleted_id = g_signal_connect (priv->book_manager,
- "book-deleted",
- G_CALLBACK (book_tree_book_deleted_or_disabled_cb),
- tree);
- priv->book_enabled_id = g_signal_connect (priv->book_manager,
- "book-enabled",
- G_CALLBACK (book_tree_book_created_or_enabled_cb),
- tree);
- priv->book_disabled_id = g_signal_connect (priv->book_manager,
- "book-disabled",
- G_CALLBACK (book_tree_book_deleted_or_disabled_cb),
- tree);
- priv->group_by_language_id = g_signal_connect (priv->book_manager,
- "notify::group-by-language",
- G_CALLBACK (book_tree_group_by_language_cb),
- tree);
+ g_signal_connect_object (priv->book_manager,
+ "book-created",
+ G_CALLBACK (book_tree_book_created_or_enabled_cb),
+ tree,
+ 0);
+
+ g_signal_connect_object (priv->book_manager,
+ "book-deleted",
+ G_CALLBACK (book_tree_book_deleted_or_disabled_cb),
+ tree,
+ 0);
+
+ g_signal_connect_object (priv->book_manager,
+ "book-enabled",
+ G_CALLBACK (book_tree_book_created_or_enabled_cb),
+ tree,
+ 0);
+
+ g_signal_connect_object (priv->book_manager,
+ "book-disabled",
+ G_CALLBACK (book_tree_book_deleted_or_disabled_cb),
+ tree,
+ 0);
+
+ g_signal_connect_object (priv->book_manager,
+ "notify::group-by-language",
+ G_CALLBACK (book_tree_group_by_language_cb),
+ tree,
+ 0);
book_tree_populate_tree (tree);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]