Mercurial > pidgin
annotate src/ticker.c @ 686:cd6772d0685a
[gaim-migrate @ 696]
:)
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 15 Aug 2000 18:32:56 +0000 |
parents | 0b1a132e0f75 |
children | 2876c40108cd |
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"); |
430 | 88 |
89 ticker = gtk_ticker_new(); | |
433 | 90 gtk_ticker_set_spacing( GTK_TICKER( ticker ), 20 ); |
91 gtk_widget_set_usize( ticker, 500, -1 ); | |
430 | 92 gtk_container_add( GTK_CONTAINER( tickerwindow ), ticker ); |
93 gtk_ticker_set_interval( GTK_TICKER( ticker ), 500 ); | |
94 gtk_ticker_set_scootch( GTK_TICKER( ticker ), 10 ); | |
433 | 95 msgw = gtk_label_new( msg ); |
96 gtk_ticker_add( GTK_TICKER( ticker ), msgw ); | |
430 | 97 gtk_ticker_start_scroll( GTK_TICKER( ticker ) ); |
433 | 98 |
99 gtk_timeout_add( 60000, BuddyTickerMessageRemove, (gpointer) NULL ); | |
100 | |
101 gtk_widget_show_all (ticker); | |
102 | |
430 | 103 } |
104 | |
438 | 105 gint |
106 ButtonPressCallback( GtkWidget *widget, GdkEvent *event, gpointer callback_data ) | |
107 { | |
108 TickerData *p = (TickerData *) callback_data; | |
109 | |
110 pressed_ticker( p->buddy ); | |
604
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
111 |
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
112 return TRUE; |
438 | 113 } |
114 | |
430 | 115 void |
116 BuddyTickerAddUser( char *name, GdkPixmap *pm, GdkBitmap *bm ) | |
117 { | |
118 TickerData *p; | |
432 | 119 GList *q; |
120 | |
121 if ( userclose == TRUE ) | |
122 return; | |
436 | 123 |
124 BuddyTickerCreateWindow(); | |
125 | |
432 | 126 q = (GList *) BuddyTickerFindUser( name ); |
127 if ( q != (GList *) NULL ) | |
128 return; | |
430 | 129 |
130 p = (TickerData *) malloc( sizeof( TickerData ) ); | |
131 p->hbox = (GtkWidget *) NULL; | |
132 p->label = (GtkWidget *) NULL; | |
133 p->pix = (GtkWidget *) NULL; | |
134 strcpy( p->buddy, name ); | |
135 tickerbuds = g_list_append( tickerbuds, p ); | |
136 | |
137 p->hbox = gtk_hbox_new( FALSE, 0 ); | |
138 gtk_ticker_add( GTK_TICKER( ticker ), p->hbox ); | |
139 gtk_widget_show_all( p->hbox ); | |
140 | |
141 BuddyTickerSetPixmap( name, pm, bm ); | |
142 | |
438 | 143 p->ebox = gtk_event_box_new(); |
144 | |
145 // click detection | |
146 | |
147 gtk_widget_set_events (p->ebox, GDK_BUTTON_PRESS_MASK); | |
148 gtk_signal_connect (GTK_OBJECT (p->ebox), "button_press_event", | |
149 GTK_SIGNAL_FUNC(ButtonPressCallback), (gpointer) p); | |
150 | |
151 gtk_box_pack_start_defaults( GTK_BOX( p->hbox ), p->ebox ); | |
152 gtk_widget_show( p->ebox ); | |
153 | |
430 | 154 p->label = gtk_label_new( name ); |
438 | 155 gtk_container_add( GTK_CONTAINER(p->ebox), p->label ); |
156 | |
430 | 157 gtk_widget_show( p->label ); |
158 | |
159 gtk_widget_show( tickerwindow ); | |
160 } | |
161 | |
162 void | |
163 BuddyTickerRemoveUser( char *name ) | |
164 { | |
165 GList *p = (GList *) BuddyTickerFindUser( name ); | |
460 | 166 TickerData *data; |
167 | |
168 if ( !p ) | |
169 return; | |
170 | |
171 data = (TickerData *) p->data; | |
430 | 172 |
432 | 173 if ( userclose == TRUE ) |
174 return; | |
430 | 175 if ( data ) { |
176 gtk_ticker_remove( GTK_TICKER( ticker ), data->hbox ); | |
177 tickerbuds = g_list_remove( tickerbuds, data ); | |
178 free( data ); | |
179 } | |
180 } | |
181 | |
182 void | |
183 BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm ) | |
184 { | |
432 | 185 GList *p; |
186 TickerData *data; | |
430 | 187 |
432 | 188 if ( userclose == TRUE ) |
189 return; | |
190 p = (GList *) BuddyTickerFindUser( name ); | |
436 | 191 if ( p ) |
192 data = (TickerData *) p->data; | |
193 else | |
194 return; | |
430 | 195 if ( data->pix == (GtkWidget *) NULL ) { |
196 data->pix = gtk_pixmap_new( pm, bm ); | |
197 gtk_box_pack_start_defaults( GTK_BOX( data->hbox ), data->pix ); | |
198 } else { | |
199 gtk_widget_hide( data->pix ); | |
200 gtk_pixmap_set(GTK_PIXMAP(data->pix), pm, bm); | |
201 } | |
202 gtk_widget_show( data->pix ); | |
203 } | |
204 | |
205 GList * | |
206 BuddyTickerFindUser( char *name ) | |
207 { | |
208 GList *p = tickerbuds; | |
209 | |
210 while ( p ) { | |
211 TickerData *q = (TickerData *) p->data; | |
212 if ( !strcmp( name, q->buddy ) ) | |
213 return( p ); | |
214 p = p->next; | |
215 } | |
216 return (GList *) NULL; | |
217 } | |
218 | |
219 int | |
433 | 220 BuddyTickerMessageRemove( gpointer data ) |
221 { | |
222 if ( userclose == TRUE ) | |
604
0b1a132e0f75
[gaim-migrate @ 614]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
223 return FALSE; |
433 | 224 gtk_ticker_remove( GTK_TICKER( ticker ), msgw ); |
225 return FALSE; | |
226 } | |
227 | |
228 int | |
430 | 229 BuddyTickerLogonTimeout( gpointer data ) |
230 { | |
231 return FALSE; | |
232 } | |
233 | |
234 int | |
235 BuddyTickerLogoutTimeout( gpointer data ) | |
236 { | |
237 char *name = (char *) data; | |
238 | |
432 | 239 if ( userclose == TRUE ) |
240 return FALSE; | |
430 | 241 BuddyTickerRemoveUser( name ); |
242 | |
243 return FALSE; | |
244 } | |
432 | 245 |
246 void | |
247 BuddyTickerSignoff( void ) | |
248 { | |
249 GList *p = tickerbuds; | |
250 TickerData *q; | |
251 | |
252 while ( p ) { | |
253 q = (TickerData *) p->data; | |
436 | 254 if ( q ) |
255 BuddyTickerRemoveUser( q->buddy ); | |
432 | 256 p = tickerbuds; |
257 } | |
258 userclose = FALSE; | |
434 | 259 gtk_widget_hide( tickerwindow ); |
432 | 260 } |
261 | |
262 void | |
263 BuddyTickerClearList( void ) | |
264 { | |
265 GList *p = tickerbuds; | |
266 | |
436 | 267 while ( p ) |
432 | 268 p = g_list_remove( p, p->data ); |
269 tickerbuds = (GList *) NULL; | |
270 } | |
271 | |
272 |