about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-04-17 23:17:43 +0100
committerJames Booth <boothj5@gmail.com>2016-04-17 23:17:43 +0100
commit2daa02cb60fc27e4dddadc32e487088c38b97b02 (patch)
tree54f6f1ff3cc2013647478e860280d635036bbc3e /src/command
parent6cc04bc3ba85415e6ec532ddf60738961a3a9560 (diff)
parent4cb1d73a8358f660056156b5632e8c41659eb6e0 (diff)
downloadprofani-tty-2daa02cb60fc27e4dddadc32e487088c38b97b02.tar.gz
Merge remote-tracking branch 'asdil12/tray_config'
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c19
-rw-r--r--src/command/commands.c24
-rw-r--r--src/command/commands.h1
3 files changed, 41 insertions, 3 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 191415ae..984812f5 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1253,6 +1253,19 @@ static struct cmd_t command_defs[] =
         CMD_NOEXAMPLES
     },
 
+    { "/tray",
+        cmd_tray, parse_args, 1, 1, &cons_tray_setting,
+        CMD_TAGS(
+            CMD_TAG_UI)
+        CMD_SYN(
+            "/tray on|off")
+        CMD_DESC(
+            "Display an icon in the tray that will indicate new messages.")
+        CMD_ARGS(
+            { "on|off", "Enable or disable tray icon." })
+        CMD_NOEXAMPLES
+    },
+
     { "/intype",
         cmd_intype, parse_args, 1, 1, &cons_intype_setting,
         CMD_TAGS(
@@ -3061,9 +3074,9 @@ _cmd_complete_parameters(ProfWin *window, const char *const input)
     jabber_conn_status_t conn_status = jabber_get_connection_status();
 
     // autocomplete boolean settings
-    gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype",
-        "/flash", "/splash", "/chlog", "/grlog", "/history", "/vercheck",
-        "/privileges", "/presence", "/wrap", "/winstidy", "/carbons", "/encwarn", "/lastactivity" };
+    gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/chlog", "/grlog",
+        "/history", "/vercheck", "/privileges", "/presence", "/wrap", "/winstidy", "/carbons", "/encwarn",
+        "/lastactivity", "/tray" };
 
     for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
         result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice);
diff --git a/src/command/commands.c b/src/command/commands.c
index 8d32237b..c60a3a3e 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -77,6 +77,9 @@
 #include "ui/ui.h"
 #include "window_list.h"
 #include "event/client_events.h"
+#ifdef HAVE_GTK
+#include "tray.h"
+#endif
 
 static void _update_presence(const resource_presence_t presence,
     const char *const show, gchar **args);
@@ -5526,6 +5529,27 @@ cmd_flash(ProfWin *window, const char *const command, gchar **args)
 }
 
 gboolean
+cmd_tray(ProfWin *window, const char *const command, gchar **args)
+{
+#ifdef HAVE_GTK
+    gboolean old = prefs_get_boolean(PREF_TRAY);
+    gboolean ret = _cmd_set_boolean_preference(args[0], command, "Tray icon", PREF_TRAY);
+    gboolean new = prefs_get_boolean(PREF_TRAY);
+    if (old != new) {
+        if (new) {
+            create_tray();
+        } else {
+            destroy_tray();
+        }
+    }
+    return ret;
+#else
+    cons_show("This version of Profanity has not been built with GTK Tray Icon support enabled");
+    return TRUE;
+#endif
+}
+
+gboolean
 cmd_intype(ProfWin *window, const char *const command, gchar **args)
 {
     return _cmd_set_boolean_preference(args[0], command, "Show contact typing", PREF_INTYPE);
diff --git a/src/command/commands.h b/src/command/commands.h
index 3e1a4592..cfa9d966 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -89,6 +89,7 @@ gboolean cmd_lastactivity(ProfWin *window, const char *const command, gchar **ar
 gboolean cmd_disconnect(ProfWin *window, const char *const command, gchar **args);
 gboolean cmd_dnd(ProfWin *window, const char *const command, gchar **args);
 gboolean cmd_flash(ProfWin *window, const char *const command, gchar **args);
+gboolean cmd_tray(ProfWin *window, const char *const command, gchar **args);
 gboolean cmd_gone(ProfWin *window, const char *const command, gchar **args);
 gboolean cmd_grlog(ProfWin *window, const char *const command, gchar **args);
 gboolean cmd_group(ProfWin *window, const char *const command, gchar **args);