Mercurial > pidgin.yaz
changeset 13150:d4698cf18986
[gaim-migrate @ 15513]
SF Patch #1417663 from Sadrul
It compiles and appears to work in a quick test. Nobody is maintaining the ticker plugin these days, so I'm going to trust Sadrul on this one.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 07 Feb 2006 03:21:48 +0000 |
parents | 18e621aa8a43 |
children | 1646cd4f00ad |
files | plugins/ticker/ticker.c |
diffstat | 1 files changed, 61 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ticker/ticker.c Tue Feb 07 02:49:56 2006 +0000 +++ b/plugins/ticker/ticker.c Tue Feb 07 03:21:48 2006 +0000 @@ -45,7 +45,7 @@ static GtkWidget *ticker; typedef struct { - GaimBuddy *buddy; + GaimContact *contact; GtkWidget *ebox; GtkWidget *label; GtkWidget *icon; @@ -54,6 +54,8 @@ GList *tickerbuds = NULL; +static void buddy_ticker_update_contact(GaimContact *contact); + static gboolean buddy_ticker_destroy_window(GtkWidget *window, GdkEventAny *event, gpointer data) { if(window) @@ -87,24 +89,25 @@ } static gboolean buddy_click_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - GaimBuddy *b = user_data; + GaimContact *contact = user_data; + GaimBuddy *b = gaim_contact_get_priority_buddy(contact); gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); return TRUE; } -static TickerData *buddy_ticker_find_buddy(GaimBuddy *b) { +static TickerData *buddy_ticker_find_contact(GaimContact *c) { GList *tb; for(tb = tickerbuds; tb; tb = tb->next) { TickerData *td = tb->data; - if(td->buddy == b) + if(td->contact == c) return td; } return NULL; } -static void buddy_ticker_set_pixmap(GaimBuddy *b) { - TickerData *td = buddy_ticker_find_buddy(b); +static void buddy_ticker_set_pixmap(GaimContact *c) { + TickerData *td = buddy_ticker_find_contact(c); GdkPixbuf *pixbuf; if(!td) @@ -113,7 +116,7 @@ if(!td->icon) td->icon = gtk_image_new(); - pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, + pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)c, GAIM_STATUS_ICON_SMALL); gtk_image_set_from_pixbuf(GTK_IMAGE(td->icon), pixbuf); g_object_unref(G_OBJECT(pixbuf)); @@ -122,8 +125,7 @@ static gboolean buddy_ticker_set_pixmap_cb(gpointer data) { TickerData *td = data; -gaim_debug(GAIM_DEBUG_ERROR, "XXX", "we're updating the pixmap, you bitch\n"); - buddy_ticker_set_pixmap(td->buddy); + buddy_ticker_update_contact(td->contact); td->timeout = 0; return FALSE; @@ -132,31 +134,37 @@ static void buddy_ticker_add_buddy(GaimBuddy *b) { GtkWidget *hbox; TickerData *td; + GaimContact *contact; + + contact = gaim_buddy_get_contact(b); buddy_ticker_create_window(); if (!ticker) return; - if (buddy_ticker_find_buddy(b)) + if (buddy_ticker_find_contact(contact)) + { + buddy_ticker_update_contact(contact); return; + } td = g_new0(TickerData, 1); - td->buddy = b; + td->contact = contact; tickerbuds = g_list_append(tickerbuds, td); td->ebox = gtk_event_box_new(); gtk_ticker_add(GTK_TICKER(ticker), td->ebox); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(td->ebox), hbox); - buddy_ticker_set_pixmap(b); - gtk_box_pack_start(GTK_BOX(hbox), td->icon, FALSE, FALSE, 5); + buddy_ticker_set_pixmap(contact); + gtk_box_pack_start(GTK_BOX(hbox), td->icon, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(td->ebox), "button-press-event", - G_CALLBACK(buddy_click_cb), b); + G_CALLBACK(buddy_click_cb), contact); - td->label = gtk_label_new(gaim_buddy_get_alias(b)); - gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 5); + td->label = gtk_label_new(gaim_contact_get_alias(contact)); + gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 2); gtk_widget_show_all(td->ebox); gtk_widget_show(tickerwindow); @@ -168,20 +176,42 @@ td->timeout = g_timeout_add(11000, buddy_ticker_set_pixmap_cb, td); } -static void buddy_ticker_remove_buddy(GaimBuddy *b) { - TickerData *td = buddy_ticker_find_buddy(b); +static void buddy_ticker_remove(TickerData *td) { + gtk_ticker_remove(GTK_TICKER(ticker), td->ebox); + tickerbuds = g_list_remove(tickerbuds, td); + if (td->timeout != 0) + g_source_remove(td->timeout); + g_free(td); +} + +static void buddy_ticker_update_contact(GaimContact *contact) { + TickerData *td = buddy_ticker_find_contact(contact); if (!td) return; /* pop up the ticker window again */ buddy_ticker_create_window(); + if (gaim_contact_get_priority_buddy(contact) == NULL) + buddy_ticker_remove(td); + else { + buddy_ticker_set_pixmap(contact); + gtk_label_set_text(GTK_LABEL(td->label), gaim_contact_get_alias(contact)); + } +} - gtk_ticker_remove(GTK_TICKER(ticker), td->ebox); - tickerbuds = g_list_remove(tickerbuds, td); - if (td->timeout != 0) - g_source_remove(td->timeout); - g_free(td); +static void buddy_ticker_remove_buddy(GaimBuddy *b) { + GaimContact *c = gaim_buddy_get_contact(b); + TickerData *td = buddy_ticker_find_contact(c); + + if (!td) + return; + + gaim_contact_invalidate_priority_buddy(c); + + /* pop up the ticker window again */ + buddy_ticker_create_window(); + buddy_ticker_update_contact(c); } static void buddy_ticker_show() @@ -213,8 +243,10 @@ static void buddy_signon_cb(GaimBuddy *b) { - if(buddy_ticker_find_buddy(b)) - buddy_ticker_set_pixmap(b); + GaimContact *c = gaim_buddy_get_contact(b); + gaim_contact_invalidate_priority_buddy(c); + if(buddy_ticker_find_contact(c)) + buddy_ticker_update_contact(c); else buddy_ticker_add_buddy(b); } @@ -230,8 +262,9 @@ static void status_changed_cb(GaimBuddy *b, GaimStatus *os, GaimStatus *s) { - if(buddy_ticker_find_buddy(b)) - buddy_ticker_set_pixmap(b); + GaimContact *c = gaim_buddy_get_contact(b); + if(buddy_ticker_find_contact(c)) + buddy_ticker_set_pixmap(c); else buddy_ticker_add_buddy(b); } @@ -256,9 +289,7 @@ while (t) { td = t->data; t = t->next; - if (td->buddy->account == gc->account) { - buddy_signoff_cb(td->buddy); - } + buddy_ticker_update_contact(td->contact); } } }