about summary refs log tree commit diff stats
path: root/src/tray.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-04-18 00:07:15 +0100
committerJames Booth <boothj5@gmail.com>2016-04-18 00:07:15 +0100
commitde65f505a80ab2cee79fbcc01d24c9eed01691e1 (patch)
tree6f61bb1994dadb0d7e1811c868cfb65d807ca1cc /src/tray.c
parent507ea5746c277fea83984c551ffd9e8c445effb5 (diff)
downloadprofani-tty-de65f505a80ab2cee79fbcc01d24c9eed01691e1.tar.gz
Moved gtk specific code to tray.c
Diffstat (limited to 'src/tray.c')
-rw-r--r--src/tray.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tray.c b/src/tray.c
index 98039977..7c731313 100644
--- a/src/tray.c
+++ b/src/tray.c
@@ -42,7 +42,9 @@
 #include "tray.h"
 #include "window_list.h"
 #include "log.h"
+#include "config/preferences.h"
 
+static gboolean gtk_ready = FALSE;
 static GtkStatusIcon *prof_tray = NULL;
 static GString *icon_filename = NULL;
 static GString *icon_msg_filename = NULL;
@@ -141,6 +143,39 @@ _tray_change_icon(gpointer data)
 /* {{{ Public */
 
 void
+tray_init(void)
+{
+    gtk_ready = gtk_init_check(0, NULL);
+    log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
+    if (!gtk_ready) {
+        return;
+    }
+
+    gtk_init(0, NULL);
+    gtk_main_iteration_do(FALSE);
+    if (prefs_get_boolean(PREF_TRAY)) {
+        log_debug("Building GTK icon");
+        create_tray();
+    }
+}
+
+void
+tray_update(void)
+{
+    if (gtk_ready) {
+        gtk_main_iteration_do(FALSE);
+    }
+}
+
+void
+tray_close(void)
+{
+    if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
+        destroy_tray();
+    }
+}
+
+void
 create_tray(void)
 {
     _get_icons();