Mercurial > pidgin.yaz
comparison plugins/ticker/ticker.c @ 6122:914f2d5da21c
[gaim-migrate @ 6596]
Fix 2 compiler warnings.
Make auto-login for IRC accounts without passwords work. Thanks to Luke for
finding this and making a kick-assingly correct guess as to the cause.
Fix the MSN sign-off-infinite-loops-after-getting-info-about-mail bug.
Fix "Yahoo smilies for the "angel" smiley are incorrect"
http://sourceforge.net/tracker/index.php?func=detail&aid=728663&group_id=235&atid=100235
Fix a bug that I introduced yesterday freaking afternoon. I would have
commited the fix yesterday, but SF CVS was not working.
<faceprint> KingAnt: you just broke the ticker
<KingAnt> faceprint: How so?
<KingAnt> Oh, event_signon?
<faceprint> the ticker is what needs event_buddy_signon to get called twice
<faceprint> i don't know what is the right behavior, but i'm in bootloader hell,
just thought i'd alert you
<KingAnt> faceprint: So that it doesn't always show people with the open door?
<faceprint> KingAnt: right
I just added an ugly little timeout that updates the icon after 11 seconds.
The icon in the blist gets updated after 10.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 14 Jul 2003 22:09:42 +0000 |
parents | 5239a3b4ab33 |
children | 8f94cce8faa5 |
comparison
equal
deleted
inserted
replaced
6121:37c679a484c9 | 6122:914f2d5da21c |
---|---|
1 /* GTK - The GIMP Toolkit | 1 /* |
2 * Gaim Ticker Plugin | |
3 * The line below doesn't apply at all, does it? It should be Syd, Sean, and | |
4 * maybe Nathan, I believe. | |
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald | 5 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
3 * | 6 * |
4 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
41 typedef struct { | 44 typedef struct { |
42 struct buddy *buddy; | 45 struct buddy *buddy; |
43 GtkWidget *ebox; | 46 GtkWidget *ebox; |
44 GtkWidget *label; | 47 GtkWidget *label; |
45 GtkWidget *icon; | 48 GtkWidget *icon; |
49 guint timeout; | |
46 } TickerData; | 50 } TickerData; |
47 | 51 |
48 GList *tickerbuds = NULL; | 52 GList *tickerbuds = NULL; |
49 | 53 |
50 static gboolean buddy_ticker_destroy_window(GtkWidget *window, | 54 static gboolean buddy_ticker_destroy_window(GtkWidget *window, |
110 GAIM_STATUS_ICON_SMALL); | 114 GAIM_STATUS_ICON_SMALL); |
111 gtk_image_set_from_pixbuf(GTK_IMAGE(td->icon), pixbuf); | 115 gtk_image_set_from_pixbuf(GTK_IMAGE(td->icon), pixbuf); |
112 g_object_unref(G_OBJECT(pixbuf)); | 116 g_object_unref(G_OBJECT(pixbuf)); |
113 } | 117 } |
114 | 118 |
119 static gboolean buddy_ticker_set_pixmap_cb(gpointer data) { | |
120 TickerData *td = data; | |
121 | |
122 gaim_debug(GAIM_DEBUG_ERROR, "XXX", "we're updating the pixmap, you bitch\n"); | |
123 buddy_ticker_set_pixmap(td->buddy); | |
124 td->timeout = 0; | |
125 | |
126 return FALSE; | |
127 } | |
128 | |
115 static void buddy_ticker_add_buddy(struct buddy *b) { | 129 static void buddy_ticker_add_buddy(struct buddy *b) { |
116 GtkWidget *hbox; | 130 GtkWidget *hbox; |
117 TickerData *td; | 131 TickerData *td; |
118 | 132 |
119 buddy_ticker_create_window(); | 133 buddy_ticker_create_window(); |
120 | 134 |
121 if (!ticker) | 135 if (!ticker) |
122 return; | 136 return; |
123 | 137 |
124 if(buddy_ticker_find_buddy(b)) | 138 if (buddy_ticker_find_buddy(b)) |
125 return; | 139 return; |
126 | 140 |
127 td = g_new0(TickerData, 1); | 141 td = g_new0(TickerData, 1); |
128 td->buddy = b; | 142 td->buddy = b; |
129 tickerbuds = g_list_append(tickerbuds, td); | 143 tickerbuds = g_list_append(tickerbuds, td); |
141 td->label = gtk_label_new(gaim_get_buddy_alias(b)); | 155 td->label = gtk_label_new(gaim_get_buddy_alias(b)); |
142 gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 5); | 156 gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 5); |
143 | 157 |
144 gtk_widget_show_all(td->ebox); | 158 gtk_widget_show_all(td->ebox); |
145 gtk_widget_show(tickerwindow); | 159 gtk_widget_show(tickerwindow); |
160 | |
161 /* | |
162 * Update the icon in a few seconds (after the open door icon has | |
163 * changed). This is somewhat ugly. | |
164 */ | |
165 td->timeout = g_timeout_add(11000, buddy_ticker_set_pixmap_cb, td); | |
146 } | 166 } |
147 | 167 |
148 static void buddy_ticker_remove_buddy(struct buddy *b) { | 168 static void buddy_ticker_remove_buddy(struct buddy *b) { |
149 TickerData *td = buddy_ticker_find_buddy(b); | 169 TickerData *td = buddy_ticker_find_buddy(b); |
150 | 170 |
154 /* pop up the ticker window again */ | 174 /* pop up the ticker window again */ |
155 buddy_ticker_create_window(); | 175 buddy_ticker_create_window(); |
156 | 176 |
157 gtk_ticker_remove(GTK_TICKER(ticker), td->ebox); | 177 gtk_ticker_remove(GTK_TICKER(ticker), td->ebox); |
158 tickerbuds = g_list_remove(tickerbuds, td); | 178 tickerbuds = g_list_remove(tickerbuds, td); |
179 if (td->timeout != 0) | |
180 g_source_remove(td->timeout); | |
159 g_free(td); | 181 g_free(td); |
160 } | 182 } |
161 | 183 |
162 static void buddy_ticker_show() | 184 static void buddy_ticker_show() |
163 { | 185 { |
179 buddy_ticker_add_buddy(b); | 201 buddy_ticker_add_buddy(b); |
180 } | 202 } |
181 } | 203 } |
182 } | 204 } |
183 | 205 |
184 void signon_cb(GaimConnection *gc, char *who) { | |
185 struct buddy *b = gaim_find_buddy(gc->account, who); | |
186 if(buddy_ticker_find_buddy(b)) | |
187 buddy_ticker_set_pixmap(b); | |
188 else | |
189 buddy_ticker_add_buddy(b); | |
190 } | |
191 | |
192 void signoff_cb(GaimConnection *gc) { | 206 void signoff_cb(GaimConnection *gc) { |
207 TickerData *td; | |
193 if (!gaim_connections_get_all()) { | 208 if (!gaim_connections_get_all()) { |
194 while(tickerbuds) { | 209 while (tickerbuds) { |
195 g_free(tickerbuds->data); | 210 td = tickerbuds->data; |
196 tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); | 211 tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); |
212 if (td->timeout != 0) | |
213 g_source_remove(td->timeout); | |
214 g_free(td); | |
197 } | 215 } |
198 gtk_widget_destroy(tickerwindow); | 216 gtk_widget_destroy(tickerwindow); |
199 tickerwindow = NULL; | 217 tickerwindow = NULL; |
200 ticker = NULL; | 218 ticker = NULL; |
201 } else { | 219 } else { |
202 GList *t = tickerbuds; | 220 GList *t = tickerbuds; |
203 while(t) { | 221 while (t) { |
204 TickerData *td = t->data; | 222 td = t->data; |
205 t = t->next; | 223 t = t->next; |
206 if(td->buddy->account == gc->account) { | 224 if (td->buddy->account == gc->account) { |
225 tickerbuds = g_list_remove(tickerbuds, td); | |
226 if (td->timeout != 0) | |
227 g_source_remove(td->timeout); | |
207 g_free(td); | 228 g_free(td); |
208 tickerbuds = g_list_remove(tickerbuds, td); | |
209 } | 229 } |
210 } | 230 } |
211 } | 231 } |
212 } | 232 } |
213 | 233 |
234 void buddy_signon_cb(GaimConnection *gc, char *who) { | |
235 struct buddy *b = gaim_find_buddy(gc->account, who); | |
236 if(buddy_ticker_find_buddy(b)) | |
237 buddy_ticker_set_pixmap(b); | |
238 else | |
239 buddy_ticker_add_buddy(b); | |
240 } | |
241 | |
214 void buddy_signoff_cb(GaimConnection *gc, char *who) { | 242 void buddy_signoff_cb(GaimConnection *gc, char *who) { |
215 struct buddy *b = gaim_find_buddy(gc->account, who); | 243 struct buddy *b = gaim_find_buddy(gc->account, who); |
216 | |
217 buddy_ticker_remove_buddy(b); | 244 buddy_ticker_remove_buddy(b); |
218 if(!tickerbuds) | 245 if(!tickerbuds) |
219 gtk_widget_hide(tickerwindow); | 246 gtk_widget_hide(tickerwindow); |
220 } | 247 } |
221 | 248 |
232 */ | 259 */ |
233 | 260 |
234 static gboolean | 261 static gboolean |
235 plugin_load(GaimPlugin *plugin) | 262 plugin_load(GaimPlugin *plugin) |
236 { | 263 { |
237 gaim_signal_connect(plugin, event_buddy_signon, signon_cb, NULL); | |
238 gaim_signal_connect(plugin, event_signoff, signoff_cb, NULL); | 264 gaim_signal_connect(plugin, event_signoff, signoff_cb, NULL); |
265 gaim_signal_connect(plugin, event_buddy_signon, buddy_signon_cb, NULL); | |
239 gaim_signal_connect(plugin, event_buddy_signoff, buddy_signoff_cb, NULL); | 266 gaim_signal_connect(plugin, event_buddy_signoff, buddy_signoff_cb, NULL); |
240 gaim_signal_connect(plugin, event_buddy_away, away_cb, NULL); | 267 gaim_signal_connect(plugin, event_buddy_away, away_cb, NULL); |
241 gaim_signal_connect(plugin, event_buddy_back, away_cb, NULL); | 268 gaim_signal_connect(plugin, event_buddy_back, away_cb, NULL); |
242 | 269 |
243 if (gaim_connections_get_all()) | 270 if (gaim_connections_get_all()) |
247 } | 274 } |
248 | 275 |
249 static gboolean | 276 static gboolean |
250 plugin_unload(GaimPlugin *plugin) | 277 plugin_unload(GaimPlugin *plugin) |
251 { | 278 { |
252 while(tickerbuds) { | 279 TickerData *td; |
253 g_free(tickerbuds->data); | 280 |
281 while (tickerbuds) { | |
282 td = tickerbuds->data; | |
254 tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); | 283 tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); |
284 if (td->timeout != 0) | |
285 g_source_remove(td->timeout); | |
286 g_free(td); | |
255 } | 287 } |
256 | 288 |
257 if (tickerwindow != NULL) { | 289 if (tickerwindow != NULL) { |
258 gtk_widget_destroy(tickerwindow); | 290 gtk_widget_destroy(tickerwindow); |
259 tickerwindow = NULL; | 291 tickerwindow = NULL; |