From 5356118147f715109f8482b4af4d642bc5f6c4a1 Mon Sep 17 00:00:00 2001 From: Backalor Date: Mon, 14 Jan 2013 18:51:37 +0900 Subject: Add new command "/notify status" to enable/disable status messages, such as users going on/offline or room joining/parting. --- src/command.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index 82374b3a..0c495947 100644 --- a/src/command.c +++ b/src/command.c @@ -385,11 +385,14 @@ static struct cmd_t setting_commands[] = " : use 0 to disable.", "typing : Notifications when contacts are typing.", " : on|off", + "status : Notifcations for status messages.", + " : on|off", "", "Example : /notify message on (enable message notifications)", "Example : /notify remind 10 (remind every 10 seconds)", "Example : /notify remind 0 (switch off reminders)", "Example : /notify typing on (enable typing notifications)", + "Example : /notify status off (disable status notifications)", NULL } } }, { "/flash", @@ -642,6 +645,7 @@ cmd_init(void) p_autocomplete_add(notify_ac, strdup("message")); p_autocomplete_add(notify_ac, strdup("typing")); p_autocomplete_add(notify_ac, strdup("remind")); + p_autocomplete_add(notify_ac, strdup("status")); sub_ac = p_autocomplete_new(); p_autocomplete_add(sub_ac, strdup("request")); @@ -1778,7 +1782,7 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help) // bad kind if ((strcmp(kind, "message") != 0) && (strcmp(kind, "typing") != 0) && - (strcmp(kind, "remind") != 0)) { + (strcmp(kind, "remind") != 0) && (strcmp(kind, "status") != 0)) { cons_show("Usage: %s", help.usage); // set message setting @@ -1805,7 +1809,8 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help) cons_show("Usage: /notify typing on|off"); } - } else { // remind + // set remind setting + } else if (strcmp(kind, "remind") == 0) { gint period = atoi(value); prefs_set_notify_remind(period); if (period == 0) { @@ -1815,6 +1820,21 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help) } else { cons_show("Message reminder period set to %d seconds.", period); } + + // set status setting + } else if (strcmp(kind, "status") == 0) { + if (strcmp(value, "on") == 0) { + cons_show("Status notifications enabled."); + prefs_set_notify_status(TRUE); + } else if (strcmp(value, "off") == 0) { + cons_show("Status notifications disabled."); + prefs_set_notify_status(FALSE); + } else { + cons_show("Usage: /notify status on|off"); + } + + } else { + cons_show("Unknown command: %s.", kind); } return TRUE; -- cgit 1.4.1-2-gfad0 From a0a1f9017f01af9be6cac3280b47f9ae586b06ef Mon Sep 17 00:00:00 2001 From: Backalor Date: Mon, 21 Jan 2013 10:26:09 +0900 Subject: Add new command /statuses for status notifications --- src/command.c | 33 +++++++++++++++++---------------- src/preferences.c | 8 ++++---- src/preferences.h | 4 ++-- src/windows.c | 12 ++++++------ 4 files changed, 29 insertions(+), 28 deletions(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index 0c495947..2543e2ca 100644 --- a/src/command.c +++ b/src/command.c @@ -385,14 +385,11 @@ static struct cmd_t setting_commands[] = " : use 0 to disable.", "typing : Notifications when contacts are typing.", " : on|off", - "status : Notifcations for status messages.", - " : on|off", "", "Example : /notify message on (enable message notifications)", "Example : /notify remind 10 (remind every 10 seconds)", "Example : /notify remind 0 (switch off reminders)", "Example : /notify typing on (enable typing notifications)", - "Example : /notify status off (disable status notifications)", NULL } } }, { "/flash", @@ -540,6 +537,15 @@ static struct cmd_t setting_commands[] = "---------------", "Set priority for the current session.", "value : Number between -128 and 127. Default value is 0.", + NULL } } }, + + { "/statuses", + _cmd_set_statuses, parse_args, 1, 1, + { "/statuses on|off", "Set notifications for status messages.", + { "/statuses on|off", + "---------------", + "Set notifications for status messages, such as online/offline or join/part channels.", + "When notifications are off status messages, such as online/offline or join/part, are not displayed.", NULL } } } }; @@ -1782,7 +1788,7 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help) // bad kind if ((strcmp(kind, "message") != 0) && (strcmp(kind, "typing") != 0) && - (strcmp(kind, "remind") != 0) && (strcmp(kind, "status") != 0)) { + (strcmp(kind, "remind") != 0)) { cons_show("Usage: %s", help.usage); // set message setting @@ -1821,18 +1827,6 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help) cons_show("Message reminder period set to %d seconds.", period); } - // set status setting - } else if (strcmp(kind, "status") == 0) { - if (strcmp(value, "on") == 0) { - cons_show("Status notifications enabled."); - prefs_set_notify_status(TRUE); - } else if (strcmp(value, "off") == 0) { - cons_show("Status notifications disabled."); - prefs_set_notify_status(FALSE); - } else { - cons_show("Usage: /notify status on|off"); - } - } else { cons_show("Unknown command: %s.", kind); } @@ -1975,6 +1969,13 @@ _cmd_set_priority(gchar **args, struct cmd_help_t help) return TRUE; } +static gboolean +_cmd_set_statuses(gchar **args, struct cmd_help_t help) +{ + return _cmd_set_boolean_preference(args[0], help, + "Status notifications", prefs_set_statuses); +} + static gboolean _cmd_vercheck(gchar **args, struct cmd_help_t help) { diff --git a/src/preferences.c b/src/preferences.c index 7cd6f722..c4283269 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -411,15 +411,15 @@ prefs_set_splash(gboolean value) } gboolean -prefs_get_notify_status(void) +prefs_get_statuses(void) { - return g_key_file_get_boolean(prefs, "notifications", "status", NULL); + return g_key_file_get_boolean(prefs, "ui", "statuses", NULL); } void -prefs_set_notify_status(gboolean value) +prefs_set_statuses(gboolean value) { - g_key_file_set_boolean(prefs, "notifications", "status", value); + g_key_file_set_boolean(prefs, "ui", "statuses", value); _save_prefs(); } diff --git a/src/preferences.h b/src/preferences.h index a0b6224c..bd55727d 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -68,6 +68,8 @@ gint prefs_get_gone(void); void prefs_set_gone(gint value); gchar * prefs_get_theme(void); void prefs_set_theme(gchar *value); +void prefs_set_statuses(gboolean value); +gboolean prefs_get_statuses(void); void prefs_set_notify_message(gboolean value); gboolean prefs_get_notify_message(void); @@ -75,8 +77,6 @@ void prefs_set_notify_typing(gboolean value); gboolean prefs_get_notify_typing(void); void prefs_set_notify_remind(gint period); gint prefs_get_notify_remind(void); -void prefs_set_notify_status(gboolean value); -gboolean prefs_get_notify_status(void); void prefs_set_max_log_size(gint value); gint prefs_get_max_log_size(void); void prefs_set_priority(gint value); diff --git a/src/windows.c b/src/windows.c index ea3a6815..eb9b4580 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1227,6 +1227,11 @@ cons_show_ui_prefs(void) cons_show("Version checking (/vercheck) : ON"); else cons_show("Version checking (/vercheck) : OFF"); + + if (prefs_get_statuses()) + cons_show("Status (/statuses) : ON"); + else + cons_show("Status (/statuses) : OFF"); } void @@ -1253,11 +1258,6 @@ cons_show_desktop_prefs(void) } else { cons_show("Reminder period (/notify remind) : %d seconds", remind_period); } - - if (prefs_get_notify_status()) - cons_show("Status (/notify status) : ON"); - else - cons_show("Status (/notify status) : OFF"); } void @@ -1971,7 +1971,7 @@ _show_status_string(WINDOW *win, const char * const from, GDateTime *last_activity, const char * const pre, const char * const default_show) { - if (!prefs_get_notify_status()) + if (!prefs_get_statuses()) return; _win_show_time(win); -- cgit 1.4.1-2-gfad0 From 9a58017385f89e70ae820927cd2b2d8479b57cf4 Mon Sep 17 00:00:00 2001 From: Backalor Date: Tue, 22 Jan 2013 09:54:59 +0900 Subject: Add function prototype and make the default for the /statuses command be ON --- src/command.c | 1 + src/preferences.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index 2543e2ca..f372bd3f 100644 --- a/src/command.c +++ b/src/command.c @@ -118,6 +118,7 @@ static gboolean _cmd_set_gone(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_autoping(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_titlebar(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_autoaway(gchar **args, struct cmd_help_t help); +static gboolean _cmd_set_statuses(gchar **args, struct cmd_help_t help); static gboolean _cmd_vercheck(gchar **args, struct cmd_help_t help); static gboolean _cmd_away(gchar **args, struct cmd_help_t help); static gboolean _cmd_online(gchar **args, struct cmd_help_t help); diff --git a/src/preferences.c b/src/preferences.c index c4283269..97a2041e 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -413,7 +413,11 @@ prefs_set_splash(gboolean value) gboolean prefs_get_statuses(void) { - return g_key_file_get_boolean(prefs, "ui", "statuses", NULL); + if (g_key_file_has_key(prefs, "ui", "statuses", NULL)) { + return g_key_file_get_boolean(prefs, "ui", "statuses", NULL); + } else { + return TRUE; + } } void -- cgit 1.4.1-2-gfad0 From c850ee69cc88cb962db182e91fe0226d051643c1 Mon Sep 17 00:00:00 2001 From: Backalor Date: Tue, 22 Jan 2013 10:00:31 +0900 Subject: Add support for autocomplete of /statuses command --- src/command.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index f372bd3f..69f260fa 100644 --- a/src/command.c +++ b/src/command.c @@ -925,6 +925,8 @@ _cmd_complete_parameters(char *input, int *size) prefs_autocomplete_boolean_choice); _parameter_autocomplete(input, size, "/vercheck", prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/statuses", + prefs_autocomplete_boolean_choice); if (win_current_is_groupchat()) { PAutocomplete nick_ac = muc_get_roster_ac(win_current_get_recipient()); -- cgit 1.4.1-2-gfad0 rofani-tty/commit/tests/config/helpers.c?id=5f25d99357bd126bbae99c585cc9d84c265b62fc'>5f25d993 ^
1
2
3
4
5
6
7
8
9
10