mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Attention flag for groupchats
Attention flag for groupchat and display the windows via "/wins attention"
This commit is contained in:
parent
3520645366
commit
6dd11f0fff
@ -1301,7 +1301,7 @@ cmd_wins_unread(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_wins_attention(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
cons_show_wins(TRUE);
|
||||
cons_show_wins_attention();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -506,6 +506,26 @@ cons_show_wins(gboolean unread)
|
||||
cons_alert(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_wins_attention() {
|
||||
ProfWin* console = wins_get_console();
|
||||
cons_show("");
|
||||
GSList* window_strings = wins_create_summary_attention();
|
||||
|
||||
GSList* curr = window_strings;
|
||||
while (curr) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) {
|
||||
win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data);
|
||||
} else {
|
||||
win_println(console, THEME_DEFAULT, "-", "%s", curr->data);
|
||||
}
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
g_slist_free_full(window_strings, free);
|
||||
|
||||
cons_alert(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_room_invites(GList* invites)
|
||||
{
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define _XOPEN_SOURCE_EXTENDED
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/select.h>
|
||||
#include <stdlib.h>
|
||||
@ -814,8 +815,15 @@ static int
|
||||
_inp_rl_win_attention_handler(int count, int key) {
|
||||
ProfWin* current = wins_get_current();
|
||||
if ( current ) {
|
||||
ProfChatWin* chatwin = (ProfChatWin*)current;
|
||||
chatwin->has_attention = !chatwin->has_attention;
|
||||
if (current->type == WIN_CHAT) {
|
||||
ProfChatWin* chatwin = (ProfChatWin*)current;
|
||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||
chatwin->has_attention = !chatwin->has_attention;
|
||||
} else if (current->type == WIN_MUC) {
|
||||
ProfMucWin* mucwin = (ProfMucWin*)current;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
mucwin->has_attention = !mucwin->has_attention;
|
||||
}
|
||||
win_redraw(current);
|
||||
}
|
||||
return 0;
|
||||
|
@ -256,6 +256,7 @@ void cons_show_contacts(GSList* list);
|
||||
void cons_show_roster(GSList* list);
|
||||
void cons_show_roster_group(const char* const group, GSList* list);
|
||||
void cons_show_wins(gboolean unread);
|
||||
void cons_show_wins_attention();
|
||||
char* cons_get_string(ProfConsoleWin* conswin);
|
||||
void cons_show_status(const char* const barejid);
|
||||
void cons_show_info(PContact pcontact);
|
||||
|
@ -197,6 +197,7 @@ typedef struct prof_muc_win_t
|
||||
// For LMC
|
||||
char* last_message;
|
||||
char* last_msg_id;
|
||||
gboolean has_attention;
|
||||
} ProfMucWin;
|
||||
|
||||
typedef struct prof_conf_win_t ProfConfWin;
|
||||
|
@ -213,6 +213,7 @@ win_create_muc(const char* const roomjid)
|
||||
new_win->is_omemo = FALSE;
|
||||
new_win->last_message = NULL;
|
||||
new_win->last_msg_id = NULL;
|
||||
new_win->has_attention = FALSE;
|
||||
|
||||
new_win->memcheck = PROFMUCWIN_MEMCHECK;
|
||||
|
||||
|
@ -1102,6 +1102,51 @@ wins_create_summary(gboolean unread)
|
||||
return result;
|
||||
}
|
||||
|
||||
GSList*
|
||||
wins_create_summary_attention()
|
||||
{
|
||||
GSList* result = NULL;
|
||||
|
||||
GList* keys = g_hash_table_get_keys(windows);
|
||||
keys = g_list_sort(keys, _wins_cmp_num);
|
||||
GList* curr = keys;
|
||||
|
||||
while (curr) {
|
||||
ProfWin* window = g_hash_table_lookup(windows, curr->data);
|
||||
gboolean has_attention = FALSE;
|
||||
if (window->type == WIN_CHAT) {
|
||||
ProfChatWin* chatwin = (ProfChatWin*)window;
|
||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||
has_attention = chatwin->has_attention;
|
||||
} else if (window->type == WIN_MUC) {
|
||||
ProfMucWin* mucwin = (ProfMucWin*)window;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
has_attention = mucwin->has_attention;
|
||||
}
|
||||
if ( has_attention) {
|
||||
GString* line = g_string_new("");
|
||||
|
||||
int ui_index = GPOINTER_TO_INT(curr->data);
|
||||
char* winstring = win_to_string(window);
|
||||
if (!winstring) {
|
||||
g_string_free(line, TRUE);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_string_append_printf(line, "%d: %s", ui_index, winstring);
|
||||
free(winstring);
|
||||
|
||||
result = g_slist_append(result, strdup(line->str));
|
||||
g_string_free(line, TRUE);
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
g_list_free(keys);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char*
|
||||
win_autocomplete(const char* const search_str, gboolean previous, void* context)
|
||||
{
|
||||
|
@ -87,6 +87,7 @@ void wins_lost_connection(void);
|
||||
void wins_reestablished_connection(void);
|
||||
gboolean wins_tidy(void);
|
||||
GSList* wins_create_summary(gboolean unread);
|
||||
GSList* wins_create_summary_attention();
|
||||
void wins_destroy(void);
|
||||
GList* wins_get_nums(void);
|
||||
void wins_swap(int source_win, int target_win);
|
||||
|
Loading…
Reference in New Issue
Block a user