diff options
author | James Booth <boothj5@gmail.com> | 2016-01-31 20:17:20 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-01-31 20:17:20 +0000 |
commit | a00095c8a98b04c5c625d07f3ea4dfeb0e0f64c6 (patch) | |
tree | 7639d43dbf8b50358dd59bb87c16edc117c21076 /src | |
parent | dd250c679960b60a5cee86c4cafd6c9855401117 (diff) | |
download | profani-tty-a00095c8a98b04c5c625d07f3ea4dfeb0e0f64c6.tar.gz |
Added roster.rooms.private.char setting
Diffstat (limited to 'src')
-rw-r--r-- | src/command/command.c | 84 | ||||
-rw-r--r-- | src/command/commands.c | 18 | ||||
-rw-r--r-- | src/config/preferences.c | 32 | ||||
-rw-r--r-- | src/config/preferences.h | 3 | ||||
-rw-r--r-- | src/config/theme.c | 10 | ||||
-rw-r--r-- | src/ui/console.c | 6 | ||||
-rw-r--r-- | src/ui/rosterwin.c | 2 |
7 files changed, 115 insertions, 40 deletions
diff --git a/src/command/command.c b/src/command/command.c index b6935daa..5f2f64fb 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -286,6 +286,7 @@ static struct cmd_t command_defs[] = "/roster order name|presence", "/roster unread before|after|off", "/roster room char <char>|none", + "/roster room private char <char>|none", "/roster room position first|last", "/roster room order name|unread", "/roster room unread before|after|off", @@ -309,54 +310,54 @@ static struct cmd_t command_defs[] = "Manage your roster, and roster display settings. " "Passing no arguments lists all contacts in your roster.") CMD_ARGS( - { "online", "Show all online contacts in your roster." }, + { "online", "Show all online contacts in console." }, { "show", "Show the roster panel." }, - { "show offline", "Show offline contacts in the roster panel." }, - { "show resource", "Show contact's connected resources in the roster panel." }, - { "show presence", "Show contact's presence in the roster panel." }, - { "show status", "Show contact's status message in the roster panel." }, - { "show empty", "When grouping by presence, show empty presence groups." }, - { "show count", "Show number of contacts in group/presence." }, - { "show priority", "Show resource priority." }, + { "show offline", "Show offline contacts in roster panel." }, + { "show resource", "Show contact's connected resources in roster panel." }, + { "show presence", "Show contact's presence in roster panel." }, + { "show status", "Show contact's status message in roster panel." }, + { "show empty", "Show empty groups in roster panel." }, + { "show priority", "Show resource priority in roster panel." }, { "show contacts", "Show contacts in roster panel." }, { "show rooms", "Show chat rooms in roster panel." }, { "hide", "Hide the roster panel." }, - { "hide offline", "Hide offline contacts in the roster panel." }, - { "hide resource", "Hide contact's connected resources in the roster panel." }, - { "hide presence", "Hide contact's presence in the roster panel." }, - { "hide status", "Hide contact's status message in the roster panel." }, - { "hide empty", "When grouping by presence, hide empty presence groups." }, - { "hide count", "Hide number of contacts in group/presence." }, - { "hide priority", "Hide resource priority." }, + { "hide offline", "Hide offline contacts in roster panel." }, + { "hide resource", "Hide contact's connected resources in roster panel." }, + { "hide presence", "Hide contact's presence in roster panel." }, + { "hide status", "Hide contact's status message in roster panel." }, + { "hide empty", "Hide empty groups in roster panel." }, + { "hide priority", "Hide resource priority in roster panel." }, { "hide contacts", "Hide contacts in roster panel." }, { "hide rooms", "Hide chat rooms in roster panel." }, - { "by group", "Group contacts in the roster panel by roster group." }, - { "by presence", "Group contacts in the roster panel by presence." }, - { "by none", "No grouping in the roster panel." }, - { "count unread", "Show total unread message count with roster headers." }, + { "by group", "Group contacts in roster panel by roster group." }, + { "by presence", "Group contacts in roster panel by presence." }, + { "by none", "No grouping in roster panel." }, + { "count unread", "Show unread message count with roster headers." }, { "count items", "Show item count with roster headers." }, { "count off", "Do not show any count with roster headers." }, - { "count zero on", "Show roster count when 0." }, - { "count zero off", "Hide roster count when 0." }, - { "order name", "Order roster items by name only." }, - { "order presence", "Order roster items by presence, and then by name." }, - { "unread before", "Show unread message count before contact in roster." }, - { "unread after", "Show unread message count after contact in roster." }, - { "unread off", "Do not show unread message count for contacts in roster." }, - { "room char <char>", "Prefix roster rooms with specified character." }, - { "room char none", "Remove roster room character prefix." }, + { "count zero on", "Show roster header count when 0." }, + { "count zero off", "Hide roster header count when 0." }, + { "order name", "Order roster contacts by name only." }, + { "order presence", "Order roster contacts by presence, and then by name." }, + { "unread before", "Show unread message count before contact." }, + { "unread after", "Show unread message count after contact." }, + { "unread off", "Do not show unread message count for contacts." }, + { "room char <char>", "Prefix rooms with specified character." }, + { "room char none", "Remove room character prefix." }, + { "room private char <char>", "Prefix private room chat with specified character when displayed with room." }, + { "room private char none", "Remove private room chat character prefix when displayed with room." }, { "room position first", "Show rooms first in roster." }, { "room position last", "Show rooms last in roster." }, - { "room order name", "Order roster rooms by name." }, - { "room order unread", "Order roster rooms by unread messages, and then by name." }, - { "room unread before", "Show unread message count before room in roster." }, - { "room unread after", "Show unread message count after room in roster." }, - { "room unread off", "Do not show unread message count for rooms in roster." }, - { "private room", "Show room private chats below the room in the roster." }, + { "room order name", "Order rooms by name." }, + { "room order unread", "Order rooms by unread messages, and then by name." }, + { "room unread before", "Show unread message count before room." }, + { "room unread after", "Show unread message count after room." }, + { "room unread off", "Do not show unread message count for rooms." }, + { "private room", "Show room private chats with the room." }, { "private group", "Show room private chats as a separate roster group." }, - { "private off", "Do not show room private chats in the roster." }, - { "private char <char>", "Prefix roster private room chats with specified character." }, - { "private char none", "Remove roster private room chat character prefix." }, + { "private off", "Do not show room private chats." }, + { "private char <char>", "Prefix private room chats with specified character when displayed in separate group." }, + { "private char none", "Remove private room chat character prefix." }, { "header char <char>", "Prefix roster headers with specified character." }, { "header char none", "Remove roster header character prefix." }, { "contact char <char>", "Prefix roster contacts with specified character." }, @@ -2279,6 +2280,7 @@ cmd_init(void) autocomplete_add(roster_room_ac, "position"); autocomplete_add(roster_room_ac, "order"); autocomplete_add(roster_room_ac, "unread"); + autocomplete_add(roster_room_ac, "private"); roster_room_order_ac = autocomplete_new(); autocomplete_add(roster_room_order_ac, "name"); @@ -3172,6 +3174,14 @@ static char* _roster_autocomplete(ProfWin *window, const char *const input) { char *result = NULL; + result = autocomplete_param_with_ac(input, "/roster room private char", roster_char_ac, TRUE); + if (result) { + return result; + } + result = autocomplete_param_with_ac(input, "/roster room private", roster_header_ac, TRUE); + if (result) { + return result; + } result = autocomplete_param_with_ac(input, "/roster header char", roster_char_ac, TRUE); if (result) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index cdbce0f8..0a88d2bb 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2547,6 +2547,24 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); return TRUE; } + } else if (g_strcmp0(args[1], "private") == 0) { + if (g_strcmp0(args[2], "char") == 0) { + if (!args[3]) { + cons_bad_cmd_usage(command); + } else if (g_strcmp0(args[3], "none") == 0) { + prefs_clear_roster_room_private_char(); + cons_show("Roster room private char removed."); + rosterwin_roster(); + } else { + prefs_set_roster_room_private_char(args[3][0]); + cons_show("Roster room private char set to %c.", args[3][0]); + rosterwin_roster(); + } + return TRUE; + } else { + cons_bad_cmd_usage(command); + return TRUE; + } } else { cons_bad_cmd_usage(command); return TRUE; diff --git a/src/config/preferences.c b/src/config/preferences.c index 8a15cccd..0a2ae3cc 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -784,8 +784,6 @@ prefs_clear_roster_private_char(void) _save_prefs(); } - - char prefs_get_roster_room_char(void) { @@ -820,9 +818,39 @@ prefs_clear_roster_room_char(void) _save_prefs(); } +char +prefs_get_roster_room_private_char(void) +{ + char result = 0; + + char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.private.char", NULL); + if (!resultstr) { + result = 0; + } else { + result = resultstr[0]; + } + free(resultstr); + + return result; +} +void +prefs_set_roster_room_private_char(char ch) +{ + char str[2]; + str[0] = ch; + str[1] = '\0'; + g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.private.char", str); + _save_prefs(); +} +void +prefs_clear_roster_room_private_char(void) +{ + g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.rooms.pruvate.char", NULL); + _save_prefs(); +} gint prefs_get_roster_contact_indent(void) diff --git a/src/config/preferences.h b/src/config/preferences.h index 32a924ba..ff8b687d 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -199,6 +199,9 @@ void prefs_clear_roster_private_char(void); char prefs_get_roster_room_char(void); void prefs_set_roster_room_char(char ch); void prefs_clear_roster_room_char(void); +char prefs_get_roster_room_private_char(void); +void prefs_set_roster_room_private_char(char ch); +void prefs_clear_roster_room_private_char(void); gint prefs_get_roster_contact_indent(void); void prefs_set_roster_contact_indent(gint value); diff --git a/src/config/theme.c b/src/config/theme.c index b886f9e2..40bf3539 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -470,6 +470,16 @@ _load_preferences(void) prefs_clear_roster_room_char(); } + if (g_key_file_has_key(theme, "ui", "roster.rooms.private.char", NULL)) { + gchar *ch = g_key_file_get_string(theme, "ui", "roster.rooms.private.char", NULL); + if (ch && strlen(ch) > 0) { + prefs_set_roster_room_private_char(ch[0]); + g_free(ch); + } + } else { + prefs_clear_roster_room_private_char(); + } + if (g_key_file_has_key(theme, "ui", "roster.private.char", NULL)) { gchar *ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL); if (ch && strlen(ch) > 0) { diff --git a/src/ui/console.c b/src/ui/console.c index 7f80a227..e74d7c6e 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1330,6 +1330,12 @@ cons_roster_setting(void) else cons_show("Roster room char (/roster) : none"); + char room_priv_ch = prefs_get_roster_room_private_char(); + if (room_priv_ch) + cons_show("Roster room private char (/roster) : %c", room_priv_ch); + else + cons_show("Roster room private char (/roster) : none"); + char private_ch = prefs_get_roster_private_char(); if (private_ch) cons_show("Roster private char (/roster) : %c", private_ch); diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index db7a12be..cf7709b0 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -650,7 +650,7 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) g_string_append_printf(privmsg, "(%d) ", privwin->unread); } - ch = prefs_get_roster_private_char(); + ch = prefs_get_roster_room_private_char(); if (ch) { g_string_append_printf(privmsg, "%c", ch); } |