2013-08-20 18:08:21 -04:00
|
|
|
/*
|
|
|
|
* windows.c
|
|
|
|
*
|
2014-03-08 20:18:19 -05:00
|
|
|
* Copyright (C) 2012 - 2014 James Booth <boothj5@gmail.com>
|
2013-08-20 18:08:21 -04:00
|
|
|
*
|
|
|
|
* This file is part of Profanity.
|
|
|
|
*
|
|
|
|
* Profanity 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Profanity 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 Profanity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2014-08-24 15:57:39 -04:00
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link the code of portions of this program with the OpenSSL library under
|
|
|
|
* certain conditions as described in each individual source file, and
|
|
|
|
* distribute linked combinations including the two.
|
|
|
|
*
|
|
|
|
* You must obey the GNU General Public License in all respects for all of the
|
|
|
|
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
|
|
|
* may extend this exception to your version of the file(s), but you are not
|
|
|
|
* obligated to do so. If you do not wish to do so, delete this exception
|
|
|
|
* statement from your version. If you delete this exception statement from all
|
|
|
|
* source files in the program, then also delete it here.
|
|
|
|
*
|
2013-08-20 18:08:21 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
2014-12-18 18:57:19 -05:00
|
|
|
#include <assert.h>
|
2014-12-21 17:01:56 -05:00
|
|
|
#include <stdlib.h>
|
2013-08-20 18:08:21 -04:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_NCURSESW_NCURSES_H
|
|
|
|
#include <ncursesw/ncurses.h>
|
|
|
|
#elif HAVE_NCURSES_H
|
|
|
|
#include <ncurses.h>
|
|
|
|
#endif
|
|
|
|
|
2013-08-27 17:02:23 -04:00
|
|
|
#include "common.h"
|
2013-12-14 10:34:17 -05:00
|
|
|
#include "roster_list.h"
|
2013-08-20 18:08:21 -04:00
|
|
|
#include "config/theme.h"
|
|
|
|
#include "ui/ui.h"
|
2014-04-07 16:12:30 -04:00
|
|
|
#include "ui/statusbar.h"
|
2013-08-20 18:08:21 -04:00
|
|
|
#include "ui/window.h"
|
|
|
|
#include "ui/windows.h"
|
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
static GHashTable *windows;
|
2013-08-20 18:08:21 -04:00
|
|
|
static int current;
|
|
|
|
static int max_cols;
|
|
|
|
|
|
|
|
void
|
|
|
|
wins_init(void)
|
|
|
|
{
|
|
|
|
windows = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
|
2013-08-27 18:38:25 -04:00
|
|
|
(GDestroyNotify)win_free);
|
2013-08-20 18:08:21 -04:00
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
max_cols = getmaxx(stdscr);
|
2014-12-14 19:28:28 -05:00
|
|
|
ProfWin *console = win_create_console();
|
2013-08-27 18:38:25 -04:00
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(1), console);
|
2013-08-20 18:08:21 -04:00
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
current = 1;
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ProfWin *
|
|
|
|
wins_get_console(void)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
return g_hash_table_lookup(windows, GINT_TO_POINTER(1));
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2014-12-18 18:57:19 -05:00
|
|
|
ProfChatWin *
|
|
|
|
wins_get_chat(const char * const barejid)
|
|
|
|
{
|
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
|
|
|
if (window->type == WIN_CHAT) {
|
|
|
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
|
|
|
if (g_strcmp0(chatwin->barejid, barejid) == 0) {
|
|
|
|
g_list_free(values);
|
|
|
|
return chatwin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(values);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfMucConfWin *
|
2014-12-21 17:01:56 -05:00
|
|
|
wins_get_muc_conf(const char * const roomjid)
|
2014-12-18 18:57:19 -05:00
|
|
|
{
|
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
|
|
|
if (window->type == WIN_MUC_CONFIG) {
|
|
|
|
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
2014-12-21 17:01:56 -05:00
|
|
|
if (g_strcmp0(confwin->roomjid, roomjid) == 0) {
|
2014-12-18 18:57:19 -05:00
|
|
|
g_list_free(values);
|
|
|
|
return confwin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(values);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfMucWin *
|
2014-12-19 19:52:35 -05:00
|
|
|
wins_get_muc(const char * const roomjid)
|
2014-12-18 18:57:19 -05:00
|
|
|
{
|
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
2014-12-19 19:52:35 -05:00
|
|
|
if (window->type == WIN_MUC) {
|
|
|
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
|
|
|
if (g_strcmp0(mucwin->roomjid, roomjid) == 0) {
|
|
|
|
return mucwin;
|
|
|
|
}
|
2014-12-18 18:57:19 -05:00
|
|
|
}
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(values);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfPrivateWin *
|
|
|
|
wins_get_private(const char * const fulljid)
|
|
|
|
{
|
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
|
|
|
if (window->type == WIN_PRIVATE) {
|
|
|
|
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
|
|
|
if (g_strcmp0(privatewin->fulljid, fulljid) == 0) {
|
|
|
|
return privatewin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(values);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-20 18:08:21 -04:00
|
|
|
ProfWin *
|
|
|
|
wins_get_current(void)
|
|
|
|
{
|
2014-09-16 17:23:59 -04:00
|
|
|
if (windows != NULL) {
|
|
|
|
return g_hash_table_lookup(windows, GINT_TO_POINTER(current));
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2014-12-18 18:57:19 -05:00
|
|
|
ProfChatWin *
|
|
|
|
wins_get_current_chat(void)
|
|
|
|
{
|
|
|
|
if (windows) {
|
|
|
|
ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(current));
|
|
|
|
if (window) {
|
|
|
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
|
|
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
|
|
|
return chatwin;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfMucWin *
|
|
|
|
wins_get_current_muc(void)
|
|
|
|
{
|
|
|
|
if (windows) {
|
|
|
|
ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(current));
|
|
|
|
if (window) {
|
|
|
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
|
|
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
|
|
|
return mucwin;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfPrivateWin *
|
|
|
|
wins_get_current_private(void)
|
|
|
|
{
|
|
|
|
if (windows) {
|
|
|
|
ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(current));
|
|
|
|
if (window) {
|
|
|
|
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
|
|
|
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
|
|
|
return privatewin;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfMucConfWin *
|
|
|
|
wins_get_current_muc_conf(void)
|
|
|
|
{
|
|
|
|
if (windows) {
|
|
|
|
ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(current));
|
|
|
|
if (window) {
|
|
|
|
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
|
|
|
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
|
|
|
|
return confwin;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-29 19:33:46 -04:00
|
|
|
GList *
|
|
|
|
wins_get_nums(void)
|
|
|
|
{
|
|
|
|
return g_hash_table_get_keys(windows);
|
|
|
|
}
|
|
|
|
|
2013-08-20 18:08:21 -04:00
|
|
|
void
|
|
|
|
wins_set_current_by_num(int i)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
if (g_hash_table_lookup(windows, GINT_TO_POINTER(i)) != NULL) {
|
2013-08-20 18:08:21 -04:00
|
|
|
current = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfWin *
|
|
|
|
wins_get_by_num(int i)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
return g_hash_table_lookup(windows, GINT_TO_POINTER(i));
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2014-12-18 18:57:19 -05:00
|
|
|
ProfChatWin *
|
|
|
|
wins_get_chat_by_num(int i)
|
|
|
|
{
|
|
|
|
ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(i));
|
|
|
|
if (window) {
|
|
|
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
|
|
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
|
|
|
return chatwin;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfMucWin *
|
|
|
|
wins_get_muc_by_num(int i)
|
|
|
|
{
|
|
|
|
ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(i));
|
|
|
|
if (window) {
|
|
|
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
|
|
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
|
|
|
return mucwin;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 19:25:04 -04:00
|
|
|
ProfWin *
|
|
|
|
wins_get_next(void)
|
|
|
|
{
|
|
|
|
// get and sort win nums
|
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
keys = g_list_sort(keys, cmp_win_num);
|
|
|
|
GList *curr = keys;
|
|
|
|
|
|
|
|
// find our place in the list
|
|
|
|
while (curr != NULL) {
|
|
|
|
if (current == GPOINTER_TO_INT(curr->data)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if there is a next window return it
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
if (curr != NULL) {
|
2014-07-07 16:29:51 -04:00
|
|
|
int next = GPOINTER_TO_INT(curr->data);
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(keys);
|
2014-07-07 16:29:51 -04:00
|
|
|
return wins_get_by_num(next);
|
2013-09-25 19:25:04 -04:00
|
|
|
// otherwise return the first window (console)
|
|
|
|
} else {
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(keys);
|
2013-09-25 19:25:04 -04:00
|
|
|
return wins_get_console();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfWin *
|
|
|
|
wins_get_previous(void)
|
|
|
|
{
|
|
|
|
// get and sort win nums
|
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
keys = g_list_sort(keys, cmp_win_num);
|
|
|
|
GList *curr = keys;
|
|
|
|
|
|
|
|
// find our place in the list
|
|
|
|
while (curr != NULL) {
|
|
|
|
if (current == GPOINTER_TO_INT(curr->data)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if there is a previous window return it
|
|
|
|
curr = g_list_previous(curr);
|
|
|
|
if (curr != NULL) {
|
2014-07-07 16:29:51 -04:00
|
|
|
int previous = GPOINTER_TO_INT(curr->data);
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(keys);
|
2014-07-07 16:29:51 -04:00
|
|
|
return wins_get_by_num(previous);
|
2013-09-25 19:25:04 -04:00
|
|
|
// otherwise return the last window
|
|
|
|
} else {
|
|
|
|
int new_num = GPOINTER_TO_INT(g_list_last(keys)->data);
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(keys);
|
2013-09-25 19:25:04 -04:00
|
|
|
return wins_get_by_num(new_num);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-20 18:08:21 -04:00
|
|
|
int
|
|
|
|
wins_get_num(ProfWin *window)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
GList *curr = keys;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
gconstpointer num_p = curr->data;
|
|
|
|
ProfWin *curr_win = g_hash_table_lookup(windows, num_p);
|
2014-12-19 19:52:35 -05:00
|
|
|
if (curr_win == window) {
|
2014-06-15 16:36:47 -04:00
|
|
|
g_list_free(keys);
|
2013-08-27 18:38:25 -04:00
|
|
|
return GPOINTER_TO_INT(num_p);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2013-08-27 18:38:25 -04:00
|
|
|
curr = g_list_next(curr);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2014-06-15 16:36:47 -04:00
|
|
|
g_list_free(keys);
|
2013-08-27 18:38:25 -04:00
|
|
|
return -1;
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
wins_get_current_num(void)
|
|
|
|
{
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wins_close_current(void)
|
|
|
|
{
|
|
|
|
wins_close_by_num(current);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wins_close_by_num(int i)
|
|
|
|
{
|
2014-04-06 16:06:50 -04:00
|
|
|
// console cannot be closed
|
2013-08-27 18:38:25 -04:00
|
|
|
if (i != 1) {
|
2014-04-06 16:06:50 -04:00
|
|
|
|
|
|
|
// go to console if closing current window
|
2013-08-20 18:08:21 -04:00
|
|
|
if (i == current) {
|
2013-08-27 18:38:25 -04:00
|
|
|
current = 1;
|
2014-04-06 16:06:50 -04:00
|
|
|
ProfWin *window = wins_get_current();
|
|
|
|
win_update_virtual(window);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2014-04-06 16:06:50 -04:00
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
g_hash_table_remove(windows, GINT_TO_POINTER(i));
|
2013-08-29 19:21:41 -04:00
|
|
|
status_bar_inactive(i);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wins_clear_current(void)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
ProfWin *window = wins_get_current();
|
2014-12-15 20:39:47 -05:00
|
|
|
werase(window->layout->win);
|
2014-04-06 16:06:50 -04:00
|
|
|
win_update_virtual(window);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
wins_is_current(ProfWin *window)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
ProfWin *current_window = wins_get_current();
|
|
|
|
|
2014-12-19 19:52:35 -05:00
|
|
|
if (current_window == window) {
|
2013-08-20 18:08:21 -04:00
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfWin *
|
2014-12-14 19:28:28 -05:00
|
|
|
wins_new_xmlconsole(void)
|
2013-08-20 18:08:21 -04:00
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
int result = get_next_available_win_num(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
ProfWin *newwin = win_create_xmlconsole();
|
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
2014-06-15 16:23:21 -04:00
|
|
|
g_list_free(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
return newwin;
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2014-12-10 17:34:33 -05:00
|
|
|
ProfWin *
|
|
|
|
wins_new_chat(const char * const barejid)
|
|
|
|
{
|
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
int result = get_next_available_win_num(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
ProfWin *newwin = win_create_chat(barejid);
|
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
2014-12-10 17:34:33 -05:00
|
|
|
g_list_free(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
return newwin;
|
2014-12-10 17:34:33 -05:00
|
|
|
}
|
|
|
|
|
2014-12-14 19:28:28 -05:00
|
|
|
ProfWin *
|
|
|
|
wins_new_muc(const char * const roomjid)
|
|
|
|
{
|
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
int result = get_next_available_win_num(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
ProfWin *newwin = win_create_muc(roomjid);
|
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
2014-12-14 19:28:28 -05:00
|
|
|
g_list_free(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
return newwin;
|
2014-12-14 19:28:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ProfWin *
|
2014-12-21 17:01:56 -05:00
|
|
|
wins_new_muc_config(const char * const roomjid, DataForm *form)
|
2014-12-14 19:28:28 -05:00
|
|
|
{
|
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
int result = get_next_available_win_num(keys);
|
2014-12-21 17:01:56 -05:00
|
|
|
ProfWin *newwin = win_create_muc_config(roomjid, form);
|
2014-12-19 19:52:35 -05:00
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
2014-12-14 19:28:28 -05:00
|
|
|
g_list_free(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
return newwin;
|
2014-12-14 19:28:28 -05:00
|
|
|
}
|
|
|
|
|
2014-12-10 17:34:33 -05:00
|
|
|
ProfWin *
|
|
|
|
wins_new_private(const char * const fulljid)
|
|
|
|
{
|
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
int result = get_next_available_win_num(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
ProfWin *newwin = win_create_private(fulljid);
|
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
2014-12-10 17:34:33 -05:00
|
|
|
g_list_free(keys);
|
2014-12-19 19:52:35 -05:00
|
|
|
return newwin;
|
2014-12-10 17:34:33 -05:00
|
|
|
}
|
|
|
|
|
2013-08-20 18:08:21 -04:00
|
|
|
int
|
|
|
|
wins_get_total_unread(void)
|
|
|
|
{
|
|
|
|
int result = 0;
|
2013-08-27 18:38:25 -04:00
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
|
|
|
result += window->unread;
|
|
|
|
curr = g_list_next(curr);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2014-06-17 17:01:01 -04:00
|
|
|
g_list_free(values);
|
2013-08-20 18:08:21 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wins_resize_all(void)
|
|
|
|
{
|
2014-11-15 17:59:13 -05:00
|
|
|
int cols = getmaxx(stdscr);
|
2013-08-20 18:08:21 -04:00
|
|
|
|
2014-06-29 09:04:23 -04:00
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
while (curr != NULL) {
|
2014-10-07 12:06:02 -04:00
|
|
|
ProfWin *window = curr->data;
|
2014-12-09 19:54:46 -05:00
|
|
|
int subwin_cols = 0;
|
|
|
|
|
2014-12-15 20:39:47 -05:00
|
|
|
if (window->layout->type == LAYOUT_SPLIT) {
|
2014-12-16 16:18:32 -05:00
|
|
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
|
2014-12-15 20:39:47 -05:00
|
|
|
if (layout->subwin) {
|
2014-12-16 16:18:32 -05:00
|
|
|
if (window->type == WIN_CONSOLE) {
|
|
|
|
subwin_cols = win_roster_cols();
|
|
|
|
} else if (window->type == WIN_MUC) {
|
|
|
|
subwin_cols = win_occpuants_cols();
|
|
|
|
}
|
2014-12-21 14:40:15 -05:00
|
|
|
wresize(layout->base.win, PAD_SIZE, cols - subwin_cols);
|
2014-12-15 20:39:47 -05:00
|
|
|
wresize(layout->subwin, PAD_SIZE, subwin_cols);
|
2014-12-16 18:00:05 -05:00
|
|
|
rosterwin_roster();
|
2014-12-09 19:54:46 -05:00
|
|
|
} else {
|
2014-12-21 14:40:15 -05:00
|
|
|
wresize(layout->base.win, PAD_SIZE, cols);
|
2014-11-10 17:47:53 -05:00
|
|
|
}
|
2014-12-15 20:39:47 -05:00
|
|
|
} else {
|
|
|
|
wresize(window->layout->win, PAD_SIZE, cols);
|
2014-10-07 12:06:02 -04:00
|
|
|
}
|
2014-12-09 19:54:46 -05:00
|
|
|
|
2014-10-07 12:06:02 -04:00
|
|
|
win_redraw(window);
|
|
|
|
curr = g_list_next(curr);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2014-06-29 09:04:23 -04:00
|
|
|
g_list_free(values);
|
2013-08-20 18:08:21 -04:00
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
ProfWin *current_win = wins_get_current();
|
2014-11-15 17:59:13 -05:00
|
|
|
win_update_virtual(current_win);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2014-10-09 16:27:16 -04:00
|
|
|
void
|
|
|
|
wins_hide_subwin(ProfWin *window)
|
|
|
|
{
|
|
|
|
int rows, cols;
|
|
|
|
getmaxyx(stdscr, rows, cols);
|
|
|
|
|
|
|
|
win_hide_subwin(window);
|
2014-10-09 16:42:09 -04:00
|
|
|
|
2014-10-09 16:27:16 -04:00
|
|
|
ProfWin *current_win = wins_get_current();
|
2014-11-09 19:06:13 -05:00
|
|
|
if ((current_win->type == WIN_MUC) || (current_win->type == WIN_CONSOLE)) {
|
2014-12-15 20:39:47 -05:00
|
|
|
pnoutrefresh(current_win->layout->win, current_win->layout->y_pos, 0, 1, 0, rows-3, cols-1);
|
2014-10-09 16:27:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-09 16:42:09 -04:00
|
|
|
void
|
|
|
|
wins_show_subwin(ProfWin *window)
|
|
|
|
{
|
|
|
|
int rows, cols;
|
|
|
|
getmaxyx(stdscr, rows, cols);
|
2014-11-15 17:59:13 -05:00
|
|
|
int subwin_cols = 0;
|
2014-10-09 16:42:09 -04:00
|
|
|
|
|
|
|
win_show_subwin(window);
|
|
|
|
|
|
|
|
ProfWin *current_win = wins_get_current();
|
2014-11-15 17:59:13 -05:00
|
|
|
if (current_win->type == WIN_MUC) {
|
2014-12-15 20:39:47 -05:00
|
|
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)current_win->layout;
|
2014-11-15 17:59:13 -05:00
|
|
|
subwin_cols = win_occpuants_cols();
|
2014-12-21 14:40:15 -05:00
|
|
|
pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
|
2014-12-15 20:39:47 -05:00
|
|
|
pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
|
2014-11-15 17:59:13 -05:00
|
|
|
} else if (current_win->type == WIN_CONSOLE) {
|
2014-12-15 20:39:47 -05:00
|
|
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)current_win->layout;
|
2014-11-15 17:59:13 -05:00
|
|
|
subwin_cols = win_roster_cols();
|
2014-12-21 14:40:15 -05:00
|
|
|
pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
|
2014-12-15 20:39:47 -05:00
|
|
|
pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
|
2014-10-09 16:42:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-15 08:16:32 -04:00
|
|
|
gboolean
|
|
|
|
wins_xmlconsole_exists(void)
|
|
|
|
{
|
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
2014-06-15 12:43:16 -04:00
|
|
|
if (window->type == WIN_XML) {
|
|
|
|
g_list_free(values);
|
2014-04-15 08:16:32 -04:00
|
|
|
return TRUE;
|
2014-06-15 12:43:16 -04:00
|
|
|
}
|
2014-04-15 08:16:32 -04:00
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
2014-06-15 12:43:16 -04:00
|
|
|
g_list_free(values);
|
2014-04-15 08:16:32 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfWin *
|
|
|
|
wins_get_xmlconsole(void)
|
|
|
|
{
|
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
2014-06-17 18:14:54 -04:00
|
|
|
if (window->type == WIN_XML) {
|
|
|
|
g_list_free(values);
|
2014-04-15 08:16:32 -04:00
|
|
|
return window;
|
2014-06-17 18:14:54 -04:00
|
|
|
}
|
2014-04-15 08:16:32 -04:00
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(values);
|
2014-04-15 08:16:32 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-20 18:08:21 -04:00
|
|
|
GSList *
|
|
|
|
wins_get_chat_recipients(void)
|
|
|
|
{
|
|
|
|
GSList *result = NULL;
|
2013-08-27 18:38:25 -04:00
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
|
|
|
if (window->type == WIN_CHAT) {
|
2014-12-19 19:52:35 -05:00
|
|
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
|
|
|
result = g_slist_append(result, chatwin->barejid);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2013-08-27 18:38:25 -04:00
|
|
|
curr = g_list_next(curr);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2014-06-17 17:27:14 -04:00
|
|
|
g_list_free(values);
|
2013-08-20 18:08:21 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
2014-12-19 19:52:35 -05:00
|
|
|
wins_get_prune_wins(void)
|
2013-08-20 18:08:21 -04:00
|
|
|
{
|
|
|
|
GSList *result = NULL;
|
2013-08-27 18:38:25 -04:00
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
2014-09-06 19:49:42 -04:00
|
|
|
if (window->unread == 0 &&
|
|
|
|
window->type != WIN_MUC &&
|
|
|
|
window->type != WIN_MUC_CONFIG &&
|
|
|
|
window->type != WIN_XML &&
|
|
|
|
window->type != WIN_CONSOLE) {
|
2014-12-19 19:52:35 -05:00
|
|
|
result = g_slist_append(result, window);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2013-08-27 18:38:25 -04:00
|
|
|
curr = g_list_next(curr);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(values);
|
2013-08-20 18:08:21 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wins_lost_connection(void)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
GList *values = g_hash_table_get_values(windows);
|
|
|
|
GList *curr = values;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = curr->data;
|
|
|
|
if (window->type != WIN_CONSOLE) {
|
2014-11-16 15:40:19 -05:00
|
|
|
win_save_print(window, '-', NULL, 0, THEME_ERROR, "", "Lost connection.");
|
2013-08-20 18:08:21 -04:00
|
|
|
|
|
|
|
// if current win, set current_win_dirty
|
|
|
|
if (wins_is_current(window)) {
|
2014-04-06 16:06:50 -04:00
|
|
|
win_update_virtual(window);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
}
|
2013-08-27 18:38:25 -04:00
|
|
|
curr = g_list_next(curr);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(values);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2014-04-24 16:50:59 -04:00
|
|
|
gboolean
|
|
|
|
wins_swap(int source_win, int target_win)
|
|
|
|
{
|
|
|
|
ProfWin *source = g_hash_table_lookup(windows, GINT_TO_POINTER(source_win));
|
|
|
|
|
|
|
|
if (source != NULL) {
|
|
|
|
ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win));
|
|
|
|
|
2014-04-24 18:06:42 -04:00
|
|
|
// target window empty
|
2014-04-24 16:50:59 -04:00
|
|
|
if (target == NULL) {
|
|
|
|
g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
|
|
|
|
status_bar_inactive(source_win);
|
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
|
|
|
if (source->unread > 0) {
|
|
|
|
status_bar_new(target_win);
|
|
|
|
} else {
|
|
|
|
status_bar_active(target_win);
|
|
|
|
}
|
|
|
|
if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
|
|
|
|
ui_switch_win(1);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2014-04-24 18:06:42 -04:00
|
|
|
|
|
|
|
// target window occupied
|
2014-04-24 16:50:59 -04:00
|
|
|
} else {
|
2014-04-24 18:06:42 -04:00
|
|
|
g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
|
|
|
|
g_hash_table_steal(windows, GINT_TO_POINTER(target_win));
|
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(source_win), target);
|
|
|
|
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
|
|
|
if (source->unread > 0) {
|
|
|
|
status_bar_new(target_win);
|
|
|
|
} else {
|
|
|
|
status_bar_active(target_win);
|
|
|
|
}
|
|
|
|
if (target->unread > 0) {
|
|
|
|
status_bar_new(source_win);
|
|
|
|
} else {
|
|
|
|
status_bar_active(source_win);
|
|
|
|
}
|
|
|
|
if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
|
|
|
|
ui_switch_win(1);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2014-04-24 16:50:59 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-20 18:08:21 -04:00
|
|
|
gboolean
|
|
|
|
wins_tidy(void)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
gboolean tidy_required = FALSE;
|
|
|
|
// check for gaps
|
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
keys = g_list_sort(keys, cmp_win_num);
|
|
|
|
|
|
|
|
// get last used
|
|
|
|
GList *last = g_list_last(keys);
|
|
|
|
int last_num = GPOINTER_TO_INT(last->data);
|
|
|
|
|
|
|
|
// find first free num TODO - Will sort again
|
|
|
|
int next_available = get_next_available_win_num(keys);
|
|
|
|
|
2013-08-28 16:45:46 -04:00
|
|
|
// found gap (next available before last window)
|
|
|
|
if (cmp_win_num(GINT_TO_POINTER(next_available), GINT_TO_POINTER(last_num)) < 0) {
|
2013-08-27 18:38:25 -04:00
|
|
|
tidy_required = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tidy_required) {
|
2013-08-29 19:49:38 -04:00
|
|
|
status_bar_set_all_inactive();
|
2013-08-27 18:38:25 -04:00
|
|
|
GHashTable *new_windows = g_hash_table_new_full(g_direct_hash,
|
|
|
|
g_direct_equal, NULL, (GDestroyNotify)win_free);
|
|
|
|
|
|
|
|
int num = 1;
|
|
|
|
GList *curr = keys;
|
|
|
|
while (curr != NULL) {
|
2013-08-28 18:09:54 -04:00
|
|
|
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
2013-08-27 18:38:25 -04:00
|
|
|
if (num == 10) {
|
2013-08-28 18:09:54 -04:00
|
|
|
g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window);
|
2013-08-27 18:38:25 -04:00
|
|
|
if (window->unread > 0) {
|
|
|
|
status_bar_new(0);
|
|
|
|
} else {
|
|
|
|
status_bar_active(0);
|
|
|
|
}
|
|
|
|
} else {
|
2013-08-28 18:09:54 -04:00
|
|
|
g_hash_table_insert(new_windows, GINT_TO_POINTER(num), window);
|
2013-08-27 18:38:25 -04:00
|
|
|
if (window->unread > 0) {
|
|
|
|
status_bar_new(num);
|
|
|
|
} else {
|
|
|
|
status_bar_active(num);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
}
|
2013-08-27 18:38:25 -04:00
|
|
|
num++;
|
|
|
|
curr = g_list_next(curr);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
windows = new_windows;
|
2013-10-02 19:02:30 -04:00
|
|
|
current = 1;
|
|
|
|
ui_switch_win(1);
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(keys);
|
2013-08-27 18:38:25 -04:00
|
|
|
return TRUE;
|
|
|
|
} else {
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(keys);
|
2013-08-27 18:38:25 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
wins_create_summary(void)
|
|
|
|
{
|
|
|
|
GSList *result = NULL;
|
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
GList *keys = g_hash_table_get_keys(windows);
|
|
|
|
keys = g_list_sort(keys, cmp_win_num);
|
|
|
|
GList *curr = keys;
|
|
|
|
|
|
|
|
while (curr != NULL) {
|
|
|
|
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
|
|
|
int ui_index = GPOINTER_TO_INT(curr->data);
|
|
|
|
|
|
|
|
GString *chat_string;
|
|
|
|
GString *priv_string;
|
|
|
|
GString *muc_string;
|
2014-09-06 19:49:42 -04:00
|
|
|
GString *muc_config_string;
|
2014-04-15 08:16:32 -04:00
|
|
|
GString *xml_string;
|
2013-08-27 18:38:25 -04:00
|
|
|
|
|
|
|
switch (window->type)
|
|
|
|
{
|
|
|
|
case WIN_CONSOLE:
|
|
|
|
result = g_slist_append(result, strdup("1: Console"));
|
|
|
|
break;
|
|
|
|
case WIN_CHAT:
|
|
|
|
chat_string = g_string_new("");
|
|
|
|
|
2014-12-19 19:52:35 -05:00
|
|
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
|
|
|
PContact contact = roster_get_contact(chatwin->barejid);
|
2013-08-31 10:07:05 -04:00
|
|
|
if (contact == NULL) {
|
2014-12-19 19:52:35 -05:00
|
|
|
g_string_printf(chat_string, "%d: Chat %s", ui_index, chatwin->barejid);
|
2013-08-31 10:07:05 -04:00
|
|
|
} else {
|
|
|
|
const char *display_name = p_contact_name_or_jid(contact);
|
|
|
|
g_string_printf(chat_string, "%d: Chat %s", ui_index, display_name);
|
2013-08-27 18:38:25 -04:00
|
|
|
GString *chat_presence = g_string_new("");
|
|
|
|
g_string_printf(chat_presence, " - %s", p_contact_presence(contact));
|
|
|
|
g_string_append(chat_string, chat_presence->str);
|
|
|
|
g_string_free(chat_presence, TRUE);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
if (window->unread > 0) {
|
|
|
|
GString *chat_unread = g_string_new("");
|
|
|
|
g_string_printf(chat_unread, ", %d unread", window->unread);
|
|
|
|
g_string_append(chat_string, chat_unread->str);
|
|
|
|
g_string_free(chat_unread, TRUE);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2013-08-27 18:38:25 -04:00
|
|
|
|
|
|
|
result = g_slist_append(result, strdup(chat_string->str));
|
|
|
|
g_string_free(chat_string, TRUE);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WIN_PRIVATE:
|
|
|
|
priv_string = g_string_new("");
|
2014-12-19 19:52:35 -05:00
|
|
|
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
|
|
|
g_string_printf(priv_string, "%d: Private %s", ui_index, privatewin->fulljid);
|
2013-08-27 18:38:25 -04:00
|
|
|
|
|
|
|
if (window->unread > 0) {
|
|
|
|
GString *priv_unread = g_string_new("");
|
|
|
|
g_string_printf(priv_unread, ", %d unread", window->unread);
|
|
|
|
g_string_append(priv_string, priv_unread->str);
|
|
|
|
g_string_free(priv_unread, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = g_slist_append(result, strdup(priv_string->str));
|
|
|
|
g_string_free(priv_string, TRUE);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WIN_MUC:
|
|
|
|
muc_string = g_string_new("");
|
2014-12-19 19:52:35 -05:00
|
|
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
|
|
|
g_string_printf(muc_string, "%d: Room %s", ui_index, mucwin->roomjid);
|
2013-08-27 18:38:25 -04:00
|
|
|
|
|
|
|
if (window->unread > 0) {
|
|
|
|
GString *muc_unread = g_string_new("");
|
|
|
|
g_string_printf(muc_unread, ", %d unread", window->unread);
|
|
|
|
g_string_append(muc_string, muc_unread->str);
|
|
|
|
g_string_free(muc_unread, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = g_slist_append(result, strdup(muc_string->str));
|
|
|
|
g_string_free(muc_string, TRUE);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2014-09-06 19:49:42 -04:00
|
|
|
case WIN_MUC_CONFIG:
|
|
|
|
muc_config_string = g_string_new("");
|
2014-12-21 17:01:56 -05:00
|
|
|
char *title = win_get_title(window);
|
|
|
|
g_string_printf(muc_config_string, "%d: %s", ui_index, title);
|
2014-09-06 19:49:42 -04:00
|
|
|
result = g_slist_append(result, strdup(muc_config_string->str));
|
|
|
|
g_string_free(muc_config_string, TRUE);
|
2014-12-21 17:01:56 -05:00
|
|
|
free(title);
|
2014-09-06 19:49:42 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2014-04-15 08:16:32 -04:00
|
|
|
case WIN_XML:
|
|
|
|
xml_string = g_string_new("");
|
|
|
|
g_string_printf(xml_string, "%d: XML console", ui_index);
|
|
|
|
result = g_slist_append(result, strdup(xml_string->str));
|
|
|
|
g_string_free(xml_string, TRUE);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2013-08-27 18:38:25 -04:00
|
|
|
default:
|
|
|
|
break;
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
2013-08-27 18:38:25 -04:00
|
|
|
curr = g_list_next(curr);
|
2013-08-20 18:08:21 -04:00
|
|
|
}
|
|
|
|
|
2014-06-17 18:14:54 -04:00
|
|
|
g_list_free(keys);
|
2013-08-20 18:08:21 -04:00
|
|
|
return result;
|
|
|
|
}
|
2013-08-26 12:47:29 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
wins_destroy(void)
|
|
|
|
{
|
2013-08-27 18:38:25 -04:00
|
|
|
g_hash_table_destroy(windows);
|
2013-08-26 12:47:29 -04:00
|
|
|
}
|