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"
|
|
26
|
|
27 GtkWidget *tickerwindow = NULL;
|
|
28 GtkWidget *ticker;
|
|
29
|
|
30 typedef struct {
|
|
31 char buddy[ 128 ];
|
|
32 GtkWidget *hbox;
|
|
33 GtkWidget *label;
|
|
34 GtkWidget *pix;
|
|
35 } TickerData;
|
|
36
|
|
37 static GList *tickerbuds = (GList *) NULL;
|
432
|
38 static gboolean userclose = FALSE;
|
433
|
39 static GtkWidget *msgw;
|
430
|
40
|
|
41 void BuddyTickerDestroyWindow( GtkWidget *window );
|
|
42 void BuddyTickerCreateWindow( void );
|
|
43 void BuddyTickerAddUser( char *name, GdkPixmap *pm, GdkBitmap *bm );
|
|
44 void BuddyTickerRemoveUser( char *name );
|
|
45 void BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm );
|
432
|
46 void BuddyTickerClearList( void );
|
|
47 void BuddyTickerSignOff( void );
|
430
|
48 GList * BuddyTickerFindUser( char *name );
|
433
|
49 int BuddyTickerMessageRemove( gpointer data );
|
430
|
50
|
|
51 void
|
|
52 BuddyTickerDestroyWindow( GtkWidget *window )
|
|
53 {
|
432
|
54 BuddyTickerClearList();
|
430
|
55 gtk_ticker_stop_scroll( GTK_TICKER( ticker ) );
|
|
56 gtk_widget_destroy( window );
|
|
57 ticker = tickerwindow = (GtkWidget *) NULL;
|
432
|
58 userclose = TRUE;
|
430
|
59 }
|
|
60
|
433
|
61 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";
|
|
62
|
430
|
63 void
|
|
64 BuddyTickerCreateWindow()
|
|
65 {
|
|
66 if ( tickerwindow != (GtkWidget *) NULL )
|
|
67 return;
|
|
68 tickerwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
69 gtk_signal_connect (GTK_OBJECT(tickerwindow), "destroy",
|
|
70 GTK_SIGNAL_FUNC (BuddyTickerDestroyWindow), "WM destroy");
|
433
|
71 gtk_window_set_title (GTK_WINDOW(tickerwindow), "GAIM - Buddy Ticker");
|
430
|
72
|
|
73 ticker = gtk_ticker_new();
|
433
|
74 gtk_ticker_set_spacing( GTK_TICKER( ticker ), 20 );
|
|
75 gtk_widget_set_usize( ticker, 500, -1 );
|
430
|
76 gtk_container_add( GTK_CONTAINER( tickerwindow ), ticker );
|
|
77 gtk_ticker_set_interval( GTK_TICKER( ticker ), 500 );
|
|
78 gtk_ticker_set_scootch( GTK_TICKER( ticker ), 10 );
|
433
|
79 msgw = gtk_label_new( msg );
|
|
80 gtk_ticker_add( GTK_TICKER( ticker ), msgw );
|
430
|
81 gtk_ticker_start_scroll( GTK_TICKER( ticker ) );
|
433
|
82
|
|
83 gtk_timeout_add( 60000, BuddyTickerMessageRemove, (gpointer) NULL );
|
|
84
|
|
85 gtk_widget_show_all (ticker);
|
|
86
|
430
|
87 }
|
|
88
|
|
89 void
|
|
90 BuddyTickerAddUser( char *name, GdkPixmap *pm, GdkBitmap *bm )
|
|
91 {
|
|
92 GtkWidget *hbox, *label, *pmap;
|
|
93 TickerData *p;
|
432
|
94 GList *q;
|
|
95
|
|
96 if ( userclose == TRUE )
|
|
97 return;
|
|
98 q = (GList *) BuddyTickerFindUser( name );
|
|
99 if ( q != (GList *) NULL )
|
|
100 return;
|
430
|
101
|
|
102 BuddyTickerCreateWindow();
|
|
103 p = (TickerData *) malloc( sizeof( TickerData ) );
|
|
104 p->hbox = (GtkWidget *) NULL;
|
|
105 p->label = (GtkWidget *) NULL;
|
|
106 p->pix = (GtkWidget *) NULL;
|
|
107 strcpy( p->buddy, name );
|
|
108 tickerbuds = g_list_append( tickerbuds, p );
|
|
109
|
|
110 p->hbox = gtk_hbox_new( FALSE, 0 );
|
|
111 gtk_ticker_add( GTK_TICKER( ticker ), p->hbox );
|
|
112 gtk_widget_show_all( p->hbox );
|
|
113
|
|
114 BuddyTickerSetPixmap( name, pm, bm );
|
|
115
|
|
116 p->label = gtk_label_new( name );
|
|
117 gtk_box_pack_start_defaults( GTK_BOX( p->hbox ), p->label );
|
|
118 gtk_widget_show( p->label );
|
|
119
|
|
120 gtk_widget_show( tickerwindow );
|
|
121 }
|
|
122
|
|
123 void
|
|
124 BuddyTickerRemoveUser( char *name )
|
|
125 {
|
|
126 GList *p = (GList *) BuddyTickerFindUser( name );
|
|
127 TickerData *data = (TickerData *) p->data;
|
|
128
|
432
|
129 if ( userclose == TRUE )
|
|
130 return;
|
430
|
131 if ( data ) {
|
|
132 gtk_ticker_remove( GTK_TICKER( ticker ), data->hbox );
|
|
133 tickerbuds = g_list_remove( tickerbuds, data );
|
|
134 free( data );
|
|
135 }
|
|
136 }
|
|
137
|
|
138 void
|
|
139 BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm )
|
|
140 {
|
432
|
141 GList *p;
|
|
142 TickerData *data;
|
430
|
143
|
432
|
144 if ( userclose == TRUE )
|
|
145 return;
|
|
146 p = (GList *) BuddyTickerFindUser( name );
|
|
147 data = (TickerData *) p->data;
|
430
|
148 if ( data->pix == (GtkWidget *) NULL ) {
|
|
149 data->pix = gtk_pixmap_new( pm, bm );
|
|
150 gtk_box_pack_start_defaults( GTK_BOX( data->hbox ), data->pix );
|
|
151 } else {
|
|
152 gtk_widget_hide( data->pix );
|
|
153 gtk_pixmap_set(GTK_PIXMAP(data->pix), pm, bm);
|
|
154 }
|
|
155 gtk_widget_show( data->pix );
|
|
156 }
|
|
157
|
|
158 GList *
|
|
159 BuddyTickerFindUser( char *name )
|
|
160 {
|
|
161 GList *p = tickerbuds;
|
|
162
|
|
163 while ( p ) {
|
|
164 TickerData *q = (TickerData *) p->data;
|
|
165 if ( !strcmp( name, q->buddy ) )
|
|
166 return( p );
|
|
167 p = p->next;
|
|
168 }
|
|
169 return (GList *) NULL;
|
|
170 }
|
|
171
|
|
172 int
|
433
|
173 BuddyTickerMessageRemove( gpointer data )
|
|
174 {
|
|
175 if ( userclose == TRUE )
|
|
176 return;
|
|
177 gtk_ticker_remove( GTK_TICKER( ticker ), msgw );
|
|
178 return FALSE;
|
|
179 }
|
|
180
|
|
181 int
|
430
|
182 BuddyTickerLogonTimeout( gpointer data )
|
|
183 {
|
|
184 return FALSE;
|
|
185 }
|
|
186
|
|
187 int
|
|
188 BuddyTickerLogoutTimeout( gpointer data )
|
|
189 {
|
|
190 char *name = (char *) data;
|
|
191
|
432
|
192 if ( userclose == TRUE )
|
|
193 return FALSE;
|
430
|
194 BuddyTickerRemoveUser( name );
|
|
195
|
|
196 return FALSE;
|
|
197 }
|
432
|
198
|
|
199 void
|
|
200 BuddyTickerSignoff( void )
|
|
201 {
|
|
202 GList *p = tickerbuds;
|
|
203 TickerData *q;
|
|
204
|
|
205 while ( p ) {
|
|
206 q = (TickerData *) p->data;
|
|
207 BuddyTickerRemoveUser( q->buddy );
|
|
208 p = tickerbuds;
|
|
209 }
|
|
210 userclose = FALSE;
|
|
211 }
|
|
212
|
|
213 void
|
|
214 BuddyTickerClearList( void )
|
|
215 {
|
|
216 GList *p = tickerbuds;
|
|
217 TickerData *q;
|
|
218
|
|
219 while ( p ) {
|
|
220 q = (TickerData *) p->data;
|
|
221 p = g_list_remove( p, p->data );
|
|
222 }
|
|
223 tickerbuds = (GList *) NULL;
|
|
224 }
|
|
225
|
|
226
|