Mercurial > pidgin
annotate plugins/docklet/docklet.c @ 5223:e2e5bc3ca705
[gaim-migrate @ 5593]
debug_printf -> gaim_debug
My last one for the night.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Sat, 26 Apr 2003 09:05:51 +0000 |
| parents | fefad67de2c7 |
| children | 6d1707dc8c3d |
| 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 - 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
|
24 - handle and update tooltips to show your current accounts/queued messages? |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
25 - show a count of queued messages in the unified queue |
| 3510 | 26 - dernyi's account status menu in the right click |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
27 - optional pop up notices when GNOME2's system-tray-applet supports it */ |
| 3510 | 28 |
| 29 /* includes */ | |
| 30 #include <gtk/gtk.h> | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
31 #include "gtkplugin.h" |
| 3510 | 32 #include "gaim.h" |
| 4561 | 33 #include "sound.h" |
| 3510 | 34 #include "eggtrayicon.h" |
| 4729 | 35 #include "gtklist.h" |
| 3510 | 36 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
37 #define DOCKLET_PLUGIN_ID "gtk-docklet" |
| 3867 | 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(); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
53 static gboolean plugin_unload(GaimPlugin *plugin); |
| 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; |
| 3510 | 58 static enum docklet_status status; |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
59 static enum docklet_status icon; |
| 3510 | 60 |
| 3554 | 61 static void docklet_toggle_mute(GtkWidget *toggle, void *data) { |
| 4561 | 62 gaim_sound_set_mute(GTK_CHECK_MENU_ITEM(toggle)->active); |
| 3510 | 63 } |
| 64 | |
| 3554 | 65 static void docklet_toggle_queue(GtkWidget *widget, void *data) { |
| 66 away_options ^= OPT_AWAY_QUEUE_UNREAD; | |
| 67 save_prefs(); | |
| 3510 | 68 } |
| 3570 | 69 |
| 70 /* static void docklet_toggle_blist_show(GtkWidget *widget, void *data) { | |
| 71 blist_options ^= OPT_BLIST_APP_BUDDY_SHOW; | |
| 72 save_prefs(); | |
| 73 } */ | |
| 74 | |
| 3554 | 75 static void docklet_flush_queue() { |
| 3570 | 76 if (unread_message_queue) { |
| 4274 | 77 purge_away_queue(&unread_message_queue); |
| 3570 | 78 } |
| 3510 | 79 } |
| 80 | |
| 81 static void docklet_menu(GdkEventButton *event) { | |
| 3513 | 82 static GtkWidget *menu = NULL; |
| 3512 | 83 GtkWidget *entry; |
| 3510 | 84 |
| 85 if (menu) { | |
| 86 gtk_widget_destroy(menu); | |
| 87 } | |
| 88 | |
| 89 menu = gtk_menu_new(); | |
| 90 | |
| 4157 | 91 switch (status) { |
| 92 case offline: | |
| 93 case offline_connecting: | |
| 5024 | 94 gaim_new_item_from_stock(menu, _("Auto-login"), GAIM_STOCK_SIGN_ON, G_CALLBACK(auto_login), NULL, 0, 0, NULL); |
| 4567 | 95 break; |
| 96 default: | |
| 5024 | 97 gaim_new_item_from_stock(menu, _("New Message.."), GAIM_STOCK_IM, G_CALLBACK(show_im_dialog), NULL, 0, 0, NULL); |
| 98 gaim_new_item_from_stock(menu, _("Join A Chat..."), GAIM_STOCK_CHAT, G_CALLBACK(join_chat), NULL, 0, 0, NULL); | |
| 4567 | 99 break; |
| 100 } | |
| 101 | |
| 102 switch (status) { | |
| 103 case offline: | |
| 104 case offline_connecting: | |
| 4157 | 105 break; |
| 106 case online: | |
| 107 case online_connecting: | |
| 108 case online_pending: { | |
| 3510 | 109 GtkWidget *docklet_awaymenu; |
| 110 GSList *awy = NULL; | |
| 111 struct away_message *a = NULL; | |
| 112 | |
| 113 docklet_awaymenu = gtk_menu_new(); | |
| 114 awy = away_messages; | |
| 115 | |
| 116 while (awy) { | |
| 117 a = (struct away_message *)awy->data; | |
| 118 | |
| 119 entry = gtk_menu_item_new_with_label(a->name); | |
| 3554 | 120 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_away_message), a); |
| 4635 | 121 gtk_menu_shell_append(GTK_MENU_SHELL(docklet_awaymenu), entry); |
| 3510 | 122 |
| 123 awy = g_slist_next(awy); | |
| 124 } | |
| 125 | |
| 4157 | 126 if (away_messages) |
| 127 gaim_separator(docklet_awaymenu); | |
| 3510 | 128 |
| 129 entry = gtk_menu_item_new_with_label(_("New...")); | |
| 3554 | 130 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(create_away_mess), NULL); |
| 4635 | 131 gtk_menu_shell_append(GTK_MENU_SHELL(docklet_awaymenu), entry); |
| 3510 | 132 |
| 133 entry = gtk_menu_item_new_with_label(_("Away")); | |
| 3512 | 134 gtk_menu_item_set_submenu(GTK_MENU_ITEM(entry), docklet_awaymenu); |
| 4635 | 135 gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry); |
| 4157 | 136 } break; |
| 137 case away: | |
| 138 case away_pending: | |
| 3510 | 139 entry = gtk_menu_item_new_with_label(_("Back")); |
| 3554 | 140 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_im_back), NULL); |
| 4635 | 141 gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry); |
| 4157 | 142 break; |
| 3510 | 143 } |
| 144 | |
| 4567 | 145 gaim_separator(menu); |
| 146 | |
| 147 entry = gtk_check_menu_item_new_with_label(_("Mute Sounds")); | |
| 148 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), gaim_sound_get_mute()); | |
| 149 g_signal_connect(G_OBJECT(entry), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); | |
| 4635 | 150 gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry); |
| 4567 | 151 |
| 5024 | 152 gaim_new_item_from_stock(menu, _("File Transfers..."), GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(gaim_show_xfer_dialog), NULL, 0, 0, NULL); |
| 153 gaim_new_item_from_stock(menu, _("Accounts..."), GAIM_STOCK_ACCOUNTS, G_CALLBACK(account_editor), NULL, 0, 0, NULL); | |
| 4567 | 154 gaim_new_item_from_stock(menu, _("Preferences..."), GTK_STOCK_PREFERENCES, G_CALLBACK(show_prefs), NULL, 0, 0, NULL); |
| 155 | |
| 156 gaim_separator(menu); | |
| 157 | |
| 4157 | 158 switch (status) { |
| 159 case offline: | |
| 160 case offline_connecting: | |
| 161 break; | |
| 162 default: | |
| 5024 | 163 gaim_new_item_from_stock(menu, _("Signoff"), GTK_STOCK_CLOSE, G_CALLBACK(signoff_all), NULL, 0, 0, 0); |
| 4157 | 164 break; |
| 165 } | |
| 166 | |
| 167 gaim_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(do_quit), NULL, 0, 0, 0); | |
| 3510 | 168 |
| 169 gtk_widget_show_all(menu); | |
| 170 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time); | |
| 171 } | |
| 172 | |
| 173 static void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data) { | |
| 3939 | 174 if (event->type != GDK_BUTTON_PRESS) |
| 175 return; | |
| 176 | |
| 3510 | 177 switch (event->button) { |
| 178 case 1: | |
| 3517 | 179 if (unread_message_queue) { |
| 3570 | 180 docklet_flush_queue(); |
| 3517 | 181 docklet_update_status(); |
| 3570 | 182 } else { |
| 4698 | 183 gaim_gtk_blist_docklet_toggle(); |
| 3554 | 184 } |
| 3510 | 185 break; |
| 186 case 2: | |
| 187 break; | |
| 188 case 3: | |
| 189 docklet_menu(event); | |
| 190 break; | |
| 191 } | |
| 192 } | |
| 193 | |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
194 static void docklet_update_icon() { |
|
4250
3b884e35e6b5
[gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents:
4157
diff
changeset
|
195 const gchar *icon_name = NULL; |
| 3510 | 196 |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
197 switch (icon) { |
| 4157 | 198 case offline: |
| 5024 | 199 icon_name = GAIM_STOCK_ICON_OFFLINE; |
| 4157 | 200 break; |
| 201 case offline_connecting: | |
| 202 case online_connecting: | |
| 5024 | 203 icon_name = GAIM_STOCK_ICON_CONNECT; |
| 4157 | 204 break; |
| 3510 | 205 case online: |
| 5024 | 206 icon_name = GAIM_STOCK_ICON_ONLINE; |
| 3510 | 207 break; |
| 4157 | 208 case online_pending: |
| 5024 | 209 icon_name = GAIM_STOCK_ICON_ONLINE_MSG; |
| 4157 | 210 break; |
| 3510 | 211 case away: |
| 5024 | 212 icon_name = GAIM_STOCK_ICON_AWAY; |
| 3510 | 213 break; |
| 214 case away_pending: | |
| 5024 | 215 icon_name = GAIM_STOCK_ICON_AWAY_MSG; |
| 3510 | 216 break; |
| 217 } | |
| 218 | |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
219 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
|
220 } |
| 3510 | 221 |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
222 static gboolean docklet_blink_icon() { |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
223 if (status == online_pending) { |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
224 if (status == icon) { |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
225 /* last icon was the right one... let's change it */ |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
226 icon = online; |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
227 } else { |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
228 /* last icon was the wrong one, change it back */ |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
229 icon = online_pending; |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
230 } |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
231 } else if (status == away_pending) { |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
232 if (status == icon) { |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
233 /* last icon was the right one... let's change it */ |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
234 icon = away; |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
235 } else { |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
236 /* last icon was the wrong one, change it back */ |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
237 icon = away_pending; |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
238 } |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
239 } else { |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
240 /* no messages, stop blinking */ |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
241 return FALSE; |
|
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 |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
244 docklet_update_icon(); |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
245 |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
246 return TRUE; /* keep blinking */ |
| 3510 | 247 } |
| 248 | |
| 4157 | 249 static gboolean docklet_update_status() { |
| 3510 | 250 enum docklet_status oldstatus; |
| 251 | |
| 252 oldstatus = status; | |
| 253 | |
| 254 if (connections) { | |
| 3517 | 255 if (unread_message_queue) { |
| 4157 | 256 status = online_pending; |
| 3517 | 257 } else if (awaymessage) { |
| 3510 | 258 if (message_queue) { |
| 259 status = away_pending; | |
| 260 } else { | |
| 261 status = away; | |
| 262 } | |
| 3554 | 263 } else if (connecting_count) { |
| 4157 | 264 status = online_connecting; |
| 3510 | 265 } else { |
| 266 status = online; | |
| 267 } | |
| 268 } else { | |
| 3517 | 269 if (connecting_count) { |
| 4157 | 270 status = offline_connecting; |
| 3517 | 271 } else { |
| 272 status = offline; | |
| 273 } | |
| 3510 | 274 } |
| 275 | |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
276 /* update the icon if we changed status */ |
| 3510 | 277 if (status != oldstatus) { |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
278 icon = status; |
| 3510 | 279 docklet_update_icon(); |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
280 |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
281 /* and schedule the blinker function if messages are pending */ |
|
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
282 if (status == online_pending || status == away_pending) { |
| 4274 | 283 g_timeout_add(500, docklet_blink_icon, &docklet); |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
284 } |
| 3510 | 285 } |
| 4157 | 286 |
| 287 return FALSE; /* for when we're called by the glib idle handler */ | |
| 3510 | 288 } |
| 289 | |
| 3554 | 290 static void docklet_embedded(GtkWidget *widget, void *data) { |
| 4840 | 291 debug_printf("Tray Icon: embedded\n"); |
| 4698 | 292 gaim_gtk_blist_docklet_add(); |
| 3554 | 293 } |
| 294 | |
| 4274 | 295 static void docklet_remove_callbacks() { |
| 296 debug_printf("Tray Icon: removing callbacks"); | |
| 297 | |
| 298 while (g_source_remove_by_user_data(&docklet)) { | |
| 299 debug_printf("."); | |
| 300 } | |
| 301 | |
| 302 debug_printf("\n"); | |
| 303 } | |
| 304 | |
| 3554 | 305 static void docklet_destroyed(GtkWidget *widget, void *data) { |
| 4093 | 306 debug_printf("Tray Icon: destroyed\n"); |
| 307 | |
| 4698 | 308 gaim_gtk_blist_docklet_remove(); |
| 4093 | 309 |
| 3570 | 310 docklet_flush_queue(); |
| 4093 | 311 |
| 4274 | 312 docklet_remove_callbacks(); |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
313 |
| 4093 | 314 g_object_unref(G_OBJECT(docklet)); |
| 315 docklet = NULL; | |
| 316 | |
| 4274 | 317 g_idle_add(docklet_create, &docklet); |
| 3554 | 318 } |
| 319 | |
| 4274 | 320 static gboolean docklet_create() { |
| 3510 | 321 GtkWidget *box; |
| 322 | |
| 3570 | 323 if (docklet) { |
| 4093 | 324 /* if this is being called when a tray icon exists, it's because |
| 325 something messed up. try destroying it before we proceed, | |
| 326 although docklet_refcount may be all hosed. hopefully won't happen. */ | |
| 327 debug_printf("Tray Icon: trying to create icon but it already exists?\n"); | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
328 plugin_unload(NULL); |
| 3510 | 329 } |
| 330 | |
| 331 docklet = egg_tray_icon_new("Gaim"); | |
| 332 box = gtk_event_box_new(); | |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
333 image = gtk_image_new(); |
| 3510 | 334 |
| 3554 | 335 g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_embedded), NULL); |
| 336 g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_destroyed), NULL); | |
| 337 g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_clicked), NULL); | |
| 3510 | 338 |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
339 gtk_container_add(GTK_CONTAINER(box), image); |
| 3510 | 340 gtk_container_add(GTK_CONTAINER(docklet), box); |
| 341 gtk_widget_show_all(GTK_WIDGET(docklet)); | |
| 342 | |
| 3554 | 343 /* ref the docklet before we bandy it about the place */ |
| 344 g_object_ref(G_OBJECT(docklet)); | |
| 3510 | 345 docklet_update_status(); |
| 346 docklet_update_icon(); | |
| 347 | |
| 4093 | 348 debug_printf("Tray Icon: created\n"); |
| 349 | |
| 350 return FALSE; /* for when we're called by the glib idle handler */ | |
| 3510 | 351 } |
| 352 | |
| 353 static void gaim_signon(struct gaim_connection *gc, void *data) { | |
| 354 docklet_update_status(); | |
| 355 } | |
| 356 | |
| 357 static void gaim_signoff(struct gaim_connection *gc, void *data) { | |
| 4157 | 358 /* do this when idle so that if the prpl was connecting |
| 359 and was cancelled, we register that connecting_count | |
| 360 has returned to 0 */ | |
| 4274 | 361 g_idle_add(docklet_update_status, &docklet); |
| 3510 | 362 } |
| 363 | |
| 4491 | 364 static void gaim_connecting(struct gaim_account *account, void *data) { |
| 3510 | 365 docklet_update_status(); |
| 366 } | |
| 367 | |
| 368 static void gaim_away(struct gaim_connection *gc, char *state, char *message, void *data) { | |
| 369 /* we only support global away. this is the way it is, ok? */ | |
| 370 docklet_update_status(); | |
| 371 } | |
| 372 | |
| 4274 | 373 static void gaim_im_recv(struct gaim_connection *gc, char **who, char **what, void *data) { |
| 3510 | 374 /* if message queuing while away is enabled, this event could be the first |
| 4274 | 375 message so we need to see if the status (and hence icon) needs changing. |
| 376 do this when idle so that all message processing is completed, queuing | |
| 377 etc, before we run. */ | |
| 378 g_idle_add(docklet_update_status, &docklet); | |
| 3510 | 379 } |
| 380 | |
| 3570 | 381 /* static void gaim_buddy_signon(struct gaim_connection *gc, char *who, void *data) { |
| 3510 | 382 } |
| 383 | |
| 384 static void gaim_buddy_signoff(struct gaim_connection *gc, char *who, void *data) { | |
| 385 } | |
| 386 | |
| 387 static void gaim_buddy_away(struct gaim_connection *gc, char *who, void *data) { | |
| 388 } | |
| 389 | |
| 390 static void gaim_buddy_back(struct gaim_connection *gc, char *who, void *data) { | |
| 391 } | |
| 392 | |
| 393 static void gaim_new_conversation(char *who, void *data) { | |
| 3570 | 394 } */ |
| 3510 | 395 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
396 static gboolean |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
397 plugin_load(GaimPlugin *plugin) |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
398 { |
| 4093 | 399 docklet_create(NULL); |
| 3510 | 400 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
401 gaim_signal_connect(plugin, event_signon, gaim_signon, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
402 gaim_signal_connect(plugin, event_signoff, gaim_signoff, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
403 gaim_signal_connect(plugin, event_connecting, gaim_connecting, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
404 gaim_signal_connect(plugin, event_away, gaim_away, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
405 gaim_signal_connect(plugin, event_im_recv, gaim_im_recv, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
406 /* gaim_signal_connect(plugin, event_buddy_signon, gaim_buddy_signon, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
407 gaim_signal_connect(plugin, event_buddy_signoff, gaim_buddy_signoff, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
408 gaim_signal_connect(plugin, event_buddy_away, gaim_buddy_away, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
409 gaim_signal_connect(plugin, event_buddy_back, gaim_buddy_back, NULL); |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
410 gaim_signal_connect(plugin, event_new_conversation, gaim_new_conversation, NULL); */ |
| 3510 | 411 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
412 return TRUE; |
| 3510 | 413 } |
| 414 | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
415 static gboolean |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
416 plugin_unload(GaimPlugin *plugin) |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
417 { |
| 3570 | 418 if (GTK_WIDGET_VISIBLE(docklet)) { |
| 4698 | 419 gaim_gtk_blist_docklet_remove(); |
| 3570 | 420 } |
| 3554 | 421 |
| 3570 | 422 docklet_flush_queue(); |
| 3554 | 423 |
| 4274 | 424 docklet_remove_callbacks(); |
|
4261
e252238f99df
[gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents:
4250
diff
changeset
|
425 |
| 3570 | 426 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL); |
| 427 gtk_widget_destroy(GTK_WIDGET(docklet)); | |
| 3554 | 428 |
| 4093 | 429 g_object_unref(G_OBJECT(docklet)); |
| 430 docklet = NULL; | |
| 431 | |
| 4567 | 432 /* do this while gaim has no other way to toggle the global mute */ |
| 433 gaim_sound_set_mute(FALSE); | |
| 434 | |
| 4093 | 435 debug_printf("Tray Icon: removed\n"); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
436 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
437 return TRUE; |
| 3554 | 438 } |
| 439 | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
440 static GtkWidget * |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
441 get_config_frame(GaimPlugin *plugin) |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
442 { |
| 3570 | 443 GtkWidget *frame; |
| 444 GtkWidget *vbox, *hbox; | |
| 445 GtkWidget *toggle; | |
| 3517 | 446 |
| 3570 | 447 frame = gtk_vbox_new(FALSE, 18); |
| 448 gtk_container_set_border_width(GTK_CONTAINER(frame), 12); | |
| 449 | |
| 4093 | 450 vbox = make_frame(frame, _("Tray Icon Configuration")); |
| 3570 | 451 hbox = gtk_hbox_new(FALSE, 18); |
| 452 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
| 3517 | 453 |
| 3570 | 454 /* toggle = gtk_check_button_new_with_mnemonic(_("_Automatically show buddy list on sign on")); |
| 455 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), blist_options & OPT_BLIST_APP_BUDDY_SHOW); | |
| 456 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_blist_show), NULL); | |
| 457 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); */ | |
| 3517 | 458 |
| 4093 | 459 toggle = gtk_check_button_new_with_mnemonic(_("_Hide new messages until tray icon is clicked")); |
| 3570 | 460 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), away_options & OPT_AWAY_QUEUE_UNREAD); |
| 461 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_queue), NULL); | |
| 462 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 463 | |
| 464 gtk_widget_show_all(frame); | |
| 465 return frame; | |
| 3517 | 466 } |
| 3570 | 467 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
468 static GaimGtkPluginUiInfo ui_info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
469 { |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
470 get_config_frame |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
471 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
472 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
473 static GaimPluginInfo info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
474 { |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
475 2, /**< api_version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
476 GAIM_PLUGIN_STANDARD, /**< type */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
477 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
478 0, /**< flags */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
479 NULL, /**< dependencies */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
480 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
481 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
482 DOCKLET_PLUGIN_ID, /**< id */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
483 N_("System Tray Icon"), /**< name */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
484 VERSION, /**< version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
485 /** summary */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
486 N_("Displays an icon for Gaim in the system tray."), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
487 /** description */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
488 N_("Interacts with a Notification Area applet (in GNOME or KDE, " |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
489 "for example) to display the current status of Gaim, allow fast " |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
490 "access to commonly used functions, and to toggle display of the " |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
491 "buddy list or login window. Also allows messages to be queued " |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
492 "until the icon is clicked, similar to ICQ."), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
493 "Robert McQueen <robot101@debian.org>", /**< author */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
494 WEBSITE, /**< homepage */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
495 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
496 plugin_load, /**< load */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
497 plugin_unload, /**< unload */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
498 NULL, /**< destroy */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
499 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
500 &ui_info, /**< ui_info */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
501 NULL /**< extra_info */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
502 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
503 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
504 static void |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
505 __init_plugin(GaimPlugin *plugin) |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
506 { |
| 3551 | 507 } |
| 3510 | 508 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
509 GAIM_INIT_PLUGIN(docklet, __init_plugin, info); |
