mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 09:06:21 +00:00
Removed limit on number of windows, WIP
This commit is contained in:
@@ -2144,11 +2144,6 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_windows_full()) {
|
|
||||||
cons_show_error("Windows all used, close a window and try again.");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (win_type == WIN_MUC) {
|
if (win_type == WIN_MUC) {
|
||||||
char *room_name = ui_current_recipient();
|
char *room_name = ui_current_recipient();
|
||||||
if (muc_nick_in_roster(room_name, usr)) {
|
if (muc_nick_in_roster(room_name, usr)) {
|
||||||
@@ -2399,11 +2394,6 @@ _cmd_duck(gchar **args, struct cmd_help_t help)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_windows_full()) {
|
|
||||||
cons_show_error("Windows all used, close a window and try again.");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no duck win open, create it and send a help command
|
// if no duck win open, create it and send a help command
|
||||||
if (!ui_duck_exists()) {
|
if (!ui_duck_exists()) {
|
||||||
ui_create_duck_win();
|
ui_create_duck_win();
|
||||||
@@ -2707,11 +2697,6 @@ _cmd_join(gchar **args, struct cmd_help_t help)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_windows_full()) {
|
|
||||||
cons_show_error("Windows all used, close a window and try again.");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Jid *room_arg = jid_create(args[0]);
|
Jid *room_arg = jid_create(args[0]);
|
||||||
if (room_arg == NULL) {
|
if (room_arg == NULL) {
|
||||||
cons_show_error("Specified room has incorrect format");
|
cons_show_error("Specified room has incorrect format");
|
||||||
|
|||||||
14
src/common.c
14
src/common.c
@@ -423,23 +423,23 @@ cmp_win_num(gconstpointer a, gconstpointer b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get_next_available_win_num(GSList *used)
|
get_next_available_win_num(GList *used)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
used = g_slist_sort(used, cmp_win_num);
|
used = g_list_sort(used, cmp_win_num);
|
||||||
// only console used
|
// only console used
|
||||||
if (g_slist_length(used) == 1) {
|
if (g_list_length(used) == 1) {
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
int last_num = 1;
|
int last_num = 1;
|
||||||
GSList *curr = used;
|
GList *curr = used;
|
||||||
// skip console
|
// skip console
|
||||||
curr = g_slist_next(curr);
|
curr = g_list_next(curr);
|
||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
int curr_num = GPOINTER_TO_INT(curr->data);
|
int curr_num = GPOINTER_TO_INT(curr->data);
|
||||||
if (((last_num != 9) && ((last_num + 1) != curr_num)) ||
|
if (((last_num != 9) && ((last_num + 1) != curr_num)) ||
|
||||||
((last_num == 9) && (curr_num != 0))) {
|
((last_num == 9) && (curr_num != 0))) {
|
||||||
g_slist_free(curr);
|
g_list_free(curr);
|
||||||
result = last_num + 1;
|
result = last_num + 1;
|
||||||
if (result == 10) {
|
if (result == 10) {
|
||||||
result = 0;
|
result = 0;
|
||||||
@@ -451,7 +451,7 @@ get_next_available_win_num(GSList *used)
|
|||||||
last_num = 10;
|
last_num = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curr = g_slist_next(curr);
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
result = last_num + 1;
|
result = last_num + 1;
|
||||||
if (result == 10) {
|
if (result == 10) {
|
||||||
|
|||||||
@@ -92,6 +92,6 @@ contact_presence_t contact_presence_from_resource_presence(resource_presence_t r
|
|||||||
char * get_unique_id(void);
|
char * get_unique_id(void);
|
||||||
|
|
||||||
int cmp_win_num(gconstpointer a, gconstpointer b);
|
int cmp_win_num(gconstpointer a, gconstpointer b);
|
||||||
int get_next_available_win_num(GSList *used);
|
int get_next_available_win_num(GList *used);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
144
src/ui/core.c
144
src/ui/core.c
@@ -160,12 +160,6 @@ ui_load_colours(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
ui_windows_full(void)
|
|
||||||
{
|
|
||||||
return wins_full();
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ui_win_exists(int index)
|
ui_win_exists(int index)
|
||||||
{
|
{
|
||||||
@@ -278,112 +272,76 @@ ui_incoming_msg(const char * const from, const char * const message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
// no spare windows left
|
|
||||||
if (wins_full()) {
|
// currently viewing chat window with sender
|
||||||
ProfWin *console = wins_get_console();
|
if (wins_is_current(window)) {
|
||||||
if (tv_stamp == NULL) {
|
if (tv_stamp == NULL) {
|
||||||
win_print_time(console, '-');
|
win_print_time(window, '-');
|
||||||
} else {
|
} else {
|
||||||
GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp);
|
GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp);
|
||||||
gchar *date_fmt = g_date_time_format(time, "%H:%M:%S");
|
gchar *date_fmt = g_date_time_format(time, "%H:%M:%S");
|
||||||
wattron(console->win, COLOUR_TIME);
|
wattron(window->win, COLOUR_TIME);
|
||||||
wprintw(console->win, "%s - ", date_fmt);
|
wprintw(window->win, "%s - ", date_fmt);
|
||||||
wattroff(console->win, COLOUR_TIME);
|
wattroff(window->win, COLOUR_TIME);
|
||||||
g_date_time_unref(time);
|
g_date_time_unref(time);
|
||||||
g_free(date_fmt);
|
g_free(date_fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(message, "/me ", 4) == 0) {
|
if (strncmp(message, "/me ", 4) == 0) {
|
||||||
wattron(console->win, COLOUR_THEM);
|
wattron(window->win, COLOUR_THEM);
|
||||||
wprintw(console->win, "*%s ", display_from);
|
wprintw(window->win, "*%s ", display_from);
|
||||||
waddstr(console->win, message + 4);
|
waddstr(window->win, message + 4);
|
||||||
wprintw(console->win, "\n");
|
wprintw(window->win, "\n");
|
||||||
wattroff(console->win, COLOUR_THEM);
|
wattroff(window->win, COLOUR_THEM);
|
||||||
} else {
|
} else {
|
||||||
_win_show_user(console->win, display_from, 1);
|
_win_show_user(window->win, display_from, 1);
|
||||||
_win_show_message(console->win, message);
|
_win_show_message(window->win, message);
|
||||||
}
|
}
|
||||||
|
title_bar_set_typing(FALSE);
|
||||||
|
title_bar_draw();
|
||||||
|
status_bar_active(num);
|
||||||
|
wins_refresh_current();
|
||||||
|
|
||||||
cons_show("Windows all used, close a window to respond.");
|
// not currently viewing chat window with sender
|
||||||
|
|
||||||
if (wins_get_current_num() == 0) {
|
|
||||||
wins_refresh_current();
|
|
||||||
} else {
|
|
||||||
status_bar_new(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// window found or created
|
|
||||||
} else {
|
} else {
|
||||||
// currently viewing chat window with sender
|
status_bar_new(num);
|
||||||
if (wins_is_current(window)) {
|
cons_show_incoming_message(display_from, num);
|
||||||
if (tv_stamp == NULL) {
|
if (prefs_get_boolean(PREF_FLASH))
|
||||||
win_print_time(window, '-');
|
flash();
|
||||||
} else {
|
|
||||||
GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp);
|
|
||||||
gchar *date_fmt = g_date_time_format(time, "%H:%M:%S");
|
|
||||||
wattron(window->win, COLOUR_TIME);
|
|
||||||
wprintw(window->win, "%s - ", date_fmt);
|
|
||||||
wattroff(window->win, COLOUR_TIME);
|
|
||||||
g_date_time_unref(time);
|
|
||||||
g_free(date_fmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp(message, "/me ", 4) == 0) {
|
window->unread++;
|
||||||
wattron(window->win, COLOUR_THEM);
|
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
||||||
wprintw(window->win, "*%s ", display_from);
|
_win_show_history(window->win, num, from);
|
||||||
waddstr(window->win, message + 4);
|
}
|
||||||
wprintw(window->win, "\n");
|
|
||||||
wattroff(window->win, COLOUR_THEM);
|
|
||||||
} else {
|
|
||||||
_win_show_user(window->win, display_from, 1);
|
|
||||||
_win_show_message(window->win, message);
|
|
||||||
}
|
|
||||||
title_bar_set_typing(FALSE);
|
|
||||||
title_bar_draw();
|
|
||||||
status_bar_active(num);
|
|
||||||
wins_refresh_current();
|
|
||||||
|
|
||||||
// not currently viewing chat window with sender
|
if (tv_stamp == NULL) {
|
||||||
|
win_print_time(window, '-');
|
||||||
} else {
|
} else {
|
||||||
status_bar_new(num);
|
// show users status first, when receiving message via delayed delivery
|
||||||
cons_show_incoming_message(display_from, num);
|
if (win_created) {
|
||||||
if (prefs_get_boolean(PREF_FLASH))
|
PContact pcontact = roster_get_contact(from);
|
||||||
flash();
|
if (pcontact != NULL) {
|
||||||
|
win_show_contact(window, pcontact);
|
||||||
window->unread++;
|
|
||||||
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
|
||||||
_win_show_history(window->win, num, from);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tv_stamp == NULL) {
|
|
||||||
win_print_time(window, '-');
|
|
||||||
} else {
|
|
||||||
// show users status first, when receiving message via delayed delivery
|
|
||||||
if (win_created) {
|
|
||||||
PContact pcontact = roster_get_contact(from);
|
|
||||||
if (pcontact != NULL) {
|
|
||||||
win_show_contact(window, pcontact);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp);
|
|
||||||
gchar *date_fmt = g_date_time_format(time, "%H:%M:%S");
|
|
||||||
wattron(window->win, COLOUR_TIME);
|
|
||||||
wprintw(window->win, "%s - ", date_fmt);
|
|
||||||
wattroff(window->win, COLOUR_TIME);
|
|
||||||
g_date_time_unref(time);
|
|
||||||
g_free(date_fmt);
|
|
||||||
}
|
}
|
||||||
|
GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp);
|
||||||
|
gchar *date_fmt = g_date_time_format(time, "%H:%M:%S");
|
||||||
|
wattron(window->win, COLOUR_TIME);
|
||||||
|
wprintw(window->win, "%s - ", date_fmt);
|
||||||
|
wattroff(window->win, COLOUR_TIME);
|
||||||
|
g_date_time_unref(time);
|
||||||
|
g_free(date_fmt);
|
||||||
|
}
|
||||||
|
|
||||||
if (strncmp(message, "/me ", 4) == 0) {
|
if (strncmp(message, "/me ", 4) == 0) {
|
||||||
wattron(window->win, COLOUR_THEM);
|
wattron(window->win, COLOUR_THEM);
|
||||||
wprintw(window->win, "*%s ", display_from);
|
wprintw(window->win, "*%s ", display_from);
|
||||||
waddstr(window->win, message + 4);
|
waddstr(window->win, message + 4);
|
||||||
wprintw(window->win, "\n");
|
wprintw(window->win, "\n");
|
||||||
wattroff(window->win, COLOUR_THEM);
|
wattroff(window->win, COLOUR_THEM);
|
||||||
} else {
|
} else {
|
||||||
_win_show_user(window->win, display_from, 1);
|
_win_show_user(window->win, display_from, 1);
|
||||||
_win_show_message(window->win, message);
|
_win_show_message(window->win, message);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ void ui_idle(void);
|
|||||||
void ui_handle_special_keys(const wint_t * const ch, const char * const inp,
|
void ui_handle_special_keys(const wint_t * const ch, const char * const inp,
|
||||||
const int size);
|
const int size);
|
||||||
void ui_switch_win(const int i);
|
void ui_switch_win(const int i);
|
||||||
gboolean ui_windows_full(void);
|
|
||||||
unsigned long ui_get_idle_time(void);
|
unsigned long ui_get_idle_time(void);
|
||||||
void ui_reset_idle_time(void);
|
void ui_reset_idle_time(void);
|
||||||
void ui_new_chat_win(const char * const to);
|
void ui_new_chat_win(const char * const to);
|
||||||
|
|||||||
452
src/ui/windows.c
452
src/ui/windows.c
@@ -38,56 +38,42 @@
|
|||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
#include "ui/windows.h"
|
#include "ui/windows.h"
|
||||||
|
|
||||||
#define NUM_WINS 10
|
|
||||||
#define CONS_WIN_TITLE "_cons"
|
#define CONS_WIN_TITLE "_cons"
|
||||||
|
|
||||||
static ProfWin* windows[NUM_WINS];
|
static GHashTable *windows;
|
||||||
static int current;
|
static int current;
|
||||||
static int max_cols;
|
static int max_cols;
|
||||||
|
|
||||||
//static GHashTable *windows;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wins_init(void)
|
wins_init(void)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
windows = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
|
windows = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
|
||||||
window_free);
|
(GDestroyNotify)win_free);
|
||||||
|
|
||||||
int cols = getmaxx(stdscr);
|
|
||||||
ProfWin *console = win_create(CONS_WIN_TITLE, cols, WIN_CONSOLE);
|
|
||||||
g_hash_table_insert(GINT_TO_POINTER(1), console);
|
|
||||||
|
|
||||||
current = console;
|
|
||||||
*/
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < NUM_WINS; i++) {
|
|
||||||
windows[i] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
max_cols = getmaxx(stdscr);
|
max_cols = getmaxx(stdscr);
|
||||||
int cols = getmaxx(stdscr);
|
int cols = getmaxx(stdscr);
|
||||||
windows[0] = win_create(CONS_WIN_TITLE, cols, WIN_CONSOLE);
|
ProfWin *console = win_create(CONS_WIN_TITLE, cols, WIN_CONSOLE);
|
||||||
current = 0;
|
g_hash_table_insert(windows, GINT_TO_POINTER(1), console);
|
||||||
|
|
||||||
|
current = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfWin *
|
ProfWin *
|
||||||
wins_get_console(void)
|
wins_get_console(void)
|
||||||
{
|
{
|
||||||
return windows[0];
|
return g_hash_table_lookup(windows, GINT_TO_POINTER(1));
|
||||||
// return g_hash_table_lookup(windows, GINT_TO_POINTER(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfWin *
|
ProfWin *
|
||||||
wins_get_current(void)
|
wins_get_current(void)
|
||||||
{
|
{
|
||||||
return windows[current];
|
return g_hash_table_lookup(windows, GINT_TO_POINTER(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wins_set_current_by_num(int i)
|
wins_set_current_by_num(int i)
|
||||||
{
|
{
|
||||||
if (i < NUM_WINS) {
|
if (g_hash_table_lookup(windows, GINT_TO_POINTER(i)) != NULL) {
|
||||||
current = i;
|
current = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,21 +81,21 @@ wins_set_current_by_num(int i)
|
|||||||
ProfWin *
|
ProfWin *
|
||||||
wins_get_by_num(int i)
|
wins_get_by_num(int i)
|
||||||
{
|
{
|
||||||
if (i >= NUM_WINS) {
|
return g_hash_table_lookup(windows, GINT_TO_POINTER(i));
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
return windows[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfWin *
|
ProfWin *
|
||||||
wins_get_by_recipient(const char * const recipient)
|
wins_get_by_recipient(const char * const recipient)
|
||||||
{
|
{
|
||||||
int i = 0;
|
GList *values = g_hash_table_get_values(windows);
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
GList *curr = values;
|
||||||
if ((windows[i] != NULL) && g_strcmp0(windows[i]->from, recipient) == 0) {
|
|
||||||
return windows[i];
|
while (curr != NULL) {
|
||||||
|
ProfWin *window = curr->data;
|
||||||
|
if (g_strcmp0(window->from, recipient) == 0) {
|
||||||
|
return window;
|
||||||
}
|
}
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -118,14 +104,19 @@ wins_get_by_recipient(const char * const recipient)
|
|||||||
int
|
int
|
||||||
wins_get_num(ProfWin *window)
|
wins_get_num(ProfWin *window)
|
||||||
{
|
{
|
||||||
int i = 0;
|
GList *keys = g_hash_table_get_keys(windows);
|
||||||
for (i = 0; i < NUM_WINS; i++) {
|
GList *curr = keys;
|
||||||
if ((windows[i] != NULL) && g_strcmp0(windows[i]->from, window->from) == 0) {
|
|
||||||
return i;
|
while (curr != NULL) {
|
||||||
|
gconstpointer num_p = curr->data;
|
||||||
|
ProfWin *curr_win = g_hash_table_lookup(windows, num_p);
|
||||||
|
if (g_strcmp0(curr_win->from, window->from) == 0) {
|
||||||
|
return GPOINTER_TO_INT(num_p);
|
||||||
}
|
}
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -143,35 +134,38 @@ wins_close_current(void)
|
|||||||
void
|
void
|
||||||
wins_close_by_num(int i)
|
wins_close_by_num(int i)
|
||||||
{
|
{
|
||||||
if (i > 0 && i < NUM_WINS) {
|
if (i != 1) {
|
||||||
win_free(windows[i]);
|
|
||||||
windows[i] = NULL;
|
|
||||||
if (i == current) {
|
if (i == current) {
|
||||||
current = 0;
|
current = 1;
|
||||||
wins_refresh_current();
|
wins_refresh_current();
|
||||||
}
|
}
|
||||||
|
g_hash_table_remove(windows, GINT_TO_POINTER(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wins_refresh_current(void)
|
wins_refresh_current(void)
|
||||||
{
|
{
|
||||||
|
ProfWin *window = wins_get_current();
|
||||||
int rows, cols;
|
int rows, cols;
|
||||||
getmaxyx(stdscr, rows, cols);
|
getmaxyx(stdscr, rows, cols);
|
||||||
prefresh(windows[current]->win, windows[current]->y_pos, 0, 1, 0, rows-3, cols-1);
|
prefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wins_clear_current(void)
|
wins_clear_current(void)
|
||||||
{
|
{
|
||||||
werase(windows[current]->win);
|
ProfWin *window = wins_get_current();
|
||||||
|
werase(window->win);
|
||||||
wins_refresh_current();
|
wins_refresh_current();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
wins_is_current(ProfWin *window)
|
wins_is_current(ProfWin *window)
|
||||||
{
|
{
|
||||||
if (g_strcmp0(windows[current]->from, window->from) == 0) {
|
ProfWin *current_window = wins_get_current();
|
||||||
|
|
||||||
|
if (g_strcmp0(current_window->from, window->from) == 0) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -181,31 +175,25 @@ wins_is_current(ProfWin *window)
|
|||||||
ProfWin *
|
ProfWin *
|
||||||
wins_new(const char * const from, win_type_t type)
|
wins_new(const char * const from, win_type_t type)
|
||||||
{
|
{
|
||||||
int i;
|
GList *keys = g_hash_table_get_keys(windows);
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
int result = get_next_available_win_num(keys);
|
||||||
if (windows[i] == NULL) {
|
int cols = getmaxx(stdscr);
|
||||||
break;
|
ProfWin *new = win_create(from, cols, type);
|
||||||
}
|
g_hash_table_insert(windows, GINT_TO_POINTER(result), new);
|
||||||
}
|
return new;
|
||||||
|
|
||||||
if (i != NUM_WINS) {
|
|
||||||
int cols = getmaxx(stdscr);
|
|
||||||
windows[i] = win_create(from, cols, type);
|
|
||||||
return windows[i];
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
wins_get_total_unread(void)
|
wins_get_total_unread(void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (i = 0; i < NUM_WINS; i++) {
|
GList *values = g_hash_table_get_values(windows);
|
||||||
if (windows[i] != NULL) {
|
GList *curr = values;
|
||||||
result += windows[i]->unread;
|
|
||||||
}
|
while (curr != NULL) {
|
||||||
|
ProfWin *window = curr->data;
|
||||||
|
result += window->unread;
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -220,15 +208,19 @@ wins_resize_all(void)
|
|||||||
if (cols > max_cols) {
|
if (cols > max_cols) {
|
||||||
max_cols = cols;
|
max_cols = cols;
|
||||||
|
|
||||||
int i;
|
GList *values = g_hash_table_get_values(windows);
|
||||||
for (i = 0; i < NUM_WINS; i++) {
|
GList *curr = values;
|
||||||
if (windows[i] != NULL) {
|
|
||||||
wresize(windows[i]->win, PAD_SIZE, cols);
|
while (curr != NULL) {
|
||||||
}
|
ProfWin *window = curr->data;
|
||||||
|
wresize(window->win, PAD_SIZE, cols);
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prefresh(windows[current]->win, windows[current]->y_pos, 0, 1, 0, rows-3, cols-1);
|
ProfWin *current_win = wins_get_current();
|
||||||
|
|
||||||
|
prefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -239,28 +231,17 @@ wins_refresh_console(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
wins_full(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
|
||||||
if (windows[i] == NULL) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
wins_duck_exists(void)
|
wins_duck_exists(void)
|
||||||
{
|
{
|
||||||
int i;
|
GList *values = g_hash_table_get_values(windows);
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
GList *curr = values;
|
||||||
if (windows[i] != NULL) {
|
|
||||||
if (windows[i]->type == WIN_DUCK)
|
while (curr != NULL) {
|
||||||
return TRUE;
|
ProfWin *window = curr->data;
|
||||||
}
|
if (window->type == WIN_DUCK)
|
||||||
|
return TRUE;
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -270,11 +251,15 @@ GSList *
|
|||||||
wins_get_chat_recipients(void)
|
wins_get_chat_recipients(void)
|
||||||
{
|
{
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
int i;
|
GList *values = g_hash_table_get_values(windows);
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
GList *curr = values;
|
||||||
if (windows[i] != NULL && windows[i]->type == WIN_CHAT) {
|
|
||||||
result = g_slist_append(result, windows[i]->from);
|
while (curr != NULL) {
|
||||||
|
ProfWin *window = curr->data;
|
||||||
|
if (window->type == WIN_CHAT) {
|
||||||
|
result = g_slist_append(result, window->from);
|
||||||
}
|
}
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -283,24 +268,28 @@ GSList *
|
|||||||
wins_get_prune_recipients(void)
|
wins_get_prune_recipients(void)
|
||||||
{
|
{
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
int i;
|
GList *values = g_hash_table_get_values(windows);
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
GList *curr = values;
|
||||||
if (windows[i] != NULL && windows[i]->unread == 0 && windows[i]->type != WIN_MUC) {
|
|
||||||
result = g_slist_append(result, windows[i]->from);
|
while (curr != NULL) {
|
||||||
|
ProfWin *window = curr->data;
|
||||||
|
if (window->unread == 0 && window->type != WIN_MUC && window->type != WIN_CONSOLE) {
|
||||||
|
result = g_slist_append(result, window->from);
|
||||||
}
|
}
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wins_lost_connection(void)
|
wins_lost_connection(void)
|
||||||
{
|
{
|
||||||
int i;
|
GList *values = g_hash_table_get_values(windows);
|
||||||
// show message in all active chats
|
GList *curr = values;
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
|
||||||
if (windows[i] != NULL) {
|
while (curr != NULL) {
|
||||||
ProfWin *window = windows[i];
|
ProfWin *window = curr->data;
|
||||||
|
if (window->type != WIN_CONSOLE) {
|
||||||
win_print_time(window, '-');
|
win_print_time(window, '-');
|
||||||
wattron(window->win, COLOUR_ERROR);
|
wattron(window->win, COLOUR_ERROR);
|
||||||
wprintw(window->win, "%s\n", "Lost connection.");
|
wprintw(window->win, "%s\n", "Lost connection.");
|
||||||
@@ -311,147 +300,161 @@ wins_lost_connection(void)
|
|||||||
wins_refresh_current();
|
wins_refresh_current();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
wins_tidy(void)
|
wins_tidy(void)
|
||||||
{
|
{
|
||||||
int gap = 1;
|
gboolean tidy_required = FALSE;
|
||||||
int filler = 1;
|
// check for gaps
|
||||||
gboolean tidied = FALSE;
|
GList *keys = g_hash_table_get_keys(windows);
|
||||||
|
keys = g_list_sort(keys, cmp_win_num);
|
||||||
|
|
||||||
for (gap = 1; gap < NUM_WINS; gap++) {
|
// get last used
|
||||||
// if a gap
|
GList *last = g_list_last(keys);
|
||||||
if (windows[gap] == NULL) {
|
int last_num = GPOINTER_TO_INT(last->data);
|
||||||
|
|
||||||
// find next used window and move into gap
|
// find first free num TODO - Will sort again
|
||||||
for (filler = gap + 1; filler < NUM_WINS; filler++) {
|
int next_available = get_next_available_win_num(keys);
|
||||||
if (windows[filler] != NULL) {
|
|
||||||
windows[gap] = windows[filler];
|
// found gap (next available after last window)
|
||||||
if (windows[gap]->unread > 0) {
|
if (cmp_win_num(GINT_TO_POINTER(next_available), GINT_TO_POINTER(last_num)) > 0) {
|
||||||
status_bar_new(gap);
|
tidy_required = TRUE;
|
||||||
} else {
|
|
||||||
status_bar_active(gap);
|
|
||||||
}
|
|
||||||
windows[filler] = NULL;
|
|
||||||
status_bar_inactive(filler);
|
|
||||||
tidied = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tidied;
|
if (tidy_required) {
|
||||||
|
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) {
|
||||||
|
ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(curr->data));
|
||||||
|
if (num == 10) {
|
||||||
|
g_hash_table_insert(windows, GINT_TO_POINTER(0), window);
|
||||||
|
if (window->unread > 0) {
|
||||||
|
status_bar_new(0);
|
||||||
|
} else {
|
||||||
|
status_bar_active(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_hash_table_insert(windows, GINT_TO_POINTER(num), window);
|
||||||
|
if (window->unread > 0) {
|
||||||
|
status_bar_new(num);
|
||||||
|
} else {
|
||||||
|
status_bar_active(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
|
||||||
|
windows = new_windows;
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
wins_create_summary(void)
|
wins_create_summary(void)
|
||||||
{
|
{
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
result = g_slist_append(result, strdup("1: Console"));
|
|
||||||
int count = 0;
|
|
||||||
int ui_index = 0;
|
|
||||||
|
|
||||||
int i;
|
GList *keys = g_hash_table_get_keys(windows);
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
keys = g_list_sort(keys, cmp_win_num);
|
||||||
if (windows[i] != NULL) {
|
GList *curr = keys;
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count != 0) {
|
while (curr != NULL) {
|
||||||
for (i = 1; i < NUM_WINS; i++) {
|
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
||||||
if (windows[i] != NULL) {
|
int ui_index = GPOINTER_TO_INT(curr->data);
|
||||||
ProfWin *window = windows[i];
|
|
||||||
ui_index = i + 1;
|
GString *chat_string;
|
||||||
if (ui_index == 10) {
|
GString *priv_string;
|
||||||
ui_index = 0;
|
GString *muc_string;
|
||||||
|
GString *duck_string;
|
||||||
|
|
||||||
|
switch (window->type)
|
||||||
|
{
|
||||||
|
case WIN_CONSOLE:
|
||||||
|
result = g_slist_append(result, strdup("1: Console"));
|
||||||
|
break;
|
||||||
|
case WIN_CHAT:
|
||||||
|
chat_string = g_string_new("");
|
||||||
|
g_string_printf(chat_string, "%d: Chat %s", ui_index, window->from);
|
||||||
|
PContact contact = roster_get_contact(window->from);
|
||||||
|
|
||||||
|
if (contact != NULL) {
|
||||||
|
if (p_contact_name(contact) != NULL) {
|
||||||
|
GString *chat_name = g_string_new("");
|
||||||
|
g_string_printf(chat_name, " (%s)", p_contact_name(contact));
|
||||||
|
g_string_append(chat_string, chat_name->str);
|
||||||
|
g_string_free(chat_name, TRUE);
|
||||||
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
GString *chat_string;
|
if (window->unread > 0) {
|
||||||
GString *priv_string;
|
GString *chat_unread = g_string_new("");
|
||||||
GString *muc_string;
|
g_string_printf(chat_unread, ", %d unread", window->unread);
|
||||||
GString *duck_string;
|
g_string_append(chat_string, chat_unread->str);
|
||||||
|
g_string_free(chat_unread, TRUE);
|
||||||
switch (window->type)
|
|
||||||
{
|
|
||||||
case WIN_CHAT:
|
|
||||||
chat_string = g_string_new("");
|
|
||||||
g_string_printf(chat_string, "%d: Chat %s", ui_index, window->from);
|
|
||||||
PContact contact = roster_get_contact(window->from);
|
|
||||||
|
|
||||||
if (contact != NULL) {
|
|
||||||
if (p_contact_name(contact) != NULL) {
|
|
||||||
GString *chat_name = g_string_new("");
|
|
||||||
g_string_printf(chat_name, " (%s)", p_contact_name(contact));
|
|
||||||
g_string_append(chat_string, chat_name->str);
|
|
||||||
g_string_free(chat_name, TRUE);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = g_slist_append(result, strdup(chat_string->str));
|
|
||||||
g_string_free(chat_string, TRUE);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIN_PRIVATE:
|
|
||||||
priv_string = g_string_new("");
|
|
||||||
g_string_printf(priv_string, "%d: Private %s", ui_index, window->from);
|
|
||||||
|
|
||||||
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("");
|
|
||||||
g_string_printf(muc_string, "%d: Room %s", ui_index, window->from);
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
case WIN_DUCK:
|
|
||||||
duck_string = g_string_new("");
|
|
||||||
g_string_printf(duck_string, "%d: DuckDuckGo search", ui_index);
|
|
||||||
result = g_slist_append(result, strdup(duck_string->str));
|
|
||||||
g_string_free(duck_string, TRUE);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
result = g_slist_append(result, strdup(chat_string->str));
|
||||||
|
g_string_free(chat_string, TRUE);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIN_PRIVATE:
|
||||||
|
priv_string = g_string_new("");
|
||||||
|
g_string_printf(priv_string, "%d: Private %s", ui_index, window->from);
|
||||||
|
|
||||||
|
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("");
|
||||||
|
g_string_printf(muc_string, "%d: Room %s", ui_index, window->from);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
case WIN_DUCK:
|
||||||
|
duck_string = g_string_new("");
|
||||||
|
g_string_printf(duck_string, "%d: DuckDuckGo search", ui_index);
|
||||||
|
result = g_slist_append(result, strdup(duck_string->str));
|
||||||
|
g_string_free(duck_string, TRUE);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -460,10 +463,5 @@ wins_create_summary(void)
|
|||||||
void
|
void
|
||||||
wins_destroy(void)
|
wins_destroy(void)
|
||||||
{
|
{
|
||||||
int i;
|
g_hash_table_destroy(windows);
|
||||||
for (i = 0; i < NUM_WINS; i++) {
|
|
||||||
if (windows[i] != NULL) {
|
|
||||||
win_free(windows[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ gboolean wins_is_current(ProfWin *window);
|
|||||||
ProfWin * wins_new(const char * const from, win_type_t type);
|
ProfWin * wins_new(const char * const from, win_type_t type);
|
||||||
int wins_get_total_unread(void);
|
int wins_get_total_unread(void);
|
||||||
void wins_resize_all(void);
|
void wins_resize_all(void);
|
||||||
gboolean wins_full(void);
|
|
||||||
gboolean wins_duck_exists(void);
|
gboolean wins_duck_exists(void);
|
||||||
GSList * wins_get_chat_recipients(void);
|
GSList * wins_get_chat_recipients(void);
|
||||||
GSList * wins_get_prune_recipients(void);
|
GSList * wins_get_prune_recipients(void);
|
||||||
|
|||||||
@@ -248,8 +248,8 @@ void compare_9_less_than_0(void)
|
|||||||
|
|
||||||
void next_available_when_only_console(void)
|
void next_available_when_only_console(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
@@ -258,9 +258,9 @@ void next_available_when_only_console(void)
|
|||||||
|
|
||||||
void next_available_3_at_end(void)
|
void next_available_3_at_end(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(2));
|
used = g_list_append(used, GINT_TO_POINTER(2));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
@@ -269,15 +269,15 @@ void next_available_3_at_end(void)
|
|||||||
|
|
||||||
void next_available_9_at_end(void)
|
void next_available_9_at_end(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(2));
|
used = g_list_append(used, GINT_TO_POINTER(2));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(3));
|
used = g_list_append(used, GINT_TO_POINTER(3));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(4));
|
used = g_list_append(used, GINT_TO_POINTER(4));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(5));
|
used = g_list_append(used, GINT_TO_POINTER(5));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(6));
|
used = g_list_append(used, GINT_TO_POINTER(6));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(7));
|
used = g_list_append(used, GINT_TO_POINTER(7));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(8));
|
used = g_list_append(used, GINT_TO_POINTER(8));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
@@ -286,16 +286,16 @@ void next_available_9_at_end(void)
|
|||||||
|
|
||||||
void next_available_0_at_end(void)
|
void next_available_0_at_end(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(2));
|
used = g_list_append(used, GINT_TO_POINTER(2));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(3));
|
used = g_list_append(used, GINT_TO_POINTER(3));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(4));
|
used = g_list_append(used, GINT_TO_POINTER(4));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(5));
|
used = g_list_append(used, GINT_TO_POINTER(5));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(6));
|
used = g_list_append(used, GINT_TO_POINTER(6));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(7));
|
used = g_list_append(used, GINT_TO_POINTER(7));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(8));
|
used = g_list_append(used, GINT_TO_POINTER(8));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(9));
|
used = g_list_append(used, GINT_TO_POINTER(9));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
@@ -304,13 +304,13 @@ void next_available_0_at_end(void)
|
|||||||
|
|
||||||
void next_available_2_in_first_gap(void)
|
void next_available_2_in_first_gap(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(3));
|
used = g_list_append(used, GINT_TO_POINTER(3));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(4));
|
used = g_list_append(used, GINT_TO_POINTER(4));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(5));
|
used = g_list_append(used, GINT_TO_POINTER(5));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(9));
|
used = g_list_append(used, GINT_TO_POINTER(9));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(0));
|
used = g_list_append(used, GINT_TO_POINTER(0));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
@@ -319,20 +319,20 @@ void next_available_2_in_first_gap(void)
|
|||||||
|
|
||||||
void next_available_9_in_first_gap(void)
|
void next_available_9_in_first_gap(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(2));
|
used = g_list_append(used, GINT_TO_POINTER(2));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(3));
|
used = g_list_append(used, GINT_TO_POINTER(3));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(4));
|
used = g_list_append(used, GINT_TO_POINTER(4));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(5));
|
used = g_list_append(used, GINT_TO_POINTER(5));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(6));
|
used = g_list_append(used, GINT_TO_POINTER(6));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(7));
|
used = g_list_append(used, GINT_TO_POINTER(7));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(8));
|
used = g_list_append(used, GINT_TO_POINTER(8));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(0));
|
used = g_list_append(used, GINT_TO_POINTER(0));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(11));
|
used = g_list_append(used, GINT_TO_POINTER(11));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(12));
|
used = g_list_append(used, GINT_TO_POINTER(12));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(13));
|
used = g_list_append(used, GINT_TO_POINTER(13));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(20));
|
used = g_list_append(used, GINT_TO_POINTER(20));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
@@ -341,20 +341,20 @@ void next_available_9_in_first_gap(void)
|
|||||||
|
|
||||||
void next_available_0_in_first_gap(void)
|
void next_available_0_in_first_gap(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(2));
|
used = g_list_append(used, GINT_TO_POINTER(2));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(3));
|
used = g_list_append(used, GINT_TO_POINTER(3));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(4));
|
used = g_list_append(used, GINT_TO_POINTER(4));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(5));
|
used = g_list_append(used, GINT_TO_POINTER(5));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(6));
|
used = g_list_append(used, GINT_TO_POINTER(6));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(7));
|
used = g_list_append(used, GINT_TO_POINTER(7));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(8));
|
used = g_list_append(used, GINT_TO_POINTER(8));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(9));
|
used = g_list_append(used, GINT_TO_POINTER(9));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(11));
|
used = g_list_append(used, GINT_TO_POINTER(11));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(12));
|
used = g_list_append(used, GINT_TO_POINTER(12));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(13));
|
used = g_list_append(used, GINT_TO_POINTER(13));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(20));
|
used = g_list_append(used, GINT_TO_POINTER(20));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
@@ -363,20 +363,20 @@ void next_available_0_in_first_gap(void)
|
|||||||
|
|
||||||
void next_available_11_in_first_gap(void)
|
void next_available_11_in_first_gap(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(2));
|
used = g_list_append(used, GINT_TO_POINTER(2));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(3));
|
used = g_list_append(used, GINT_TO_POINTER(3));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(4));
|
used = g_list_append(used, GINT_TO_POINTER(4));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(5));
|
used = g_list_append(used, GINT_TO_POINTER(5));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(6));
|
used = g_list_append(used, GINT_TO_POINTER(6));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(7));
|
used = g_list_append(used, GINT_TO_POINTER(7));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(8));
|
used = g_list_append(used, GINT_TO_POINTER(8));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(9));
|
used = g_list_append(used, GINT_TO_POINTER(9));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(0));
|
used = g_list_append(used, GINT_TO_POINTER(0));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(12));
|
used = g_list_append(used, GINT_TO_POINTER(12));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(13));
|
used = g_list_append(used, GINT_TO_POINTER(13));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(20));
|
used = g_list_append(used, GINT_TO_POINTER(20));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
@@ -385,38 +385,38 @@ void next_available_11_in_first_gap(void)
|
|||||||
|
|
||||||
void next_available_24_first_big_gap(void)
|
void next_available_24_first_big_gap(void)
|
||||||
{
|
{
|
||||||
GSList *used = NULL;
|
GList *used = NULL;
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(1));
|
used = g_list_append(used, GINT_TO_POINTER(1));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(2));
|
used = g_list_append(used, GINT_TO_POINTER(2));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(3));
|
used = g_list_append(used, GINT_TO_POINTER(3));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(4));
|
used = g_list_append(used, GINT_TO_POINTER(4));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(5));
|
used = g_list_append(used, GINT_TO_POINTER(5));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(6));
|
used = g_list_append(used, GINT_TO_POINTER(6));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(7));
|
used = g_list_append(used, GINT_TO_POINTER(7));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(8));
|
used = g_list_append(used, GINT_TO_POINTER(8));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(9));
|
used = g_list_append(used, GINT_TO_POINTER(9));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(0));
|
used = g_list_append(used, GINT_TO_POINTER(0));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(11));
|
used = g_list_append(used, GINT_TO_POINTER(11));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(12));
|
used = g_list_append(used, GINT_TO_POINTER(12));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(13));
|
used = g_list_append(used, GINT_TO_POINTER(13));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(14));
|
used = g_list_append(used, GINT_TO_POINTER(14));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(15));
|
used = g_list_append(used, GINT_TO_POINTER(15));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(16));
|
used = g_list_append(used, GINT_TO_POINTER(16));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(17));
|
used = g_list_append(used, GINT_TO_POINTER(17));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(18));
|
used = g_list_append(used, GINT_TO_POINTER(18));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(19));
|
used = g_list_append(used, GINT_TO_POINTER(19));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(20));
|
used = g_list_append(used, GINT_TO_POINTER(20));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(21));
|
used = g_list_append(used, GINT_TO_POINTER(21));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(22));
|
used = g_list_append(used, GINT_TO_POINTER(22));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(23));
|
used = g_list_append(used, GINT_TO_POINTER(23));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(51));
|
used = g_list_append(used, GINT_TO_POINTER(51));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(52));
|
used = g_list_append(used, GINT_TO_POINTER(52));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(53));
|
used = g_list_append(used, GINT_TO_POINTER(53));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(89));
|
used = g_list_append(used, GINT_TO_POINTER(89));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(90));
|
used = g_list_append(used, GINT_TO_POINTER(90));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(100));
|
used = g_list_append(used, GINT_TO_POINTER(100));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(101));
|
used = g_list_append(used, GINT_TO_POINTER(101));
|
||||||
used = g_slist_append(used, GINT_TO_POINTER(102));
|
used = g_list_append(used, GINT_TO_POINTER(102));
|
||||||
|
|
||||||
int result = get_next_available_win_num(used);
|
int result = get_next_available_win_num(used);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user