mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-01 19:24:15 -04:00
Added /wins unread
This commit is contained in:
parent
d9435d3b65
commit
0920b65ddf
@ -799,6 +799,8 @@ static struct cmd_t command_defs[] =
|
|||||||
CMD_TAGS(
|
CMD_TAGS(
|
||||||
CMD_TAG_UI)
|
CMD_TAG_UI)
|
||||||
CMD_SYN(
|
CMD_SYN(
|
||||||
|
"/wins",
|
||||||
|
"/wins unread",
|
||||||
"/wins tidy",
|
"/wins tidy",
|
||||||
"/wins autotidy on|off",
|
"/wins autotidy on|off",
|
||||||
"/wins prune",
|
"/wins prune",
|
||||||
@ -807,6 +809,7 @@ static struct cmd_t command_defs[] =
|
|||||||
"Manage windows. "
|
"Manage windows. "
|
||||||
"Passing no argument will list all currently active windows and information about their usage.")
|
"Passing no argument will list all currently active windows and information about their usage.")
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
|
{ "unread", "List windows with unread messages." },
|
||||||
{ "tidy", "Move windows so there are no gaps." },
|
{ "tidy", "Move windows so there are no gaps." },
|
||||||
{ "autotidy on|off", "Automatically remove gaps when closing windows." },
|
{ "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." },
|
{ "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");
|
autocomplete_add(close_ac, "all");
|
||||||
|
|
||||||
wins_ac = autocomplete_new();
|
wins_ac = autocomplete_new();
|
||||||
|
autocomplete_add(wins_ac, "unread");
|
||||||
autocomplete_add(wins_ac, "prune");
|
autocomplete_add(wins_ac, "prune");
|
||||||
autocomplete_add(wins_ac, "tidy");
|
autocomplete_add(wins_ac, "tidy");
|
||||||
autocomplete_add(wins_ac, "autotidy");
|
autocomplete_add(wins_ac, "autotidy");
|
||||||
|
@ -1013,7 +1013,9 @@ gboolean
|
|||||||
cmd_wins(ProfWin *window, const char *const command, gchar **args)
|
cmd_wins(ProfWin *window, const char *const command, gchar **args)
|
||||||
{
|
{
|
||||||
if (args[0] == NULL) {
|
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) {
|
} else if (strcmp(args[0], "tidy") == 0) {
|
||||||
if (wins_tidy()) {
|
if (wins_tidy()) {
|
||||||
cons_show("Windows tidied.");
|
cons_show("Windows tidied.");
|
||||||
|
@ -403,12 +403,20 @@ cons_show_login_success(ProfAccount *account, int secured)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_wins(void)
|
cons_show_wins(gboolean unread)
|
||||||
{
|
{
|
||||||
ProfWin *console = wins_get_console();
|
ProfWin *console = wins_get_console();
|
||||||
cons_show("");
|
cons_show("");
|
||||||
cons_show("Active windows:");
|
GSList *window_strings = wins_create_summary(unread);
|
||||||
GSList *window_strings = wins_create_summary();
|
|
||||||
|
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;
|
GSList *curr = window_strings;
|
||||||
while (curr) {
|
while (curr) {
|
||||||
@ -417,7 +425,6 @@ cons_show_wins(void)
|
|||||||
}
|
}
|
||||||
g_slist_free_full(window_strings, free);
|
g_slist_free_full(window_strings, free);
|
||||||
|
|
||||||
cons_show("");
|
|
||||||
cons_alert();
|
cons_alert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ void cons_show_error(const char *const cmd, ...);
|
|||||||
void cons_show_contacts(GSList *list);
|
void cons_show_contacts(GSList *list);
|
||||||
void cons_show_roster(GSList *list);
|
void cons_show_roster(GSList *list);
|
||||||
void cons_show_roster_group(const char *const group, 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);
|
char* cons_get_string(ProfConsoleWin *conswin);
|
||||||
void cons_show_status(const char *const barejid);
|
void cons_show_status(const char *const barejid);
|
||||||
void cons_show_info(PContact pcontact);
|
void cons_show_info(PContact pcontact);
|
||||||
|
@ -647,8 +647,12 @@ wins_tidy(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
wins_create_summary(void)
|
wins_create_summary(gboolean unread)
|
||||||
{
|
{
|
||||||
|
if (unread && wins_get_total_unread() == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
|
|
||||||
GList *keys = g_hash_table_get_keys(windows);
|
GList *keys = g_hash_table_get_keys(windows);
|
||||||
@ -657,21 +661,23 @@ wins_create_summary(void)
|
|||||||
|
|
||||||
while (curr) {
|
while (curr) {
|
||||||
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
ProfWin *window = g_hash_table_lookup(windows, curr->data);
|
||||||
GString *line = g_string_new("");
|
if (!unread || (unread && win_unread(window) > 0)) {
|
||||||
|
GString *line = g_string_new("");
|
||||||
|
|
||||||
int ui_index = GPOINTER_TO_INT(curr->data);
|
int ui_index = GPOINTER_TO_INT(curr->data);
|
||||||
char *winstring = win_get_string(window);
|
char *winstring = win_get_string(window);
|
||||||
if (!winstring) {
|
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);
|
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);
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ GSList* wins_get_chat_recipients(void);
|
|||||||
GSList* wins_get_prune_wins(void);
|
GSList* wins_get_prune_wins(void);
|
||||||
void wins_lost_connection(void);
|
void wins_lost_connection(void);
|
||||||
gboolean wins_tidy(void);
|
gboolean wins_tidy(void);
|
||||||
GSList* wins_create_summary(void);
|
GSList* wins_create_summary(gboolean unread);
|
||||||
void wins_destroy(void);
|
void wins_destroy(void);
|
||||||
GList* wins_get_nums(void);
|
GList* wins_get_nums(void);
|
||||||
gboolean wins_swap(int source_win, int target_win);
|
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_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_status(const char * const barejid) {}
|
||||||
void cons_show_info(PContact pcontact) {}
|
void cons_show_info(PContact pcontact) {}
|
||||||
void cons_show_caps(const char * const fulljid, resource_presence_t presence) {}
|
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_println(ProfWin *window, int pad, const char * const message) {}
|
||||||
void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) {}
|
void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) {}
|
||||||
void win_clear(ProfWin *window) {}
|
void win_clear(ProfWin *window) {}
|
||||||
|
char* win_get_string(ProfWin *window)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// desktop notifier actions
|
// desktop notifier actions
|
||||||
void notifier_uninit(void) {}
|
void notifier_uninit(void) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user