[balsa/wip/gtk4: 295/351] message: Store the signal handler id
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gtk4: 295/351] message: Store the signal handler id
- Date: Wed, 23 May 2018 21:41:46 +0000 (UTC)
commit 1d2a7f644614455cf72815c4c59b8bb708be7073
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu Apr 26 14:12:58 2018 -0400
message: Store the signal handler id
and use it to make sure we don't connect multiple times, and to simplify
disconnecting.
src/balsa-message.c | 15 ++++++++-------
src/balsa-message.h | 1 +
2 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/balsa-message.c b/src/balsa-message.c
index c61a7eb..2a091fe 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -675,11 +675,9 @@ bm_disable_find_entry(BalsaMessage * bm)
if (GTK_IS_APPLICATION_WINDOW(toplevel))
libbalsa_window_block_accels((GtkApplicationWindow *) toplevel, FALSE);
- if (bm->find_key_controller != NULL) {
- g_signal_handlers_disconnect_by_func(bm->find_key_controller,
- G_CALLBACK(bm_find_pass_to_entry),
- bm);
- }
+ if (bm->find_key_controller != NULL && bm->key_pressed_id != 0)
+ g_signal_handler_disconnect(bm->find_key_controller, bm->key_pressed_id);
+ bm->key_pressed_id = 0;
gtk_widget_hide(bm->find_bar);
}
@@ -3312,8 +3310,11 @@ balsa_message_find_in_message(BalsaMessage * bm)
bm->find_key_controller =
gtk_event_controller_key_new(gtk_widget_get_toplevel(GTK_WIDGET(bm)));
}
- g_signal_connect(bm->find_key_controller, "key-pressed",
- G_CALLBACK(bm_find_pass_to_entry), bm);
+ if (bm->key_pressed_id == 0) {
+ bm->key_pressed_id =
+ g_signal_connect(bm->find_key_controller, "key-pressed",
+ G_CALLBACK(bm_find_pass_to_entry), bm);
+ }
bm_find_set_status(bm, BM_FIND_STATUS_INIT);
diff --git a/src/balsa-message.h b/src/balsa-message.h
index 684c90f..69c0eb9 100644
--- a/src/balsa-message.h
+++ b/src/balsa-message.h
@@ -105,6 +105,7 @@ struct _BalsaMessage {
GtkEventController *button_key_controller;
GtkEventController *header_key_controller;
GtkEventController *find_key_controller;
+ gulong key_pressed_id;
};
struct _BalsaMessageClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]