Mercurial > pidgin
comparison plugins/docklet/docklet.c @ 6485:70d5122bc3ff
[gaim-migrate @ 6999]
Removed the old event system and replaced it with a much better signal
system. There will most likely be some bugs in this, but it seems to be
working for now. Plugins can now generate their own signals, and other
plugins can find those plugins and connect to them. This could give
plugins a form of IPC. It's also useful for other things. It's rather
flexible, except for the damn marshalling, but there's no way around that
that I or the glib people can see.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 18 Aug 2003 01:03:43 +0000 |
parents | 8f94cce8faa5 |
children | c2fb9192377b |
comparison
equal
deleted
inserted
replaced
6484:5ced8e111473 | 6485:70d5122bc3ff |
---|---|
1 /* | 1 /* |
2 * System tray icon (aka docklet) plugin for Gaim | 2 * System tray icon (aka docklet) plugin for Gaim |
3 * | 3 * |
4 * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> | 4 * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> |
5 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> | 5 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> |
6 * Inspired by a similar plugin by: | 6 * Inspired by a similar plugin by: |
7 * John (J5) Palmieri <johnp@martianrock.com> | 7 * John (J5) Palmieri <johnp@martianrock.com> |
8 * | 8 * |
9 * This program is free software; you can redistribute it and/or | 9 * This program is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU General Public License as | 10 * modify it under the terms of the GNU General Public License as |
11 * published by the Free Software Foundation; either version 2 of the | 11 * published by the Free Software Foundation; either version 2 of the |
12 * License, or (at your option) any later version. | 12 * License, or (at your option) any later version. |
13 * | 13 * |
14 * This program is distributed in the hope that it will be useful, but | 14 * This program is distributed in the hope that it will be useful, but |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 * General Public License for more details. | 17 * General Public License for more details. |
18 * | 18 * |
19 * You should have received a copy of the GNU General Public License | 19 * You should have received a copy of the GNU General Public License |
20 * along with this program; if not, write to the Free Software | 20 * along with this program; if not, write to the Free Software |
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
22 * 02111-1307, USA. | 22 * 02111-1307, USA. |
23 */ | 23 */ |
33 #include "gtkinternal.h" | 33 #include "gtkinternal.h" |
34 | 34 |
35 #include "core.h" | 35 #include "core.h" |
36 #include "debug.h" | 36 #include "debug.h" |
37 #include "prefs.h" | 37 #include "prefs.h" |
38 #include "signals.h" | |
38 #include "sound.h" | 39 #include "sound.h" |
39 | 40 |
40 #include "gtkaccount.h" | 41 #include "gtkaccount.h" |
41 #include "gtkblist.h" | 42 #include "gtkblist.h" |
42 #include "gtkft.h" | 43 #include "gtkft.h" |
370 { | 371 { |
371 docklet_update_status(); | 372 docklet_update_status(); |
372 } | 373 } |
373 | 374 |
374 static void | 375 static void |
375 gaim_away(GaimConnection *gc, char *state, char *message, void *data) | 376 gaim_away(GaimAccount *account, char *state, char *message, void *data) |
376 { | 377 { |
377 /* we only support global away. this is the way it is, ok? */ | 378 /* we only support global away. this is the way it is, ok? */ |
378 docklet_update_status(); | 379 docklet_update_status(); |
379 } | 380 } |
380 | 381 |
381 static void | 382 static gboolean |
382 gaim_im_recv(GaimConnection *gc, char **who, char **what, void *data) | 383 gaim_im_recv(GaimAccount *account, GaimConversation *conv, char **who, |
384 char **what, int *flags, void *data) | |
383 { | 385 { |
384 /* if message queuing while away is enabled, this event could be the first | 386 /* if message queuing while away is enabled, this event could be the first |
385 message so we need to see if the status (and hence icon) needs changing. | 387 message so we need to see if the status (and hence icon) needs changing. |
386 do this when idle so that all message processing is completed, queuing | 388 do this when idle so that all message processing is completed, queuing |
387 etc, before we run. */ | 389 etc, before we run. */ |
388 g_idle_add(docklet_update_status, &handle); | 390 g_idle_add(docklet_update_status, &handle); |
389 } | 391 |
390 | 392 return FALSE; |
391 static void | 393 } |
392 gaim_new_conversation(char *who, void *data) | 394 |
395 static void | |
396 gaim_new_conversation(GaimConversation *conv, void *data) | |
393 { | 397 { |
394 /* queue a callback here so if the queue is being | 398 /* queue a callback here so if the queue is being |
395 flushed, we stop flashing. thanks javabsp. */ | 399 flushed, we stop flashing. thanks javabsp. */ |
396 g_idle_add(docklet_update_status, &handle); | 400 g_idle_add(docklet_update_status, &handle); |
397 } | 401 } |
413 #define DOCKLET_PLUGIN_ID "gtk-docklet" | 417 #define DOCKLET_PLUGIN_ID "gtk-docklet" |
414 | 418 |
415 static gboolean | 419 static gboolean |
416 plugin_load(GaimPlugin *plugin) | 420 plugin_load(GaimPlugin *plugin) |
417 { | 421 { |
422 void *conn_handle = gaim_connections_get_handle(); | |
423 void *conv_handle = gaim_conversations_get_handle(); | |
424 void *accounts_handle = gaim_accounts_get_handle(); | |
425 | |
418 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "plugin loaded\n"); | 426 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "plugin loaded\n"); |
419 | 427 |
420 handle = plugin; | 428 handle = plugin; |
421 | 429 |
422 docklet_ui_init(); | 430 docklet_ui_init(); |
423 if (ui_ops->create) | 431 if (ui_ops->create) |
424 ui_ops->create(); | 432 ui_ops->create(); |
425 | 433 |
426 gaim_signal_connect(plugin, event_signon, gaim_signon, NULL); | 434 gaim_signal_connect(conn_handle, "signed-on", |
427 gaim_signal_connect(plugin, event_signoff, gaim_signoff, NULL); | 435 plugin, GAIM_CALLBACK(gaim_signon), NULL); |
428 gaim_signal_connect(plugin, event_connecting, gaim_connecting, NULL); | 436 gaim_signal_connect(conn_handle, "signed-off", |
429 gaim_signal_connect(plugin, event_away, gaim_away, NULL); | 437 plugin, GAIM_CALLBACK(gaim_signoff), NULL); |
430 gaim_signal_connect(plugin, event_im_recv, gaim_im_recv, NULL); | 438 gaim_signal_connect(accounts_handle, "account-connecting", |
431 gaim_signal_connect(plugin, event_new_conversation, gaim_new_conversation, NULL); | 439 plugin, GAIM_CALLBACK(gaim_connecting), NULL); |
440 gaim_signal_connect(accounts_handle, "account-away", | |
441 plugin, GAIM_CALLBACK(gaim_away), NULL); | |
442 gaim_signal_connect(conv_handle, "received-im-msg", | |
443 plugin, GAIM_CALLBACK(gaim_im_recv), NULL); | |
444 gaim_signal_connect(conv_handle, "conversation-created", | |
445 plugin, GAIM_CALLBACK(gaim_new_conversation), NULL); | |
446 | |
432 /* gaim_signal_connect(plugin, event_buddy_signon, gaim_buddy_signon, NULL); | 447 /* gaim_signal_connect(plugin, event_buddy_signon, gaim_buddy_signon, NULL); |
433 gaim_signal_connect(plugin, event_buddy_signoff, gaim_buddy_signoff, NULL); | 448 gaim_signal_connect(plugin, event_buddy_signoff, gaim_buddy_signoff, NULL); |
434 gaim_signal_connect(plugin, event_buddy_away, gaim_buddy_away, NULL); | 449 gaim_signal_connect(plugin, event_buddy_away, gaim_buddy_away, NULL); |
435 gaim_signal_connect(plugin, event_buddy_back, gaim_buddy_back, NULL); */ | 450 gaim_signal_connect(plugin, event_buddy_back, gaim_buddy_back, NULL); */ |
436 | 451 |