about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c15
-rw-r--r--src/command/commands.c21
-rw-r--r--src/command/commands.h3
-rw-r--r--src/config/preferences.c11
-rw-r--r--src/config/preferences.h3
-rw-r--r--src/profanity.c4
-rw-r--r--src/ui/console.c14
-rw-r--r--src/ui/ui.h3
8 files changed, 72 insertions, 2 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 191415ae..e94d3406 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1253,6 +1253,21 @@ static struct cmd_t command_defs[] =
         CMD_NOEXAMPLES
     },
 
+#ifdef HAVE_GTK
+    { "/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
+    },
+#endif
+
     { "/intype",
         cmd_intype, parse_args, 1, 1, &cons_intype_setting,
         CMD_TAGS(
diff --git a/src/command/commands.c b/src/command/commands.c
index 8d32237b..b2795a43 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);
@@ -5525,6 +5528,24 @@ cmd_flash(ProfWin *window, const char *const command, gchar **args)
     return _cmd_set_boolean_preference(args[0], command, "Screen flash", PREF_FLASH);
 }
 
+#ifdef HAVE_GTK
+gboolean
+cmd_tray(ProfWin *window, const char *const command, gchar **args)
+{
+    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;
+}
+#endif
+
 gboolean
 cmd_intype(ProfWin *window, const char *const command, gchar **args)
 {
diff --git a/src/command/commands.h b/src/command/commands.h
index 3e1a4592..34c9cc49 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -89,6 +89,9 @@ 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);
+#ifdef HAVE_GTK
+gboolean cmd_tray(ProfWin *window, const char *const command, gchar **args);
+#endif
 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);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 0ad95dc4..4f403888 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -47,6 +47,10 @@
 #include "tools/autocomplete.h"
 #include "config/conflists.h"
 
+#ifdef HAVE_GTK
+#include "tray.h"
+#endif
+
 // preference groups refer to the sections in .profrc, for example [ui]
 #define PREF_GROUP_LOGGING "logging"
 #define PREF_GROUP_CHATSTATES "chatstates"
@@ -1171,6 +1175,9 @@ _get_group(preference_t pref)
         case PREF_TITLEBAR_SHOW:
         case PREF_TITLEBAR_GOODBYE:
         case PREF_FLASH:
+#ifdef HAVE_GTK
+        case PREF_TRAY:
+#endif
         case PREF_INTYPE:
         case PREF_HISTORY:
         case PREF_OCCUPANTS:
@@ -1289,6 +1296,10 @@ _get_key(preference_t pref)
             return "titlebar.goodbye";
         case PREF_FLASH:
             return "flash";
+#ifdef HAVE_GTK
+        case PREF_TRAY:
+            return "tray";
+#endif
         case PREF_INTYPE:
             return "intype";
         case PREF_HISTORY:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 287e56d3..eb749b16 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -52,6 +52,9 @@ typedef enum {
     PREF_TITLEBAR_SHOW,
     PREF_TITLEBAR_GOODBYE,
     PREF_FLASH,
+#ifdef HAVE_GTK
+    PREF_TRAY,
+#endif
     PREF_INTYPE,
     PREF_HISTORY,
     PREF_CARBONS,
diff --git a/src/profanity.c b/src/profanity.c
index 2595f5f7..4ca649cd 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -373,7 +373,7 @@ _init(char *log_level)
     atexit(_shutdown);
     plugins_init();
 #ifdef HAVE_GTK
-    if (gtk_ready) {
+    if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
         log_debug("Building GTK icon");
         create_tray();
     }
@@ -397,7 +397,7 @@ _shutdown(void)
         cl_ev_disconnect();
     }
 #ifdef HAVE_GTK
-    if (gtk_ready) {
+    if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
         destroy_tray();
     }
 #endif
diff --git a/src/ui/console.c b/src/ui/console.c
index c104e21b..73cfbfd1 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1182,6 +1182,17 @@ cons_flash_setting(void)
         cons_show("Terminal flash (/flash)             : OFF");
 }
 
+#ifdef HAVE_GTK
+void
+cons_tray_setting(void)
+{
+    if (prefs_get_boolean(PREF_TRAY))
+        cons_show("Tray icon (/tray)             : ON");
+    else
+        cons_show("Tray icon (/tray)             : OFF");
+}
+#endif
+
 void
 cons_splash_setting(void)
 {
@@ -1497,6 +1508,9 @@ cons_show_ui_prefs(void)
     cons_theme_setting();
     cons_beep_setting();
     cons_flash_setting();
+#ifdef HAVE_GTK
+    cons_tray_setting();
+#endif
     cons_splash_setting();
     cons_wrap_setting();
     cons_winstidy_setting();
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 924ba33c..09215595 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -284,6 +284,9 @@ void cons_privileges_setting(void);
 void cons_beep_setting(void);
 void cons_console_setting(void);
 void cons_flash_setting(void);
+#ifdef HAVE_GTK
+void cons_tray_setting(void);
+#endif
 void cons_splash_setting(void);
 void cons_encwarn_setting(void);
 void cons_tlsshow_setting(void);
='n481' href='#n481'>481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589