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