diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-01-26 18:07:13 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-01-26 18:07:13 +0100 |
commit | 754cf874bcc28f4d1ec8c3f118a8b1a86500ca90 (patch) | |
tree | 8fbc9bd9bf82cf441b4a20699fa5ce598984137a | |
parent | ac19ec05be992ca3188d96a7e5cb949fccb457b7 (diff) | |
download | weechat-754cf874bcc28f4d1ec8c3f118a8b1a86500ca90.zip |
Send signal "day_changed" even if option weechat.look.day_change is set to off
-rw-r--r-- | src/core/wee-config.c | 93 |
1 files changed, 35 insertions, 58 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 384e42e69..4436a9526 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -357,23 +357,26 @@ config_day_change_timer_cb (void *data, int remaining_calls) if ((config_day_change_old_day >= 0) && (local_time->tm_mday != config_day_change_old_day)) { - strftime (text_time, sizeof (text_time), - CONFIG_STRING(config_look_day_change_time_format), - local_time); - text_time2 = string_iconv_to_internal (NULL, text_time); - gui_add_hotlist = 0; - for (ptr_buffer = gui_buffers; ptr_buffer; - ptr_buffer = ptr_buffer->next_buffer) + if (CONFIG_BOOLEAN(config_look_day_change)) { - if (ptr_buffer->type == GUI_BUFFER_TYPE_FORMATTED) - gui_chat_printf (ptr_buffer, - _("\t\tDay changed to %s"), - (text_time2) ? - text_time2 : text_time); + strftime (text_time, sizeof (text_time), + CONFIG_STRING(config_look_day_change_time_format), + local_time); + text_time2 = string_iconv_to_internal (NULL, text_time); + gui_add_hotlist = 0; + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) + { + if (ptr_buffer->type == GUI_BUFFER_TYPE_FORMATTED) + gui_chat_printf (ptr_buffer, + _("\t\tDay changed to %s"), + (text_time2) ? + text_time2 : text_time); + } + if (text_time2) + free (text_time2); + gui_add_hotlist = 1; } - if (text_time2) - free (text_time2); - gui_add_hotlist = 1; /* send signal "day_changed" */ strftime (text_time, sizeof (text_time), "%Y-%m-%d", local_time); @@ -386,47 +389,6 @@ config_day_change_timer_cb (void *data, int remaining_calls) } /* - * config_change_day_change: called when day_change option changed - */ - -void -config_change_day_change (void *data, struct t_config_option *option) -{ - struct timeval tv_time; - struct tm *local_time; - - /* make C compiler happy */ - (void) data; - (void) option; - - if (CONFIG_BOOLEAN(config_look_day_change)) - { - if (!config_day_change_timer) - { - gettimeofday (&tv_time, NULL); - local_time = localtime (&tv_time.tv_sec); - config_day_change_old_day = local_time->tm_mday; - - config_day_change_timer = hook_timer (NULL, - 60 * 1000, /* each minute */ - 60, /* when second is 00 */ - 0, - &config_day_change_timer_cb, - NULL); - } - } - else - { - if (config_day_change_timer) - { - unhook (config_day_change_timer); - config_day_change_timer = NULL; - config_day_change_old_day = -1; - } - } -} - -/* * config_weechat_reload_cb: reload WeeChat configuration file * return one of these values: * WEECHAT_CONFIG_READ_OK @@ -1275,7 +1237,7 @@ config_weechat_init_options () weechat_config_file, ptr_section, "day_change", "boolean", N_("display special message when day changes"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_day_change, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); config_look_day_change_time_format = config_file_new_option ( weechat_config_file, ptr_section, "day_change_time_format", "string", @@ -2100,6 +2062,8 @@ int config_weechat_init () { int rc; + struct timeval tv_time; + struct tm *local_time; rc = config_weechat_init_options (); @@ -2109,6 +2073,20 @@ config_weechat_init () _("FATAL: error initializing configuration options")); } + /* create timer to check if day has changed */ + if (!config_day_change_timer) + { + gettimeofday (&tv_time, NULL); + local_time = localtime (&tv_time.tv_sec); + config_day_change_old_day = local_time->tm_mday; + config_day_change_timer = hook_timer (NULL, + 60 * 1000, /* each minute */ + 60, /* when second is 00 */ + 0, + &config_day_change_timer_cb, + NULL); + } + return rc; } @@ -2128,7 +2106,6 @@ config_weechat_read () rc = config_file_read (weechat_config_file); if (rc == WEECHAT_CONFIG_READ_OK) { - config_change_day_change (NULL, NULL); proxy_use_temp_proxies (); gui_bar_use_temp_bars (); gui_bar_create_default (); |