Thu, 10 Mar 2011 09:08:51 +0000
Dutch translation updated (Gideon van Melle). Fixes #13452
|
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 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
30 | #include "blist.h" |
|
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 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5607
diff
changeset
|
37 | #include "gtkblist.h" |
|
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 | |
|
26893
351f48f83366
Bring the conversation to front from a click on the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24956
diff
changeset
|
95 | PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, |
|
351f48f83366
Bring the conversation to front from a click on the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24956
diff
changeset
|
96 | purple_buddy_get_account(b), |
|
351f48f83366
Bring the conversation to front from a click on the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24956
diff
changeset
|
97 | purple_buddy_get_name(b)); |
|
351f48f83366
Bring the conversation to front from a click on the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24956
diff
changeset
|
98 | purple_conversation_present(conv); |
| 3391 | 99 | return TRUE; |
| 100 | } | |
| 101 | ||
| 15884 | 102 | static TickerData *buddy_ticker_find_contact(PurpleContact *c) { |
| 5170 | 103 | GList *tb; |
| 104 | for(tb = tickerbuds; tb; tb = tb->next) { | |
| 105 | TickerData *td = tb->data; | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
106 | if(td->contact == c) |
| 5170 | 107 | return td; |
| 108 | } | |
| 109 | return NULL; | |
| 110 | } | |
| 111 | ||
|
26895
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
112 | 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
|
113 | { |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
114 | 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
|
115 | PurpleBuddy *buddy; |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
116 | PurplePresence *presence; |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
117 | const char *stock; |
| 3391 | 118 | |
| 5170 | 119 | if(!td) |
| 3391 | 120 | return; |
| 5170 | 121 | |
|
26895
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
122 | buddy = purple_contact_get_priority_buddy(c); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
123 | presence = purple_buddy_get_presence(buddy); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
124 | stock = pidgin_stock_id_from_presence(presence); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
125 | if(!td->icon) { |
| 5170 | 126 | td->icon = gtk_image_new(); |
|
26895
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
127 | 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
|
128 | "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
|
129 | NULL); |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
130 | } else { |
|
287b2c32dd29
Use stock id in the ticker.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
26893
diff
changeset
|
131 | 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
|
132 | } |
| 5170 | 133 | } |
| 134 | ||
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
135 | static gboolean buddy_ticker_set_pixmap_cb(gpointer data) { |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
136 | TickerData *td = data; |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
137 | |
|
20206
a121040d571b
applied changes from 0573c84391460ff90a7de830442aad5ffb6a0c5f
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
138 | if (g_list_find(tickerbuds, td) != NULL) { |
|
a121040d571b
applied changes from 0573c84391460ff90a7de830442aad5ffb6a0c5f
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
139 | buddy_ticker_update_contact(td->contact); |
|
a121040d571b
applied changes from 0573c84391460ff90a7de830442aad5ffb6a0c5f
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
140 | td->timeout = 0; |
|
a121040d571b
applied changes from 0573c84391460ff90a7de830442aad5ffb6a0c5f
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
141 | } |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
142 | |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
143 | return FALSE; |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
144 | } |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
145 | |
| 15884 | 146 | static void buddy_ticker_add_buddy(PurpleBuddy *b) { |
| 5170 | 147 | GtkWidget *hbox; |
| 148 | TickerData *td; | |
| 15884 | 149 | PurpleContact *contact; |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
150 | |
| 15884 | 151 | contact = purple_buddy_get_contact(b); |
| 5170 | 152 | |
| 153 | buddy_ticker_create_window(); | |
| 5172 | 154 | |
| 3391 | 155 | if (!ticker) |
| 156 | return; | |
| 157 | ||
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
158 | if (buddy_ticker_find_contact(contact)) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
159 | { |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
160 | buddy_ticker_update_contact(contact); |
| 3391 | 161 | return; |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
162 | } |
| 3391 | 163 | |
| 5170 | 164 | td = g_new0(TickerData, 1); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
165 | td->contact = contact; |
| 5170 | 166 | tickerbuds = g_list_append(tickerbuds, td); |
| 3391 | 167 | |
| 5170 | 168 | td->ebox = gtk_event_box_new(); |
| 169 | gtk_ticker_add(GTK_TICKER(ticker), td->ebox); | |
| 170 | hbox = gtk_hbox_new(FALSE, 0); | |
| 171 | gtk_container_add(GTK_CONTAINER(td->ebox), hbox); | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
172 | buddy_ticker_set_pixmap(contact); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
173 | gtk_box_pack_start(GTK_BOX(hbox), td->icon, FALSE, FALSE, 0); |
| 3391 | 174 | |
| 5170 | 175 | 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
|
176 | G_CALLBACK(buddy_click_cb), contact); |
| 3391 | 177 | |
| 15884 | 178 | 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
|
179 | gtk_box_pack_start(GTK_BOX(hbox), td->label, FALSE, FALSE, 2); |
| 5170 | 180 | |
| 181 | gtk_widget_show_all(td->ebox); | |
| 182 | gtk_widget_show(tickerwindow); | |
|
6122
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 | /* |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
185 | * 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
|
186 | * changed). This is somewhat ugly. |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
187 | */ |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
188 | td->timeout = g_timeout_add(11000, buddy_ticker_set_pixmap_cb, td); |
| 3391 | 189 | } |
| 190 | ||
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
191 | static void buddy_ticker_remove(TickerData *td) { |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
192 | gtk_ticker_remove(GTK_TICKER(ticker), td->ebox); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
193 | tickerbuds = g_list_remove(tickerbuds, td); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
194 | if (td->timeout != 0) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
195 | g_source_remove(td->timeout); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
196 | g_free(td); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
197 | } |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
198 | |
| 15884 | 199 | static void buddy_ticker_update_contact(PurpleContact *contact) { |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
200 | TickerData *td = buddy_ticker_find_contact(contact); |
| 3391 | 201 | |
| 5170 | 202 | if (!td) |
| 203 | return; | |
| 3391 | 204 | |
| 5172 | 205 | /* pop up the ticker window again */ |
| 206 | buddy_ticker_create_window(); | |
| 15884 | 207 | if (purple_contact_get_priority_buddy(contact) == NULL) |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
208 | buddy_ticker_remove(td); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
209 | else { |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
210 | buddy_ticker_set_pixmap(contact); |
| 15884 | 211 | 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
|
212 | } |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
213 | } |
| 5172 | 214 | |
| 15884 | 215 | static void buddy_ticker_remove_buddy(PurpleBuddy *b) { |
| 216 | PurpleContact *c = purple_buddy_get_contact(b); | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
217 | TickerData *td = buddy_ticker_find_contact(c); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
218 | |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
219 | if (!td) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
220 | return; |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
221 | |
| 15884 | 222 | purple_contact_invalidate_priority_buddy(c); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
223 | |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
224 | /* pop up the ticker window again */ |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
225 | buddy_ticker_create_window(); |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
226 | buddy_ticker_update_contact(c); |
| 3391 | 227 | } |
| 228 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20288
diff
changeset
|
229 | static void buddy_ticker_show(void) |
| 3391 | 230 | { |
| 15884 | 231 | PurpleBlistNode *gnode, *cnode, *bnode; |
| 232 | PurpleBuddy *b; | |
| 3391 | 233 | |
|
24956
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
234 | 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
|
235 | gnode; |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
236 | 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
|
237 | { |
| 15884 | 238 | if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
| 5170 | 239 | continue; |
|
24956
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
240 | 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
|
241 | cnode; |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
242 | 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
|
243 | { |
| 15884 | 244 | if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
| 5170 | 245 | continue; |
|
24956
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
246 | 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
|
247 | bnode; |
|
05aa5ba1eab4
updated the pidgin plugins for the blist struct hiding
Gary Kramlich <grim@reaperworld.com>
parents:
22104
diff
changeset
|
248 | 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
|
249 | { |
| 15884 | 250 | if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
| 6695 | 251 | continue; |
| 15884 | 252 | b = (PurpleBuddy *)bnode; |
| 253 | if(PURPLE_BUDDY_IS_ONLINE(b)) | |
| 6695 | 254 | buddy_ticker_add_buddy(b); |
| 255 | } | |
| 3391 | 256 | } |
| 257 | } | |
| 258 | } | |
| 259 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
260 | static void |
| 15884 | 261 | buddy_signon_cb(PurpleBuddy *b) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
262 | { |
| 15884 | 263 | PurpleContact *c = purple_buddy_get_contact(b); |
| 264 | purple_contact_invalidate_priority_buddy(c); | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
265 | if(buddy_ticker_find_contact(c)) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
266 | buddy_ticker_update_contact(c); |
| 5170 | 267 | else |
| 268 | buddy_ticker_add_buddy(b); | |
| 3391 | 269 | } |
| 270 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
271 | static void |
| 15884 | 272 | buddy_signoff_cb(PurpleBuddy *b) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
273 | { |
| 5170 | 274 | buddy_ticker_remove_buddy(b); |
| 5185 | 275 | if(!tickerbuds) |
| 276 | gtk_widget_hide(tickerwindow); | |
| 3391 | 277 | } |
| 278 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
279 | static void |
| 15884 | 280 | status_changed_cb(PurpleBuddy *b, PurpleStatus *os, PurpleStatus *s) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
281 | { |
| 15884 | 282 | PurpleContact *c = purple_buddy_get_contact(b); |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
283 | if(buddy_ticker_find_contact(c)) |
|
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
284 | buddy_ticker_set_pixmap(c); |
| 5170 | 285 | else |
| 286 | buddy_ticker_add_buddy(b); | |
| 3391 | 287 | } |
| 288 | ||
| 8213 | 289 | static void |
| 15884 | 290 | signoff_cb(PurpleConnection *gc) |
| 8213 | 291 | { |
| 292 | TickerData *td; | |
| 15884 | 293 | if (!purple_connections_get_all()) { |
| 8213 | 294 | while (tickerbuds) { |
| 295 | td = tickerbuds->data; | |
| 296 | tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); | |
| 297 | if (td->timeout != 0) | |
| 298 | g_source_remove(td->timeout); | |
| 299 | g_free(td); | |
| 300 | } | |
| 301 | gtk_widget_destroy(tickerwindow); | |
| 302 | tickerwindow = NULL; | |
| 303 | ticker = NULL; | |
| 304 | } else { | |
| 305 | GList *t = tickerbuds; | |
| 306 | while (t) { | |
| 307 | td = t->data; | |
| 308 | t = t->next; | |
|
13151
e6f06eacea11
[gaim-migrate @ 15513]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11935
diff
changeset
|
309 | buddy_ticker_update_contact(td->contact); |
| 8213 | 310 | } |
| 311 | } | |
| 312 | } | |
| 313 | ||
| 314 | ||
| 3630 | 315 | /* |
| 316 | * EXPORTED FUNCTIONS | |
| 317 | */ | |
| 318 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
319 | static gboolean |
| 15884 | 320 | plugin_load(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
321 | { |
| 15884 | 322 | void *blist_handle = purple_blist_get_handle(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
323 | |
| 15884 | 324 | purple_signal_connect(purple_connections_get_handle(), "signed-off", |
| 325 | plugin, PURPLE_CALLBACK(signoff_cb), NULL); | |
| 326 | purple_signal_connect(blist_handle, "buddy-signed-on", | |
| 327 | plugin, PURPLE_CALLBACK(buddy_signon_cb), NULL); | |
| 328 | purple_signal_connect(blist_handle, "buddy-signed-off", | |
| 329 | plugin, PURPLE_CALLBACK(buddy_signoff_cb), NULL); | |
| 330 | purple_signal_connect(blist_handle, "buddy-status-changed", | |
| 331 | plugin, PURPLE_CALLBACK(status_changed_cb), NULL); | |
| 3391 | 332 | |
| 15884 | 333 | if (purple_connections_get_all()) |
| 5170 | 334 | buddy_ticker_show(); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
335 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
336 | return TRUE; |
| 3391 | 337 | } |
| 338 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
339 | static gboolean |
| 15884 | 340 | plugin_unload(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
341 | { |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
342 | TickerData *td; |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
343 | |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
344 | while (tickerbuds) { |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
345 | td = tickerbuds->data; |
| 5186 | 346 | tickerbuds = g_list_delete_link(tickerbuds, tickerbuds); |
|
6122
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
347 | if (td->timeout != 0) |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
348 | g_source_remove(td->timeout); |
|
9fbbcb229460
[gaim-migrate @ 6596]
Mark Doliner <markdoliner@pidgin.im>
parents:
6063
diff
changeset
|
349 | g_free(td); |
| 5185 | 350 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
351 | |
|
5984
a5b22eb728ef
[gaim-migrate @ 6432]
Christian Hammond <chipx86@chipx86.com>
parents:
5983
diff
changeset
|
352 | if (tickerwindow != NULL) { |
|
5983
435a19acf12a
[gaim-migrate @ 6431]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
353 | gtk_widget_destroy(tickerwindow); |
|
5984
a5b22eb728ef
[gaim-migrate @ 6432]
Christian Hammond <chipx86@chipx86.com>
parents:
5983
diff
changeset
|
354 | tickerwindow = NULL; |
|
a5b22eb728ef
[gaim-migrate @ 6432]
Christian Hammond <chipx86@chipx86.com>
parents:
5983
diff
changeset
|
355 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
356 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
357 | return TRUE; |
| 3391 | 358 | } |
| 5170 | 359 | |
| 15884 | 360 | static PurplePluginInfo info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
361 | { |
| 15884 | 362 | PURPLE_PLUGIN_MAGIC, |
| 363 | PURPLE_MAJOR_VERSION, | |
| 364 | PURPLE_MINOR_VERSION, | |
| 365 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
366 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
367 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
368 | NULL, /**< dependencies */ |
| 15884 | 369 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
370 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
371 | TICKER_PLUGIN_ID, /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
372 | N_("Buddy Ticker"), /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20206
diff
changeset
|
373 | DISPLAY_VERSION, /**< version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
374 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
375 | N_("A horizontal scrolling version of the buddy list."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
376 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
377 | N_("A horizontal scrolling version of the buddy list."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
378 | "Syd Logan", /**< author */ |
| 15884 | 379 | PURPLE_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
380 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
381 | plugin_load, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
382 | plugin_unload, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
383 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
384 | |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
385 | NULL, /**< ui_info */ |
| 8993 | 386 | NULL, /**< extra_info */ |
| 387 | 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
|
388 | 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
|
389 | |
|
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 | /* 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
|
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, |
|
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
|
393 | NULL, |
| 8993 | 394 | NULL |
|
5205
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 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
397 | static void |
| 15884 | 398 | init_plugin(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
399 | { |
| 3551 | 400 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5186
diff
changeset
|
401 | |
| 15884 | 402 | PURPLE_INIT_PLUGIN(ticker, init_plugin, info) |