Mercurial > pidgin
annotate plugins/docklet/docklet.c @ 4418:3270d3536e12
[gaim-migrate @ 4691]
paco-paco got gaim to compile on solaris :-)
(23:18:49) Paco-Paco: Fixes getopt handling and libsocket detection on Solaris
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sun, 26 Jan 2003 04:18:46 +0000 |
parents | 906f61f27479 |
children | 3196d9044a45 |
rev | line source |
---|---|
4093 | 1 /* System tray icon (aka docklet) plugin for Gaim |
3510 | 2 * Copyright (C) 2002 Robert McQueen <robot101@debian.org> |
3 * Inspired by a similar plugin by: | |
4 * John (J5) Palmieri <johnp@martianrock.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation; either version 2 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 * 02111-1307, USA. | |
20 */ | |
21 | |
22 /* todo (in order of importance): | |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
23 - check removing the icon factory actually frees the icons |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
24 - unify the queue so we can have a global away without the dialog |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
25 - handle and update tooltips to show your current accounts/queued messages? |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
26 - show a count of queued messages in the unified queue |
3510 | 27 - dernyi's account status menu in the right click |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
28 - optional pop up notices when GNOME2's system-tray-applet supports it */ |
3510 | 29 |
30 /* includes */ | |
31 #include <gtk/gtk.h> | |
32 #include "gaim.h" | |
33 #include "eggtrayicon.h" | |
34 | |
3867 | 35 #ifndef GAIM_PLUGINS |
36 #define GAIM_PLUGINS | |
37 #endif | |
38 | |
3510 | 39 /* types */ |
40 enum docklet_status { | |
4157 | 41 offline, |
42 offline_connecting, | |
3510 | 43 online, |
4157 | 44 online_connecting, |
45 online_pending, | |
3510 | 46 away, |
4157 | 47 away_pending |
3510 | 48 }; |
49 | |
50 /* functions */ | |
4093 | 51 static gboolean docklet_create(); |
4157 | 52 static gboolean docklet_update_status(); |
4093 | 53 void gaim_plugin_remove(); |
3510 | 54 |
55 /* globals */ | |
3513 | 56 static EggTrayIcon *docklet = NULL; |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
57 static GtkWidget *image = NULL; |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
58 static GtkIconFactory *icon_factory = NULL; |
3510 | 59 static enum docklet_status status; |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
60 static enum docklet_status icon; |
3510 | 61 |
3554 | 62 static void docklet_toggle_mute(GtkWidget *toggle, void *data) { |
63 mute_sounds = GTK_CHECK_MENU_ITEM(toggle)->active; | |
3510 | 64 } |
65 | |
3554 | 66 static void docklet_toggle_queue(GtkWidget *widget, void *data) { |
67 away_options ^= OPT_AWAY_QUEUE_UNREAD; | |
68 save_prefs(); | |
3510 | 69 } |
3570 | 70 |
71 /* static void docklet_toggle_blist_show(GtkWidget *widget, void *data) { | |
72 blist_options ^= OPT_BLIST_APP_BUDDY_SHOW; | |
73 save_prefs(); | |
74 } */ | |
75 | |
3554 | 76 static void docklet_flush_queue() { |
3570 | 77 if (unread_message_queue) { |
4274 | 78 purge_away_queue(&unread_message_queue); |
3570 | 79 } |
3510 | 80 } |
81 | |
82 static void docklet_menu(GdkEventButton *event) { | |
3513 | 83 static GtkWidget *menu = NULL; |
3512 | 84 GtkWidget *entry; |
3510 | 85 |
86 if (menu) { | |
87 gtk_widget_destroy(menu); | |
88 } | |
89 | |
90 menu = gtk_menu_new(); | |
91 | |
4157 | 92 switch (status) { |
93 case offline: | |
94 case offline_connecting: | |
95 break; | |
96 case online: | |
97 case online_connecting: | |
98 case online_pending: { | |
3510 | 99 GtkWidget *docklet_awaymenu; |
100 GSList *awy = NULL; | |
101 struct away_message *a = NULL; | |
102 | |
103 docklet_awaymenu = gtk_menu_new(); | |
104 awy = away_messages; | |
105 | |
106 while (awy) { | |
107 a = (struct away_message *)awy->data; | |
108 | |
109 entry = gtk_menu_item_new_with_label(a->name); | |
3554 | 110 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_away_message), a); |
3510 | 111 gtk_menu_append(GTK_MENU(docklet_awaymenu), entry); |
112 | |
113 awy = g_slist_next(awy); | |
114 } | |
115 | |
4157 | 116 if (away_messages) |
117 gaim_separator(docklet_awaymenu); | |
3510 | 118 |
119 entry = gtk_menu_item_new_with_label(_("New...")); | |
3554 | 120 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(create_away_mess), NULL); |
3510 | 121 gtk_menu_append(GTK_MENU(docklet_awaymenu), entry); |
122 | |
123 entry = gtk_menu_item_new_with_label(_("Away")); | |
3512 | 124 gtk_menu_item_set_submenu(GTK_MENU_ITEM(entry), docklet_awaymenu); |
3510 | 125 gtk_menu_append(GTK_MENU(menu), entry); |
4157 | 126 } break; |
127 case away: | |
128 case away_pending: | |
3510 | 129 entry = gtk_menu_item_new_with_label(_("Back")); |
3554 | 130 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_im_back), NULL); |
3510 | 131 gtk_menu_append(GTK_MENU(menu), entry); |
4157 | 132 break; |
3510 | 133 } |
134 | |
4157 | 135 switch (status) { |
136 case offline: | |
137 case offline_connecting: | |
138 entry = gtk_menu_item_new_with_label(_("Auto-login")); | |
139 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(auto_login), NULL); | |
140 gtk_menu_append(GTK_MENU(menu), entry); | |
141 break; | |
142 default: | |
143 entry = gtk_menu_item_new_with_label(_("Signoff")); | |
144 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(signoff_all), NULL); | |
145 gtk_menu_append(GTK_MENU(menu), entry); | |
146 break; | |
147 } | |
148 | |
149 gaim_separator(menu); | |
3510 | 150 |
3517 | 151 entry = gtk_check_menu_item_new_with_label(_("Mute Sounds")); |
152 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), mute_sounds); | |
3554 | 153 g_signal_connect(G_OBJECT(entry), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); |
3517 | 154 gtk_menu_append(GTK_MENU(menu), entry); |
155 | |
4157 | 156 gaim_new_item_from_pixbuf(menu, _("Accounts..."), "accounts-menu.png", G_CALLBACK(account_editor), NULL, 0, 0, 0); |
157 gaim_new_item_from_stock(menu, _("Preferences..."), GTK_STOCK_PREFERENCES, G_CALLBACK(show_prefs), NULL, 0, 0, 0); | |
3510 | 158 |
4157 | 159 gaim_separator(menu); |
3510 | 160 |
4157 | 161 gaim_new_item_from_pixbuf(menu, _("About Gaim..."), "about_menu.png", G_CALLBACK(show_about), NULL, 0, 0, 0); |
162 gaim_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(do_quit), NULL, 0, 0, 0); | |
3510 | 163 |
164 gtk_widget_show_all(menu); | |
165 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time); | |
166 } | |
167 | |
168 static void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data) { | |
3939 | 169 if (event->type != GDK_BUTTON_PRESS) |
170 return; | |
171 | |
3510 | 172 switch (event->button) { |
173 case 1: | |
3517 | 174 if (unread_message_queue) { |
3570 | 175 docklet_flush_queue(); |
3517 | 176 docklet_update_status(); |
3570 | 177 } else { |
3517 | 178 docklet_toggle(); |
3554 | 179 } |
3510 | 180 break; |
181 case 2: | |
182 break; | |
183 case 3: | |
184 docklet_menu(event); | |
185 break; | |
186 } | |
187 } | |
188 | |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
189 static void docklet_update_icon() { |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
190 const gchar *icon_name = NULL; |
3510 | 191 |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
192 switch (icon) { |
4157 | 193 case offline: |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
194 icon_name = "gaim-docklet-offline"; |
4157 | 195 break; |
196 case offline_connecting: | |
197 case online_connecting: | |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
198 icon_name = "gaim-docklet-connect"; |
4157 | 199 break; |
3510 | 200 case online: |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
201 icon_name = "gaim-docklet-online"; |
3510 | 202 break; |
4157 | 203 case online_pending: |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
204 icon_name = "gaim-docklet-msgunread"; |
4157 | 205 break; |
3510 | 206 case away: |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
207 icon_name = "gaim-docklet-away"; |
3510 | 208 break; |
209 case away_pending: | |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
210 icon_name = "gaim-docklet-msgpend"; |
3510 | 211 break; |
212 } | |
213 | |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
214 gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
215 |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
216 debug_printf("Tray Icon: updated icon to '%s'\n", icon_name); |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
217 } |
3510 | 218 |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
219 static gboolean docklet_blink_icon() { |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
220 if (status == online_pending) { |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
221 if (status == icon) { |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
222 /* last icon was the right one... let's change it */ |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
223 icon = online; |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
224 } else { |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
225 /* last icon was the wrong one, change it back */ |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
226 icon = online_pending; |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
227 } |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
228 } else if (status == away_pending) { |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
229 if (status == icon) { |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
230 /* last icon was the right one... let's change it */ |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
231 icon = away; |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
232 } else { |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
233 /* last icon was the wrong one, change it back */ |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
234 icon = away_pending; |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
235 } |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
236 } else { |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
237 /* no messages, stop blinking */ |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
238 return FALSE; |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
239 } |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
240 |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
241 docklet_update_icon(); |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
242 |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
243 return TRUE; /* keep blinking */ |
3510 | 244 } |
245 | |
4157 | 246 static gboolean docklet_update_status() { |
3510 | 247 enum docklet_status oldstatus; |
248 | |
249 oldstatus = status; | |
250 | |
251 if (connections) { | |
3517 | 252 if (unread_message_queue) { |
4157 | 253 status = online_pending; |
3517 | 254 } else if (awaymessage) { |
3510 | 255 if (message_queue) { |
256 status = away_pending; | |
257 } else { | |
258 status = away; | |
259 } | |
3554 | 260 } else if (connecting_count) { |
4157 | 261 status = online_connecting; |
3510 | 262 } else { |
263 status = online; | |
264 } | |
265 } else { | |
3517 | 266 if (connecting_count) { |
4157 | 267 status = offline_connecting; |
3517 | 268 } else { |
269 status = offline; | |
270 } | |
3510 | 271 } |
272 | |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
273 /* update the icon if we changed status */ |
3510 | 274 if (status != oldstatus) { |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
275 icon = status; |
3510 | 276 docklet_update_icon(); |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
277 |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
278 /* and schedule the blinker function if messages are pending */ |
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
279 if (status == online_pending || status == away_pending) { |
4274 | 280 g_timeout_add(500, docklet_blink_icon, &docklet); |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
281 } |
3510 | 282 } |
4157 | 283 |
284 return FALSE; /* for when we're called by the glib idle handler */ | |
3510 | 285 } |
286 | |
3554 | 287 static void docklet_embedded(GtkWidget *widget, void *data) { |
4093 | 288 debug_printf("Tray Icon: embedded\n"); |
3570 | 289 docklet_add(); |
3554 | 290 } |
291 | |
4274 | 292 static void docklet_remove_callbacks() { |
293 debug_printf("Tray Icon: removing callbacks"); | |
294 | |
295 while (g_source_remove_by_user_data(&docklet)) { | |
296 debug_printf("."); | |
297 } | |
298 | |
299 debug_printf("\n"); | |
300 } | |
301 | |
3554 | 302 static void docklet_destroyed(GtkWidget *widget, void *data) { |
4093 | 303 debug_printf("Tray Icon: destroyed\n"); |
304 | |
305 docklet_remove(); | |
306 | |
3570 | 307 docklet_flush_queue(); |
4093 | 308 |
4274 | 309 docklet_remove_callbacks(); |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
310 |
4093 | 311 g_object_unref(G_OBJECT(docklet)); |
312 docklet = NULL; | |
313 | |
4274 | 314 g_idle_add(docklet_create, &docklet); |
3554 | 315 } |
316 | |
4274 | 317 static gboolean docklet_create() { |
3510 | 318 GtkWidget *box; |
319 | |
3570 | 320 if (docklet) { |
4093 | 321 /* if this is being called when a tray icon exists, it's because |
322 something messed up. try destroying it before we proceed, | |
323 although docklet_refcount may be all hosed. hopefully won't happen. */ | |
324 debug_printf("Tray Icon: trying to create icon but it already exists?\n"); | |
325 gaim_plugin_remove(); | |
3510 | 326 } |
327 | |
328 docklet = egg_tray_icon_new("Gaim"); | |
329 box = gtk_event_box_new(); | |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
330 image = gtk_image_new(); |
3510 | 331 |
3554 | 332 g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_embedded), NULL); |
333 g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_destroyed), NULL); | |
334 g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_clicked), NULL); | |
3510 | 335 |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
336 gtk_container_add(GTK_CONTAINER(box), image); |
3510 | 337 gtk_container_add(GTK_CONTAINER(docklet), box); |
338 gtk_widget_show_all(GTK_WIDGET(docklet)); | |
339 | |
3554 | 340 /* ref the docklet before we bandy it about the place */ |
341 g_object_ref(G_OBJECT(docklet)); | |
3510 | 342 docklet_update_status(); |
343 docklet_update_icon(); | |
344 | |
4093 | 345 debug_printf("Tray Icon: created\n"); |
346 | |
347 return FALSE; /* for when we're called by the glib idle handler */ | |
3510 | 348 } |
349 | |
350 static void gaim_signon(struct gaim_connection *gc, void *data) { | |
351 docklet_update_status(); | |
352 } | |
353 | |
354 static void gaim_signoff(struct gaim_connection *gc, void *data) { | |
4157 | 355 /* do this when idle so that if the prpl was connecting |
356 and was cancelled, we register that connecting_count | |
357 has returned to 0 */ | |
4274 | 358 g_idle_add(docklet_update_status, &docklet); |
3510 | 359 } |
360 | |
361 static void gaim_connecting(struct aim_user *user, void *data) { | |
362 docklet_update_status(); | |
363 } | |
364 | |
365 static void gaim_away(struct gaim_connection *gc, char *state, char *message, void *data) { | |
366 /* we only support global away. this is the way it is, ok? */ | |
367 docklet_update_status(); | |
368 } | |
369 | |
4274 | 370 static void gaim_im_recv(struct gaim_connection *gc, char **who, char **what, void *data) { |
3510 | 371 /* if message queuing while away is enabled, this event could be the first |
4274 | 372 message so we need to see if the status (and hence icon) needs changing. |
373 do this when idle so that all message processing is completed, queuing | |
374 etc, before we run. */ | |
375 g_idle_add(docklet_update_status, &docklet); | |
3510 | 376 } |
377 | |
3570 | 378 /* static void gaim_buddy_signon(struct gaim_connection *gc, char *who, void *data) { |
3510 | 379 } |
380 | |
381 static void gaim_buddy_signoff(struct gaim_connection *gc, char *who, void *data) { | |
382 } | |
383 | |
384 static void gaim_buddy_away(struct gaim_connection *gc, char *who, void *data) { | |
385 } | |
386 | |
387 static void gaim_buddy_back(struct gaim_connection *gc, char *who, void *data) { | |
388 } | |
389 | |
390 static void gaim_new_conversation(char *who, void *data) { | |
3570 | 391 } */ |
3510 | 392 |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
393 static void docklet_register_icon(const char *name, char *fn) { |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
394 gchar *filename; |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
395 |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
396 filename = g_build_filename(DATADIR, "pixmaps", "gaim", fn, NULL); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
397 gtk_icon_factory_add(icon_factory, name, |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
398 gtk_icon_set_new_from_pixbuf(gdk_pixbuf_new_from_file(filename, NULL))); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
399 g_free(filename); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
400 } |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
401 |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
402 static void docklet_register_icon_factory() { |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
403 icon_factory = gtk_icon_factory_new(); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
404 |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
405 docklet_register_icon("gaim-docklet-offline", "offline.png"); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
406 docklet_register_icon("gaim-docklet-connect", "connect.png"); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
407 docklet_register_icon("gaim-docklet-online", "online.png"); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
408 docklet_register_icon("gaim-docklet-msgunread", "msgunread.png"); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
409 docklet_register_icon("gaim-docklet-away", "away.png"); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
410 docklet_register_icon("gaim-docklet-msgpend", "msgpend.png"); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
411 |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
412 gtk_icon_factory_add_default(icon_factory); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
413 } |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
414 |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
415 static void docklet_unregister_icon_factory() { |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
416 gtk_icon_factory_remove_default(icon_factory); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
417 } |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
418 |
3510 | 419 char *gaim_plugin_init(GModule *handle) { |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
420 docklet_register_icon_factory(); |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
421 |
4093 | 422 docklet_create(NULL); |
3510 | 423 |
424 gaim_signal_connect(handle, event_signon, gaim_signon, NULL); | |
425 gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL); | |
426 gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL); | |
427 gaim_signal_connect(handle, event_away, gaim_away, NULL); | |
4274 | 428 gaim_signal_connect(handle, event_im_recv, gaim_im_recv, NULL); |
3570 | 429 /* gaim_signal_connect(handle, event_buddy_signon, gaim_buddy_signon, NULL); |
3510 | 430 gaim_signal_connect(handle, event_buddy_signoff, gaim_buddy_signoff, NULL); |
431 gaim_signal_connect(handle, event_buddy_away, gaim_buddy_away, NULL); | |
432 gaim_signal_connect(handle, event_buddy_back, gaim_buddy_back, NULL); | |
3570 | 433 gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL); */ |
3510 | 434 |
435 return NULL; | |
436 } | |
437 | |
3554 | 438 void gaim_plugin_remove() { |
3570 | 439 if (GTK_WIDGET_VISIBLE(docklet)) { |
440 docklet_remove(); | |
441 } | |
3554 | 442 |
3570 | 443 docklet_flush_queue(); |
3554 | 444 |
4274 | 445 docklet_remove_callbacks(); |
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
446 |
3570 | 447 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL); |
448 gtk_widget_destroy(GTK_WIDGET(docklet)); | |
3554 | 449 |
4093 | 450 g_object_unref(G_OBJECT(docklet)); |
451 docklet = NULL; | |
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
452 |
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
453 docklet_unregister_icon_factory(); |
4093 | 454 |
455 debug_printf("Tray Icon: removed\n"); | |
3554 | 456 } |
457 | |
3570 | 458 GtkWidget *gaim_plugin_config_gtk() { |
459 GtkWidget *frame; | |
460 GtkWidget *vbox, *hbox; | |
461 GtkWidget *toggle; | |
3517 | 462 |
3570 | 463 frame = gtk_vbox_new(FALSE, 18); |
464 gtk_container_set_border_width(GTK_CONTAINER(frame), 12); | |
465 | |
4093 | 466 vbox = make_frame(frame, _("Tray Icon Configuration")); |
3570 | 467 hbox = gtk_hbox_new(FALSE, 18); |
468 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
3517 | 469 |
3570 | 470 /* toggle = gtk_check_button_new_with_mnemonic(_("_Automatically show buddy list on sign on")); |
471 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), blist_options & OPT_BLIST_APP_BUDDY_SHOW); | |
472 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_blist_show), NULL); | |
473 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); */ | |
3517 | 474 |
4093 | 475 toggle = gtk_check_button_new_with_mnemonic(_("_Hide new messages until tray icon is clicked")); |
3570 | 476 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), away_options & OPT_AWAY_QUEUE_UNREAD); |
477 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_queue), NULL); | |
478 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
479 | |
480 gtk_widget_show_all(frame); | |
481 return frame; | |
3517 | 482 } |
3570 | 483 |
3551 | 484 struct gaim_plugin_description desc; |
485 struct gaim_plugin_description *gaim_plugin_desc() { | |
486 desc.api_version = PLUGIN_API_VERSION; | |
3773 | 487 desc.name = g_strdup(_("Tray Icon")); |
3551 | 488 desc.version = g_strdup(VERSION); |
4108 | 489 desc.description = g_strdup(_("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window. Also allows messages to be queued until the icon is clicked, similar to ICQ (although the icon doesn't flash yet =).")); |
3570 | 490 desc.authors = g_strdup(_("Robert McQueen <robot101@debian.org>")); |
3551 | 491 desc.url = g_strdup(WEBSITE); |
492 return &desc; | |
493 } | |
3510 | 494 |
3570 | 495 char *name() { |
4093 | 496 return _("System Tray Icon"); |
3510 | 497 } |
498 | |
3570 | 499 char *description() { |
4093 | 500 return _("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window. Also allows messages to be queued until the icon is clicked, similar to ICQ (although the icon doesn't flash yet =)."); |
3510 | 501 } |