about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBackalor <backalor@backalor.com>2013-01-21 10:26:09 +0900
committerBackalor <backalor@backalor.com>2013-01-21 10:26:09 +0900
commita0a1f9017f01af9be6cac3280b47f9ae586b06ef (patch)
tree922d3a2c20bca505ae01cf6b646e506c46e6e2e1
parentba0438607cf377af100987413b024d755963b969 (diff)
downloadprofani-tty-a0a1f9017f01af9be6cac3280b47f9ae586b06ef.tar.gz
Add new command /statuses for status notifications
-rw-r--r--src/command.c33
-rw-r--r--src/preferences.c8
-rw-r--r--src/preferences.h4
-rw-r--r--src/windows.c12
4 files changed, 29 insertions, 28 deletions
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);
     }
@@ -1976,6 +1970,13 @@ _cmd_set_priority(gchar **args, struct cmd_help_t help)
 }
 
 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)
 {
     int num_args = g_strv_length(args);
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);