]> jfr.im git - irc/hexchat/hexchat.git/commitdiff
Apply timeout changes made in preferences dialog
authorBen Gamari <redacted>
Mon, 9 May 2016 07:01:09 +0000 (09:01 +0200)
committerPatrick Griffis <redacted>
Wed, 29 Jun 2016 19:42:11 +0000 (15:42 -0400)
Just involves a bit of refactoring.

src/common/hexchat.c
src/common/hexchatc.h
src/fe-gtk/setup.c

index f2c79024c3e292b9355255a5cfe71bea74170efa..3104ec5306eed4741e310a8690fe4f2c7a5e1174 100644 (file)
@@ -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)
        {
index 9d603870c312efea3592a84fb340f99f8bbc6b0f..ae1c540cb670b6f41c0fa43f0995d9a9a7e0438d 100644 (file)
@@ -50,6 +50,7 @@ extern GList *sess_list_by_lastact[];
 session * find_channel (server *serv, char *chan);
 session * find_dialog (server *serv, char *nick);
 session * new_ircwindow (server *serv, char *name, int type, int focus);
+void hexchat_reinit_timers (void);
 void lastact_update (session * sess);
 session * lastact_getfirst (int (*filter) (session *sess));
 int is_session (session * sess);
index a934b9d7d4872d6f5d0f7ba80a4c3ec0832125c6..eaac870e47dbd9261c99d99015425cc083b5ec1c 100644 (file)
@@ -2132,6 +2132,7 @@ setup_apply_real (int new_pix, int do_ulist, int do_layout, int do_identd)
 
        mg_apply_setup ();
        tray_apply_setup ();
+       hexchat_reinit_timers ();
 
        if (do_layout)
                menu_change_layout ();