summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2021-10-24 15:25:27 +0200
committerraveit65 <[email protected]>2023-04-16 14:35:19 +0200
commit27ba0c85ae8284a8edfdbf8cda52e99100b7185b (patch)
treee5fe584321e839bb607f6c75b53ee2c146f4134c
parent86f35430ef224a01842a731ab0977f3356e6f1b0 (diff)
downloadlibmatekbd-27ba0c85ae8284a8edfdbf8cda52e99100b7185b.tar.bz2
libmatekbd-27ba0c85ae8284a8edfdbf8cda52e99100b7185b.tar.xz
Use GLib's new g_clear_signal_handler() function to simplify code
-rw-r--r--libmatekbd/matekbd-desktop-config.c13
-rw-r--r--libmatekbd/matekbd-indicator-config.c13
-rw-r--r--libmatekbd/matekbd-keyboard-config.c13
-rw-r--r--libmatekbd/matekbd-status.c13
4 files changed, 43 insertions, 9 deletions
diff --git a/libmatekbd/matekbd-desktop-config.c b/libmatekbd/matekbd-desktop-config.c
index 1d854ff..19e0dae 100644
--- a/libmatekbd/matekbd-desktop-config.c
+++ b/libmatekbd/matekbd-desktop-config.c
@@ -256,9 +256,16 @@ matekbd_desktop_config_start_listen (MatekbdDesktopConfig * config,
void
matekbd_desktop_config_stop_listen (MatekbdDesktopConfig * config)
{
- g_signal_handler_disconnect (config->settings,
- config->config_listener_id);
- config->config_listener_id = 0;
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&config->config_listener_id,
+ config->settings);
+#else
+ if (config->config_listener_id != 0) {
+ g_signal_handler_disconnect (config->settings,
+ config->config_listener_id);
+ config->config_listener_id = 0;
+ }
+#endif
}
gboolean
diff --git a/libmatekbd/matekbd-indicator-config.c b/libmatekbd/matekbd-indicator-config.c
index 869b26e..a606af8 100644
--- a/libmatekbd/matekbd-indicator-config.c
+++ b/libmatekbd/matekbd-indicator-config.c
@@ -332,7 +332,14 @@ matekbd_indicator_config_start_listen (MatekbdIndicatorConfig *
void
matekbd_indicator_config_stop_listen (MatekbdIndicatorConfig * ind_config)
{
- g_signal_handler_disconnect (ind_config->settings,
- ind_config->config_listener_id);
- ind_config->config_listener_id = 0;
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&ind_config->config_listener_id,
+ ind_config->settings);
+#else
+ if (ind_config->config_listener_id != 0) {
+ g_signal_handler_disconnect (ind_config->settings,
+ ind_config->config_listener_id);
+ ind_config->config_listener_id = 0;
+ }
+#endif
}
diff --git a/libmatekbd/matekbd-keyboard-config.c b/libmatekbd/matekbd-keyboard-config.c
index 7338e28..8a683c5 100644
--- a/libmatekbd/matekbd-keyboard-config.c
+++ b/libmatekbd/matekbd-keyboard-config.c
@@ -650,9 +650,16 @@ matekbd_keyboard_config_start_listen (MatekbdKeyboardConfig * kbd_config,
void
matekbd_keyboard_config_stop_listen (MatekbdKeyboardConfig * kbd_config)
{
- g_signal_handler_disconnect (kbd_config->settings,
- kbd_config->config_listener_id);
- kbd_config->config_listener_id = 0;
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&kbd_config->config_listener_id,
+ kbd_config->settings);
+#else
+ if (kbd_config->config_listener_id != 0) {
+ g_signal_handler_disconnect (kbd_config->settings,
+ kbd_config->config_listener_id);
+ kbd_config->config_listener_id = 0;
+ }
+#endif
}
gboolean
diff --git a/libmatekbd/matekbd-status.c b/libmatekbd/matekbd-status.c
index 68c15dc..029ea73 100644
--- a/libmatekbd/matekbd-status.c
+++ b/libmatekbd/matekbd-status.c
@@ -720,6 +720,18 @@ matekbd_status_global_term (void)
matekbd_keyboard_config_term (&globals.kbd_cfg);
matekbd_desktop_config_term (&globals.cfg);
+#if GLIB_CHECK_VERSION(2,62,0)
+ if ((globals.state_changed_handler != 0) &&
+ g_signal_handler_is_connected (globals.engine,
+ globals.state_changed_handler))
+ g_clear_signal_handler (&globals.state_changed_handler,
+ globals.engine);
+ if ((globals.config_changed_handler != 0) &&
+ g_signal_handler_is_connected (globals.engine,
+ globals.config_changed_handler))
+ g_clear_signal_handler (&globals.config_changed_handler,
+ globals.engine);
+#else
if (g_signal_handler_is_connected
(globals.engine, globals.state_changed_handler)) {
g_signal_handler_disconnect (globals.engine,
@@ -732,6 +744,7 @@ matekbd_status_global_term (void)
globals.config_changed_handler);
globals.config_changed_handler = 0;
}
+#endif
g_object_unref (G_OBJECT (globals.registry));
globals.registry = NULL;