mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into osx-functional
This commit is contained in:
commit
db184a398d
@ -799,6 +799,8 @@ static struct cmd_t command_defs[] =
|
||||
CMD_TAGS(
|
||||
CMD_TAG_UI)
|
||||
CMD_SYN(
|
||||
"/wins",
|
||||
"/wins unread",
|
||||
"/wins tidy",
|
||||
"/wins autotidy on|off",
|
||||
"/wins prune",
|
||||
@ -807,6 +809,7 @@ static struct cmd_t command_defs[] =
|
||||
"Manage windows. "
|
||||
"Passing no argument will list all currently active windows and information about their usage.")
|
||||
CMD_ARGS(
|
||||
{ "unread", "List windows with unread messages." },
|
||||
{ "tidy", "Move windows so there are no gaps." },
|
||||
{ "autotidy on|off", "Automatically remove gaps when closing windows." },
|
||||
{ "prune", "Close all windows with no unread messages, and then tidy so there are no gaps." },
|
||||
@ -2079,6 +2082,7 @@ cmd_init(void)
|
||||
autocomplete_add(close_ac, "all");
|
||||
|
||||
wins_ac = autocomplete_new();
|
||||
autocomplete_add(wins_ac, "unread");
|
||||
autocomplete_add(wins_ac, "prune");
|
||||
autocomplete_add(wins_ac, "tidy");
|
||||
autocomplete_add(wins_ac, "autotidy");
|
||||
|
@ -1013,7 +1013,9 @@ gboolean
|
||||
cmd_wins(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
if (args[0] == NULL) {
|
||||
cons_show_wins();
|
||||
cons_show_wins(FALSE);
|
||||
} else if (strcmp(args[0], "unread") == 0) {
|
||||
cons_show_wins(TRUE);
|
||||
} else if (strcmp(args[0], "tidy") == 0) {
|
||||
if (wins_tidy()) {
|
||||
cons_show("Windows tidied.");
|
||||
|
@ -355,6 +355,32 @@ chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status)
|
||||
free(display_str);
|
||||
}
|
||||
|
||||
char*
|
||||
chatwin_get_string(ProfChatWin *chatwin)
|
||||
{
|
||||
assert(chatwin != NULL);
|
||||
|
||||
GString *res = g_string_new("Chat ");
|
||||
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact == NULL) {
|
||||
g_string_append(res, chatwin->barejid);
|
||||
} else {
|
||||
const char *display_name = p_contact_name_or_jid(contact);
|
||||
g_string_append(res, display_name);
|
||||
g_string_append_printf(res, " - %s", p_contact_presence(contact));
|
||||
}
|
||||
|
||||
if (chatwin->unread > 0) {
|
||||
g_string_append_printf(res, ", %d unread", chatwin->unread);
|
||||
}
|
||||
|
||||
char *resstr = res->str;
|
||||
g_string_free(res, FALSE);
|
||||
|
||||
return resstr;
|
||||
}
|
||||
|
||||
static void
|
||||
_chatwin_history(ProfChatWin *chatwin, const char *const contact)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_NCURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
@ -402,12 +403,20 @@ cons_show_login_success(ProfAccount *account, int secured)
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_wins(void)
|
||||
cons_show_wins(gboolean unread)
|
||||
{
|
||||
ProfWin *console = wins_get_console();
|
||||
cons_show("");
|
||||
cons_show("Active windows:");
|
||||
GSList *window_strings = wins_create_summary();
|
||||
GSList *window_strings = wins_create_summary(unread);
|
||||
|
||||
if (unread && window_strings == NULL) {
|
||||
cons_show("No windows with unread messages.");
|
||||
return;
|
||||
} else if (unread) {
|
||||
cons_show("Unread:");
|
||||
} else {
|
||||
cons_show("Active windows:");
|
||||
}
|
||||
|
||||
GSList *curr = window_strings;
|
||||
while (curr) {
|
||||
@ -416,7 +425,6 @@ cons_show_wins(void)
|
||||
}
|
||||
g_slist_free_full(window_strings, free);
|
||||
|
||||
cons_show("");
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1901,6 +1909,14 @@ cons_alert(void)
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
cons_get_string(ProfConsoleWin *conswin)
|
||||
{
|
||||
assert(conswin != NULL);
|
||||
|
||||
return strdup("Console");
|
||||
}
|
||||
|
||||
void
|
||||
cons_theme_colours(void)
|
||||
{
|
||||
|
@ -328,3 +328,20 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
mucconfwin_get_string(ProfMucConfWin *confwin)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
GString *res = g_string_new("");
|
||||
|
||||
char *title = win_get_title((ProfWin*)confwin);
|
||||
g_string_append(res, title);
|
||||
free(title);
|
||||
|
||||
char *resstr = res->str;
|
||||
g_string_free(res, FALSE);
|
||||
|
||||
return resstr;
|
||||
}
|
||||
|
@ -773,3 +773,20 @@ mucwin_hide_occupants(ProfMucWin *mucwin)
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
mucwin_get_string(ProfMucWin *mucwin)
|
||||
{
|
||||
assert(mucwin != NULL);
|
||||
|
||||
GString *res = g_string_new("Room ");
|
||||
g_string_append(res, mucwin->roomjid);
|
||||
|
||||
if (mucwin->unread > 0) {
|
||||
g_string_append_printf(res, ", %d unread", mucwin->unread);
|
||||
}
|
||||
|
||||
char *resstr = res->str;
|
||||
g_string_free(res, FALSE);
|
||||
|
||||
return resstr;
|
||||
}
|
||||
|
@ -107,3 +107,21 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message)
|
||||
|
||||
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message);
|
||||
}
|
||||
|
||||
char*
|
||||
privwin_get_string(ProfPrivateWin *privwin)
|
||||
{
|
||||
assert(privwin != NULL);
|
||||
|
||||
GString *res = g_string_new("Private ");
|
||||
g_string_append(res, privwin->fulljid);
|
||||
|
||||
if (privwin->unread > 0) {
|
||||
g_string_append_printf(res, ", %d unread", privwin->unread);
|
||||
}
|
||||
|
||||
char *resstr = res->str;
|
||||
g_string_free(res, FALSE);
|
||||
|
||||
return resstr;
|
||||
}
|
||||
|
10
src/ui/ui.h
10
src/ui/ui.h
@ -134,6 +134,8 @@ void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char
|
||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message);
|
||||
void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity);
|
||||
void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status);
|
||||
char* chatwin_get_string(ProfChatWin *chatwin);
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
void chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted);
|
||||
void chatwin_otr_unsecured(ProfChatWin *chatwin);
|
||||
@ -187,10 +189,12 @@ void mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const cha
|
||||
void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error);
|
||||
void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks);
|
||||
void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error);
|
||||
char* mucwin_get_string(ProfMucWin *mucwin);
|
||||
|
||||
// MUC private chat window
|
||||
void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp);
|
||||
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message);
|
||||
char* privwin_get_string(ProfPrivateWin *privwin);
|
||||
|
||||
// MUC room config window
|
||||
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
|
||||
@ -198,9 +202,11 @@ void mucconfwin_show_form(ProfMucConfWin *confwin);
|
||||
void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag);
|
||||
void mucconfwin_form_help(ProfMucConfWin *confwin);
|
||||
void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag);
|
||||
char* mucconfwin_get_string(ProfMucConfWin *confwin);
|
||||
|
||||
// xml console
|
||||
void xmlwin_show(ProfXMLWin *xmlwin, const char *const msg);
|
||||
char* xmlwin_get_string(ProfXMLWin *xmlwin);
|
||||
|
||||
// Input window
|
||||
char* inp_readline(void);
|
||||
@ -231,7 +237,8 @@ void cons_show_error(const char *const cmd, ...);
|
||||
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(void);
|
||||
void cons_show_wins(gboolean unread);
|
||||
char* cons_get_string(ProfConsoleWin *conswin);
|
||||
void cons_show_status(const char *const barejid);
|
||||
void cons_show_info(PContact pcontact);
|
||||
void cons_show_caps(const char *const fulljid, resource_presence_t presence);
|
||||
@ -336,6 +343,7 @@ void win_show_info(ProfWin *window, PContact contact);
|
||||
void win_println(ProfWin *window, int pad, const char *const message);
|
||||
void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...);
|
||||
void win_clear(ProfWin *window);
|
||||
char* win_get_string(ProfWin *window);
|
||||
|
||||
// desktop notifications
|
||||
void notifier_initialise(void);
|
||||
|
@ -285,6 +285,47 @@ win_get_title(ProfWin *window)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char*
|
||||
win_get_string(ProfWin *window)
|
||||
{
|
||||
assert(window != NULL);
|
||||
|
||||
switch (window->type) {
|
||||
case WIN_CONSOLE:
|
||||
{
|
||||
ProfConsoleWin *conswin = (ProfConsoleWin*)window;
|
||||
return cons_get_string(conswin);
|
||||
}
|
||||
case WIN_CHAT:
|
||||
{
|
||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||
return chatwin_get_string(chatwin);
|
||||
}
|
||||
case WIN_MUC:
|
||||
{
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
return mucwin_get_string(mucwin);
|
||||
}
|
||||
case WIN_MUC_CONFIG:
|
||||
{
|
||||
ProfMucConfWin *mucconfwin = (ProfMucConfWin*)window;
|
||||
return mucconfwin_get_string(mucconfwin);
|
||||
}
|
||||
case WIN_PRIVATE:
|
||||
{
|
||||
ProfPrivateWin *privwin = (ProfPrivateWin*)window;
|
||||
return privwin_get_string(privwin);
|
||||
}
|
||||
case WIN_XML:
|
||||
{
|
||||
ProfXMLWin *xmlwin = (ProfXMLWin*)window;
|
||||
return xmlwin_get_string(xmlwin);
|
||||
}
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_hide_subwin(ProfWin *window)
|
||||
{
|
||||
|
@ -53,3 +53,11 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg)
|
||||
win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", "");
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
xmlwin_get_string(ProfXMLWin *xmlwin)
|
||||
{
|
||||
assert(xmlwin != NULL);
|
||||
|
||||
return strdup("XML console");
|
||||
}
|
||||
|
@ -647,8 +647,12 @@ wins_tidy(void)
|
||||
}
|
||||
|
||||
GSList*
|
||||
wins_create_summary(void)
|
||||
wins_create_summary(gboolean unread)
|
||||
{
|
||||
if (unread && wins_get_total_unread() == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GSList *result = NULL;
|
||||
|
||||
GList *keys = g_hash_table_get_keys(windows);
|
||||
@ -657,106 +661,28 @@ wins_create_summary(void)
|
||||
|
||||
while (curr) {
|
||||
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
||||
int ui_index = GPOINTER_TO_INT(curr->data);
|
||||
if (!unread || (unread && win_unread(window) > 0)) {
|
||||
GString *line = g_string_new("");
|
||||
|
||||
GString *chat_string;
|
||||
GString *priv_string;
|
||||
GString *muc_string;
|
||||
GString *muc_config_string;
|
||||
GString *xml_string;
|
||||
int ui_index = GPOINTER_TO_INT(curr->data);
|
||||
char *winstring = win_get_string(window);
|
||||
if (!winstring) {
|
||||
g_string_free(line, TRUE);
|
||||
continue;
|
||||
}
|
||||
|
||||
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_append_printf(line, "%d: %s", ui_index, winstring);
|
||||
free(winstring);
|
||||
|
||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact == NULL) {
|
||||
g_string_printf(chat_string, "%d: Chat %s", ui_index, chatwin->barejid);
|
||||
} else {
|
||||
const char *display_name = p_contact_name_or_jid(contact);
|
||||
g_string_printf(chat_string, "%d: Chat %s", ui_index, display_name);
|
||||
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 (chatwin->unread > 0) {
|
||||
GString *chat_unread = g_string_new("");
|
||||
g_string_printf(chat_unread, ", %d unread", chatwin->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("");
|
||||
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
||||
g_string_printf(priv_string, "%d: Private %s", ui_index, privatewin->fulljid);
|
||||
|
||||
if (privatewin->unread > 0) {
|
||||
GString *priv_unread = g_string_new("");
|
||||
g_string_printf(priv_unread, ", %d unread", privatewin->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("");
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
g_string_printf(muc_string, "%d: Room %s", ui_index, mucwin->roomjid);
|
||||
|
||||
if (mucwin->unread > 0) {
|
||||
GString *muc_unread = g_string_new("");
|
||||
g_string_printf(muc_unread, ", %d unread", mucwin->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_MUC_CONFIG:
|
||||
muc_config_string = g_string_new("");
|
||||
char *title = win_get_title(window);
|
||||
g_string_printf(muc_config_string, "%d: %s", ui_index, title);
|
||||
result = g_slist_append(result, strdup(muc_config_string->str));
|
||||
g_string_free(muc_config_string, TRUE);
|
||||
free(title);
|
||||
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
default:
|
||||
break;
|
||||
result = g_slist_append(result, strdup(line->str));
|
||||
g_string_free(line, TRUE);
|
||||
}
|
||||
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
g_list_free(keys);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ GSList* wins_get_chat_recipients(void);
|
||||
GSList* wins_get_prune_wins(void);
|
||||
void wins_lost_connection(void);
|
||||
gboolean wins_tidy(void);
|
||||
GSList* wins_create_summary(void);
|
||||
GSList* wins_create_summary(gboolean unread);
|
||||
void wins_destroy(void);
|
||||
GList* wins_get_nums(void);
|
||||
gboolean wins_swap(int source_win, int target_win);
|
||||
|
@ -358,7 +358,7 @@ cons_bad_cmd_usage(const char * const cmd)
|
||||
}
|
||||
|
||||
void cons_show_roster_group(const char * const group, GSList * list) {}
|
||||
void cons_show_wins(void) {}
|
||||
void cons_show_wins(gboolean unread) {}
|
||||
void cons_show_status(const char * const barejid) {}
|
||||
void cons_show_info(PContact pcontact) {}
|
||||
void cons_show_caps(const char * const fulljid, resource_presence_t presence) {}
|
||||
@ -513,6 +513,10 @@ void win_show_info(ProfWin *window, PContact contact) {}
|
||||
void win_println(ProfWin *window, int pad, const char * const message) {}
|
||||
void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) {}
|
||||
void win_clear(ProfWin *window) {}
|
||||
char* win_get_string(ProfWin *window)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// desktop notifier actions
|
||||
void notifier_uninit(void) {}
|
||||
|
Loading…
Reference in New Issue
Block a user