diff options
author | James Booth <boothj5@gmail.com> | 2015-11-15 22:17:36 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-11-15 22:17:36 +0000 |
commit | 98a395e933672320c773a6653f79106373d8b1e3 (patch) | |
tree | 1bbd9a5b8ea81649fbdad03aed0fa7d7d7cba279 | |
parent | badbc3003f1a6e2d6eecb166a36fef8bc66f9b17 (diff) | |
download | profani-tty-98a395e933672320c773a6653f79106373d8b1e3.tar.gz |
Show presence when resource hidden
-rw-r--r-- | src/ui/console.c | 10 | ||||
-rw-r--r-- | src/ui/rosterwin.c | 88 |
2 files changed, 67 insertions, 31 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index 01f05bca..8825cf69 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1207,6 +1207,16 @@ cons_roster_setting(void) else cons_show("Roster resource (/roster) : hide"); + if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) + cons_show("Roster presence (/roster) : show"); + else + cons_show("Roster presence (/roster) : hide"); + + if (prefs_get_boolean(PREF_ROSTER_STATUS)) + cons_show("Roster status (/roster) : show"); + else + cons_show("Roster status (/roster) : hide"); + if (prefs_get_boolean(PREF_ROSTER_EMPTY)) cons_show("Roster empty (/roster) : show"); else diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index 6201394d..e3cff25e 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -62,45 +62,71 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) { GList *resources = p_contact_get_available_resources(contact); - GList *curr_resource = resources; - while (curr_resource) { - Resource *resource = curr_resource->data; - const char *resource_presence = string_from_resource_presence(resource->presence); - theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence); + if (resources) { + GList *curr_resource = resources; + while (curr_resource) { + Resource *resource = curr_resource->data; + const char *resource_presence = string_from_resource_presence(resource->presence); + theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence); - wattron(layout->subwin, theme_attrs(resource_presence_colour)); - GString *msg = g_string_new(" "); - g_string_append(msg, resource->name); - win_printline_nowrap(layout->subwin, msg->str); - g_string_free(msg, TRUE); - wattroff(layout->subwin, theme_attrs(resource_presence_colour)); - - if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) { - gboolean by_presence = g_strcmp0(by, "presence") == 0; - gboolean has_status = resource->status != NULL; - gboolean show_status = prefs_get_boolean(PREF_ROSTER_STATUS); - if (!by_presence || (has_status && show_status)) { - wattron(layout->subwin, theme_attrs(resource_presence_colour)); - GString *msg = g_string_new(" "); - if (!by_presence) { - g_string_append(msg, resource_presence); - } - if (has_status && show_status) { + wattron(layout->subwin, theme_attrs(resource_presence_colour)); + GString *msg = g_string_new(" "); + g_string_append(msg, resource->name); + win_printline_nowrap(layout->subwin, msg->str); + g_string_free(msg, TRUE); + wattroff(layout->subwin, theme_attrs(resource_presence_colour)); + + if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) { + gboolean by_presence = g_strcmp0(by, "presence") == 0; + gboolean has_status = resource->status != NULL; + gboolean show_status = prefs_get_boolean(PREF_ROSTER_STATUS); + if (!by_presence || (has_status && show_status)) { + wattron(layout->subwin, theme_attrs(resource_presence_colour)); + GString *msg = g_string_new(" "); if (!by_presence) { - g_string_append(msg, ", \""); - } else { + g_string_append(msg, resource_presence); + } + if (has_status && show_status) { + if (!by_presence) { + g_string_append(msg, ", \""); + } else { + g_string_append(msg, "\""); + } + g_string_append(msg, resource->status); g_string_append(msg, "\""); } - g_string_append(msg, resource->status); + win_printline_nowrap(layout->subwin, msg->str); + g_string_free(msg, TRUE); + wattroff(layout->subwin, theme_attrs(resource_presence_colour)); + } + } + + curr_resource = g_list_next(curr_resource); + } + } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) { + gboolean by_presence = g_strcmp0(by, "presence") == 0; + gboolean has_status = p_contact_status(contact) != NULL; + gboolean show_status = prefs_get_boolean(PREF_ROSTER_STATUS); + if (!by_presence || (has_status && show_status)) { + wattron(layout->subwin, theme_attrs(presence_colour)); + GString *msg = g_string_new(" "); + if (!by_presence) { + g_string_append(msg, presence); + } + if (has_status && show_status) { + if (!by_presence) { + g_string_append(msg, ", \""); + } else { g_string_append(msg, "\""); } - win_printline_nowrap(layout->subwin, msg->str); - g_string_free(msg, TRUE); - wattroff(layout->subwin, theme_attrs(resource_presence_colour)); + const char *status = p_contact_status(contact); + g_string_append(msg, status); + g_string_append(msg, "\""); } + win_printline_nowrap(layout->subwin, msg->str); + g_string_free(msg, TRUE); + wattroff(layout->subwin, theme_attrs(presence_colour)); } - - curr_resource = g_list_next(curr_resource); } g_list_free(resources); } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) { |