1
|
1 /**************************************************************
|
|
2 **
|
|
3 ** GaimGnomeAppletMgr
|
|
4 ** Author - Quinticent (John Palmieri: johnp@martianrock.com)
|
|
5 **
|
|
6 ** Purpose - Takes over the task of managing the GNOME applet
|
|
7 ** code and provides a centralized codebase for
|
|
8 ** GNOME integration for Gaim.
|
|
9 **
|
|
10 **
|
|
11 ** gaim
|
|
12 **
|
|
13 ** Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
|
|
14 **
|
|
15 ** This program is free software; you can redistribute it and/or modify
|
|
16 ** it under the terms of the GNU General Public License as published by
|
|
17 ** the Free Software Foundation; either version 2 of the License, or
|
|
18 ** (at your option) any later version.
|
|
19 **
|
|
20 ** This program is distributed in the hope that it will be useful,
|
|
21 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23 ** GNU General Public License for more details.
|
|
24 **
|
|
25 ** You should have received a copy of the GNU General Public License
|
|
26 ** along with this program; if not, write to the Free Software
|
|
27 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
28 */
|
|
29
|
|
30 #ifdef USE_APPLET
|
|
31 #include <string.h>
|
|
32 #include <gdk_imlib.h>
|
|
33 #include "gaim.h"
|
|
34 #include "gnome_applet_mgr.h"
|
|
35
|
|
36 enum gaim_user_states MRI_user_status;
|
|
37 gint total_num_of_buddies; /* how many buddies I have in my list */
|
|
38 gint num_of_buddies_online; /* how many of them are online */
|
|
39
|
|
40 gboolean buddy_created = FALSE;
|
|
41 gboolean applet_draw_open = FALSE;
|
|
42 GtkWidget *applet_popup = NULL;
|
|
43
|
|
44 GtkWidget *applet;
|
|
45 GtkWidget *button;
|
|
46 GtkWidget *status_label;
|
|
47
|
|
48 GtkWidget *icon;
|
|
49 GdkPixmap *icon_offline_pm=NULL;
|
|
50 GdkPixmap *icon_offline_bm=NULL;
|
|
51
|
|
52 GdkPixmap *icon_online_pm=NULL;
|
|
53 GdkPixmap *icon_online_bm=NULL;
|
|
54
|
|
55 GdkPixmap *icon_connect_pm=NULL;
|
|
56 GdkPixmap *icon_connect_bm=NULL;
|
|
57
|
|
58 GdkPixmap *icon_msg_pending_pm=NULL;
|
|
59 GdkPixmap *icon_msg_pending_bm=NULL;
|
|
60
|
|
61 GdkPixmap *icon_away_pm=NULL;
|
|
62 GdkPixmap *icon_away_bm=NULL;
|
|
63
|
|
64 /***************************************************************
|
|
65 **
|
|
66 ** function load_applet_icon
|
|
67 ** visibility - private
|
|
68 **
|
|
69 ** input:
|
|
70 ** name - the name of the file to load
|
|
71 ** height, width - the height and width
|
|
72 ** that the icon should be
|
|
73 ** scaled to.
|
|
74 **
|
|
75 ** output:
|
|
76 ** TRUE - success
|
|
77 ** FALSE - failure
|
|
78 ** pm - a GdkPixmap structure that the icon is loaded into
|
|
79 ** bm - a GdkBitmap structure that the icon's transparancy
|
|
80 ** mask is loaded into
|
|
81 **
|
|
82 ** description - loads an icon from
|
|
83 ** /usr/share/pixmap/gaim/gnome/
|
|
84 ** and scales it using imlib
|
|
85 **
|
|
86 ****************************************************************/
|
|
87
|
|
88 gboolean load_applet_icon( const char *name, int height, int width, GdkPixmap **pm, GdkBitmap **bm ){
|
|
89 gboolean result = TRUE;
|
|
90 char path[255] = GAIM_GNOME_PIXMAP_DIR;
|
|
91 GdkImlibImage *im;
|
|
92 GdkPixmap *temp_pm;
|
|
93 GdkPixmap *temp_bm;
|
|
94
|
|
95 strcat( path, name);
|
|
96
|
|
97 im=gdk_imlib_load_image( path );
|
|
98
|
|
99 if ((*pm)!=NULL)
|
|
100 gdk_imlib_free_pixmap((*pm));
|
|
101
|
|
102 if( im!= NULL ){
|
|
103 gdk_imlib_render(im,width,height);
|
|
104
|
|
105 (*pm) = gdk_imlib_move_image(im);
|
|
106 (*bm) = gdk_imlib_move_mask(im);
|
|
107
|
|
108 } else {
|
|
109 result = FALSE;
|
|
110 sprintf(debug_buff,"file not found: %s\n",path);
|
|
111 debug_print(debug_buff);
|
|
112 }
|
|
113
|
|
114 return result;
|
|
115 }
|
|
116
|
|
117 /***************************************************************
|
|
118 **
|
|
119 ** function update_applet
|
|
120 ** visibility - private
|
|
121 **
|
|
122 ** input:
|
|
123 ** ap - not in use
|
|
124 **
|
|
125 ** description - takes care of swapping status icons and
|
|
126 ** updating the status label
|
|
127 **
|
|
128 ****************************************************************/
|
|
129
|
|
130 gboolean update_applet( gpointer *ap ){
|
|
131 char temp_string[25];
|
|
132 static enum gaim_user_states old_user_status = offline;
|
|
133 static gint old_total_num_of_buddies = -1;
|
|
134 static gint old_num_of_buddies_online = -1;
|
|
135 if( applet_draw_open ){
|
|
136 sprintf(debug_buff, "Drawer is open\n");
|
|
137 debug_print(debug_buff);
|
|
138 } else {
|
|
139 sprintf(debug_buff, "Drawer is closed\n");
|
|
140 debug_print(debug_buff);
|
|
141 }
|
|
142
|
|
143 if( MRI_user_status != old_user_status ){
|
|
144
|
|
145 switch( MRI_user_status ){
|
|
146 case offline:
|
|
147 gtk_pixmap_set( GTK_PIXMAP(icon),
|
|
148 icon_offline_pm,
|
|
149 icon_offline_bm );
|
|
150 gtk_label_set( GTK_LABEL(status_label), _MSG_OFFLINE_ );
|
|
151 break;
|
|
152 case signing_on:
|
|
153 gtk_pixmap_set( GTK_PIXMAP(icon),
|
|
154 icon_connect_pm,
|
|
155 icon_connect_bm );
|
|
156 gtk_label_set( GTK_LABEL(status_label), _MSG_CONNECT_ );
|
|
157 old_total_num_of_buddies = -1;
|
|
158 old_num_of_buddies_online = -1;
|
|
159 break;
|
|
160 case online:
|
|
161 gtk_pixmap_set( GTK_PIXMAP(icon),
|
|
162 icon_online_pm,
|
|
163 icon_online_bm );
|
|
164
|
|
165 gtk_label_set( GTK_LABEL(status_label), _MSG_ONLINE_ );
|
|
166 break;
|
|
167
|
|
168 case unread_message_pending:
|
|
169 gtk_pixmap_set( GTK_PIXMAP(icon),
|
|
170 icon_msg_pending_pm,
|
|
171 icon_msg_pending_bm );
|
|
172 gtk_label_set( GTK_LABEL(status_label), "msg" );
|
|
173 break;
|
|
174 case away:
|
|
175 gtk_pixmap_set( GTK_PIXMAP(icon),
|
|
176 icon_away_pm,
|
|
177 icon_away_bm );
|
|
178 gtk_label_set( GTK_LABEL(status_label), "Away" );
|
|
179 break;
|
|
180 }
|
|
181 old_user_status = MRI_user_status;
|
|
182 }
|
|
183 #ifdef _USE_BUDDY_COUNT_
|
|
184 if( (( old_total_num_of_buddies != total_num_of_buddies ) ||
|
|
185 ( old_num_of_buddies_online != num_of_buddies_online )) &&
|
|
186 ( MRI_user_status == online ) ){
|
|
187 /*make user buffer can not overflow*/
|
|
188 if(total_num_of_buddies<1000){
|
|
189 sprintf(temp_string, "%i/%i", num_of_buddies_online, total_num_of_buddies);
|
|
190 } else {
|
|
191 if(num_of_buddies_online<100000){
|
|
192 sprintf(temp_string, "%i", num_of_buddies_online);
|
|
193 } else {
|
|
194 /*we most likely will never get to here but
|
|
195 hey, people also thought computer wouldn't
|
|
196 be around by the year 2000 :-) */
|
|
197 sprintf(temp_string, _MSG_ONLINE_ );
|
|
198 }
|
|
199 }
|
|
200 gtk_label_set( GTK_LABEL(status_label), temp_string );
|
|
201 old_total_num_of_buddies = total_num_of_buddies;
|
|
202 old_num_of_buddies_online = num_of_buddies_online;
|
|
203 }
|
|
204 #endif /*_USE_BUDDY_COUNT_*/
|
|
205 return TRUE;
|
|
206
|
|
207 }
|
|
208
|
|
209
|
|
210 /***************************************************************
|
|
211 **
|
|
212 ** function make_buddy
|
|
213 ** visibility - private
|
|
214 **
|
|
215 ** description - If buddylist is not created create it
|
|
216 ** else show the buddy list
|
|
217 **
|
|
218 ****************************************************************/
|
|
219 void make_buddy(void) {
|
|
220 set_applet_draw_open();
|
|
221 if( !buddy_created ){
|
|
222 show_buddy_list();
|
|
223 buddy_created = TRUE;
|
|
224 } else {
|
|
225 gnome_buddy_show();
|
|
226 }
|
16
|
227 build_edit_tree();
|
1
|
228 applet_widget_unregister_callback(APPLET_WIDGET(applet),"buddy");
|
|
229
|
|
230 }
|
|
231
|
|
232 /***************************************************************
|
|
233 **
|
|
234 ** function applet_show_login
|
|
235 ** visibility - private
|
|
236 **
|
|
237 ** input:
|
|
238 **
|
|
239 **
|
|
240 ** description - I guess it shows the login dialog
|
|
241 **
|
|
242 ****************************************************************/
|
|
243
|
|
244 void applet_show_login(AppletWidget *widget, gpointer data) {
|
|
245 show_login();
|
|
246 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signon");
|
|
247 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
248 "signoff",
|
|
249 _("Signoff"),
|
|
250 signoff,
|
|
251 NULL);
|
18
|
252 insert_applet_away();
|
1
|
253 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
254 "buddy",
|
|
255 _("Buddy List"),
|
|
256 (AppletCallbackFunc)make_buddy,
|
|
257 NULL);
|
|
258 }
|
|
259
|
18
|
260 void insert_applet_away() {
|
|
261 GList *awy = away_messages;
|
|
262 struct away_message *a;
|
|
263 char *awayname;
|
|
264
|
|
265 applet_widget_register_callback_dir(APPLET_WIDGET(applet),
|
|
266 "away",
|
|
267 _("Away"));
|
|
268 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
269 "away/new",
|
|
270 _("New Away Message"),
|
|
271 (AppletCallbackFunc)create_away_mess,
|
|
272 NULL);
|
|
273
|
|
274 while(awy) {
|
|
275 a = (struct away_message *)awy->data;
|
|
276
|
|
277 awayname = malloc(sizeof *awayname * (6 + strlen(a->name)));
|
|
278 awayname[0] = '\0';
|
|
279 strcat(awayname, "away/");
|
|
280 strcat(awayname, a->name);
|
|
281 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
282 awayname,
|
|
283 a->name,
|
|
284 (AppletCallbackFunc)do_away_message,
|
|
285 a);
|
|
286
|
|
287 awy = awy->next;
|
|
288 }
|
|
289 }
|
|
290
|
|
291 void remove_applet_away() {
|
|
292 GList *awy = away_messages;
|
|
293 struct away_message *a;
|
|
294 char *awayname;
|
|
295
|
|
296 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new");
|
|
297
|
|
298 while (awy) {
|
|
299 a = (struct away_message *)awy->data;
|
|
300
|
|
301 awayname = malloc(sizeof *awayname * (5 + strlen(a->name)));
|
|
302 awayname[0] = '\0';
|
|
303 strcat(awayname, "away/");
|
|
304 strcat(awayname, a->name);
|
|
305 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname);
|
|
306
|
|
307 awy = awy->next;
|
|
308 }
|
|
309 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away");
|
|
310 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away");
|
|
311 }
|
|
312
|
1
|
313 /***************************************************************
|
|
314 **
|
|
315 ** function applet_show_about
|
|
316 ** visibility - public
|
|
317 **
|
|
318 **
|
|
319 ** description - takes care of creating and
|
|
320 ** displaying the about box
|
|
321 **
|
|
322 ****************************************************************/
|
|
323 void applet_show_about(AppletWidget *widget, gpointer data) {
|
|
324
|
|
325 const gchar *authors[] = {"Mark Spencer <markster@marko.net>",
|
|
326 "Jim Duchek <jimduchek@ou.edu>",
|
|
327 "Rob Flynn <rflynn@blueridge.net>",
|
|
328
|
|
329 NULL};
|
|
330
|
|
331 GtkWidget *about=gnome_about_new(_("GAIM"),
|
|
332 _(VERSION),
|
|
333 _(""),
|
|
334 authors,
|
|
335 "",
|
|
336 NULL);
|
|
337 gtk_widget_show(about);
|
|
338 }
|
|
339
|
|
340 /***************************************************************
|
|
341 **
|
|
342 ** function AppletCancelLogin (name should be changed to
|
|
343 ** applet_cancel_login)
|
|
344 ** visibility - public
|
|
345 **
|
|
346 ** description - called when user cancels login
|
|
347 **
|
|
348 ****************************************************************/
|
|
349 void AppletCancelLogon(){
|
|
350 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signoff");
|
|
351 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
352 "signon",
|
|
353 _("Signon"),
|
|
354 applet_show_login,
|
|
355 NULL);
|
|
356 }
|
|
357
|
|
358 /***************************************************************
|
|
359 **
|
|
360 ** function get_applet_pos
|
|
361 ** visibility - private
|
|
362 **
|
|
363 ** output:
|
|
364 ** GtKAllocation - a Gtk struct that holds the
|
|
365 ** position of the dialog
|
|
366 **
|
|
367 ** description - returns the x,y position the buddy list should
|
|
368 ** should be placed based on the position
|
|
369 ** of the applet and the orientation
|
|
370 ** of the Gnome panel.
|
|
371 **
|
|
372 ****************************************************************/
|
|
373 GtkAllocation get_applet_pos(){
|
|
374 GtkAllocation pos;
|
|
375 gint x,y,pad;
|
|
376 GtkRequisition buddy_req, applet_req;
|
|
377 GtkAllocation result;
|
|
378 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient( APPLET_WIDGET(applet) );
|
|
379 pad = 5;
|
|
380 gdk_window_get_position( gtk_widget_get_parent_window( button ),&x,&y );
|
|
381 buddy_req = gnome_buddy_get_dimentions();
|
|
382 applet_req = button->requisition;
|
|
383 switch( orient ){
|
|
384 case ORIENT_UP:
|
|
385 result.x=x;
|
|
386 result.y=y-(buddy_req.height+pad);
|
|
387 break;
|
|
388 case ORIENT_DOWN:
|
|
389 result.x=x;
|
|
390 result.y=y+applet_req.height+pad;
|
|
391
|
|
392 break;
|
|
393 case ORIENT_LEFT:
|
|
394 result.x=x-(buddy_req.width + pad );
|
|
395 result.y=y;
|
|
396 break;
|
|
397 case ORIENT_RIGHT:
|
|
398 result.x=x+applet_req.width+pad;
|
|
399 result.y=y;
|
|
400 break;
|
|
401 }
|
|
402
|
|
403
|
|
404 return result;
|
|
405 }
|
|
406
|
|
407
|
|
408
|
|
409 void createOfflinePopup(){
|
|
410 applet_show_login( APPLET_WIDGET(applet), NULL );
|
|
411 }
|
|
412
|
|
413
|
|
414 void createSignonPopup(){
|
|
415 applet_draw_open = FALSE;
|
|
416 }
|
|
417
|
|
418
|
|
419 void createOnlinePopup(){
|
|
420 GtkAllocation al;
|
|
421 make_buddy();
|
|
422 al = get_applet_pos();
|
|
423 gnome_buddy_set_pos( al.x, al.y );
|
|
424 }
|
|
425
|
|
426
|
|
427 void createPendingPopup(){
|
|
428 applet_draw_open = FALSE;
|
|
429 }
|
|
430
|
|
431
|
|
432 void createAwayPopup(){
|
|
433 applet_draw_open = FALSE;
|
|
434 }
|
|
435
|
|
436
|
|
437 void closeOfflinePopup(){
|
|
438 cancel_logon();
|
|
439 set_applet_draw_closed();
|
|
440 }
|
|
441
|
|
442
|
|
443 void closeSignonPopup(){
|
|
444
|
|
445 }
|
|
446
|
|
447
|
|
448 void closeOnlinePopup(){
|
|
449 set_applet_draw_closed();
|
|
450 applet_destroy_buddy();
|
|
451 }
|
|
452
|
|
453
|
|
454 void closePendingPopup(){
|
|
455 applet_draw_open = FALSE;
|
|
456 }
|
|
457
|
|
458
|
|
459 void closeAwayPopup(){
|
|
460 applet_draw_open = FALSE;
|
|
461 }
|
|
462
|
|
463 void AppletClicked( GtkWidget *sender, gpointer data ){
|
|
464
|
|
465 if( applet_draw_open ){
|
|
466 switch( MRI_user_status ){
|
|
467 case offline:
|
|
468 closeOfflinePopup();
|
|
469 break;
|
|
470 case signing_on:
|
|
471 closeSignonPopup();
|
|
472 break;
|
|
473 case online:
|
|
474 closeOnlinePopup();
|
|
475
|
|
476 break;
|
|
477 case unread_message_pending:
|
|
478 closePendingPopup();
|
|
479 break;
|
|
480 case away:
|
|
481 closeAwayPopup();
|
|
482 break;
|
|
483 }
|
|
484 } else {
|
|
485 set_applet_draw_open();
|
|
486 switch( MRI_user_status ){
|
|
487 case offline:
|
|
488 createOfflinePopup();
|
|
489 break;
|
|
490 case signing_on:
|
|
491 createSignonPopup();
|
|
492 break;
|
|
493 case online:
|
|
494 createOnlinePopup();
|
|
495 break;
|
|
496 case unread_message_pending:
|
|
497 createPendingPopup();
|
|
498 break;
|
|
499 case away:
|
|
500 createAwayPopup();
|
|
501 break;
|
|
502 }
|
|
503
|
|
504
|
|
505 }
|
|
506 }
|
|
507
|
|
508
|
|
509 #ifdef HAVE_PANEL_SIZE
|
|
510 /***************************************************************
|
|
511 **
|
|
512 ** Code for panel resizing
|
|
513 **
|
|
514 ****************************************************************/
|
|
515 static void applet_change_size(GtkWidget *w, PanelSizeType o, gpointer data) {
|
|
516 switch(o) {
|
|
517 case SIZE_TINY:
|
|
518 /*24x24*/
|
|
519 gtk_widget_set_usize( button, 24,24 );
|
|
520
|
|
521 /*load offline icon*/
|
|
522 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
523 24, 24, &icon_offline_pm, &icon_offline_bm );
|
|
524
|
|
525 /*load connecting icon*/
|
|
526 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
527 24, 24, &icon_connect_pm, &icon_connect_bm );
|
|
528
|
|
529 /*load online icon*/
|
|
530 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
531 24, 24, &icon_online_pm, &icon_online_bm );
|
|
532 break;
|
|
533
|
|
534 case SIZE_STANDARD:
|
|
535 /*48x48*/
|
|
536 gtk_widget_set_usize( button, 48,48 );
|
|
537
|
|
538 /*load offline icon*/
|
|
539 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
540 32, 34, &icon_offline_pm, &icon_offline_bm );
|
|
541
|
|
542 /*load connecting icon*/
|
|
543 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
544 32, 34, &icon_connect_pm, &icon_connect_bm );
|
|
545
|
|
546 /*load online icon*/
|
|
547 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
548 32, 34, &icon_online_pm, &icon_online_bm );
|
|
549 break;
|
|
550
|
|
551 case SIZE_LARGE:
|
|
552 /*64x64*/
|
|
553 gtk_widget_set_usize( button, 64, 64 );
|
|
554
|
|
555 /*load offline icon*/
|
|
556 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
557 55, 55, &icon_offline_pm, &icon_offline_bm );
|
|
558
|
|
559 /*load connecting icon*/
|
|
560 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
561 55, 55, &icon_connect_pm, &icon_connect_bm );
|
|
562
|
|
563 /*load online icon*/
|
|
564 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
565 55, 55, &icon_online_pm, &icon_online_bm );
|
|
566 break;
|
|
567
|
|
568 case SIZE_HUGE:
|
|
569 /*80x80*/
|
|
570 gtk_widget_set_usize( button, 80, 80 );
|
|
571
|
|
572 /*load offline icon*/
|
|
573 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
574 70, 70, &icon_offline_pm, &icon_offline_bm );
|
|
575
|
|
576 /*load connecting icon*/
|
|
577 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
578 70, 70, &icon_connect_pm, &icon_connect_bm );
|
|
579
|
|
580 /*load online icon*/
|
|
581 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
582 70, 70, &icon_online_pm, &icon_online_bm );
|
|
583
|
|
584 break;
|
|
585 }
|
|
586 }
|
|
587 #endif /*HAVE_PANEL_SIZE*/
|
|
588
|
|
589
|
|
590 /***************************************************************
|
|
591 **
|
|
592 ** Initialize GNOME stuff
|
|
593 **
|
|
594 ****************************************************************/
|
|
595
|
|
596 gint InitAppletMgr( int argc, char *argv[] ){
|
|
597 GtkWidget *vbox;
|
|
598
|
|
599 GtkStyle *label_style;
|
|
600 GdkFont *label_font = NULL;
|
|
601
|
|
602 applet_widget_init("GAIM",VERSION,argc,argv,NULL,0,NULL);
|
|
603
|
|
604 /*init imlib for graphics*/
|
|
605 gdk_imlib_init();
|
|
606 gtk_widget_push_visual(gdk_imlib_get_visual());
|
|
607 gtk_widget_push_colormap(gdk_imlib_get_colormap());
|
|
608
|
|
609 applet=applet_widget_new("gaim_applet");
|
|
610 if(!applet) g_error(_("Can't create GAIM applet!"));
|
|
611
|
|
612 button=gtk_button_new();
|
|
613
|
|
614
|
|
615 gtk_widget_set_usize( button, 48,48 );
|
|
616
|
|
617
|
|
618 /*load offline icon*/
|
|
619 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
620 32, 32, &icon_offline_pm, &icon_offline_bm );
|
|
621
|
|
622 /*load connecting icon*/
|
|
623 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
624 32, 32, &icon_connect_pm, &icon_connect_bm );
|
|
625
|
|
626 /*load online icon*/
|
|
627 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
628 32, 32, &icon_online_pm, &icon_online_bm );
|
|
629
|
|
630 /*icon_away and icon_msg_pennding need to be implemented*/
|
|
631
|
|
632 icon=gtk_pixmap_new(icon_offline_pm,icon_offline_bm);
|
|
633
|
|
634 gtk_timeout_add( 1500, (GtkFunction)update_applet, NULL );
|
|
635
|
|
636 vbox = gtk_vbox_new(FALSE,0);
|
|
637
|
|
638 gtk_box_pack_start(GTK_BOX(vbox), icon, FALSE, TRUE, 0);
|
|
639
|
|
640 status_label = gtk_label_new("Offline");
|
|
641 /*set this label's font*/
|
|
642 label_style = gtk_widget_get_style( status_label );
|
|
643
|
|
644 label_font = gdk_font_load( _MSG_FONT_ );
|
|
645
|
|
646
|
|
647 if( label_font != NULL ){
|
|
648 label_style->font = label_font;
|
|
649 gtk_widget_set_style( status_label, label_style );
|
|
650 } else {
|
|
651 sprintf(debug_buff, "Font does not exist" );
|
|
652 debug_print(debug_buff);
|
|
653 }
|
|
654
|
|
655 #ifdef HAVE_PANEL_SIZE
|
|
656 gtk_signal_connect(GTK_OBJECT(applet),"change_size",
|
|
657 GTK_SIGNAL_FUNC(applet_change_size),
|
|
658 NULL);
|
|
659 #endif /*HAVE_PANEL_SIZE*/
|
|
660
|
|
661 gtk_box_pack_start(GTK_BOX(vbox), status_label, FALSE, TRUE, 0);
|
|
662
|
|
663 gtk_container_add( GTK_CONTAINER(button), vbox );
|
|
664 applet_widget_add(APPLET_WIDGET(applet), button);
|
|
665
|
|
666 gtk_widget_show( status_label );
|
|
667 gtk_widget_show( vbox );
|
|
668 gtk_widget_show( button );
|
|
669
|
|
670 applet_widget_set_tooltip(APPLET_WIDGET(applet),"GAIM");
|
|
671
|
|
672 applet_widget_register_stock_callback(APPLET_WIDGET(applet),
|
|
673 "about",
|
|
674 GNOME_STOCK_MENU_ABOUT,
|
|
675 _("About..."),
|
|
676 applet_show_about,
|
|
677 NULL);
|
|
678
|
|
679 gtk_signal_connect( GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC( AppletClicked), NULL);
|
|
680
|
|
681 gtk_widget_show(icon);
|
|
682 gtk_widget_show(applet);
|
|
683 return 0;
|
|
684 }
|
|
685
|
|
686 void setUserState( enum gaim_user_states state ){
|
|
687 MRI_user_status = state;
|
|
688 update_applet( (gpointer *)applet );
|
|
689 }
|
|
690
|
|
691 void setTotalBuddies( gint num ){
|
|
692 total_num_of_buddies = num;
|
|
693 }
|
|
694
|
|
695 void setNumBuddiesOnline( gint num ){
|
|
696 num_of_buddies_online=num;
|
|
697 }
|
|
698
|
|
699 enum gaim_user_states getUserState(){
|
|
700 return MRI_user_status;
|
|
701 }
|
|
702
|
|
703 gint getTotalBuddies(){
|
|
704 return total_num_of_buddies;
|
|
705 }
|
|
706
|
|
707 gint getNumBuddiesOnline(){
|
|
708 return num_of_buddies_online;
|
|
709 }
|
|
710
|
|
711 void set_applet_draw_open(){
|
|
712 applet_draw_open = TRUE;
|
|
713 }
|
|
714
|
|
715 void set_applet_draw_closed(){
|
|
716 applet_draw_open = FALSE;
|
|
717 }
|
|
718
|
|
719 #endif /*USE_APPLET*/
|