[gaim-migrate @ 2949]
[pidgin-git.git] / plugins / notify.c
blob15e6173c796ccbc168ac52611eea737a0a7ecc5c
1 #define GAIM_PLUGINS
2 #include "gaim.h"
4 #include <gtk/gtk.h>
5 #include <string.h>
7 void *handle;
9 void received_im(struct gaim_connection *gc, char **who, char **what, void *m) {
10 char buf[256];
11 struct conversation *cnv = find_conversation(*who);
12 GtkWindow *win;
13 char *me = g_strdup(normalize(gc->username));
15 if (!strcmp(me, normalize(*who))) {
16 g_free(me);
17 return;
19 g_free(me);
21 if (cnv == NULL)
23 if (away_options & OPT_AWAY_QUEUE)
24 return;
26 cnv = new_conversation(*who);
29 win = (GtkWindow *)cnv->window;
31 g_snprintf(buf, sizeof(buf), "%s", win->title);
32 if (!strstr(buf, "(*) ")) {
33 g_snprintf(buf, sizeof(buf), "(*) %s", win->title);
34 gtk_window_set_title(win, buf);
38 void sent_im(struct gaim_connection *gc, char *who, char **what, void *m) {
39 char buf[256];
40 struct conversation *c = find_conversation(who);
41 GtkWindow *win = (GtkWindow *)c->window;
43 g_snprintf(buf, sizeof(buf), "%s", win->title);
44 if (strstr(buf, "(*) ")) {
45 g_snprintf(buf, sizeof(buf), "%s", &win->title[4]);
46 gtk_window_set_title(win, buf);
50 char *gaim_plugin_init(GModule *hndl) {
51 handle = hndl;
53 gaim_signal_connect(handle, event_im_recv, received_im, NULL);
54 gaim_signal_connect(handle, event_im_send, sent_im, NULL);
56 return NULL;
59 char *name() {
60 return "Visual Notification";
63 char *description() {
64 return "Puts an asterisk in the title bar of all conversations"
65 " where you have not responded to a message yet.";