Mercurial > pidgin.yaz
comparison src/ticker.c @ 430:0cd2ba801eb4
[gaim-migrate @ 440]
First pass at a buddy ticker.
committer: Tailor Script <tailor@pidgin.im>
author | Syd Logan <slogan> |
---|---|
date | Sat, 24 Jun 2000 23:15:48 +0000 |
parents | |
children | 5741dca6cc8a |
comparison
equal
deleted
inserted
replaced
429:ccf7fc40263f | 430:0cd2ba801eb4 |
---|---|
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; | |
38 | |
39 void BuddyTickerDestroyWindow( GtkWidget *window ); | |
40 void BuddyTickerCreateWindow( void ); | |
41 void BuddyTickerAddUser( char *name, GdkPixmap *pm, GdkBitmap *bm ); | |
42 void BuddyTickerRemoveUser( char *name ); | |
43 void BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm ); | |
44 GList * BuddyTickerFindUser( char *name ); | |
45 | |
46 void | |
47 BuddyTickerDestroyWindow( GtkWidget *window ) | |
48 { | |
49 gtk_ticker_stop_scroll( GTK_TICKER( ticker ) ); | |
50 gtk_widget_destroy( window ); | |
51 ticker = tickerwindow = (GtkWidget *) NULL; | |
52 } | |
53 | |
54 void | |
55 BuddyTickerCreateWindow() | |
56 { | |
57 if ( tickerwindow != (GtkWidget *) NULL ) | |
58 return; | |
59 tickerwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); | |
60 gtk_signal_connect (GTK_OBJECT(tickerwindow), "destroy", | |
61 GTK_SIGNAL_FUNC (BuddyTickerDestroyWindow), "WM destroy"); | |
62 gtk_window_set_title (GTK_WINDOW(tickerwindow), "Buddy Ticker"); | |
63 | |
64 ticker = gtk_ticker_new(); | |
65 gtk_container_add( GTK_CONTAINER( tickerwindow ), ticker ); | |
66 gtk_ticker_set_spacing( GTK_TICKER( ticker ), 20 ); | |
67 gtk_widget_set_usize( ticker, 200, -1 ); | |
68 gtk_widget_show (ticker); | |
69 | |
70 gtk_ticker_set_interval( GTK_TICKER( ticker ), 500 ); | |
71 gtk_ticker_set_scootch( GTK_TICKER( ticker ), 10 ); | |
72 gtk_ticker_start_scroll( GTK_TICKER( ticker ) ); | |
73 } | |
74 | |
75 void | |
76 BuddyTickerAddUser( char *name, GdkPixmap *pm, GdkBitmap *bm ) | |
77 { | |
78 GtkWidget *hbox, *label, *pmap; | |
79 TickerData *p; | |
80 | |
81 BuddyTickerCreateWindow(); | |
82 p = (TickerData *) malloc( sizeof( TickerData ) ); | |
83 p->hbox = (GtkWidget *) NULL; | |
84 p->label = (GtkWidget *) NULL; | |
85 p->pix = (GtkWidget *) NULL; | |
86 strcpy( p->buddy, name ); | |
87 tickerbuds = g_list_append( tickerbuds, p ); | |
88 | |
89 p->hbox = gtk_hbox_new( FALSE, 0 ); | |
90 gtk_ticker_add( GTK_TICKER( ticker ), p->hbox ); | |
91 gtk_widget_show_all( p->hbox ); | |
92 | |
93 BuddyTickerSetPixmap( name, pm, bm ); | |
94 | |
95 p->label = gtk_label_new( name ); | |
96 gtk_box_pack_start_defaults( GTK_BOX( p->hbox ), p->label ); | |
97 gtk_widget_show( p->label ); | |
98 | |
99 gtk_widget_show( tickerwindow ); | |
100 } | |
101 | |
102 void | |
103 BuddyTickerRemoveUser( char *name ) | |
104 { | |
105 GList *p = (GList *) BuddyTickerFindUser( name ); | |
106 TickerData *data = (TickerData *) p->data; | |
107 | |
108 if ( data ) { | |
109 gtk_ticker_remove( GTK_TICKER( ticker ), data->hbox ); | |
110 tickerbuds = g_list_remove( tickerbuds, data ); | |
111 free( data ); | |
112 } | |
113 } | |
114 | |
115 void | |
116 BuddyTickerSetPixmap( char *name, GdkPixmap *pm, GdkBitmap *bm ) | |
117 { | |
118 GList *p = (GList *) BuddyTickerFindUser( name ); | |
119 TickerData *data = (TickerData *) p->data; | |
120 | |
121 if ( data->pix == (GtkWidget *) NULL ) { | |
122 data->pix = gtk_pixmap_new( pm, bm ); | |
123 gtk_box_pack_start_defaults( GTK_BOX( data->hbox ), data->pix ); | |
124 } else { | |
125 gtk_widget_hide( data->pix ); | |
126 gtk_pixmap_set(GTK_PIXMAP(data->pix), pm, bm); | |
127 } | |
128 gtk_widget_show( data->pix ); | |
129 } | |
130 | |
131 GList * | |
132 BuddyTickerFindUser( char *name ) | |
133 { | |
134 GList *p = tickerbuds; | |
135 | |
136 while ( p ) { | |
137 TickerData *q = (TickerData *) p->data; | |
138 if ( !strcmp( name, q->buddy ) ) | |
139 return( p ); | |
140 p = p->next; | |
141 } | |
142 return (GList *) NULL; | |
143 } | |
144 | |
145 int | |
146 BuddyTickerLogonTimeout( gpointer data ) | |
147 { | |
148 char *name = (char *) data; | |
149 | |
150 GList *p = (GList *) BuddyTickerFindUser( name ); | |
151 TickerData *q = (TickerData *) p->data; | |
152 | |
153 if ( q ) { | |
154 | |
155 } | |
156 | |
157 return FALSE; | |
158 } | |
159 | |
160 int | |
161 BuddyTickerLogoutTimeout( gpointer data ) | |
162 { | |
163 char *name = (char *) data; | |
164 | |
165 BuddyTickerRemoveUser( name ); | |
166 | |
167 return FALSE; | |
168 } |