mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05: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_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.");
|
||||
|
@ -403,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) {
|
||||
@ -417,7 +425,6 @@ cons_show_wins(void)
|
||||
}
|
||||
g_slist_free_full(window_strings, free);
|
||||
|
||||
cons_show("");
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ 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);
|
||||
|
@ -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,21 +661,23 @@ wins_create_summary(void)
|
||||
|
||||
while (curr) {
|
||||
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);
|
||||
char *winstring = win_get_string(window);
|
||||
if (!winstring) {
|
||||
int ui_index = GPOINTER_TO_INT(curr->data);
|
||||
char *winstring = win_get_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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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