Thu, 25 Jul 2013 02:22:35 +0530
Renamed PurpleBListNode back to PurpleBlistNode
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
1 | /* |
| 15884 | 2 | * Purple Ticker Plugin |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
26895
diff
changeset
|
3 | * The line below doesn't apply at all, does it? It should be Syd, Sean, and |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
4 | * maybe Nathan, I believe. |
| 3391 | 5 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 6 | * | |
| 7 | * This library is free software; you can redistribute it and/or | |
| 8 | * modify it under the terms of the GNU Library General Public | |
| 9 | * License as published by the Free Software Foundation; either | |
| 10 | * version 2 of the License, or (at your option) any later version. | |
| 11 | * | |
| 12 | * This library is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 | * Library General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU Library General Public | |
| 18 | * License along with this library; if not, write to the | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17241
diff
changeset
|
19 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17241
diff
changeset
|
20 | * Boston, MA 02111-1301, USA. |
| 3391 | 21 | */ |
| 22 | ||
| 23 | /* | |
| 24 | * ticker.c -- Syd Logan, Summer 2000 | |
| 25 | * pluginized- Sean Egan, Summer 2002 | |
| 26 | */ | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
27 | #include "internal.h" |
| 15577 | 28 | #include "pidgin.h" |
| 3391 | 29 | |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
30 | #include "buddylist.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
31 | #include "conversation.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
32 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
33 | #include "prpl.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
34 | #include "signals.h" |
| 9943 | 35 | #include "version.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
36 | |
|
34708
dd67596485ca
Undo renames of UI blist headers back to gntblist.h and gtkblist.h
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
37 | #include "gtkblist.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
38 | #include "gtkplugin.h" |
| 17241 | 39 | #include "gtkutils.h" |
|
26895
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
40 | #include "pidginstock.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
41 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
42 | #include "gtkticker.h" |
| 3391 | 43 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
44 | #define TICKER_PLUGIN_ID "gtk-ticker" |
| 3867 | 45 | |
| 3391 | 46 | static GtkWidget *tickerwindow = NULL; |
| 47 | static GtkWidget *ticker; | |
| 48 | ||
| 49 | typedef struct { | |
| 15884 | 50 | PurpleContact *contact; |
| 3391 | 51 | GtkWidget *ebox; |
| 52 | GtkWidget *label; | |
| 5170 | 53 | GtkWidget *icon; |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
54 | guint timeout; |
| 3391 | 55 | } TickerData; |
| 56 | ||
|
26893
351f48f83366
Bring the conversation to front from a click on the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24956
diff
changeset
|
57 | static GList *tickerbuds = NULL; |
| 3391 | 58 | |
| 15884 | 59 | static void buddy_ticker_update_contact(PurpleContact *contact); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
60 | |
| 5172 | 61 | static gboolean buddy_ticker_destroy_window(GtkWidget *window, |
| 62 | GdkEventAny *event, gpointer data) { | |
| 63 | if(window) | |
| 64 | gtk_widget_hide(window); | |
| 65 | ||
| 66 | return TRUE; /* don't actually destroy the window */ | |
| 3391 | 67 | } |
| 68 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20288
diff
changeset
|
69 | static void buddy_ticker_create_window(void) { |
| 5170 | 70 | if(tickerwindow) { |
| 71 | gtk_widget_show(tickerwindow); | |
| 72 | return; | |
| 73 | } | |
| 3391 | 74 | |
| 17213 | 75 | tickerwindow = pidgin_create_window(_("Buddy Ticker"), 0, "ticker", TRUE); |
|
5286
a35f037e7841
[gaim-migrate @ 5658]
David J. Brigada <brigada@prism.net>
parents:
5234
diff
changeset
|
76 | gtk_window_set_default_size(GTK_WINDOW(tickerwindow), 500, -1); |
| 5172 | 77 | g_signal_connect(G_OBJECT(tickerwindow), "delete_event", |
| 5170 | 78 | G_CALLBACK (buddy_ticker_destroy_window), NULL); |
| 3391 | 79 | |
|
4850
ca9d06f1bb54
[gaim-migrate @ 5175]
Mark Doliner <markdoliner@pidgin.im>
parents:
4770
diff
changeset
|
80 | ticker = gtk_ticker_new(); |
| 5170 | 81 | gtk_ticker_set_spacing(GTK_TICKER(ticker), 20); |
| 82 | gtk_container_add(GTK_CONTAINER(tickerwindow), ticker); | |
| 83 | gtk_ticker_set_interval(GTK_TICKER(ticker), 500); | |
| 84 | gtk_ticker_set_scootch(GTK_TICKER(ticker), 10); | |
| 85 | gtk_ticker_start_scroll(GTK_TICKER(ticker)); | |
|
5286
a35f037e7841
[gaim-migrate @ 5658]
David J. Brigada <brigada@prism.net>
parents:
5234
diff
changeset
|
86 | gtk_widget_set_size_request(ticker, 1, -1); |
| 3391 | 87 | |
| 5170 | 88 | gtk_widget_show_all(tickerwindow); |
| 3391 | 89 | } |
| 90 | ||
| 5170 | 91 | static gboolean buddy_click_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { |
| 15884 | 92 | PurpleContact *contact = user_data; |
| 93 | PurpleBuddy *b = purple_contact_get_priority_buddy(contact); | |
|
4850
ca9d06f1bb54
[gaim-migrate @ 5175]
Mark Doliner <markdoliner@pidgin.im>
parents:
4770
diff
changeset
|
94 | |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
31294
diff
changeset
|
95 | PurpleIMConversation *im = purple_im_conversation_new(purple_buddy_get_account(b), |
|
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
31294
diff
changeset
|
96 | purple_buddy_get_name(b)); |
|
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
31294
diff
changeset
|
97 | purple_conversation_present(PURPLE_CONVERSATION(im)); |
| 3391 | 98 | return TRUE; |
| 99 | } | |
| 100 | ||
| 15884 | 101 | static TickerData *buddy_ticker_find_contact(PurpleContact *c) { |
| 5170 | 102 | GList *tb; |
| 103 | for(tb = tickerbuds; tb; tb = tb->next) { | |
| 104 | TickerData *td = tb->data; | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
105 | if(td->contact == c) |
| 5170 | 106 | return td; |
| 107 | } | |
| 108 | return NULL; | |
| 109 | } | |
| 110 | ||
|
26895
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
111 | static void buddy_ticker_set_pixmap(PurpleContact *c) |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
112 | { |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
113 | TickerData *td = buddy_ticker_find_contact(c); |
|
26895
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
114 | PurpleBuddy *buddy; |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
115 | PurplePresence *presence; |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
116 | const char *stock; |
| 3391 | 117 | |
| 5170 | 118 | if(!td) |
| 3391 | 119 | return; |
| 5170 | 120 | |
|
26895
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
121 | buddy = purple_contact_get_priority_buddy(c); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
122 | presence = purple_buddy_get_presence(buddy); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
123 | stock = pidgin_stock_id_from_presence(presence); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
124 | if(!td->icon) { |
| 5170 | 125 | td->icon = gtk_image_new(); |
|
26895
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
126 | g_object_set(G_OBJECT(td->icon), "stock", stock, |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
127 | "icon-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC), |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
128 | NULL); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
129 | } else { |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
130 | g_object_set(G_OBJECT(td->icon), "stock", stock, NULL); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
131 | } |
| 5170 | 132 | } |
| 133 | ||
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
134 | static gboolean buddy_ticker_set_pixmap_cb(gpointer data) { |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
135 | TickerData *td = data; |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
136 | |
|
20206
a121040d571b
applied changes from 0573c84391460ff90a7de830442aad5ffb6a0c5f
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
137 | if (g_list_find(tickerbuds, td) != NULL) { |
|
a121040d571b
applied changes from 0573c84391460ff90a7de830442aad5ffb6a0c5f
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
138 | buddy_ticker_update_contact(td->contact); |
|
a121040d571b
applied changes from 0573c84391460ff90a7de830442aad5ffb6a0c5f
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
139 | td->timeout = 0; |
|
a121040d571b
applied changes from 0573c84391460ff90a7de830442aad5ffb6a0c5f
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
140 | } |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
141 | |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
142 | return FALSE; |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
143 | } |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
144 | |
| 15884 | 145 | static void buddy_ticker_add_buddy(PurpleBuddy *b) { |
| 5170 | 146 | GtkWidget *hbox; |
| 147 | TickerData *td; | |
| 15884 | 148 | PurpleContact *contact; |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
149 | |
| 15884 | 150 | contact = purple_buddy_get_contact(b); |
| 5170 | 151 | |
| 152 | buddy_ticker_create_window(); | |
| 5172 | 153 | |
| 3391 | 154 | if (!ticker) |
| 155 | return; | |
| 156 | ||
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
157 | if (buddy_ticker_find_contact(contact)) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
158 | { |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
159 | buddy_ticker_update_contact(contact); |
| 3391 | 160 | return; |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
161 | } |
| 3391 | 162 | |
| 5170 | 163 | td = g_new0(TickerData, 1); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
164 | td->contact = contact; |
| 5170 | 165 | tickerbuds = g_list_append(tickerbuds, td); |
| 3391 | 166 | |
| 5170 | 167 | td->ebox = gtk_event_box_new(); |
| 168 | gtk_ticker_add(GTK_TICKER(ticker), td->ebox); | |
| 169 | hbox = gtk_hbox_new(FALSE, 0); | |
| 170 | gtk_container_add(GTK_CONTAINER(td->ebox), hbox); | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
171 | buddy_ticker_set_pixmap(contact); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
172 | gtk_box_pack_start(GTK_BOX(hbox), td->icon, FALSE, FALSE, 0); |
| 3391 | 173 | |
| 5170 | 174 | g_signal_connect(G_OBJECT(td->ebox), "button-press-event", |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
175 | G_CALLBACK(buddy_click_cb), contact); |
| 3391 | 176 | |
| 15884 | 177 | td->label = gtk_label_new(purple_contact_get_alias(contact)); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
178 | gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 2); |
| 5170 | 179 | |
| 180 | gtk_widget_show_all(td->ebox); | |
| 181 | gtk_widget_show(tickerwindow); | |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
182 | |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
183 | /* |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
184 | * Update the icon in a few seconds (after the open door icon has |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
185 | * changed). This is somewhat ugly. |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
186 | */ |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
187 | td->timeout = g_timeout_add(11000, buddy_ticker_set_pixmap_cb, td); |
| 3391 | 188 | } |
| 189 | ||
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
190 | static void buddy_ticker_remove(TickerData *td) { |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
191 | gtk_ticker_remove(GTK_TICKER(ticker), td->ebox); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
192 | tickerbuds = g_list_remove(tickerbuds, td); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
193 | if (td->timeout != 0) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
194 | g_source_remove(td->timeout); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
195 | g_free(td); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
196 | } |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
197 | |
| 15884 | 198 | static void buddy_ticker_update_contact(PurpleContact *contact) { |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
199 | TickerData *td = buddy_ticker_find_contact(contact); |
| 3391 | 200 | |
| 5170 | 201 | if (!td) |
| 202 | return; | |
| 3391 | 203 | |
| 5172 | 204 | /* pop up the ticker window again */ |
| 205 | buddy_ticker_create_window(); | |
| 15884 | 206 | if (purple_contact_get_priority_buddy(contact) == NULL) |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
207 | buddy_ticker_remove(td); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
208 | else { |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
209 | buddy_ticker_set_pixmap(contact); |
| 15884 | 210 | gtk_label_set_text(GTK_LABEL(td->label), purple_contact_get_alias(contact)); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
211 | } |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
212 | } |
| 5172 | 213 | |
| 15884 | 214 | static void buddy_ticker_remove_buddy(PurpleBuddy *b) { |
| 215 | PurpleContact *c = purple_buddy_get_contact(b); | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
216 | TickerData *td = buddy_ticker_find_contact(c); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
217 | |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
218 | if (!td) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
219 | return; |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
220 | |
| 15884 | 221 | purple_contact_invalidate_priority_buddy(c); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
222 | |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
223 | /* pop up the ticker window again */ |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
224 | buddy_ticker_create_window(); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
225 | buddy_ticker_update_contact(c); |
| 3391 | 226 | } |
| 227 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20288
diff
changeset
|
228 | static void buddy_ticker_show(void) |
| 3391 | 229 | { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34760
diff
changeset
|
230 | PurpleBlistNode *gnode, *cnode, *bnode; |
| 15884 | 231 | PurpleBuddy *b; |
| 3391 | 232 | |
|
24956
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
233 | for(gnode = purple_blist_get_root(); |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
234 | gnode; |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
235 | gnode = purple_blist_node_get_sibling_next(gnode)) |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
236 | { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
237 | if(!PURPLE_IS_GROUP(gnode)) |
| 5170 | 238 | continue; |
|
24956
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
239 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
240 | cnode; |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
241 | cnode = purple_blist_node_get_sibling_next(cnode)) |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
242 | { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
243 | if(!PURPLE_IS_CONTACT(cnode)) |
| 5170 | 244 | continue; |
|
24956
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
245 | for(bnode = purple_blist_node_get_first_child(cnode); |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
246 | bnode; |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
247 | bnode = purple_blist_node_get_sibling_next(bnode)) |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
248 | { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
249 | if(!PURPLE_IS_BUDDY(bnode)) |
| 6695 | 250 | continue; |
|
34740
9401f9b1ca68
Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents:
34708
diff
changeset
|
251 | b = PURPLE_BUDDY(bnode); |
|
34760
062535fbe1e9
Renamed PURPLE_IS_BUDDY_ONLINE back to PURPLE_BUDDY_IS_ONLINE
Ankit Vani <a@nevitus.org>
parents:
34740
diff
changeset
|
252 | if(PURPLE_BUDDY_IS_ONLINE(b)) |
| 6695 | 253 | buddy_ticker_add_buddy(b); |
| 254 | } | |
| 3391 | 255 | } |
| 256 | } | |
| 257 | } | |
| 258 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
259 | static void |
| 15884 | 260 | buddy_signon_cb(PurpleBuddy *b) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
261 | { |
| 15884 | 262 | PurpleContact *c = purple_buddy_get_contact(b); |
| 263 | purple_contact_invalidate_priority_buddy(c); | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
264 | if(buddy_ticker_find_contact(c)) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
265 | buddy_ticker_update_contact(c); |
| 5170 | 266 | else |
| 267 | buddy_ticker_add_buddy(b); | |
| 3391 | 268 | } |
| 269 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
270 | static void |
| 15884 | 271 | buddy_signoff_cb(PurpleBuddy *b) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
272 | { |
| 5170 | 273 | buddy_ticker_remove_buddy(b); |
| 5185 | 274 | if(!tickerbuds) |
| 275 | gtk_widget_hide(tickerwindow); | |
| 3391 | 276 | } |
| 277 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
278 | static void |
| 15884 | 279 | status_changed_cb(PurpleBuddy *b, PurpleStatus *os, PurpleStatus *s) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
280 | { |
| 15884 | 281 | PurpleContact *c = purple_buddy_get_contact(b); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
282 | if(buddy_ticker_find_contact(c)) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
283 | buddy_ticker_set_pixmap(c); |
| 5170 | 284 | else |
| 285 | buddy_ticker_add_buddy(b); | |
| 3391 | 286 | } |
| 287 | ||
| 8213 | 288 | static void |
| 15884 | 289 | signoff_cb(PurpleConnection *gc) |
| 8213 | 290 | { |
| 291 | TickerData *td; | |
| 15884 | 292 | if (!purple_connections_get_all()) { |
| 8213 | 293 | while (tickerbuds) { |
| 294 | td = tickerbuds->data; | |
| 295 | tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); | |
| 296 | if (td->timeout != 0) | |
| 297 | g_source_remove(td->timeout); | |
| 298 | g_free(td); | |
| 299 | } | |
| 300 | gtk_widget_destroy(tickerwindow); | |
| 301 | tickerwindow = NULL; | |
| 302 | ticker = NULL; | |
| 303 | } else { | |
| 304 | GList *t = tickerbuds; | |
| 305 | while (t) { | |
| 306 | td = t->data; | |
| 307 | t = t->next; | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
308 | buddy_ticker_update_contact(td->contact); |
| 8213 | 309 | } |
| 310 | } | |
| 311 | } | |
| 312 | ||
| 313 | ||
| 3630 | 314 | /* |
| 315 | * EXPORTED FUNCTIONS | |
| 316 | */ | |
| 317 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
318 | static gboolean |
| 15884 | 319 | plugin_load(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
320 | { |
| 15884 | 321 | void *blist_handle = purple_blist_get_handle(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
322 | |
| 15884 | 323 | purple_signal_connect(purple_connections_get_handle(), "signed-off", |
| 324 | plugin, PURPLE_CALLBACK(signoff_cb), NULL); | |
| 325 | purple_signal_connect(blist_handle, "buddy-signed-on", | |
| 326 | plugin, PURPLE_CALLBACK(buddy_signon_cb), NULL); | |
| 327 | purple_signal_connect(blist_handle, "buddy-signed-off", | |
| 328 | plugin, PURPLE_CALLBACK(buddy_signoff_cb), NULL); | |
| 329 | purple_signal_connect(blist_handle, "buddy-status-changed", | |
| 330 | plugin, PURPLE_CALLBACK(status_changed_cb), NULL); | |
| 3391 | 331 | |
| 15884 | 332 | if (purple_connections_get_all()) |
| 5170 | 333 | buddy_ticker_show(); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
334 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
335 | return TRUE; |
| 3391 | 336 | } |
| 337 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
338 | static gboolean |
| 15884 | 339 | plugin_unload(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
340 | { |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
341 | TickerData *td; |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
342 | |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
343 | while (tickerbuds) { |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
344 | td = tickerbuds->data; |
| 5186 | 345 | tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
346 | if (td->timeout != 0) |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
347 | g_source_remove(td->timeout); |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
348 | g_free(td); |
| 5185 | 349 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
350 | |
|
5984
a5b22eb728ef
[gaim-migrate @ 6432]
Christian Hammond <chipx86@chipx86.com>
parents:
5983
diff
changeset
|
351 | if (tickerwindow != NULL) { |
|
5983
435a19acf12a
[gaim-migrate @ 6431]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
352 | gtk_widget_destroy(tickerwindow); |
|
5984
a5b22eb728ef
[gaim-migrate @ 6432]
Christian Hammond <chipx86@chipx86.com>
parents:
5983
diff
changeset
|
353 | tickerwindow = NULL; |
|
a5b22eb728ef
[gaim-migrate @ 6432]
Christian Hammond <chipx86@chipx86.com>
parents:
5983
diff
changeset
|
354 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
355 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
356 | return TRUE; |
| 3391 | 357 | } |
| 5170 | 358 | |
| 15884 | 359 | static PurplePluginInfo info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
360 | { |
| 15884 | 361 | PURPLE_PLUGIN_MAGIC, |
| 362 | PURPLE_MAJOR_VERSION, | |
| 363 | PURPLE_MINOR_VERSION, | |
| 364 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
365 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
366 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
367 | NULL, /**< dependencies */ |
| 15884 | 368 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
369 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
370 | TICKER_PLUGIN_ID, /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
371 | N_("Buddy Ticker"), /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20206
diff
changeset
|
372 | DISPLAY_VERSION, /**< version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
373 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
374 | N_("A horizontal scrolling version of the buddy list."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
375 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
376 | N_("A horizontal scrolling version of the buddy list."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
377 | "Syd Logan", /**< author */ |
| 15884 | 378 | PURPLE_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
379 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
380 | plugin_load, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
381 | plugin_unload, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
382 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
383 | |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
384 | NULL, /**< ui_info */ |
| 8993 | 385 | NULL, /**< extra_info */ |
| 386 | NULL, | |
|
16749
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
387 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
388 | |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
389 | /* padding */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
390 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
391 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
392 | NULL, |
| 8993 | 393 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
394 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
395 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
396 | static void |
| 15884 | 397 | init_plugin(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
398 | { |
| 3551 | 399 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
400 | |
| 15884 | 401 | PURPLE_INIT_PLUGIN(ticker, init_plugin, info) |