2000-04-26 04:03:38 -04:00
|
|
|
/*
|
|
|
|
windows.c : irssi
|
|
|
|
|
|
|
|
Copyright (C) 1999-2000 Timo Sirainen
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "module.h"
|
|
|
|
#include "module-formats.h"
|
|
|
|
#include "modules.h"
|
|
|
|
#include "signals.h"
|
|
|
|
#include "commands.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "servers.h"
|
2000-05-04 06:32:42 -04:00
|
|
|
#include "misc.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
#include "levels.h"
|
|
|
|
|
|
|
|
#include "printtext.h"
|
2000-11-17 11:27:14 -05:00
|
|
|
#include "fe-windows.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
#include "window-items.h"
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
GSList *windows; /* first in the list is the active window,
|
|
|
|
next is the last active, etc. */
|
2000-04-26 04:03:38 -04:00
|
|
|
WINDOW_REC *active_win;
|
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
static int daytag;
|
2000-06-10 14:56:03 -04:00
|
|
|
static int daycheck; /* 0 = don't check, 1 = time is 00:00, check,
|
|
|
|
2 = time is 00:00, already checked */
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
static int window_get_new_refnum(void)
|
|
|
|
{
|
|
|
|
WINDOW_REC *win;
|
|
|
|
GSList *tmp;
|
|
|
|
int refnum;
|
|
|
|
|
|
|
|
refnum = 1;
|
|
|
|
tmp = windows;
|
|
|
|
while (tmp != NULL) {
|
|
|
|
win = tmp->data;
|
|
|
|
|
|
|
|
if (refnum != win->refnum) {
|
|
|
|
tmp = tmp->next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
refnum++;
|
|
|
|
tmp = windows;
|
|
|
|
}
|
|
|
|
|
|
|
|
return refnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
|
|
|
|
{
|
|
|
|
WINDOW_REC *rec;
|
|
|
|
|
|
|
|
rec = g_new0(WINDOW_REC, 1);
|
|
|
|
rec->refnum = window_get_new_refnum();
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
windows = g_slist_prepend(windows, rec);
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_emit("window created", 2, rec, GINT_TO_POINTER(automatic));
|
|
|
|
|
2000-12-02 14:08:21 -05:00
|
|
|
if (item != NULL) window_item_add(rec, item, automatic);
|
2000-04-26 04:03:38 -04:00
|
|
|
if (windows->next == NULL || !automatic || settings_get_bool("window_auto_change")) {
|
|
|
|
if (automatic && windows->next != NULL)
|
|
|
|
signal_emit("window changed automatic", 1, rec);
|
|
|
|
window_set_active(rec);
|
|
|
|
}
|
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
/* removed_refnum was removed from the windows list, pack the windows so
|
|
|
|
there won't be any holes. If there is any holes after removed_refnum,
|
|
|
|
leave the windows behind it alone. */
|
|
|
|
static void windows_pack(int removed_refnum)
|
|
|
|
{
|
|
|
|
WINDOW_REC *window;
|
|
|
|
int refnum;
|
|
|
|
|
|
|
|
for (refnum = removed_refnum+1;; refnum++) {
|
|
|
|
window = window_find_refnum(refnum);
|
|
|
|
if (window == NULL) break;
|
|
|
|
|
|
|
|
window_set_refnum(window, refnum-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
void window_destroy(WINDOW_REC *window)
|
|
|
|
{
|
|
|
|
g_return_if_fail(window != NULL);
|
|
|
|
|
|
|
|
if (window->destroying) return;
|
|
|
|
window->destroying = TRUE;
|
2000-08-11 15:57:58 -04:00
|
|
|
windows = g_slist_remove(windows, window);
|
|
|
|
|
|
|
|
if (active_win == window && windows != NULL) {
|
|
|
|
active_win = NULL; /* it's corrupted */
|
|
|
|
window_set_active(windows->data);
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
while (window->items != NULL)
|
2000-12-02 14:08:21 -05:00
|
|
|
window_item_destroy(window, window->items->data);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-09-26 20:08:03 -04:00
|
|
|
windows_pack(window->refnum);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_emit("window destroyed", 1, window);
|
|
|
|
|
|
|
|
g_slist_foreach(window->waiting_channels, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free(window->waiting_channels);
|
|
|
|
|
2000-07-31 21:02:46 -04:00
|
|
|
g_free_not_null(window->theme_name);
|
2000-04-26 04:03:38 -04:00
|
|
|
g_free_not_null(window->name);
|
|
|
|
g_free(window);
|
|
|
|
}
|
|
|
|
|
|
|
|
void window_set_active(WINDOW_REC *window)
|
|
|
|
{
|
2000-06-14 13:41:45 -04:00
|
|
|
WINDOW_REC *old_window;
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
if (window == active_win)
|
|
|
|
return;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-14 13:41:45 -04:00
|
|
|
old_window = active_win;
|
2000-04-26 04:03:38 -04:00
|
|
|
active_win = window;
|
2000-10-22 08:33:47 -04:00
|
|
|
if (active_win != NULL) {
|
|
|
|
windows = g_slist_remove(windows, active_win);
|
|
|
|
windows = g_slist_prepend(windows, active_win);
|
|
|
|
}
|
2000-05-04 06:32:42 -04:00
|
|
|
|
2000-06-14 13:41:45 -04:00
|
|
|
signal_emit("window changed", 2, active_win, old_window);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void window_change_server(WINDOW_REC *window, void *server)
|
|
|
|
{
|
|
|
|
window->active_server = server;
|
|
|
|
signal_emit("window server changed", 2, window, server);
|
|
|
|
}
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
void window_set_refnum(WINDOW_REC *window, int refnum)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
int old_refnum;
|
|
|
|
|
|
|
|
g_return_if_fail(window != NULL);
|
|
|
|
g_return_if_fail(refnum >= 1);
|
|
|
|
if (window->refnum == refnum) return;
|
|
|
|
|
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if (rec->refnum == refnum) {
|
|
|
|
rec->refnum = window->refnum;
|
|
|
|
signal_emit("window refnum changed", 2, rec, GINT_TO_POINTER(refnum));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
old_refnum = window->refnum;
|
|
|
|
window->refnum = refnum;
|
|
|
|
signal_emit("window refnum changed", 2, window, GINT_TO_POINTER(old_refnum));
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
void window_set_name(WINDOW_REC *window, const char *name)
|
|
|
|
{
|
|
|
|
g_free_not_null(window->name);
|
|
|
|
window->name = g_strdup(name);
|
|
|
|
|
|
|
|
signal_emit("window name changed", 1, window);
|
|
|
|
}
|
|
|
|
|
|
|
|
void window_set_level(WINDOW_REC *window, int level)
|
|
|
|
{
|
|
|
|
g_return_if_fail(window != NULL);
|
|
|
|
|
|
|
|
window->level = level;
|
|
|
|
signal_emit("window level changed", 1, window);
|
|
|
|
}
|
|
|
|
|
2000-05-09 07:42:42 -04:00
|
|
|
/* return active item's name, or if none is active, window's name */
|
|
|
|
char *window_get_active_name(WINDOW_REC *window)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail(window != NULL, NULL);
|
|
|
|
|
|
|
|
if (window->active != NULL)
|
|
|
|
return window->active->name;
|
|
|
|
|
|
|
|
return window->name;
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
WINDOW_REC *window_find_level(void *server, int level)
|
|
|
|
{
|
|
|
|
WINDOW_REC *match;
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
match = NULL;
|
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if ((server == NULL || rec->active_server == server) &&
|
|
|
|
(rec->level & level)) {
|
|
|
|
if (server == NULL || rec->active_server == server)
|
|
|
|
return rec;
|
|
|
|
match = rec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
|
|
|
|
WINDOW_REC *window_find_closest(void *server, const char *name, int level)
|
|
|
|
{
|
|
|
|
WINDOW_REC *window;
|
|
|
|
WI_ITEM_REC *item;
|
|
|
|
|
|
|
|
/* match by name */
|
|
|
|
item = name == NULL ? NULL :
|
|
|
|
window_item_find(server, name);
|
|
|
|
if (item != NULL)
|
|
|
|
return window_item_window(item);
|
|
|
|
|
|
|
|
/* match by level */
|
|
|
|
if (level != MSGLEVEL_HILIGHT)
|
|
|
|
level &= ~(MSGLEVEL_HILIGHT | MSGLEVEL_NOHILIGHT);
|
|
|
|
window = window_find_level(server, level);
|
|
|
|
if (window != NULL) return window;
|
|
|
|
|
2000-05-28 20:32:48 -04:00
|
|
|
/* match by level - ignore server */
|
|
|
|
window = window_find_level(NULL, level);
|
|
|
|
if (window != NULL) return window;
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
/* fallback to active */
|
|
|
|
return active_win;
|
|
|
|
}
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
WINDOW_REC *window_find_refnum(int refnum)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if (rec->refnum == refnum)
|
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WINDOW_REC *window_find_name(const char *name)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-05-04 06:32:42 -04:00
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
|
|
|
|
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if (rec->name != NULL && g_strcasecmp(rec->name, name) == 0)
|
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-12-02 14:08:21 -05:00
|
|
|
WINDOW_REC *window_find_item(SERVER_REC *server, const char *name)
|
2000-05-04 06:32:42 -04:00
|
|
|
{
|
|
|
|
WINDOW_REC *rec;
|
2000-04-26 04:03:38 -04:00
|
|
|
WI_ITEM_REC *item;
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
|
|
|
|
|
|
|
rec = window_find_name(name);
|
|
|
|
if (rec != NULL) return rec;
|
|
|
|
|
2000-12-02 14:08:21 -05:00
|
|
|
item = server == NULL ? NULL :
|
|
|
|
window_item_find(server, name);
|
|
|
|
if (item == NULL && server == NULL) {
|
2000-04-26 04:03:38 -04:00
|
|
|
/* not found from the active server - any server? */
|
|
|
|
item = window_item_find(NULL, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item == NULL) {
|
|
|
|
char *chan;
|
|
|
|
|
|
|
|
/* still nothing? maybe user just left the # in front of
|
|
|
|
channel, try again with it.. */
|
|
|
|
chan = g_strdup_printf("#%s", name);
|
2000-12-02 14:08:21 -05:00
|
|
|
item = server == NULL ? NULL :
|
|
|
|
window_item_find(server, chan);
|
2000-04-26 04:03:38 -04:00
|
|
|
if (item == NULL) item = window_item_find(NULL, chan);
|
|
|
|
g_free(chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
return MODULE_DATA(item);
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-12 18:57:53 -04:00
|
|
|
int window_refnum_prev(int refnum, int wrap)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
2000-05-15 04:25:45 -04:00
|
|
|
int prev, max;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
max = prev = -1;
|
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
if (rec->refnum < refnum && (prev == -1 || rec->refnum > prev))
|
|
|
|
prev = rec->refnum;
|
2000-06-12 18:57:53 -04:00
|
|
|
if (wrap && (max == -1 || rec->refnum > max))
|
2000-05-15 04:25:45 -04:00
|
|
|
max = rec->refnum;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
return prev != -1 ? prev : max;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-06-12 18:57:53 -04:00
|
|
|
int window_refnum_next(int refnum, int wrap)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
2000-05-15 04:25:45 -04:00
|
|
|
int min, next;
|
2000-05-04 06:32:42 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
min = next = -1;
|
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
2000-05-04 06:32:42 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
if (rec->refnum > refnum && (next == -1 || rec->refnum < next))
|
|
|
|
next = rec->refnum;
|
2000-06-12 18:57:53 -04:00
|
|
|
if (wrap && (min == -1 || rec->refnum < min))
|
2000-05-15 04:25:45 -04:00
|
|
|
min = rec->refnum;
|
2000-05-04 06:32:42 -04:00
|
|
|
}
|
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
return next != -1 ? next : min;
|
2000-05-04 06:32:42 -04:00
|
|
|
}
|
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
int windows_refnum_last(void)
|
2000-05-04 06:32:42 -04:00
|
|
|
{
|
2000-05-15 04:25:45 -04:00
|
|
|
GSList *tmp;
|
|
|
|
int max;
|
2000-05-04 06:32:42 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
max = -1;
|
2000-05-04 06:32:42 -04:00
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
if (rec->refnum > max)
|
|
|
|
max = rec->refnum;
|
2000-05-04 06:32:42 -04:00
|
|
|
}
|
2000-05-15 04:25:45 -04:00
|
|
|
|
|
|
|
return max;
|
2000-05-04 06:32:42 -04:00
|
|
|
}
|
|
|
|
|
2001-01-01 09:57:55 -05:00
|
|
|
static int window_refnum_cmp(WINDOW_REC *w1, WINDOW_REC *w2)
|
|
|
|
{
|
|
|
|
return w1->refnum < w2->refnum ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *windows_get_sorted(void)
|
|
|
|
{
|
|
|
|
GSList *tmp, *sorted;
|
|
|
|
|
|
|
|
sorted = NULL;
|
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
sorted = g_slist_insert_sorted(sorted, rec, (GCompareFunc)
|
|
|
|
window_refnum_cmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sorted;
|
|
|
|
}
|
|
|
|
|
2000-09-29 20:11:56 -04:00
|
|
|
static void sig_server_looking(SERVER_REC *server)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
g_return_if_fail(server != NULL);
|
|
|
|
|
2000-09-29 20:11:56 -04:00
|
|
|
/* Try to keep some server assigned to windows..
|
|
|
|
Also change active window's server if the window is empty */
|
2000-04-26 04:03:38 -04:00
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
|
|
|
|
2000-09-29 20:11:56 -04:00
|
|
|
if (rec->active_server == NULL ||
|
|
|
|
(rec == active_win && rec->items == NULL))
|
2000-10-01 19:37:31 -04:00
|
|
|
window_change_server(rec, server);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-29 20:11:56 -04:00
|
|
|
static void sig_server_disconnected(SERVER_REC *server)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
2000-08-04 11:52:32 -04:00
|
|
|
SERVER_REC *new_server;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_return_if_fail(server != NULL);
|
|
|
|
|
2000-08-04 11:52:32 -04:00
|
|
|
new_server = servers == NULL ? NULL : servers->data;
|
2000-04-26 04:03:38 -04:00
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
WINDOW_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if (rec->active_server == server)
|
2000-08-04 11:52:32 -04:00
|
|
|
window_change_server(rec, new_server);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-10 14:56:03 -04:00
|
|
|
static void sig_print_text(void)
|
2000-05-15 04:25:45 -04:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
2000-07-01 17:15:53 -04:00
|
|
|
char month[10];
|
2000-05-15 04:25:45 -04:00
|
|
|
time_t t;
|
|
|
|
struct tm *tm;
|
|
|
|
|
|
|
|
t = time(NULL);
|
|
|
|
tm = localtime(&t);
|
2000-07-01 17:15:53 -04:00
|
|
|
strftime(month, sizeof(month)-1, "%b", tm);
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-06-10 14:56:03 -04:00
|
|
|
if (tm->tm_hour != 0 || tm->tm_min != 0)
|
|
|
|
return;
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-06-10 14:56:03 -04:00
|
|
|
daycheck = 2;
|
|
|
|
signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
|
2000-05-15 04:25:45 -04:00
|
|
|
|
|
|
|
/* day changed, print notice about it to every window */
|
|
|
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
|
|
|
printformat_window(tmp->data, MSGLEVEL_NEVER, IRCTXT_DAYCHANGE,
|
2000-11-12 15:20:05 -05:00
|
|
|
tm->tm_mday, tm->tm_mon+1,
|
|
|
|
1900+tm->tm_year, month);
|
2000-05-15 04:25:45 -04:00
|
|
|
}
|
2000-06-10 14:56:03 -04:00
|
|
|
}
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-06-10 14:56:03 -04:00
|
|
|
static int sig_check_daychange(void)
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
struct tm *tm;
|
|
|
|
|
|
|
|
t = time(NULL);
|
|
|
|
tm = localtime(&t);
|
|
|
|
|
|
|
|
if (daycheck == 1 && tm->tm_hour == 0 && tm->tm_min == 0) {
|
|
|
|
sig_print_text();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tm->tm_hour != 23 || tm->tm_min != 59) {
|
|
|
|
daycheck = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* time is 23:59 */
|
|
|
|
if (daycheck == 0) {
|
|
|
|
daycheck = 1;
|
|
|
|
signal_add("print text", (SIGNAL_FUNC) sig_print_text);
|
|
|
|
}
|
2000-05-15 04:25:45 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-06-10 14:56:03 -04:00
|
|
|
static void read_settings(void)
|
|
|
|
{
|
|
|
|
if (daytag != -1) {
|
|
|
|
g_source_remove(daytag);
|
|
|
|
daytag = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings_get_bool("timestamps"))
|
|
|
|
daytag = g_timeout_add(30000, (GSourceFunc) sig_check_daychange, NULL);
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
void windows_init(void)
|
|
|
|
{
|
|
|
|
active_win = NULL;
|
2000-06-10 14:56:03 -04:00
|
|
|
daycheck = 0; daytag = -1;
|
2000-04-26 04:03:38 -04:00
|
|
|
settings_add_bool("lookandfeel", "window_auto_change", FALSE);
|
|
|
|
|
2000-06-10 14:56:03 -04:00
|
|
|
read_settings();
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_add("server looking", (SIGNAL_FUNC) sig_server_looking);
|
|
|
|
signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
|
|
|
signal_add("server connect failed", (SIGNAL_FUNC) sig_server_disconnected);
|
2000-06-10 14:56:03 -04:00
|
|
|
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void windows_deinit(void)
|
|
|
|
{
|
2000-06-10 14:56:03 -04:00
|
|
|
if (daytag != -1) g_source_remove(daytag);
|
|
|
|
if (daycheck == 1) signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
signal_remove("server looking", (SIGNAL_FUNC) sig_server_looking);
|
|
|
|
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
|
|
|
signal_remove("server connect failed", (SIGNAL_FUNC) sig_server_disconnected);
|
2000-06-10 14:56:03 -04:00
|
|
|
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|