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();
|
|
271 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signon");
|
|
272 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
273 "signoff",
|
|
274 _("Signoff"),
|
|
275 signoff,
|
|
276 NULL);
|
18
|
277 insert_applet_away();
|
1
|
278 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
279 "buddy",
|
|
280 _("Buddy List"),
|
|
281 (AppletCallbackFunc)make_buddy,
|
|
282 NULL);
|
|
283 }
|
|
284
|
18
|
285 void insert_applet_away() {
|
|
286 GList *awy = away_messages;
|
|
287 struct away_message *a;
|
|
288 char *awayname;
|
|
289
|
|
290 applet_widget_register_callback_dir(APPLET_WIDGET(applet),
|
46
|
291 "away/",
|
18
|
292 _("Away"));
|
|
293 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
294 "away/new",
|
|
295 _("New Away Message"),
|
|
296 (AppletCallbackFunc)create_away_mess,
|
|
297 NULL);
|
|
298
|
|
299 while(awy) {
|
|
300 a = (struct away_message *)awy->data;
|
|
301
|
79
|
302 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name)));
|
18
|
303 awayname[0] = '\0';
|
|
304 strcat(awayname, "away/");
|
|
305 strcat(awayname, a->name);
|
|
306 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
307 awayname,
|
|
308 a->name,
|
|
309 (AppletCallbackFunc)do_away_message,
|
|
310 a);
|
|
311
|
|
312 awy = awy->next;
|
23
|
313 free(awayname);
|
18
|
314 }
|
82
|
315
|
|
316 MRI_user_status = online;
|
18
|
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");
|
82
|
340
|
|
341 MRI_user_status = away;
|
18
|
342 }
|
|
343
|
1
|
344 /***************************************************************
|
|
345 **
|
|
346 ** function applet_show_about
|
|
347 ** visibility - public
|
|
348 **
|
|
349 **
|
|
350 ** description - takes care of creating and
|
|
351 ** displaying the about box
|
|
352 **
|
|
353 ****************************************************************/
|
|
354 void applet_show_about(AppletWidget *widget, gpointer data) {
|
|
355
|
|
356 const gchar *authors[] = {"Mark Spencer <markster@marko.net>",
|
|
357 "Jim Duchek <jimduchek@ou.edu>",
|
|
358 "Rob Flynn <rflynn@blueridge.net>",
|
82
|
359 "Eric Warmenhoven <warmenhoven@yahoo.com>",
|
1
|
360 NULL};
|
|
361
|
|
362 GtkWidget *about=gnome_about_new(_("GAIM"),
|
|
363 _(VERSION),
|
|
364 _(""),
|
|
365 authors,
|
|
366 "",
|
|
367 NULL);
|
|
368 gtk_widget_show(about);
|
|
369 }
|
|
370
|
|
371 /***************************************************************
|
|
372 **
|
|
373 ** function AppletCancelLogin (name should be changed to
|
|
374 ** applet_cancel_login)
|
|
375 ** visibility - public
|
|
376 **
|
|
377 ** description - called when user cancels login
|
|
378 **
|
|
379 ****************************************************************/
|
|
380 void AppletCancelLogon(){
|
|
381 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signoff");
|
|
382 applet_widget_register_callback(APPLET_WIDGET(applet),
|
|
383 "signon",
|
|
384 _("Signon"),
|
|
385 applet_show_login,
|
|
386 NULL);
|
|
387 }
|
|
388
|
|
389 /***************************************************************
|
|
390 **
|
|
391 ** function get_applet_pos
|
|
392 ** visibility - private
|
|
393 **
|
|
394 ** output:
|
|
395 ** GtKAllocation - a Gtk struct that holds the
|
|
396 ** position of the dialog
|
|
397 **
|
|
398 ** description - returns the x,y position the buddy list should
|
|
399 ** should be placed based on the position
|
|
400 ** of the applet and the orientation
|
|
401 ** of the Gnome panel.
|
|
402 **
|
|
403 ****************************************************************/
|
|
404 GtkAllocation get_applet_pos(){
|
|
405 GtkAllocation pos;
|
|
406 gint x,y,pad;
|
|
407 GtkRequisition buddy_req, applet_req;
|
|
408 GtkAllocation result;
|
|
409 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient( APPLET_WIDGET(applet) );
|
|
410 pad = 5;
|
|
411 gdk_window_get_position( gtk_widget_get_parent_window( button ),&x,&y );
|
|
412 buddy_req = gnome_buddy_get_dimentions();
|
|
413 applet_req = button->requisition;
|
|
414 switch( orient ){
|
|
415 case ORIENT_UP:
|
|
416 result.x=x;
|
|
417 result.y=y-(buddy_req.height+pad);
|
|
418 break;
|
|
419 case ORIENT_DOWN:
|
|
420 result.x=x;
|
|
421 result.y=y+applet_req.height+pad;
|
|
422
|
|
423 break;
|
|
424 case ORIENT_LEFT:
|
|
425 result.x=x-(buddy_req.width + pad );
|
|
426 result.y=y;
|
|
427 break;
|
|
428 case ORIENT_RIGHT:
|
|
429 result.x=x+applet_req.width+pad;
|
|
430 result.y=y;
|
|
431 break;
|
|
432 }
|
|
433
|
|
434
|
|
435 return result;
|
|
436 }
|
|
437
|
|
438
|
|
439
|
|
440 void createOfflinePopup(){
|
|
441 applet_show_login( APPLET_WIDGET(applet), NULL );
|
|
442 }
|
|
443
|
|
444
|
|
445 void createSignonPopup(){
|
|
446 applet_draw_open = FALSE;
|
|
447 }
|
|
448
|
|
449
|
|
450 void createOnlinePopup(){
|
|
451 GtkAllocation al;
|
|
452 make_buddy();
|
|
453 al = get_applet_pos();
|
|
454 gnome_buddy_set_pos( al.x, al.y );
|
|
455 }
|
|
456
|
|
457
|
|
458 void createPendingPopup(){
|
|
459 applet_draw_open = FALSE;
|
|
460 }
|
|
461
|
|
462
|
|
463 void createAwayPopup(){
|
|
464 applet_draw_open = FALSE;
|
|
465 }
|
|
466
|
|
467
|
|
468 void closeOfflinePopup(){
|
|
469 cancel_logon();
|
|
470 set_applet_draw_closed();
|
|
471 }
|
|
472
|
|
473
|
|
474 void closeSignonPopup(){
|
|
475
|
|
476 }
|
|
477
|
|
478
|
|
479 void closeOnlinePopup(){
|
|
480 set_applet_draw_closed();
|
|
481 applet_destroy_buddy();
|
|
482 }
|
|
483
|
|
484
|
|
485 void closePendingPopup(){
|
|
486 applet_draw_open = FALSE;
|
|
487 }
|
|
488
|
|
489
|
|
490 void closeAwayPopup(){
|
|
491 applet_draw_open = FALSE;
|
|
492 }
|
|
493
|
|
494 void AppletClicked( GtkWidget *sender, gpointer data ){
|
|
495
|
|
496 if( applet_draw_open ){
|
|
497 switch( MRI_user_status ){
|
|
498 case offline:
|
|
499 closeOfflinePopup();
|
|
500 break;
|
|
501 case signing_on:
|
|
502 closeSignonPopup();
|
|
503 break;
|
|
504 case online:
|
|
505 closeOnlinePopup();
|
|
506
|
|
507 break;
|
|
508 case unread_message_pending:
|
|
509 closePendingPopup();
|
|
510 break;
|
|
511 case away:
|
|
512 closeAwayPopup();
|
|
513 break;
|
|
514 }
|
|
515 } else {
|
|
516 set_applet_draw_open();
|
|
517 switch( MRI_user_status ){
|
|
518 case offline:
|
|
519 createOfflinePopup();
|
|
520 break;
|
|
521 case signing_on:
|
|
522 createSignonPopup();
|
|
523 break;
|
|
524 case online:
|
|
525 createOnlinePopup();
|
|
526 break;
|
|
527 case unread_message_pending:
|
|
528 createPendingPopup();
|
|
529 break;
|
|
530 case away:
|
|
531 createAwayPopup();
|
|
532 break;
|
|
533 }
|
|
534
|
|
535
|
|
536 }
|
|
537 }
|
|
538
|
|
539
|
|
540 #ifdef HAVE_PANEL_SIZE
|
|
541 /***************************************************************
|
|
542 **
|
|
543 ** Code for panel resizing
|
|
544 **
|
|
545 ****************************************************************/
|
|
546 static void applet_change_size(GtkWidget *w, PanelSizeType o, gpointer data) {
|
|
547 switch(o) {
|
|
548 case SIZE_TINY:
|
|
549 /*24x24*/
|
|
550 gtk_widget_set_usize( button, 24,24 );
|
|
551
|
|
552 /*load offline icon*/
|
|
553 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
554 24, 24, &icon_offline_pm, &icon_offline_bm );
|
|
555
|
|
556 /*load connecting icon*/
|
|
557 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
558 24, 24, &icon_connect_pm, &icon_connect_bm );
|
|
559
|
|
560 /*load online icon*/
|
|
561 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
562 24, 24, &icon_online_pm, &icon_online_bm );
|
|
563 break;
|
|
564
|
|
565 case SIZE_STANDARD:
|
|
566 /*48x48*/
|
|
567 gtk_widget_set_usize( button, 48,48 );
|
|
568
|
|
569 /*load offline icon*/
|
|
570 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
571 32, 34, &icon_offline_pm, &icon_offline_bm );
|
|
572
|
|
573 /*load connecting icon*/
|
|
574 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
575 32, 34, &icon_connect_pm, &icon_connect_bm );
|
|
576
|
|
577 /*load online icon*/
|
|
578 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
579 32, 34, &icon_online_pm, &icon_online_bm );
|
|
580 break;
|
|
581
|
|
582 case SIZE_LARGE:
|
|
583 /*64x64*/
|
|
584 gtk_widget_set_usize( button, 64, 64 );
|
|
585
|
|
586 /*load offline icon*/
|
|
587 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
588 55, 55, &icon_offline_pm, &icon_offline_bm );
|
|
589
|
|
590 /*load connecting icon*/
|
|
591 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
592 55, 55, &icon_connect_pm, &icon_connect_bm );
|
|
593
|
|
594 /*load online icon*/
|
|
595 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
596 55, 55, &icon_online_pm, &icon_online_bm );
|
|
597 break;
|
|
598
|
|
599 case SIZE_HUGE:
|
|
600 /*80x80*/
|
|
601 gtk_widget_set_usize( button, 80, 80 );
|
|
602
|
|
603 /*load offline icon*/
|
|
604 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
605 70, 70, &icon_offline_pm, &icon_offline_bm );
|
|
606
|
|
607 /*load connecting icon*/
|
|
608 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
609 70, 70, &icon_connect_pm, &icon_connect_bm );
|
|
610
|
|
611 /*load online icon*/
|
|
612 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
613 70, 70, &icon_online_pm, &icon_online_bm );
|
|
614
|
|
615 break;
|
|
616 }
|
|
617 }
|
|
618 #endif /*HAVE_PANEL_SIZE*/
|
|
619
|
|
620
|
|
621 /***************************************************************
|
|
622 **
|
|
623 ** Initialize GNOME stuff
|
|
624 **
|
|
625 ****************************************************************/
|
|
626
|
|
627 gint InitAppletMgr( int argc, char *argv[] ){
|
|
628 GtkWidget *vbox;
|
|
629
|
|
630 GtkStyle *label_style;
|
|
631 GdkFont *label_font = NULL;
|
|
632
|
|
633 applet_widget_init("GAIM",VERSION,argc,argv,NULL,0,NULL);
|
|
634
|
|
635 /*init imlib for graphics*/
|
|
636 gdk_imlib_init();
|
|
637 gtk_widget_push_visual(gdk_imlib_get_visual());
|
|
638 gtk_widget_push_colormap(gdk_imlib_get_colormap());
|
|
639
|
|
640 applet=applet_widget_new("gaim_applet");
|
|
641 if(!applet) g_error(_("Can't create GAIM applet!"));
|
|
642
|
|
643 button=gtk_button_new();
|
|
644
|
|
645
|
|
646 gtk_widget_set_usize( button, 48,48 );
|
|
647
|
|
648
|
|
649 /*load offline icon*/
|
|
650 load_applet_icon( GAIM_GNOME_OFFLINE_ICON,
|
|
651 32, 32, &icon_offline_pm, &icon_offline_bm );
|
|
652
|
|
653 /*load connecting icon*/
|
|
654 load_applet_icon( GAIM_GNOME_CONNECT_ICON,
|
|
655 32, 32, &icon_connect_pm, &icon_connect_bm );
|
|
656
|
|
657 /*load online icon*/
|
|
658 load_applet_icon( GAIM_GNOME_ONLINE_ICON,
|
|
659 32, 32, &icon_online_pm, &icon_online_bm );
|
|
660
|
|
661 /*icon_away and icon_msg_pennding need to be implemented*/
|
|
662
|
|
663 icon=gtk_pixmap_new(icon_offline_pm,icon_offline_bm);
|
|
664
|
|
665 gtk_timeout_add( 1500, (GtkFunction)update_applet, NULL );
|
|
666
|
|
667 vbox = gtk_vbox_new(FALSE,0);
|
|
668
|
|
669 gtk_box_pack_start(GTK_BOX(vbox), icon, FALSE, TRUE, 0);
|
|
670
|
|
671 status_label = gtk_label_new("Offline");
|
|
672 /*set this label's font*/
|
|
673 label_style = gtk_widget_get_style( status_label );
|
|
674
|
|
675 label_font = gdk_font_load( _MSG_FONT_ );
|
|
676
|
|
677
|
|
678 if( label_font != NULL ){
|
|
679 label_style->font = label_font;
|
|
680 gtk_widget_set_style( status_label, label_style );
|
|
681 } else {
|
|
682 sprintf(debug_buff, "Font does not exist" );
|
|
683 debug_print(debug_buff);
|
|
684 }
|
|
685
|
|
686 #ifdef HAVE_PANEL_SIZE
|
|
687 gtk_signal_connect(GTK_OBJECT(applet),"change_size",
|
|
688 GTK_SIGNAL_FUNC(applet_change_size),
|
|
689 NULL);
|
|
690 #endif /*HAVE_PANEL_SIZE*/
|
|
691
|
|
692 gtk_box_pack_start(GTK_BOX(vbox), status_label, FALSE, TRUE, 0);
|
|
693
|
|
694 gtk_container_add( GTK_CONTAINER(button), vbox );
|
|
695 applet_widget_add(APPLET_WIDGET(applet), button);
|
|
696
|
|
697 gtk_widget_show( status_label );
|
|
698 gtk_widget_show( vbox );
|
|
699 gtk_widget_show( button );
|
|
700
|
|
701 applet_widget_set_tooltip(APPLET_WIDGET(applet),"GAIM");
|
|
702
|
|
703 applet_widget_register_stock_callback(APPLET_WIDGET(applet),
|
|
704 "about",
|
|
705 GNOME_STOCK_MENU_ABOUT,
|
|
706 _("About..."),
|
|
707 applet_show_about,
|
|
708 NULL);
|
|
709
|
|
710 gtk_signal_connect( GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC( AppletClicked), NULL);
|
|
711
|
|
712 gtk_widget_show(icon);
|
|
713 gtk_widget_show(applet);
|
|
714 return 0;
|
|
715 }
|
|
716
|
|
717 void setUserState( enum gaim_user_states state ){
|
|
718 MRI_user_status = state;
|
82
|
719 update_applet(NULL);
|
1
|
720 }
|
|
721
|
|
722 void setTotalBuddies( gint num ){
|
|
723 total_num_of_buddies = num;
|
|
724 }
|
|
725
|
|
726 void setNumBuddiesOnline( gint num ){
|
|
727 num_of_buddies_online=num;
|
|
728 }
|
|
729
|
|
730 enum gaim_user_states getUserState(){
|
|
731 return MRI_user_status;
|
|
732 }
|
|
733
|
|
734 gint getTotalBuddies(){
|
|
735 return total_num_of_buddies;
|
|
736 }
|
|
737
|
|
738 gint getNumBuddiesOnline(){
|
|
739 return num_of_buddies_online;
|
|
740 }
|
|
741
|
|
742 void set_applet_draw_open(){
|
|
743 applet_draw_open = TRUE;
|
|
744 }
|
|
745
|
|
746 void set_applet_draw_closed(){
|
|
747 applet_draw_open = FALSE;
|
|
748 }
|
|
749
|
|
750 #endif /*USE_APPLET*/
|