Helper function for getting window item type

This commit is contained in:
Jari Matilainen 2017-01-13 16:45:20 +00:00
commit f272976505
2 changed files with 28 additions and 0 deletions

View file

@ -138,6 +138,23 @@ void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item)
}
}
WindowType window_item_get_type(WI_ITEM_REC *item)
{
g_return_val_if_fail(item != NULL, WITEM_TYPE_OTHER);
const char *type = module_find_id_str("WINDOW ITEM TYPE", item->type);
if (g_ascii_strcasecmp(type, "CHANNEL") == 0)
return WITEM_TYPE_CHANNEL;
else if (g_ascii_strcasecmp(type, "QUERY") == 0) {
if (g_str_has_prefix("=", item->name))
return WITEM_TYPE_QUERY | WITEM_TYPE_DCCCHAT;
else
return WITEM_TYPE_QUERY | WITEM_TYPE_PRIVMSG;
}
else
return WITEM_TYPE_OTHER;
}
/* Return TRUE if `item' is the active window item in the window.
`item' can be NULL. */
int window_item_is_active(WI_ITEM_REC *item)