Mercurial > pidgin
annotate src/ticker.c @ 921:d2e865d64dd8
[gaim-migrate @ 931]
bah. maybe i'll get this working for the next release, but i don't think it's possible to get it working.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 16 Sep 2000 00:54:29 +0000 |
parents | 2876c40108cd |
children | 889e5026fd98 |
rev | line source |
---|---|
430 | 1 /* GTK - The GIMP Toolkit |
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald | |
3 * | |
4 * This library is free software; you can redistribute it and/or | |
5 * modify it under the terms of the GNU Library General Public | |
6 * License as published by the Free Software Foundation; either | |
7 * version 2 of the License, or (at your option) any later version. | |
8 * | |
9 * This library is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 * Library General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU Library General Public | |
15 * License along with this library; if not, write to the | |
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
17 * Boston, MA 02111-1307, USA. | |
18 */ | |
19 | |
20 /* | |
21 * ticker.c -- Syd Logan, Summer 2000 | |
22 */ | |
23 | |
24 #include <gtk/gtk.h> | |
25 #include "gtkticker.h" | |
469 | 26 #include <string.h> |
604
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
27 #include <stdlib.h> |
430 | 28 |
29 GtkWidget *tickerwindow = NULL; | |
30 GtkWidget *ticker; | |
31 | |
32 typedef struct { | |
33 char buddy[ 128 ]; | |
34 GtkWidget *hbox; | |
438 | 35 GtkWidget *ebox; |
430 | 36 GtkWidget *label; |
37 GtkWidget *pix; | |
38 } TickerData; | |
39 | |
40 static GList *tickerbuds = (GList *) NULL; | |
432 | 41 static gboolean userclose = FALSE; |
433 | 42 static GtkWidget *msgw; |
430 | 43 |
44 void BuddyTickerDestroyWindow( GtkWidget *window ); | |
45 void BuddyTickerCreateWindow( void ); | |
46 void BuddyTickerAddUser( char *name, GdkPixmap *pm, GdkBitmap *bm ); | |
47 void BuddyTickerRemoveUser( char *name ); | |
48 void BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm ); | |
432 | 49 void BuddyTickerClearList( void ); |
50 void BuddyTickerSignOff( void ); | |
430 | 51 GList * BuddyTickerFindUser( char *name ); |
433 | 52 int BuddyTickerMessageRemove( gpointer data ); |
604
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
53 extern void pressed_ticker(char *); |
430 | 54 |
436 | 55 // this pref is startup only, so make a shadow here of settings at startup |
56 // code uses this variable, not display_prefs | |
57 | |
58 extern int display_options; | |
59 int ticker_prefs; | |
60 | |
61 void | |
62 SetTickerPrefs( void ) | |
63 { | |
64 ticker_prefs = display_options; | |
65 } | |
66 | |
430 | 67 void |
68 BuddyTickerDestroyWindow( GtkWidget *window ) | |
69 { | |
432 | 70 BuddyTickerClearList(); |
430 | 71 gtk_ticker_stop_scroll( GTK_TICKER( ticker ) ); |
72 gtk_widget_destroy( window ); | |
73 ticker = tickerwindow = (GtkWidget *) NULL; | |
432 | 74 userclose = TRUE; |
430 | 75 } |
76 | |
433 | 77 static char *msg = "Welcome to GAIM 0.9.20, brought to you by Rob Flynn (maintainer), Eric Warmenhoven, Mark Spencer, Jeramey Crawford, Jim Duchek, and Syd Logan"; |
78 | |
430 | 79 void |
80 BuddyTickerCreateWindow() | |
81 { | |
82 if ( tickerwindow != (GtkWidget *) NULL ) | |
83 return; | |
84 tickerwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); | |
85 gtk_signal_connect (GTK_OBJECT(tickerwindow), "destroy", | |
86 GTK_SIGNAL_FUNC (BuddyTickerDestroyWindow), "WM destroy"); | |
433 | 87 gtk_window_set_title (GTK_WINDOW(tickerwindow), "GAIM - Buddy Ticker"); |
905 | 88 gtk_window_set_wmclass (GTK_WINDOW(tickerwindow), |
89 "ticker", "Gaim"); | |
430 | 90 |
91 ticker = gtk_ticker_new(); | |
433 | 92 gtk_ticker_set_spacing( GTK_TICKER( ticker ), 20 ); |
93 gtk_widget_set_usize( ticker, 500, -1 ); | |
430 | 94 gtk_container_add( GTK_CONTAINER( tickerwindow ), ticker ); |
95 gtk_ticker_set_interval( GTK_TICKER( ticker ), 500 ); | |
96 gtk_ticker_set_scootch( GTK_TICKER( ticker ), 10 ); | |
433 | 97 msgw = gtk_label_new( msg ); |
98 gtk_ticker_add( GTK_TICKER( ticker ), msgw ); | |
430 | 99 gtk_ticker_start_scroll( GTK_TICKER( ticker ) ); |
433 | 100 |
101 gtk_timeout_add( 60000, BuddyTickerMessageRemove, (gpointer) NULL ); | |
102 | |
103 gtk_widget_show_all (ticker); | |
104 | |
430 | 105 } |
106 | |
438 | 107 gint |
108 ButtonPressCallback( GtkWidget *widget, GdkEvent *event, gpointer callback_data ) | |
109 { | |
110 TickerData *p = (TickerData *) callback_data; | |
111 | |
112 pressed_ticker( p->buddy ); | |
604
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
113 |
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
114 return TRUE; |
438 | 115 } |
116 | |
430 | 117 void |
118 BuddyTickerAddUser( char *name, GdkPixmap *pm, GdkBitmap *bm ) | |
119 { | |
120 TickerData *p; | |
432 | 121 GList *q; |
122 | |
123 if ( userclose == TRUE ) | |
124 return; | |
436 | 125 |
126 BuddyTickerCreateWindow(); | |
127 | |
432 | 128 q = (GList *) BuddyTickerFindUser( name ); |
129 if ( q != (GList *) NULL ) | |
130 return; | |
430 | 131 |
132 p = (TickerData *) malloc( sizeof( TickerData ) ); | |
133 p->hbox = (GtkWidget *) NULL; | |
134 p->label = (GtkWidget *) NULL; | |
135 p->pix = (GtkWidget *) NULL; | |
136 strcpy( p->buddy, name ); | |
137 tickerbuds = g_list_append( tickerbuds, p ); | |
138 | |
139 p->hbox = gtk_hbox_new( FALSE, 0 ); | |
140 gtk_ticker_add( GTK_TICKER( ticker ), p->hbox ); | |
141 gtk_widget_show_all( p->hbox ); | |
142 | |
143 BuddyTickerSetPixmap( name, pm, bm ); | |
144 | |
438 | 145 p->ebox = gtk_event_box_new(); |
146 | |
147 // click detection | |
148 | |
149 gtk_widget_set_events (p->ebox, GDK_BUTTON_PRESS_MASK); | |
150 gtk_signal_connect (GTK_OBJECT (p->ebox), "button_press_event", | |
151 GTK_SIGNAL_FUNC(ButtonPressCallback), (gpointer) p); | |
152 | |
153 gtk_box_pack_start_defaults( GTK_BOX( p->hbox ), p->ebox ); | |
154 gtk_widget_show( p->ebox ); | |
155 | |
430 | 156 p->label = gtk_label_new( name ); |
438 | 157 gtk_container_add( GTK_CONTAINER(p->ebox), p->label ); |
158 | |
430 | 159 gtk_widget_show( p->label ); |
160 | |
161 gtk_widget_show( tickerwindow ); | |
162 } | |
163 | |
164 void | |
165 BuddyTickerRemoveUser( char *name ) | |
166 { | |
167 GList *p = (GList *) BuddyTickerFindUser( name ); | |
460 | 168 TickerData *data; |
169 | |
170 if ( !p ) | |
171 return; | |
172 | |
173 data = (TickerData *) p->data; | |
430 | 174 |
432 | 175 if ( userclose == TRUE ) |
176 return; | |
430 | 177 if ( data ) { |
178 gtk_ticker_remove( GTK_TICKER( ticker ), data->hbox ); | |
179 tickerbuds = g_list_remove( tickerbuds, data ); | |
180 free( data ); | |
181 } | |
182 } | |
183 | |
184 void | |
185 BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm ) | |
186 { | |
432 | 187 GList *p; |
188 TickerData *data; | |
430 | 189 |
432 | 190 if ( userclose == TRUE ) |
191 return; | |
192 p = (GList *) BuddyTickerFindUser( name ); | |
436 | 193 if ( p ) |
194 data = (TickerData *) p->data; | |
195 else | |
196 return; | |
430 | 197 if ( data->pix == (GtkWidget *) NULL ) { |
198 data->pix = gtk_pixmap_new( pm, bm ); | |
199 gtk_box_pack_start_defaults( GTK_BOX( data->hbox ), data->pix ); | |
200 } else { | |
201 gtk_widget_hide( data->pix ); | |
202 gtk_pixmap_set(GTK_PIXMAP(data->pix), pm, bm); | |
203 } | |
204 gtk_widget_show( data->pix ); | |
205 } | |
206 | |
207 GList * | |
208 BuddyTickerFindUser( char *name ) | |
209 { | |
210 GList *p = tickerbuds; | |
211 | |
212 while ( p ) { | |
213 TickerData *q = (TickerData *) p->data; | |
214 if ( !strcmp( name, q->buddy ) ) | |
215 return( p ); | |
216 p = p->next; | |
217 } | |
218 return (GList *) NULL; | |
219 } | |
220 | |
221 int | |
433 | 222 BuddyTickerMessageRemove( gpointer data ) |
223 { | |
224 if ( userclose == TRUE ) | |
604
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
225 return FALSE; |
433 | 226 gtk_ticker_remove( GTK_TICKER( ticker ), msgw ); |
227 return FALSE; | |
228 } | |
229 | |
230 int | |
430 | 231 BuddyTickerLogonTimeout( gpointer data ) |
232 { | |
233 return FALSE; | |
234 } | |
235 | |
236 int | |
237 BuddyTickerLogoutTimeout( gpointer data ) | |
238 { | |
239 char *name = (char *) data; | |
240 | |
432 | 241 if ( userclose == TRUE ) |
242 return FALSE; | |
430 | 243 BuddyTickerRemoveUser( name ); |
244 | |
245 return FALSE; | |
246 } | |
432 | 247 |
248 void | |
249 BuddyTickerSignoff( void ) | |
250 { | |
251 GList *p = tickerbuds; | |
252 TickerData *q; | |
253 | |
254 while ( p ) { | |
255 q = (TickerData *) p->data; | |
436 | 256 if ( q ) |
257 BuddyTickerRemoveUser( q->buddy ); | |
432 | 258 p = tickerbuds; |
259 } | |
260 userclose = FALSE; | |
434 | 261 gtk_widget_hide( tickerwindow ); |
432 | 262 } |
263 | |
264 void | |
265 BuddyTickerClearList( void ) | |
266 { | |
267 GList *p = tickerbuds; | |
268 | |
436 | 269 while ( p ) |
432 | 270 p = g_list_remove( p, p->data ); |
271 tickerbuds = (GList *) NULL; | |
272 } | |
273 | |
274 |