Mercurial > pidgin.yaz
comparison pidgin/plugins/ticker/ticker.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 535f002e7b0f |
children | 3d41d0d7fb9b |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /* | 1 /* |
2 * Gaim Ticker Plugin | 2 * Purple Ticker Plugin |
3 * The line below doesn't apply at all, does it? It should be Syd, Sean, and | 3 * The line below doesn't apply at all, does it? It should be Syd, Sean, and |
4 * maybe Nathan, I believe. | 4 * maybe Nathan, I believe. |
5 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald | 5 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
43 | 43 |
44 static GtkWidget *tickerwindow = NULL; | 44 static GtkWidget *tickerwindow = NULL; |
45 static GtkWidget *ticker; | 45 static GtkWidget *ticker; |
46 | 46 |
47 typedef struct { | 47 typedef struct { |
48 GaimContact *contact; | 48 PurpleContact *contact; |
49 GtkWidget *ebox; | 49 GtkWidget *ebox; |
50 GtkWidget *label; | 50 GtkWidget *label; |
51 GtkWidget *icon; | 51 GtkWidget *icon; |
52 guint timeout; | 52 guint timeout; |
53 } TickerData; | 53 } TickerData; |
54 | 54 |
55 GList *tickerbuds = NULL; | 55 GList *tickerbuds = NULL; |
56 | 56 |
57 static void buddy_ticker_update_contact(GaimContact *contact); | 57 static void buddy_ticker_update_contact(PurpleContact *contact); |
58 | 58 |
59 static gboolean buddy_ticker_destroy_window(GtkWidget *window, | 59 static gboolean buddy_ticker_destroy_window(GtkWidget *window, |
60 GdkEventAny *event, gpointer data) { | 60 GdkEventAny *event, gpointer data) { |
61 if(window) | 61 if(window) |
62 gtk_widget_hide(window); | 62 gtk_widget_hide(window); |
87 | 87 |
88 gtk_widget_show_all(tickerwindow); | 88 gtk_widget_show_all(tickerwindow); |
89 } | 89 } |
90 | 90 |
91 static gboolean buddy_click_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { | 91 static gboolean buddy_click_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { |
92 GaimContact *contact = user_data; | 92 PurpleContact *contact = user_data; |
93 GaimBuddy *b = gaim_contact_get_priority_buddy(contact); | 93 PurpleBuddy *b = purple_contact_get_priority_buddy(contact); |
94 | 94 |
95 gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); | 95 purple_conversation_new(PURPLE_CONV_TYPE_IM, b->account, b->name); |
96 return TRUE; | 96 return TRUE; |
97 } | 97 } |
98 | 98 |
99 static TickerData *buddy_ticker_find_contact(GaimContact *c) { | 99 static TickerData *buddy_ticker_find_contact(PurpleContact *c) { |
100 GList *tb; | 100 GList *tb; |
101 for(tb = tickerbuds; tb; tb = tb->next) { | 101 for(tb = tickerbuds; tb; tb = tb->next) { |
102 TickerData *td = tb->data; | 102 TickerData *td = tb->data; |
103 if(td->contact == c) | 103 if(td->contact == c) |
104 return td; | 104 return td; |
105 } | 105 } |
106 return NULL; | 106 return NULL; |
107 } | 107 } |
108 | 108 |
109 static void buddy_ticker_set_pixmap(GaimContact *c) { | 109 static void buddy_ticker_set_pixmap(PurpleContact *c) { |
110 TickerData *td = buddy_ticker_find_contact(c); | 110 TickerData *td = buddy_ticker_find_contact(c); |
111 GdkPixbuf *pixbuf; | 111 GdkPixbuf *pixbuf; |
112 | 112 |
113 if(!td) | 113 if(!td) |
114 return; | 114 return; |
115 | 115 |
116 if(!td->icon) | 116 if(!td->icon) |
117 td->icon = gtk_image_new(); | 117 td->icon = gtk_image_new(); |
118 | 118 |
119 pixbuf = pidgin_blist_get_status_icon((GaimBlistNode*)c, | 119 pixbuf = pidgin_blist_get_status_icon((PurpleBlistNode*)c, |
120 PIDGIN_STATUS_ICON_SMALL); | 120 PIDGIN_STATUS_ICON_SMALL); |
121 gtk_image_set_from_pixbuf(GTK_IMAGE(td->icon), pixbuf); | 121 gtk_image_set_from_pixbuf(GTK_IMAGE(td->icon), pixbuf); |
122 g_object_unref(G_OBJECT(pixbuf)); | 122 g_object_unref(G_OBJECT(pixbuf)); |
123 } | 123 } |
124 | 124 |
129 td->timeout = 0; | 129 td->timeout = 0; |
130 | 130 |
131 return FALSE; | 131 return FALSE; |
132 } | 132 } |
133 | 133 |
134 static void buddy_ticker_add_buddy(GaimBuddy *b) { | 134 static void buddy_ticker_add_buddy(PurpleBuddy *b) { |
135 GtkWidget *hbox; | 135 GtkWidget *hbox; |
136 TickerData *td; | 136 TickerData *td; |
137 GaimContact *contact; | 137 PurpleContact *contact; |
138 | 138 |
139 contact = gaim_buddy_get_contact(b); | 139 contact = purple_buddy_get_contact(b); |
140 | 140 |
141 buddy_ticker_create_window(); | 141 buddy_ticker_create_window(); |
142 | 142 |
143 if (!ticker) | 143 if (!ticker) |
144 return; | 144 return; |
161 gtk_box_pack_start(GTK_BOX(hbox), td->icon, FALSE, FALSE, 0); | 161 gtk_box_pack_start(GTK_BOX(hbox), td->icon, FALSE, FALSE, 0); |
162 | 162 |
163 g_signal_connect(G_OBJECT(td->ebox), "button-press-event", | 163 g_signal_connect(G_OBJECT(td->ebox), "button-press-event", |
164 G_CALLBACK(buddy_click_cb), contact); | 164 G_CALLBACK(buddy_click_cb), contact); |
165 | 165 |
166 td->label = gtk_label_new(gaim_contact_get_alias(contact)); | 166 td->label = gtk_label_new(purple_contact_get_alias(contact)); |
167 gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 2); | 167 gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 2); |
168 | 168 |
169 gtk_widget_show_all(td->ebox); | 169 gtk_widget_show_all(td->ebox); |
170 gtk_widget_show(tickerwindow); | 170 gtk_widget_show(tickerwindow); |
171 | 171 |
182 if (td->timeout != 0) | 182 if (td->timeout != 0) |
183 g_source_remove(td->timeout); | 183 g_source_remove(td->timeout); |
184 g_free(td); | 184 g_free(td); |
185 } | 185 } |
186 | 186 |
187 static void buddy_ticker_update_contact(GaimContact *contact) { | 187 static void buddy_ticker_update_contact(PurpleContact *contact) { |
188 TickerData *td = buddy_ticker_find_contact(contact); | 188 TickerData *td = buddy_ticker_find_contact(contact); |
189 | 189 |
190 if (!td) | 190 if (!td) |
191 return; | 191 return; |
192 | 192 |
193 /* pop up the ticker window again */ | 193 /* pop up the ticker window again */ |
194 buddy_ticker_create_window(); | 194 buddy_ticker_create_window(); |
195 if (gaim_contact_get_priority_buddy(contact) == NULL) | 195 if (purple_contact_get_priority_buddy(contact) == NULL) |
196 buddy_ticker_remove(td); | 196 buddy_ticker_remove(td); |
197 else { | 197 else { |
198 buddy_ticker_set_pixmap(contact); | 198 buddy_ticker_set_pixmap(contact); |
199 gtk_label_set_text(GTK_LABEL(td->label), gaim_contact_get_alias(contact)); | 199 gtk_label_set_text(GTK_LABEL(td->label), purple_contact_get_alias(contact)); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 static void buddy_ticker_remove_buddy(GaimBuddy *b) { | 203 static void buddy_ticker_remove_buddy(PurpleBuddy *b) { |
204 GaimContact *c = gaim_buddy_get_contact(b); | 204 PurpleContact *c = purple_buddy_get_contact(b); |
205 TickerData *td = buddy_ticker_find_contact(c); | 205 TickerData *td = buddy_ticker_find_contact(c); |
206 | 206 |
207 if (!td) | 207 if (!td) |
208 return; | 208 return; |
209 | 209 |
210 gaim_contact_invalidate_priority_buddy(c); | 210 purple_contact_invalidate_priority_buddy(c); |
211 | 211 |
212 /* pop up the ticker window again */ | 212 /* pop up the ticker window again */ |
213 buddy_ticker_create_window(); | 213 buddy_ticker_create_window(); |
214 buddy_ticker_update_contact(c); | 214 buddy_ticker_update_contact(c); |
215 } | 215 } |
216 | 216 |
217 static void buddy_ticker_show() | 217 static void buddy_ticker_show() |
218 { | 218 { |
219 GaimBuddyList *list = gaim_get_blist(); | 219 PurpleBuddyList *list = purple_get_blist(); |
220 GaimBlistNode *gnode, *cnode, *bnode; | 220 PurpleBlistNode *gnode, *cnode, *bnode; |
221 GaimBuddy *b; | 221 PurpleBuddy *b; |
222 | 222 |
223 if(!list) | 223 if(!list) |
224 return; | 224 return; |
225 | 225 |
226 for(gnode = list->root; gnode; gnode = gnode->next) { | 226 for(gnode = list->root; gnode; gnode = gnode->next) { |
227 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | 227 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
228 continue; | 228 continue; |
229 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 229 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
230 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | 230 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
231 continue; | 231 continue; |
232 for(bnode = cnode->child; bnode; bnode = bnode->next) { | 232 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
233 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | 233 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
234 continue; | 234 continue; |
235 b = (GaimBuddy *)bnode; | 235 b = (PurpleBuddy *)bnode; |
236 if(GAIM_BUDDY_IS_ONLINE(b)) | 236 if(PURPLE_BUDDY_IS_ONLINE(b)) |
237 buddy_ticker_add_buddy(b); | 237 buddy_ticker_add_buddy(b); |
238 } | 238 } |
239 } | 239 } |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 static void | 243 static void |
244 buddy_signon_cb(GaimBuddy *b) | 244 buddy_signon_cb(PurpleBuddy *b) |
245 { | 245 { |
246 GaimContact *c = gaim_buddy_get_contact(b); | 246 PurpleContact *c = purple_buddy_get_contact(b); |
247 gaim_contact_invalidate_priority_buddy(c); | 247 purple_contact_invalidate_priority_buddy(c); |
248 if(buddy_ticker_find_contact(c)) | 248 if(buddy_ticker_find_contact(c)) |
249 buddy_ticker_update_contact(c); | 249 buddy_ticker_update_contact(c); |
250 else | 250 else |
251 buddy_ticker_add_buddy(b); | 251 buddy_ticker_add_buddy(b); |
252 } | 252 } |
253 | 253 |
254 static void | 254 static void |
255 buddy_signoff_cb(GaimBuddy *b) | 255 buddy_signoff_cb(PurpleBuddy *b) |
256 { | 256 { |
257 buddy_ticker_remove_buddy(b); | 257 buddy_ticker_remove_buddy(b); |
258 if(!tickerbuds) | 258 if(!tickerbuds) |
259 gtk_widget_hide(tickerwindow); | 259 gtk_widget_hide(tickerwindow); |
260 } | 260 } |
261 | 261 |
262 static void | 262 static void |
263 status_changed_cb(GaimBuddy *b, GaimStatus *os, GaimStatus *s) | 263 status_changed_cb(PurpleBuddy *b, PurpleStatus *os, PurpleStatus *s) |
264 { | 264 { |
265 GaimContact *c = gaim_buddy_get_contact(b); | 265 PurpleContact *c = purple_buddy_get_contact(b); |
266 if(buddy_ticker_find_contact(c)) | 266 if(buddy_ticker_find_contact(c)) |
267 buddy_ticker_set_pixmap(c); | 267 buddy_ticker_set_pixmap(c); |
268 else | 268 else |
269 buddy_ticker_add_buddy(b); | 269 buddy_ticker_add_buddy(b); |
270 } | 270 } |
271 | 271 |
272 static void | 272 static void |
273 signoff_cb(GaimConnection *gc) | 273 signoff_cb(PurpleConnection *gc) |
274 { | 274 { |
275 TickerData *td; | 275 TickerData *td; |
276 if (!gaim_connections_get_all()) { | 276 if (!purple_connections_get_all()) { |
277 while (tickerbuds) { | 277 while (tickerbuds) { |
278 td = tickerbuds->data; | 278 td = tickerbuds->data; |
279 tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); | 279 tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); |
280 if (td->timeout != 0) | 280 if (td->timeout != 0) |
281 g_source_remove(td->timeout); | 281 g_source_remove(td->timeout); |
298 /* | 298 /* |
299 * EXPORTED FUNCTIONS | 299 * EXPORTED FUNCTIONS |
300 */ | 300 */ |
301 | 301 |
302 static gboolean | 302 static gboolean |
303 plugin_load(GaimPlugin *plugin) | 303 plugin_load(PurplePlugin *plugin) |
304 { | 304 { |
305 void *blist_handle = gaim_blist_get_handle(); | 305 void *blist_handle = purple_blist_get_handle(); |
306 | 306 |
307 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | 307 purple_signal_connect(purple_connections_get_handle(), "signed-off", |
308 plugin, GAIM_CALLBACK(signoff_cb), NULL); | 308 plugin, PURPLE_CALLBACK(signoff_cb), NULL); |
309 gaim_signal_connect(blist_handle, "buddy-signed-on", | 309 purple_signal_connect(blist_handle, "buddy-signed-on", |
310 plugin, GAIM_CALLBACK(buddy_signon_cb), NULL); | 310 plugin, PURPLE_CALLBACK(buddy_signon_cb), NULL); |
311 gaim_signal_connect(blist_handle, "buddy-signed-off", | 311 purple_signal_connect(blist_handle, "buddy-signed-off", |
312 plugin, GAIM_CALLBACK(buddy_signoff_cb), NULL); | 312 plugin, PURPLE_CALLBACK(buddy_signoff_cb), NULL); |
313 gaim_signal_connect(blist_handle, "buddy-status-changed", | 313 purple_signal_connect(blist_handle, "buddy-status-changed", |
314 plugin, GAIM_CALLBACK(status_changed_cb), NULL); | 314 plugin, PURPLE_CALLBACK(status_changed_cb), NULL); |
315 | 315 |
316 if (gaim_connections_get_all()) | 316 if (purple_connections_get_all()) |
317 buddy_ticker_show(); | 317 buddy_ticker_show(); |
318 | 318 |
319 return TRUE; | 319 return TRUE; |
320 } | 320 } |
321 | 321 |
322 static gboolean | 322 static gboolean |
323 plugin_unload(GaimPlugin *plugin) | 323 plugin_unload(PurplePlugin *plugin) |
324 { | 324 { |
325 TickerData *td; | 325 TickerData *td; |
326 | 326 |
327 while (tickerbuds) { | 327 while (tickerbuds) { |
328 td = tickerbuds->data; | 328 td = tickerbuds->data; |
338 } | 338 } |
339 | 339 |
340 return TRUE; | 340 return TRUE; |
341 } | 341 } |
342 | 342 |
343 static GaimPluginInfo info = | 343 static PurplePluginInfo info = |
344 { | 344 { |
345 GAIM_PLUGIN_MAGIC, | 345 PURPLE_PLUGIN_MAGIC, |
346 GAIM_MAJOR_VERSION, | 346 PURPLE_MAJOR_VERSION, |
347 GAIM_MINOR_VERSION, | 347 PURPLE_MINOR_VERSION, |
348 GAIM_PLUGIN_STANDARD, /**< type */ | 348 PURPLE_PLUGIN_STANDARD, /**< type */ |
349 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ | 349 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
350 0, /**< flags */ | 350 0, /**< flags */ |
351 NULL, /**< dependencies */ | 351 NULL, /**< dependencies */ |
352 GAIM_PRIORITY_DEFAULT, /**< priority */ | 352 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
353 | 353 |
354 TICKER_PLUGIN_ID, /**< id */ | 354 TICKER_PLUGIN_ID, /**< id */ |
355 N_("Buddy Ticker"), /**< name */ | 355 N_("Buddy Ticker"), /**< name */ |
356 VERSION, /**< version */ | 356 VERSION, /**< version */ |
357 /** summary */ | 357 /** summary */ |
358 N_("A horizontal scrolling version of the buddy list."), | 358 N_("A horizontal scrolling version of the buddy list."), |
359 /** description */ | 359 /** description */ |
360 N_("A horizontal scrolling version of the buddy list."), | 360 N_("A horizontal scrolling version of the buddy list."), |
361 "Syd Logan", /**< author */ | 361 "Syd Logan", /**< author */ |
362 GAIM_WEBSITE, /**< homepage */ | 362 PURPLE_WEBSITE, /**< homepage */ |
363 | 363 |
364 plugin_load, /**< load */ | 364 plugin_load, /**< load */ |
365 plugin_unload, /**< unload */ | 365 plugin_unload, /**< unload */ |
366 NULL, /**< destroy */ | 366 NULL, /**< destroy */ |
367 | 367 |
370 NULL, | 370 NULL, |
371 NULL | 371 NULL |
372 }; | 372 }; |
373 | 373 |
374 static void | 374 static void |
375 init_plugin(GaimPlugin *plugin) | 375 init_plugin(PurplePlugin *plugin) |
376 { | 376 { |
377 } | 377 } |
378 | 378 |
379 GAIM_INIT_PLUGIN(ticker, init_plugin, info) | 379 PURPLE_INIT_PLUGIN(ticker, init_plugin, info) |