summary refs log tree commit diff stats
path: root/src/common/hexchat.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2016-05-09 09:01:09 +0200
committerPatrick Griffis <tingping@tingping.se>2016-06-29 15:42:11 -0400
commit9e4c2ddc47592d26cd4184e8942806fbd7becf18 (patch)
tree2d7aa26f19072883f18bda2315c175a8ed351044 /src/common/hexchat.c
parentbcbe42dd7a4b7bca0e699c3e52f2c9bf7b37deba (diff)
Apply timeout changes made in preferences dialog
Just involves a bit of refactoring.
Diffstat (limited to 'src/common/hexchat.c')
-rw-r--r--src/common/hexchat.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/common/hexchat.c b/src/common/hexchat.c
index f2c79024..3104ec53 100644
--- a/src/common/hexchat.c
+++ b/src/common/hexchat.c
@@ -369,6 +369,37 @@ hexchat_lag_check_update (void)   /* this gets called every 0.5 seconds */
 	return 1;
 }
 
+/* call whenever timeout intervals change */
+void
+hexchat_reinit_timers (void)
+{
+	static int lag_check_update_tag = 0;
+	static int lag_check_tag = 0;
+	static int away_tag = 0;
+
+	if (prefs.hex_notify_timeout)
+	{
+		notify_tag = fe_timeout_add_seconds (prefs.hex_notify_timeout,
+						     notify_checklist, NULL);
+	} else
+	{
+		fe_timeout_remove (notify_tag);
+	}
+
+	fe_timeout_remove (away_tag);
+	away_tag = fe_timeout_add_seconds (prefs.hex_away_timeout, away_check, NULL);
+
+	if (prefs.hex_gui_lagometer)
+	{
+		lag_check_update_tag = fe_timeout_add (500, hexchat_lag_check_update, NULL);
+		lag_check_tag = fe_timeout_add_seconds (30, hexchat_lag_check, NULL);
+	} else
+	{
+		fe_timeout_remove (lag_check_update_tag);
+		fe_timeout_remove (lag_check_tag);
+	}
+}
+
 /* executed when the first irc window opens */
 
 static void
@@ -394,16 +425,7 @@ irc_init (session *sess)
 	plugin_add (sess, NULL, NULL, dbus_plugin_init, NULL, NULL, FALSE);
 #endif
 
-	if (prefs.hex_notify_timeout)
-		notify_tag = fe_timeout_add_seconds (prefs.hex_notify_timeout,
-						     notify_checklist, NULL);
-
-	fe_timeout_add_seconds (prefs.hex_away_timeout, away_check, NULL);
-	if (prefs.hex_gui_lagometer)
-	{
-		fe_timeout_add (500, hexchat_lag_check_update, NULL);
-		fe_timeout_add_seconds (30, hexchat_lag_check, NULL);
-	}
+	hexchat_reinit_timers ();
 
 	if (arg_url != NULL)
 	{