about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-04-18 00:26:17 +0100
committerJames Booth <boothj5@gmail.com>2016-04-18 00:26:17 +0100
commit12727744ab31b28eaec2f148f2ed22cdc7338a99 (patch)
tree6789de5138a20547ed46be1af8d26b8a48ccda1d
parentde65f505a80ab2cee79fbcc01d24c9eed01691e1 (diff)
downloadprofani-tty-12727744ab31b28eaec2f148f2ed22cdc7338a99.tar.gz
Load/destroy tray icons on init/shutdown
-rw-r--r--src/command/commands.c4
-rw-r--r--src/profanity.c2
-rw-r--r--src/tray.c16
-rw-r--r--src/tray.h6
4 files changed, 14 insertions, 14 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index e1eba540..50877227 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -5546,9 +5546,9 @@ cmd_tray(ProfWin *window, const char *const command, gchar **args)
     gboolean new = prefs_get_boolean(PREF_TRAY);
     if (old != new) {
         if (new) {
-            create_tray();
+            tray_enable();
         } else {
-            destroy_tray();
+            tray_disable();
         }
     }
     return TRUE;
diff --git a/src/profanity.c b/src/profanity.c
index 3c508dcd..1140594f 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -380,7 +380,7 @@ _shutdown(void)
         cl_ev_disconnect();
     }
 #ifdef HAVE_GTK
-    tray_close();
+    tray_shutdown();
 #endif
     jabber_shutdown();
     plugins_on_shutdown();
diff --git a/src/tray.c b/src/tray.c
index 7c731313..3e2c7a68 100644
--- a/src/tray.c
+++ b/src/tray.c
@@ -145,6 +145,7 @@ _tray_change_icon(gpointer data)
 void
 tray_init(void)
 {
+    _get_icons();
     gtk_ready = gtk_init_check(0, NULL);
     log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
     if (!gtk_ready) {
@@ -155,7 +156,7 @@ tray_init(void)
     gtk_main_iteration_do(FALSE);
     if (prefs_get_boolean(PREF_TRAY)) {
         log_debug("Building GTK icon");
-        create_tray();
+        tray_enable();
     }
 }
 
@@ -168,24 +169,25 @@ tray_update(void)
 }
 
 void
-tray_close(void)
+tray_shutdown(void)
 {
     if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
-        destroy_tray();
+        tray_disable();
     }
+    g_string_free(icon_filename, TRUE);
+    g_string_free(icon_msg_filename, TRUE);
 }
 
 void
-create_tray(void)
+tray_enable(void)
 {
-    _get_icons();
     prof_tray = gtk_status_icon_new_from_file(icon_filename->str);
     shutting_down = FALSE;
     timer = g_timeout_add(5000, _tray_change_icon, NULL);
 }
 
 void
-destroy_tray(void)
+tray_disable(void)
 {
     shutting_down = TRUE;
     g_source_remove(timer);
@@ -193,8 +195,6 @@ destroy_tray(void)
         g_clear_object(&prof_tray);
         prof_tray = NULL;
     }
-    g_string_free(icon_filename, TRUE);
-    g_string_free(icon_msg_filename, TRUE);
 }
 
 /* }}} */
diff --git a/src/tray.h b/src/tray.h
index 98cac490..81ddd20f 100644
--- a/src/tray.h
+++ b/src/tray.h
@@ -37,7 +37,7 @@
 
 void tray_init(void);
 void tray_update(void);
-void tray_close(void);
+void tray_shutdown(void);
 
 /*
  * Create tray icon
@@ -45,10 +45,10 @@ void tray_close(void);
  * This will initialize the timer that will be called in order to change the icons
  * and will search the icons in the defaults paths
  */
-void create_tray(void);
+void tray_enable(void);
 /*
  * Destroy tray icon
  */
-void destroy_tray(void);
+void tray_disable(void);
 
 #endif
previous revision' href='/akspecs/ranger/blame/doc/rifle.1?h=v1.9.0b2&id=d5e6a43d9a0c29c13aecb1df1a3459aabab1c3e6'>^
5eb98930 ^
a6836d5d ^





57c2dff1 ^






a6836d5d ^

57c2dff1 ^




a6836d5d ^

57c2dff1 ^




a6836d5d ^

57c2dff1 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232