mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 14:06:21 +00:00
Moved unread to window subtypes
This commit is contained in:
@@ -369,7 +369,7 @@ _ui_incoming_msg(const char * const barejid, const char * const message, GTimeVa
|
|||||||
flash();
|
flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
window->unread++;
|
chatwin->unread++;
|
||||||
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
||||||
_win_show_history(num, barejid);
|
_win_show_history(num, barejid);
|
||||||
}
|
}
|
||||||
@@ -438,7 +438,7 @@ _ui_incoming_private_msg(const char * const fulljid, const char * const message,
|
|||||||
flash();
|
flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
window->unread++;
|
privatewin->unread++;
|
||||||
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
||||||
_win_show_history(num, fulljid);
|
_win_show_history(num, fulljid);
|
||||||
}
|
}
|
||||||
@@ -854,8 +854,6 @@ _ui_switch_win(const int i)
|
|||||||
|
|
||||||
wins_set_current_by_num(i);
|
wins_set_current_by_num(i);
|
||||||
|
|
||||||
new_current->unread = 0;
|
|
||||||
|
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
title_bar_console();
|
title_bar_console();
|
||||||
status_bar_current(1);
|
status_bar_current(1);
|
||||||
@@ -889,8 +887,6 @@ _ui_previous_win(void)
|
|||||||
int i = wins_get_num(new_current);
|
int i = wins_get_num(new_current);
|
||||||
wins_set_current_by_num(i);
|
wins_set_current_by_num(i);
|
||||||
|
|
||||||
new_current->unread = 0;
|
|
||||||
|
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
title_bar_console();
|
title_bar_console();
|
||||||
status_bar_current(1);
|
status_bar_current(1);
|
||||||
@@ -920,8 +916,6 @@ _ui_next_win(void)
|
|||||||
int i = wins_get_num(new_current);
|
int i = wins_get_num(new_current);
|
||||||
wins_set_current_by_num(i);
|
wins_set_current_by_num(i);
|
||||||
|
|
||||||
new_current->unread = 0;
|
|
||||||
|
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
title_bar_console();
|
title_bar_console();
|
||||||
status_bar_current(1);
|
status_bar_current(1);
|
||||||
@@ -1840,10 +1834,11 @@ static void
|
|||||||
_ui_room_message(const char * const roomjid, const char * const nick,
|
_ui_room_message(const char * const roomjid, const char * const nick,
|
||||||
const char * const message)
|
const char * const message)
|
||||||
{
|
{
|
||||||
ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
|
ProfMucWin *mucwin = wins_get_muc(roomjid);
|
||||||
if (window == NULL) {
|
if (mucwin == NULL) {
|
||||||
log_error("Room message received from %s, but no window open for %s", nick, roomjid);
|
log_error("Room message received from %s, but no window open for %s", nick, roomjid);
|
||||||
} else {
|
} else {
|
||||||
|
ProfWin *window = (ProfWin*) mucwin;
|
||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
char *my_nick = muc_nick(roomjid);
|
char *my_nick = muc_nick(roomjid);
|
||||||
|
|
||||||
@@ -1872,7 +1867,7 @@ _ui_room_message(const char * const roomjid, const char * const nick,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window->unread++;
|
mucwin->unread++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ui_index = num;
|
int ui_index = num;
|
||||||
@@ -2228,7 +2223,7 @@ _ui_win_unread(int index)
|
|||||||
{
|
{
|
||||||
ProfWin *window = wins_get_by_num(index);
|
ProfWin *window = wins_get_by_num(index);
|
||||||
if (window != NULL) {
|
if (window != NULL) {
|
||||||
return window->unread;
|
return win_unread(window);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ title_bar_set_presence(contact_presence_t presence)
|
|||||||
_title_bar_draw();
|
_title_bar_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove
|
|
||||||
void
|
void
|
||||||
title_bar_switch(void)
|
title_bar_switch(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ win_create_console(void)
|
|||||||
ProfConsoleWin *new_win = malloc(sizeof(ProfConsoleWin));
|
ProfConsoleWin *new_win = malloc(sizeof(ProfConsoleWin));
|
||||||
new_win->window.type = WIN_CONSOLE;
|
new_win->window.type = WIN_CONSOLE;
|
||||||
new_win->window.layout = _win_create_split_layout();
|
new_win->window.layout = _win_create_split_layout();
|
||||||
new_win->window.unread = 0;
|
|
||||||
|
|
||||||
return &new_win->window;
|
return &new_win->window;
|
||||||
}
|
}
|
||||||
@@ -131,13 +130,13 @@ win_create_chat(const char * const barejid)
|
|||||||
ProfChatWin *new_win = malloc(sizeof(ProfChatWin));
|
ProfChatWin *new_win = malloc(sizeof(ProfChatWin));
|
||||||
new_win->window.type = WIN_CHAT;
|
new_win->window.type = WIN_CHAT;
|
||||||
new_win->window.layout = _win_create_simple_layout();
|
new_win->window.layout = _win_create_simple_layout();
|
||||||
new_win->window.unread = 0;
|
|
||||||
|
|
||||||
new_win->barejid = strdup(barejid);
|
new_win->barejid = strdup(barejid);
|
||||||
new_win->resource = NULL;
|
new_win->resource = NULL;
|
||||||
new_win->is_otr = FALSE;
|
new_win->is_otr = FALSE;
|
||||||
new_win->is_trusted = FALSE;
|
new_win->is_trusted = FALSE;
|
||||||
new_win->history_shown = FALSE;
|
new_win->history_shown = FALSE;
|
||||||
|
new_win->unread = 0;
|
||||||
|
|
||||||
new_win->memcheck = PROFCHATWIN_MEMCHECK;
|
new_win->memcheck = PROFCHATWIN_MEMCHECK;
|
||||||
|
|
||||||
@@ -175,7 +174,7 @@ win_create_muc(const char * const roomjid)
|
|||||||
new_win->window.layout = (ProfLayout*)layout;
|
new_win->window.layout = (ProfLayout*)layout;
|
||||||
|
|
||||||
new_win->roomjid = strdup(roomjid);
|
new_win->roomjid = strdup(roomjid);
|
||||||
new_win->window.unread = 0;
|
new_win->unread = 0;
|
||||||
|
|
||||||
new_win->memcheck = PROFMUCWIN_MEMCHECK;
|
new_win->memcheck = PROFMUCWIN_MEMCHECK;
|
||||||
|
|
||||||
@@ -188,7 +187,6 @@ win_create_muc_config(const char * const roomjid, DataForm *form)
|
|||||||
ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin));
|
ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin));
|
||||||
new_win->window.type = WIN_MUC_CONFIG;
|
new_win->window.type = WIN_MUC_CONFIG;
|
||||||
new_win->window.layout = _win_create_simple_layout();
|
new_win->window.layout = _win_create_simple_layout();
|
||||||
new_win->window.unread = 0;
|
|
||||||
|
|
||||||
new_win->roomjid = strdup(roomjid);
|
new_win->roomjid = strdup(roomjid);
|
||||||
new_win->form = form;
|
new_win->form = form;
|
||||||
@@ -204,9 +202,9 @@ win_create_private(const char * const fulljid)
|
|||||||
ProfPrivateWin *new_win = malloc(sizeof(ProfPrivateWin));
|
ProfPrivateWin *new_win = malloc(sizeof(ProfPrivateWin));
|
||||||
new_win->window.type = WIN_PRIVATE;
|
new_win->window.type = WIN_PRIVATE;
|
||||||
new_win->window.layout = _win_create_simple_layout();
|
new_win->window.layout = _win_create_simple_layout();
|
||||||
new_win->window.unread = 0;
|
|
||||||
|
|
||||||
new_win->fulljid = strdup(fulljid);
|
new_win->fulljid = strdup(fulljid);
|
||||||
|
new_win->unread = 0;
|
||||||
|
|
||||||
new_win->memcheck = PROFPRIVATEWIN_MEMCHECK;
|
new_win->memcheck = PROFPRIVATEWIN_MEMCHECK;
|
||||||
|
|
||||||
@@ -219,7 +217,6 @@ win_create_xmlconsole(void)
|
|||||||
ProfXMLWin *new_win = malloc(sizeof(ProfXMLWin));
|
ProfXMLWin *new_win = malloc(sizeof(ProfXMLWin));
|
||||||
new_win->window.type = WIN_XML;
|
new_win->window.type = WIN_XML;
|
||||||
new_win->window.layout = _win_create_simple_layout();
|
new_win->window.layout = _win_create_simple_layout();
|
||||||
new_win->window.unread = 0;
|
|
||||||
|
|
||||||
new_win->memcheck = PROFXMLWIN_MEMCHECK;
|
new_win->memcheck = PROFXMLWIN_MEMCHECK;
|
||||||
|
|
||||||
@@ -957,6 +954,26 @@ win_has_modified_form(ProfWin *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
win_unread(ProfWin *window)
|
||||||
|
{
|
||||||
|
if (window->type == WIN_CHAT) {
|
||||||
|
ProfChatWin *chatwin = (ProfChatWin*) window;
|
||||||
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
|
return chatwin->unread;
|
||||||
|
} else if (window->type == WIN_MUC) {
|
||||||
|
ProfMucWin *mucwin = (ProfMucWin*) window;
|
||||||
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
|
return mucwin->unread;
|
||||||
|
} else if (window->type == WIN_PRIVATE) {
|
||||||
|
ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
|
||||||
|
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
||||||
|
return privatewin->unread;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
win_printline_nowrap(WINDOW *win, char *msg)
|
win_printline_nowrap(WINDOW *win, char *msg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ typedef enum {
|
|||||||
typedef struct prof_win_t {
|
typedef struct prof_win_t {
|
||||||
win_type_t type;
|
win_type_t type;
|
||||||
ProfLayout *layout;
|
ProfLayout *layout;
|
||||||
int unread;
|
|
||||||
} ProfWin;
|
} ProfWin;
|
||||||
|
|
||||||
typedef struct prof_console_win_t {
|
typedef struct prof_console_win_t {
|
||||||
@@ -109,6 +108,7 @@ typedef struct prof_console_win_t {
|
|||||||
typedef struct prof_chat_win_t {
|
typedef struct prof_chat_win_t {
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
char *barejid;
|
char *barejid;
|
||||||
|
int unread;
|
||||||
gboolean is_otr;
|
gboolean is_otr;
|
||||||
gboolean is_trusted;
|
gboolean is_trusted;
|
||||||
char *resource;
|
char *resource;
|
||||||
@@ -119,6 +119,7 @@ typedef struct prof_chat_win_t {
|
|||||||
typedef struct prof_muc_win_t {
|
typedef struct prof_muc_win_t {
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
char *roomjid;
|
char *roomjid;
|
||||||
|
int unread;
|
||||||
unsigned long memcheck;
|
unsigned long memcheck;
|
||||||
} ProfMucWin;
|
} ProfMucWin;
|
||||||
|
|
||||||
@@ -132,6 +133,7 @@ typedef struct prof_mucconf_win_t {
|
|||||||
typedef struct prof_private_win_t {
|
typedef struct prof_private_win_t {
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
char *fulljid;
|
char *fulljid;
|
||||||
|
int unread;
|
||||||
unsigned long memcheck;
|
unsigned long memcheck;
|
||||||
} ProfPrivateWin;
|
} ProfPrivateWin;
|
||||||
|
|
||||||
@@ -173,6 +175,7 @@ int win_roster_cols(void);
|
|||||||
int win_occpuants_cols(void);
|
int win_occpuants_cols(void);
|
||||||
void win_printline_nowrap(WINDOW *win, char *msg);
|
void win_printline_nowrap(WINDOW *win, char *msg);
|
||||||
|
|
||||||
|
int win_unread(ProfWin *window);
|
||||||
gboolean win_has_active_subwin(ProfWin *window);
|
gboolean win_has_active_subwin(ProfWin *window);
|
||||||
gboolean win_has_modified_form(ProfWin *window);
|
gboolean win_has_modified_form(ProfWin *window);
|
||||||
gboolean win_chat_history_shown(ProfWin *window);
|
gboolean win_chat_history_shown(ProfWin *window);
|
||||||
|
|||||||
@@ -250,8 +250,21 @@ wins_get_nums(void)
|
|||||||
void
|
void
|
||||||
wins_set_current_by_num(int i)
|
wins_set_current_by_num(int i)
|
||||||
{
|
{
|
||||||
if (g_hash_table_lookup(windows, GINT_TO_POINTER(i)) != NULL) {
|
ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(i));
|
||||||
|
if (window) {
|
||||||
current = i;
|
current = i;
|
||||||
|
if (window->type == WIN_CHAT) {
|
||||||
|
ProfChatWin *chatwin = (ProfChatWin*) window;
|
||||||
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
|
chatwin->unread = 0;
|
||||||
|
} else if (window->type == WIN_MUC) {
|
||||||
|
ProfMucWin *mucwin = (ProfMucWin*) window;
|
||||||
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
|
mucwin->unread = 0;
|
||||||
|
} else if (window->type == WIN_PRIVATE) {
|
||||||
|
ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
|
||||||
|
privatewin->unread = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +493,7 @@ wins_get_total_unread(void)
|
|||||||
|
|
||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
ProfWin *window = curr->data;
|
ProfWin *window = curr->data;
|
||||||
result += window->unread;
|
result += win_unread(window);
|
||||||
curr = g_list_next(curr);
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
g_list_free(values);
|
g_list_free(values);
|
||||||
@@ -628,7 +641,7 @@ wins_get_prune_wins(void)
|
|||||||
|
|
||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
ProfWin *window = curr->data;
|
ProfWin *window = curr->data;
|
||||||
if (window->unread == 0 &&
|
if (win_unread(window) == 0 &&
|
||||||
window->type != WIN_MUC &&
|
window->type != WIN_MUC &&
|
||||||
window->type != WIN_MUC_CONFIG &&
|
window->type != WIN_MUC_CONFIG &&
|
||||||
window->type != WIN_XML &&
|
window->type != WIN_XML &&
|
||||||
@@ -675,7 +688,7 @@ wins_swap(int source_win, int target_win)
|
|||||||
g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
|
g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
|
||||||
status_bar_inactive(source_win);
|
status_bar_inactive(source_win);
|
||||||
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
||||||
if (source->unread > 0) {
|
if (win_unread(source) > 0) {
|
||||||
status_bar_new(target_win);
|
status_bar_new(target_win);
|
||||||
} else {
|
} else {
|
||||||
status_bar_active(target_win);
|
status_bar_active(target_win);
|
||||||
@@ -691,12 +704,12 @@ wins_swap(int source_win, int target_win)
|
|||||||
g_hash_table_steal(windows, GINT_TO_POINTER(target_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(source_win), target);
|
||||||
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
||||||
if (source->unread > 0) {
|
if (win_unread(source) > 0) {
|
||||||
status_bar_new(target_win);
|
status_bar_new(target_win);
|
||||||
} else {
|
} else {
|
||||||
status_bar_active(target_win);
|
status_bar_active(target_win);
|
||||||
}
|
}
|
||||||
if (target->unread > 0) {
|
if (win_unread(target) > 0) {
|
||||||
status_bar_new(source_win);
|
status_bar_new(source_win);
|
||||||
} else {
|
} else {
|
||||||
status_bar_active(source_win);
|
status_bar_active(source_win);
|
||||||
@@ -742,14 +755,14 @@ wins_tidy(void)
|
|||||||
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
||||||
if (num == 10) {
|
if (num == 10) {
|
||||||
g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window);
|
g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window);
|
||||||
if (window->unread > 0) {
|
if (win_unread(window) > 0) {
|
||||||
status_bar_new(0);
|
status_bar_new(0);
|
||||||
} else {
|
} else {
|
||||||
status_bar_active(0);
|
status_bar_active(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g_hash_table_insert(new_windows, GINT_TO_POINTER(num), window);
|
g_hash_table_insert(new_windows, GINT_TO_POINTER(num), window);
|
||||||
if (window->unread > 0) {
|
if (win_unread(window) > 0) {
|
||||||
status_bar_new(num);
|
status_bar_new(num);
|
||||||
} else {
|
} else {
|
||||||
status_bar_active(num);
|
status_bar_active(num);
|
||||||
@@ -810,9 +823,9 @@ wins_create_summary(void)
|
|||||||
g_string_free(chat_presence, TRUE);
|
g_string_free(chat_presence, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->unread > 0) {
|
if (chatwin->unread > 0) {
|
||||||
GString *chat_unread = g_string_new("");
|
GString *chat_unread = g_string_new("");
|
||||||
g_string_printf(chat_unread, ", %d unread", window->unread);
|
g_string_printf(chat_unread, ", %d unread", chatwin->unread);
|
||||||
g_string_append(chat_string, chat_unread->str);
|
g_string_append(chat_string, chat_unread->str);
|
||||||
g_string_free(chat_unread, TRUE);
|
g_string_free(chat_unread, TRUE);
|
||||||
}
|
}
|
||||||
@@ -827,9 +840,9 @@ wins_create_summary(void)
|
|||||||
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
||||||
g_string_printf(priv_string, "%d: Private %s", ui_index, privatewin->fulljid);
|
g_string_printf(priv_string, "%d: Private %s", ui_index, privatewin->fulljid);
|
||||||
|
|
||||||
if (window->unread > 0) {
|
if (privatewin->unread > 0) {
|
||||||
GString *priv_unread = g_string_new("");
|
GString *priv_unread = g_string_new("");
|
||||||
g_string_printf(priv_unread, ", %d unread", window->unread);
|
g_string_printf(priv_unread, ", %d unread", privatewin->unread);
|
||||||
g_string_append(priv_string, priv_unread->str);
|
g_string_append(priv_string, priv_unread->str);
|
||||||
g_string_free(priv_unread, TRUE);
|
g_string_free(priv_unread, TRUE);
|
||||||
}
|
}
|
||||||
@@ -844,9 +857,9 @@ wins_create_summary(void)
|
|||||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||||
g_string_printf(muc_string, "%d: Room %s", ui_index, mucwin->roomjid);
|
g_string_printf(muc_string, "%d: Room %s", ui_index, mucwin->roomjid);
|
||||||
|
|
||||||
if (window->unread > 0) {
|
if (mucwin->unread > 0) {
|
||||||
GString *muc_unread = g_string_new("");
|
GString *muc_unread = g_string_new("");
|
||||||
g_string_printf(muc_unread, ", %d unread", window->unread);
|
g_string_printf(muc_unread, ", %d unread", mucwin->unread);
|
||||||
g_string_append(muc_string, muc_unread->str);
|
g_string_append(muc_string, muc_unread->str);
|
||||||
g_string_free(muc_unread, TRUE);
|
g_string_free(muc_unread, TRUE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user