diff --git a/src/command.c b/src/command.c index 4e79b00d..2fab3c0a 100644 --- a/src/command.c +++ b/src/command.c @@ -120,6 +120,7 @@ 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_mouse(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); @@ -551,6 +552,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 } } } }; @@ -656,6 +666,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")); @@ -929,6 +940,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()); @@ -1931,7 +1944,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) { @@ -1941,6 +1955,9 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help) } else { cons_show("Message reminder period set to %d seconds.", period); } + + } else { + cons_show("Unknown command: %s.", kind); } return TRUE; @@ -2081,6 +2098,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 f8862aa9..574ae223 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -421,12 +421,30 @@ prefs_get_mouse(void) } } +gboolean +prefs_get_statuses(void) +{ + if (g_key_file_has_key(prefs, "ui", "statuses", NULL)) { + return g_key_file_get_boolean(prefs, "ui", "statuses", NULL); + } else { + return TRUE; + } +} + void prefs_set_mouse(gboolean value) { g_key_file_set_boolean(prefs, "ui", "mouse", value); _save_prefs(); } + +void +prefs_set_statuses(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "statuses", value); + _save_prefs(); +} + static void _save_prefs(void) { diff --git a/src/preferences.h b/src/preferences.h index aa748634..e27411c6 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -70,6 +70,8 @@ gchar * prefs_get_theme(void); void prefs_set_theme(gchar *value); gboolean prefs_get_mouse(void); void prefs_set_mouse(gboolean 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); diff --git a/src/windows.c b/src/windows.c index e0811dad..c56ceb70 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1296,6 +1296,11 @@ cons_show_ui_prefs(void) cons_show("Mouse handling (/mouse) : ON"); else cons_show("Mouse handling (/mouse) : OFF"); + + if (prefs_get_statuses()) + cons_show("Status (/statuses) : ON"); + else + cons_show("Status (/statuses) : OFF"); } void @@ -2035,6 +2040,9 @@ _show_status_string(WINDOW *win, const char * const from, GDateTime *last_activity, const char * const pre, const char * const default_show) { + if (!prefs_get_statuses()) + return; + _win_show_time(win, '-'); if (show != NULL) {