mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Changed window->waiting_channels ("servertag name" format) to
bound_items containing WINDOW_BIND_REC structures. If you now use /SAVEWINDOWS, the item will _always_ be restored to saved window even if there was already some other item. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1204 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
7c21fb84ee
commit
ddf6810b0e
@ -89,8 +89,7 @@ static void sig_disconnected(SERVER_REC *server)
|
|||||||
CHANNEL_REC *channel = tmp->data;
|
CHANNEL_REC *channel = tmp->data;
|
||||||
|
|
||||||
window = window_item_window((WI_ITEM_REC *) channel);
|
window = window_item_window((WI_ITEM_REC *) channel);
|
||||||
window->waiting_channels =
|
window_bind_add(window, server->tag, channel->name);
|
||||||
g_slist_append(window->waiting_channels, g_strdup_printf("%s %s", server->tag, channel->name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ void window_destroy(WINDOW_REC *window)
|
|||||||
|
|
||||||
signal_emit("window destroyed", 1, window);
|
signal_emit("window destroyed", 1, window);
|
||||||
|
|
||||||
g_slist_foreach(window->waiting_channels, (GFunc) g_free, NULL);
|
while (window->bound_items != NULL)
|
||||||
g_slist_free(window->waiting_channels);
|
window_bind_destroy(window, window->bound_items->data);
|
||||||
|
|
||||||
g_free_not_null(window->servertag);
|
g_free_not_null(window->servertag);
|
||||||
g_free_not_null(window->theme_name);
|
g_free_not_null(window->theme_name);
|
||||||
@ -386,6 +386,68 @@ GSList *windows_get_sorted(void)
|
|||||||
return sorted;
|
return sorted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WINDOW_BIND_REC *window_bind_add(WINDOW_REC *window, const char *servertag,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
WINDOW_BIND_REC *rec;
|
||||||
|
|
||||||
|
g_return_val_if_fail(window != NULL, NULL);
|
||||||
|
g_return_val_if_fail(servertag != NULL, NULL);
|
||||||
|
g_return_val_if_fail(name != NULL, NULL);
|
||||||
|
|
||||||
|
rec = g_new0(WINDOW_BIND_REC, 1);
|
||||||
|
rec->name = g_strdup(name);
|
||||||
|
rec->servertag = g_strdup(servertag);
|
||||||
|
|
||||||
|
window->bound_items = g_slist_append(window->bound_items, rec);
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
void window_bind_destroy(WINDOW_REC *window, WINDOW_BIND_REC *rec)
|
||||||
|
{
|
||||||
|
g_return_if_fail(window != NULL);
|
||||||
|
g_return_if_fail(rec != NULL);
|
||||||
|
|
||||||
|
window->bound_items = g_slist_remove(window->bound_items, rec);
|
||||||
|
|
||||||
|
g_free(rec->servertag);
|
||||||
|
g_free(rec->name);
|
||||||
|
g_free(rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
WINDOW_BIND_REC *window_bind_find(WINDOW_REC *window, const char *servertag,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail(window != NULL, NULL);
|
||||||
|
g_return_val_if_fail(servertag != NULL, NULL);
|
||||||
|
g_return_val_if_fail(name != NULL, NULL);
|
||||||
|
|
||||||
|
for (tmp = window->bound_items; tmp != NULL; tmp = tmp->next) {
|
||||||
|
WINDOW_BIND_REC *rec = tmp->data;
|
||||||
|
|
||||||
|
if (g_strcasecmp(rec->name, name) == 0 &&
|
||||||
|
g_strcasecmp(rec->servertag, servertag) == 0)
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void window_bind_remove_unsticky(WINDOW_REC *window)
|
||||||
|
{
|
||||||
|
GSList *tmp, *next;
|
||||||
|
|
||||||
|
for (tmp = window->bound_items; tmp != NULL; tmp = tmp->next) {
|
||||||
|
WINDOW_BIND_REC *rec = tmp->data;
|
||||||
|
|
||||||
|
next = tmp->next;
|
||||||
|
if (!rec->sticky)
|
||||||
|
window_bind_destroy(window, rec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void sig_server_looking(SERVER_REC *server)
|
static void sig_server_looking(SERVER_REC *server)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
@ -13,6 +13,12 @@ enum {
|
|||||||
DATA_LEVEL_HILIGHT
|
DATA_LEVEL_HILIGHT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *servertag;
|
||||||
|
char *name;
|
||||||
|
unsigned int sticky:1;
|
||||||
|
} WINDOW_BIND_REC;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int refnum;
|
int refnum;
|
||||||
char *name;
|
char *name;
|
||||||
@ -25,7 +31,7 @@ typedef struct {
|
|||||||
char *servertag; /* active_server must be either NULL or have this tag (unless there's items in this window) */
|
char *servertag; /* active_server must be either NULL or have this tag (unless there's items in this window) */
|
||||||
|
|
||||||
int level; /* message level */
|
int level; /* message level */
|
||||||
GSList *waiting_channels; /* list of "<server tag> <channel>" */
|
GSList *bound_items; /* list of WINDOW_BIND_RECs */
|
||||||
|
|
||||||
int lines;
|
int lines;
|
||||||
unsigned int sticky_refnum:1;
|
unsigned int sticky_refnum:1;
|
||||||
@ -75,6 +81,14 @@ int windows_refnum_last(void);
|
|||||||
|
|
||||||
GSList *windows_get_sorted(void);
|
GSList *windows_get_sorted(void);
|
||||||
|
|
||||||
|
WINDOW_BIND_REC *window_bind_add(WINDOW_REC *window, const char *servertag,
|
||||||
|
const char *name);
|
||||||
|
void window_bind_destroy(WINDOW_REC *window, WINDOW_BIND_REC *rec);
|
||||||
|
|
||||||
|
WINDOW_BIND_REC *window_bind_find(WINDOW_REC *window, const char *servertag,
|
||||||
|
const char *name);
|
||||||
|
void window_bind_remove_unsticky(WINDOW_REC *window);
|
||||||
|
|
||||||
void windows_init(void);
|
void windows_init(void);
|
||||||
void windows_deinit(void);
|
void windows_deinit(void);
|
||||||
|
|
||||||
|
@ -224,36 +224,14 @@ WI_ITEM_REC *window_item_find(void *server, const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int waiting_channels_get(WINDOW_REC *window, const char *tag)
|
|
||||||
{
|
|
||||||
GSList *tmp;
|
|
||||||
|
|
||||||
g_return_val_if_fail(window != NULL, FALSE);
|
|
||||||
g_return_val_if_fail(tag != NULL, FALSE);
|
|
||||||
|
|
||||||
for (tmp = window->waiting_channels; tmp != NULL; tmp = tmp->next) {
|
|
||||||
if (g_strcasecmp(tmp->data, tag) == 0) {
|
|
||||||
g_free(tmp->data);
|
|
||||||
window->waiting_channels = g_slist_remove(window->waiting_channels, tmp->data);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void window_item_create(WI_ITEM_REC *item, int automatic)
|
void window_item_create(WI_ITEM_REC *item, int automatic)
|
||||||
{
|
{
|
||||||
WINDOW_REC *window;
|
WINDOW_REC *window;
|
||||||
GSList *tmp, *sorted;
|
GSList *tmp, *sorted;
|
||||||
char *str;
|
|
||||||
int clear_waiting, reuse_unused_windows;
|
int clear_waiting, reuse_unused_windows;
|
||||||
|
|
||||||
g_return_if_fail(item != NULL);
|
g_return_if_fail(item != NULL);
|
||||||
|
|
||||||
str = item->server == NULL ? NULL :
|
|
||||||
g_strdup_printf("%s %s", ((SERVER_REC *) item->server)->tag, item->name);
|
|
||||||
|
|
||||||
reuse_unused_windows =
|
reuse_unused_windows =
|
||||||
!settings_get_bool("autoclose_windows") ||
|
!settings_get_bool("autoclose_windows") ||
|
||||||
settings_get_bool("reuse_unused_windows");
|
settings_get_bool("reuse_unused_windows");
|
||||||
@ -267,23 +245,21 @@ void window_item_create(WI_ITEM_REC *item, int automatic)
|
|||||||
if (reuse_unused_windows &&
|
if (reuse_unused_windows &&
|
||||||
rec->items == NULL && rec->level == 0 &&
|
rec->items == NULL && rec->level == 0 &&
|
||||||
(window == NULL || rec == active_win ||
|
(window == NULL || rec == active_win ||
|
||||||
window->waiting_channels != NULL)) {
|
window->bound_items != NULL)) {
|
||||||
/* no items in this window, we should probably use it.. */
|
/* no items in this window,
|
||||||
|
we should probably use it.. */
|
||||||
window = rec;
|
window = rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec->waiting_channels != NULL && str != NULL) {
|
/* is item bound to this window? */
|
||||||
/* right name/server tag combination in
|
if (item->server != NULL &&
|
||||||
some waiting list? */
|
window_bind_find(rec, item->server->tag, item->name)) {
|
||||||
if (waiting_channels_get(rec, str)) {
|
window = rec;
|
||||||
window = rec;
|
clear_waiting = FALSE;
|
||||||
clear_waiting = FALSE;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_slist_free(sorted);
|
g_slist_free(sorted);
|
||||||
g_free_not_null(str);
|
|
||||||
|
|
||||||
if (window == NULL && !settings_get_bool("autocreate_windows")) {
|
if (window == NULL && !settings_get_bool("autocreate_windows")) {
|
||||||
/* never create new windows automatically */
|
/* never create new windows automatically */
|
||||||
@ -298,12 +274,8 @@ void window_item_create(WI_ITEM_REC *item, int automatic)
|
|||||||
window_item_add(window, item, automatic);
|
window_item_add(window, item, automatic);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clear_waiting) {
|
if (clear_waiting)
|
||||||
/* clear window's waiting_channels list */
|
window_bind_remove_unsticky(window);
|
||||||
g_slist_foreach(window->waiting_channels, (GFunc) g_free, NULL),
|
|
||||||
g_slist_free(window->waiting_channels);
|
|
||||||
window->waiting_channels = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void signal_window_item_changed(WINDOW_REC *window, WI_ITEM_REC *item)
|
static void signal_window_item_changed(WINDOW_REC *window, WI_ITEM_REC *item)
|
||||||
|
@ -38,20 +38,19 @@
|
|||||||
static void sig_window_restore_item(WINDOW_REC *window, const char *type,
|
static void sig_window_restore_item(WINDOW_REC *window, const char *type,
|
||||||
CONFIG_NODE *node)
|
CONFIG_NODE *node)
|
||||||
{
|
{
|
||||||
char *name, *tag, *chat_type, *str;
|
char *name, *tag, *chat_type;
|
||||||
|
|
||||||
chat_type = config_node_get_str(node, "chat_type", NULL);
|
chat_type = config_node_get_str(node, "chat_type", NULL);
|
||||||
name = config_node_get_str(node, "name", NULL);
|
name = config_node_get_str(node, "name", NULL);
|
||||||
tag = config_node_get_str(node, "tag", NULL);
|
tag = config_node_get_str(node, "tag", NULL);
|
||||||
if (name == NULL) return;
|
|
||||||
|
if (name == NULL || tag == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (g_strcasecmp(type, "CHANNEL") == 0) {
|
if (g_strcasecmp(type, "CHANNEL") == 0) {
|
||||||
/* add channel to "waiting channels" list */
|
/* bind channel to window */
|
||||||
str = tag == NULL ? g_strdup(name) :
|
WINDOW_BIND_REC *rec = window_bind_add(window, tag, name);
|
||||||
g_strdup_printf("%s %s", tag, name);
|
rec->sticky = TRUE;
|
||||||
|
|
||||||
window->waiting_channels =
|
|
||||||
g_slist_append(window->waiting_channels, str);
|
|
||||||
} else if (g_strcasecmp(type, "QUERY") == 0 && chat_type != NULL) {
|
} else if (g_strcasecmp(type, "QUERY") == 0 && chat_type != NULL) {
|
||||||
/* create query immediately */
|
/* create query immediately */
|
||||||
query_create(chat_protocol_lookup(chat_type),
|
query_create(chat_protocol_lookup(chat_type),
|
||||||
|
Loading…
Reference in New Issue
Block a user