annotate console/plugins/gntgf.c @ 15666:6eda87b08cdf

Don't access the list element after it has been freed.
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 19 Feb 2007 16:09:25 +0000
parents 42961709cb30
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /**
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 * @file gntgf.c Minimal toaster plugin in Gnt.
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2006 Sadrul Habib Chowdhury <sadrul@users.sourceforge.net>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * (at your option) any later version.
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * GNU General Public License for more details.
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 */
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
21
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
22 #include "internal.h"
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 #define PLUGIN_STATIC_NAME "GntGf"
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
26 #define PREFS_PREFIX "/plugins/gnt/gntgf"
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
27 #define PREFS_EVENT PREFS_PREFIX "/events"
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 #define PREFS_EVENT_SIGNONF PREFS_EVENT "/signonf"
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #define PREFS_EVENT_IM_MSG PREFS_EVENT "/immsg"
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #define PREFS_EVENT_CHAT_MSG PREFS_EVENT "/chatmsg"
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #define PREFS_EVENT_CHAT_NICK PREFS_EVENT "/chatnick"
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
32 #define PREFS_BEEP PREFS_PREFIX "/beep"
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
34 #define MAX_COLS 3
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
35
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
36 #ifdef HAVE_X11
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
37 #define PREFS_URGENT PREFS_PREFIX "/urgent"
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
38
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
39 #include <X11/Xlib.h>
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
40 #include <X11/Xutil.h>
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
41 #endif
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
42
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 #include <glib.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 #include <plugin.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 #include <version.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 #include <blist.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 #include <conversation.h>
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
49 #include <debug.h>
14146
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
50 #include <util.h>
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 #include <gnt.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 #include <gntbox.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 #include <gntbutton.h>
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
55 #include <gntcheckbox.h>
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 #include <gntlabel.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 #include <gnttree.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 #include <gntplugin.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 typedef struct
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 GntWidget *window;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 int timer;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
65 int column;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 } GntToast;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 static GList *toasters;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
69 static int gpsy[MAX_COLS];
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
70 static int gpsw[MAX_COLS];
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 destroy_toaster(GntToast *toast)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 toasters = g_list_remove(toasters, toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 gnt_widget_destroy(toast->window);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 g_source_remove(toast->timer);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 g_free(toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 static gboolean
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 remove_toaster(GntToast *toast)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 GList *iter;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 int h;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
86 int col;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
87 int nwin[MAX_COLS];
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 gnt_widget_get_size(toast->window, NULL, &h);
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
90 gpsy[toast->column] -= h;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
91 col = toast->column;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
93 memset(&nwin, 0, sizeof(nwin));
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 destroy_toaster(toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 for (iter = toasters; iter; iter = iter->next)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 int x, y;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 toast = iter->data;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
100 nwin[toast->column]++;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
101 if (toast->column != col) continue;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 gnt_widget_get_position(toast->window, &x, &y);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 y += h;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 gnt_screen_move_widget(toast->window, x, y);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
107 if (nwin[col] == 0)
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
108 gpsw[col] = 0;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
109
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 return FALSE;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
113 #ifdef HAVE_X11
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
114 static void
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
115 urgent()
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
116 {
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
117 /* This is from deryni/tuomov's urgent_test.c */
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
118 Display *dpy;
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
119 Window id;
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
120 const char *ids;
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
121 XWMHints *hints;
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
122
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
123 ids = getenv("WINDOWID");
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
124 if (ids == NULL)
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
125 return;
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
126
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
127 id = atoi(ids);
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
128
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
129 dpy = XOpenDisplay(NULL);
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
130 if (dpy == NULL)
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
131 return;
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
132
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
133 hints = XGetWMHints(dpy, id);
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
134 hints->flags|=XUrgencyHint;
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
135 XSetWMHints(dpy, id, hints);
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
136
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
137 XFlush(dpy);
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
138 XCloseDisplay(dpy);
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
139 }
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
140 #endif
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
141
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 notify(const char *fmt, ...)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 GntWidget *window;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
146 GntToast *toast;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 char *str;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
148 int h, w, i;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 va_list args;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
151 if (gaim_prefs_get_bool(PREFS_BEEP))
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
152 beep();
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
153 #ifdef HAVE_X11
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
154 if (gaim_prefs_get_bool(PREFS_URGENT))
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
155 urgent();
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
156 #endif
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
157
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
158 window = gnt_vbox_new(FALSE);
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 GNT_WIDGET_UNSET_FLAGS(window, GNT_WIDGET_NO_BORDER);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 va_start(args, fmt);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 str = g_strdup_vprintf(fmt, args);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 va_end(args);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 gnt_box_add_widget(GNT_BOX(window),
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 gnt_label_new_with_format(str, GNT_TEXT_FLAG_HIGHLIGHT));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 g_free(str);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 gnt_widget_size_request(window);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 gnt_widget_get_size(window, &w, &h);
14305
fd46a9845fc2 [gaim-migrate @ 16995]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14303
diff changeset
172 for (i = 0; i < MAX_COLS && gpsy[i] + h >= getmaxy(stdscr) ; ++i)
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
173 ;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
174 if (i >= MAX_COLS) {
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
175 gaim_debug_warning("GntGf", "Dude, that's way too many popups\n");
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
176 gnt_widget_destroy(window);
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
177 return;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
178 }
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
179
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
180 toast = g_new0(GntToast, 1);
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
181 toast->window = window;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
182 toast->column = i;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
183 gpsy[i] += h;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
184 if (w > gpsw[i]) {
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
185 if (i == 0)
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
186 gpsw[i] = w;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
187 else
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
188 gpsw[i] = gpsw[i - 1] + w + 1;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
189 }
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
190
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
191 if (i == 0 || (w + gpsw[i - 1] >= getmaxx(stdscr))) {
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
192 /* if it's going to be too far left, overlap. */
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
193 gnt_widget_set_position(window, getmaxx(stdscr) - w - 1,
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
194 getmaxy(stdscr) - gpsy[i] - 1);
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
195 } else {
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
196 gnt_widget_set_position(window, getmaxx(stdscr) - gpsw[i - 1] - w - 1,
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
197 getmaxy(stdscr) - gpsy[i] - 1);
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
198 }
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 gnt_widget_draw(window);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 toast->timer = g_timeout_add(4000, (GSourceFunc)remove_toaster, toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 toasters = g_list_prepend(toasters, toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 buddy_signed_on(GaimBuddy *buddy, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 if (gaim_prefs_get_bool(PREFS_EVENT_SIGNONF))
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 notify(_("%s just signed on"), gaim_buddy_get_alias(buddy));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 buddy_signed_off(GaimBuddy *buddy, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 if (gaim_prefs_get_bool(PREFS_EVENT_SIGNONF))
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 notify(_("%s just signed off"), gaim_buddy_get_alias(buddy));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 received_im_msg(GaimAccount *account, const char *sender, const char *msg,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 GaimConversation *conv, GaimMessageFlags flags, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 if (gaim_prefs_get_bool(PREFS_EVENT_IM_MSG))
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 notify(_("%s sent you a message"), sender);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 received_chat_msg(GaimAccount *account, const char *sender, const char *msg,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 GaimConversation *conv, GaimMessageFlags flags, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 {
14146
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
231 const char *nick;
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
232
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
233 if (flags & GAIM_MESSAGE_WHISPER)
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
234 return;
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
235
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
236 nick = GAIM_CONV_CHAT(conv)->nick;
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
237
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
238 if (g_utf8_collate(sender, nick) == 0)
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
239 return;
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
240
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
241 if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_NICK) &&
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
242 (gaim_utf8_has_word(msg, nick)))
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 notify(_("%s said your nick in %s"), sender, gaim_conversation_get_name(conv));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 else if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_MSG))
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245 notify(_("%s sent a message in %s"), sender, gaim_conversation_get_name(conv));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 static gboolean
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 plugin_load(GaimPlugin *plugin)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", plugin,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 GAIM_CALLBACK(buddy_signed_on), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", plugin,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 GAIM_CALLBACK(buddy_signed_off), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", plugin,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 GAIM_CALLBACK(received_im_msg), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 gaim_signal_connect(gaim_conversations_get_handle(), "received-chat-msg", plugin,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 GAIM_CALLBACK(received_chat_msg), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
260 memset(&gpsy, 0, sizeof(gpsy));
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
261 memset(&gpsw, 0, sizeof(gpsw));
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 return TRUE;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 static gboolean
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267 plugin_unload(GaimPlugin *plugin)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 while (toasters)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 GntToast *toast = toasters->data;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272 destroy_toaster(toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 return TRUE;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 static struct
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 char *pref;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 char *display;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281 } prefs[] =
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282 {
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
283 {PREFS_EVENT_SIGNONF, N_("Buddy signs on/off")},
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
284 {PREFS_EVENT_IM_MSG, N_("You receive an IM")},
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
285 {PREFS_EVENT_CHAT_MSG, N_("Someone speaks in a chat")},
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
286 {PREFS_EVENT_CHAT_NICK, N_("Someone says your name in a chat")},
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 {NULL, NULL}
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288 };
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291 pref_toggled(GntTree *tree, char *key, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 gaim_prefs_set_bool(key, gnt_tree_get_choice(tree, key));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
296 static void
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
297 toggle_option(GntCheckBox *check, gpointer str)
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
298 {
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
299 gaim_prefs_set_bool(str, gnt_check_box_get_checked(check));
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
300 }
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
301
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 static GntWidget *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 config_frame()
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304 {
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
305 GntWidget *window, *tree, *check;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306 int i;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 window = gnt_vbox_new(FALSE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309 gnt_box_set_pad(GNT_BOX(window), 0);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
310 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311 gnt_box_set_fill(GNT_BOX(window), TRUE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 gnt_box_add_widget(GNT_BOX(window),
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 gnt_label_new(_("Notify with a toaster when")));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 tree = gnt_tree_new();
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317 gnt_box_add_widget(GNT_BOX(window), tree);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319 for (i = 0; prefs[i].pref; i++)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
320 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321 gnt_tree_add_choice(GNT_TREE(tree), prefs[i].pref,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
322 gnt_tree_create_row(GNT_TREE(tree), prefs[i].display), NULL, NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
323 gnt_tree_set_choice(GNT_TREE(tree), prefs[i].pref,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
324 gaim_prefs_get_bool(prefs[i].pref));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
326 gnt_tree_set_col_width(GNT_TREE(tree), 0, 40);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
327 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(pref_toggled), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
329 check = gnt_check_box_new(_("Beep too!"));
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
330 gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_BEEP));
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
331 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(toggle_option), PREFS_BEEP);
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
332 gnt_box_add_widget(GNT_BOX(window), check);
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
333
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
334 #ifdef HAVE_X11
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
335 check = gnt_check_box_new(_("Set URGENT for the terminal window."));
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
336 gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_URGENT));
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
337 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(toggle_option), PREFS_URGENT);
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
338 gnt_box_add_widget(GNT_BOX(window), check);
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
339 #endif
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
340
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
341 return window;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
342 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
343
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
344 static GaimPluginInfo info =
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
345 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
346 GAIM_PLUGIN_MAGIC,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
347 GAIM_MAJOR_VERSION,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
348 GAIM_MINOR_VERSION,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
349 GAIM_PLUGIN_STANDARD,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
350 GAIM_GNT_PLUGIN_TYPE,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
351 0,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
352 NULL,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
353 GAIM_PRIORITY_DEFAULT,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
354 "gntgf",
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
355 N_("GntGf"),
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
356 VERSION,
15437
42961709cb30 This should be the last of the string changes
Sean Egan <seanegan@gmail.com>
parents: 14843
diff changeset
357 N_("Toaster plugin"),
42961709cb30 This should be the last of the string changes
Sean Egan <seanegan@gmail.com>
parents: 14843
diff changeset
358 N_("Toaster plugin"),
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
359 "Sadrul H Chowdhury <sadrul@users.sourceforge.net>",
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
360 "http://gaim.sourceforge.net",
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
361 plugin_load,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
362 plugin_unload,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
363 NULL,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
364 config_frame,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
365 NULL,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
366 NULL,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
367 NULL
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
368 };
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
369
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
370 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
371 init_plugin(GaimPlugin *plugin)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
372 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
373 gaim_prefs_add_none("/plugins");
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
374 gaim_prefs_add_none("/plugins/gnt");
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
375
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
376 gaim_prefs_add_none("/plugins/gnt/gntgf");
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
377 gaim_prefs_add_none(PREFS_EVENT);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
378
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
379 gaim_prefs_add_bool(PREFS_EVENT_SIGNONF, TRUE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
380 gaim_prefs_add_bool(PREFS_EVENT_IM_MSG, TRUE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
381 gaim_prefs_add_bool(PREFS_EVENT_CHAT_MSG, TRUE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
382 gaim_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE);
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
383
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
384 gaim_prefs_add_bool(PREFS_BEEP, TRUE);
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
385 #ifdef HAVE_X11
14400
080b16e08b2b [gaim-migrate @ 17108]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
386 gaim_prefs_add_bool(PREFS_URGENT, FALSE);
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14305
diff changeset
387 #endif
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
388 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
389
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
390 GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)