Mercurial > pidgin.yaz
annotate src/gnome_applet_mgr.c @ 340:0d9cfc3579a5
[gaim-migrate @ 350]
More changes to the applet. Now, you can have it remember the position and
not have it near the applet, or not remember the position and not near the
applet, or near the applet. Also, if you want it near the applet, the login
box will appear near the applet.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 06 Jun 2000 21:33:20 +0000 |
parents | 9d258a0aa560 |
children | f4fba304b236 |
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 | |
38 gboolean buddy_created = FALSE; | |
39 gboolean applet_draw_open = FALSE; | |
40 GtkWidget *applet_popup = NULL; | |
41 | |
82 | 42 gchar GAIM_GNOME_OFFLINE_ICON[255] = GAIM_GNOME_PENGUIN_OFFLINE; |
43 gchar GAIM_GNOME_CONNECT_ICON[255] = GAIM_GNOME_PENGUIN_CONNECT; | |
44 gchar GAIM_GNOME_ONLINE_ICON[255] = GAIM_GNOME_PENGUIN_ONLINE; | |
45 | |
1 | 46 GtkWidget *applet; |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
47 GtkWidget *appletframe; |
1 | 48 GtkWidget *status_label; |
49 | |
50 GtkWidget *icon; | |
51 GdkPixmap *icon_offline_pm=NULL; | |
52 GdkPixmap *icon_offline_bm=NULL; | |
53 | |
54 GdkPixmap *icon_online_pm=NULL; | |
55 GdkPixmap *icon_online_bm=NULL; | |
56 | |
57 GdkPixmap *icon_connect_pm=NULL; | |
58 GdkPixmap *icon_connect_bm=NULL; | |
59 | |
60 GdkPixmap *icon_msg_pending_pm=NULL; | |
61 GdkPixmap *icon_msg_pending_bm=NULL; | |
62 | |
63 GdkPixmap *icon_away_pm=NULL; | |
64 GdkPixmap *icon_away_bm=NULL; | |
65 | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
66 static GtkAllocation get_applet_pos(gboolean); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
67 |
1 | 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; |
82 | 96 |
97 path = gnome_pixmap_file(name); | |
98 | |
1 | 99 im=gdk_imlib_load_image( path ); |
100 | |
101 if ((*pm)!=NULL) | |
102 gdk_imlib_free_pixmap((*pm)); | |
103 | |
104 if( im!= NULL ){ | |
105 gdk_imlib_render(im,width,height); | |
106 | |
107 (*pm) = gdk_imlib_move_image(im); | |
108 (*bm) = gdk_imlib_move_mask(im); | |
109 | |
110 } else { | |
111 result = FALSE; | |
112 sprintf(debug_buff,"file not found: %s\n",path); | |
113 debug_print(debug_buff); | |
114 } | |
115 | |
82 | 116 free(path); |
1 | 117 return result; |
118 } | |
119 | |
120 /*************************************************************** | |
121 ** | |
122 ** function update_applet | |
123 ** visibility - private | |
124 ** | |
125 ** input: | |
82 | 126 ** ap - if not NULL, was called from update_pixmaps, and |
127 ** should update them | |
1 | 128 ** |
129 ** description - takes care of swapping status icons and | |
130 ** updating the status label | |
131 ** | |
132 ****************************************************************/ | |
133 | |
134 gboolean update_applet( gpointer *ap ){ | |
135 static enum gaim_user_states old_user_status = offline; | |
136 | |
82 | 137 if( MRI_user_status != old_user_status || ap){ |
1 | 138 |
139 switch( MRI_user_status ){ | |
140 case offline: | |
141 gtk_pixmap_set( GTK_PIXMAP(icon), | |
142 icon_offline_pm, | |
143 icon_offline_bm ); | |
144 gtk_label_set( GTK_LABEL(status_label), _MSG_OFFLINE_ ); | |
145 break; | |
146 case signing_on: | |
147 gtk_pixmap_set( GTK_PIXMAP(icon), | |
148 icon_connect_pm, | |
149 icon_connect_bm ); | |
150 gtk_label_set( GTK_LABEL(status_label), _MSG_CONNECT_ ); | |
151 break; | |
152 case online: | |
153 gtk_pixmap_set( GTK_PIXMAP(icon), | |
154 icon_online_pm, | |
155 icon_online_bm ); | |
156 | |
157 gtk_label_set( GTK_LABEL(status_label), _MSG_ONLINE_ ); | |
158 break; | |
159 | |
160 case unread_message_pending: | |
161 gtk_pixmap_set( GTK_PIXMAP(icon), | |
162 icon_msg_pending_pm, | |
163 icon_msg_pending_bm ); | |
164 gtk_label_set( GTK_LABEL(status_label), "msg" ); | |
165 break; | |
166 case away: | |
167 gtk_pixmap_set( GTK_PIXMAP(icon), | |
82 | 168 icon_online_pm, |
169 icon_online_bm ); | |
1 | 170 gtk_label_set( GTK_LABEL(status_label), "Away" ); |
171 break; | |
172 } | |
173 old_user_status = MRI_user_status; | |
174 } | |
175 return TRUE; | |
176 | |
177 } | |
178 | |
82 | 179 void update_pixmaps() { |
180 if (display_options & OPT_DISP_DEVIL_PIXMAPS) { | |
181 sprintf(GAIM_GNOME_OFFLINE_ICON, "%s", GAIM_GNOME_DEVIL_OFFLINE); | |
182 sprintf(GAIM_GNOME_CONNECT_ICON, "%s", GAIM_GNOME_DEVIL_CONNECT); | |
183 sprintf(GAIM_GNOME_ONLINE_ICON, "%s", GAIM_GNOME_DEVIL_ONLINE); | |
184 } else { | |
185 sprintf(GAIM_GNOME_OFFLINE_ICON, "%s", GAIM_GNOME_PENGUIN_OFFLINE); | |
186 sprintf(GAIM_GNOME_CONNECT_ICON, "%s", GAIM_GNOME_PENGUIN_CONNECT); | |
187 sprintf(GAIM_GNOME_ONLINE_ICON, "%s", GAIM_GNOME_PENGUIN_ONLINE); | |
188 } | |
189 load_applet_icon( GAIM_GNOME_OFFLINE_ICON, 32, 34, | |
190 &icon_offline_pm, &icon_offline_bm ); | |
191 load_applet_icon( GAIM_GNOME_CONNECT_ICON, 32, 34, | |
192 &icon_connect_pm, &icon_connect_bm ); | |
193 load_applet_icon( GAIM_GNOME_ONLINE_ICON, 32, 34, | |
194 &icon_online_pm, &icon_online_bm ); | |
195 update_applet((gpointer *)applet); | |
196 } | |
197 | |
1 | 198 |
199 /*************************************************************** | |
200 ** | |
201 ** function make_buddy | |
202 ** visibility - private | |
203 ** | |
204 ** description - If buddylist is not created create it | |
205 ** else show the buddy list | |
206 ** | |
207 ****************************************************************/ | |
208 void make_buddy(void) { | |
209 set_applet_draw_open(); | |
210 if( !buddy_created ){ | |
211 show_buddy_list(); | |
212 buddy_created = TRUE; | |
213 } else { | |
214 gnome_buddy_show(); | |
215 } | |
16 | 216 build_edit_tree(); |
246
2c5713cd9d8c
[gaim-migrate @ 256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
217 build_permit_tree(); |
1 | 218 |
219 } | |
220 | |
221 /*************************************************************** | |
222 ** | |
223 ** function applet_show_login | |
224 ** visibility - private | |
225 ** | |
226 ** input: | |
227 ** | |
228 ** | |
229 ** description - I guess it shows the login dialog | |
230 ** | |
231 ****************************************************************/ | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
232 extern GtkWidget *mainwindow; |
1 | 233 void applet_show_login(AppletWidget *widget, gpointer data) { |
234 show_login(); | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
235 if (general_options & OPT_GEN_NEAR_APPLET) { |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
236 GtkAllocation a = get_applet_pos(FALSE); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
237 gtk_widget_set_uposition(mainwindow, a.x, a.y); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
238 } |
1 | 239 } |
240 | |
18 | 241 void insert_applet_away() { |
242 GList *awy = away_messages; | |
243 struct away_message *a; | |
244 char *awayname; | |
245 | |
246 applet_widget_register_callback_dir(APPLET_WIDGET(applet), | |
46 | 247 "away/", |
18 | 248 _("Away")); |
249 applet_widget_register_callback(APPLET_WIDGET(applet), | |
250 "away/new", | |
251 _("New Away Message"), | |
252 (AppletCallbackFunc)create_away_mess, | |
253 NULL); | |
254 | |
255 while(awy) { | |
256 a = (struct away_message *)awy->data; | |
257 | |
79 | 258 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); |
18 | 259 awayname[0] = '\0'; |
260 strcat(awayname, "away/"); | |
261 strcat(awayname, a->name); | |
262 applet_widget_register_callback(APPLET_WIDGET(applet), | |
263 awayname, | |
264 a->name, | |
265 (AppletCallbackFunc)do_away_message, | |
266 a); | |
267 | |
268 awy = awy->next; | |
23 | 269 free(awayname); |
18 | 270 } |
271 } | |
272 | |
273 void remove_applet_away() { | |
274 GList *awy = away_messages; | |
275 struct away_message *a; | |
276 char *awayname; | |
277 | |
278 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new"); | |
279 | |
280 while (awy) { | |
281 a = (struct away_message *)awy->data; | |
282 | |
79 | 283 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); |
18 | 284 awayname[0] = '\0'; |
285 strcat(awayname, "away/"); | |
286 strcat(awayname, a->name); | |
287 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname); | |
288 | |
289 awy = awy->next; | |
23 | 290 free(awayname); |
18 | 291 } |
46 | 292 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/"); |
18 | 293 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); |
294 } | |
295 | |
1 | 296 /*************************************************************** |
297 ** | |
298 ** function applet_show_about | |
299 ** visibility - public | |
300 ** | |
301 ** | |
302 ** description - takes care of creating and | |
303 ** displaying the about box | |
304 ** | |
305 ****************************************************************/ | |
306 void applet_show_about(AppletWidget *widget, gpointer data) { | |
307 | |
308 const gchar *authors[] = {"Mark Spencer <markster@marko.net>", | |
309 "Jim Duchek <jimduchek@ou.edu>", | |
310 "Rob Flynn <rflynn@blueridge.net>", | |
82 | 311 "Eric Warmenhoven <warmenhoven@yahoo.com>", |
178
5d62a5d50c89
[gaim-migrate @ 188]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
312 "Syd Logan", |
1 | 313 NULL}; |
314 | |
315 GtkWidget *about=gnome_about_new(_("GAIM"), | |
316 _(VERSION), | |
317 _(""), | |
318 authors, | |
319 "", | |
320 NULL); | |
321 gtk_widget_show(about); | |
322 } | |
323 | |
324 /*************************************************************** | |
325 ** | |
326 ** function AppletCancelLogin (name should be changed to | |
327 ** applet_cancel_login) | |
328 ** visibility - public | |
329 ** | |
330 ** description - called when user cancels login | |
331 ** | |
332 ****************************************************************/ | |
333 void AppletCancelLogon(){ | |
334 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signoff"); | |
335 applet_widget_register_callback(APPLET_WIDGET(applet), | |
336 "signon", | |
337 _("Signon"), | |
338 applet_show_login, | |
339 NULL); | |
340 } | |
341 | |
342 /*************************************************************** | |
343 ** | |
344 ** function get_applet_pos | |
345 ** visibility - private | |
346 ** | |
347 ** output: | |
348 ** GtKAllocation - a Gtk struct that holds the | |
349 ** position of the dialog | |
350 ** | |
351 ** description - returns the x,y position the buddy list should | |
352 ** should be placed based on the position | |
353 ** of the applet and the orientation | |
354 ** of the Gnome panel. | |
355 ** | |
356 ****************************************************************/ | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
357 GtkAllocation get_applet_pos(gboolean for_blist) { |
1 | 358 gint x,y,pad; |
359 GtkRequisition buddy_req, applet_req; | |
360 GtkAllocation result; | |
361 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient( APPLET_WIDGET(applet) ); | |
362 pad = 5; | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
363 gdk_window_get_position(gtk_widget_get_parent_window(appletframe), &x, &y); |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
364 if (for_blist) |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
365 buddy_req = gnome_buddy_get_dimentions(); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
366 else |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
367 buddy_req = mainwindow->requisition; |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
368 applet_req = appletframe->requisition; |
1 | 369 switch( orient ){ |
370 case ORIENT_UP: | |
371 result.x=x; | |
372 result.y=y-(buddy_req.height+pad); | |
373 break; | |
374 case ORIENT_DOWN: | |
375 result.x=x; | |
376 result.y=y+applet_req.height+pad; | |
377 | |
378 break; | |
379 case ORIENT_LEFT: | |
380 result.x=x-(buddy_req.width + pad ); | |
381 result.y=y; | |
382 break; | |
383 case ORIENT_RIGHT: | |
384 result.x=x+applet_req.width+pad; | |
385 result.y=y; | |
386 break; | |
387 } | |
388 | |
389 | |
390 return result; | |
391 } | |
392 | |
393 | |
394 | |
395 void createOfflinePopup(){ | |
396 applet_show_login( APPLET_WIDGET(applet), NULL ); | |
397 } | |
398 | |
399 | |
400 void createSignonPopup(){ | |
401 applet_draw_open = FALSE; | |
402 } | |
403 | |
404 | |
405 void createOnlinePopup(){ | |
406 GtkAllocation al; | |
407 make_buddy(); | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
408 al = get_applet_pos(TRUE); |
1 | 409 gnome_buddy_set_pos( al.x, al.y ); |
410 } | |
411 | |
412 | |
413 void createPendingPopup(){ | |
414 applet_draw_open = FALSE; | |
415 } | |
416 | |
417 | |
418 void createAwayPopup(){ | |
83 | 419 createOnlinePopup(); |
1 | 420 } |
421 | |
422 | |
423 void closeOfflinePopup(){ | |
424 cancel_logon(); | |
425 set_applet_draw_closed(); | |
426 } | |
427 | |
428 | |
429 void closeSignonPopup(){ | |
430 | |
431 } | |
432 | |
433 | |
434 void closeOnlinePopup(){ | |
435 set_applet_draw_closed(); | |
436 applet_destroy_buddy(); | |
437 } | |
438 | |
439 | |
440 void closePendingPopup(){ | |
441 applet_draw_open = FALSE; | |
442 } | |
443 | |
444 | |
445 void closeAwayPopup(){ | |
83 | 446 closeOnlinePopup(); |
1 | 447 } |
448 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
449 void AppletClicked( GtkWidget *sender, GdkEventButton *ev, gpointer data ){ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
450 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
451 return; |
1 | 452 |
453 if( applet_draw_open ){ | |
454 switch( MRI_user_status ){ | |
455 case offline: | |
456 closeOfflinePopup(); | |
457 break; | |
458 case signing_on: | |
459 closeSignonPopup(); | |
460 break; | |
461 case online: | |
462 closeOnlinePopup(); | |
463 | |
464 break; | |
465 case unread_message_pending: | |
466 closePendingPopup(); | |
467 break; | |
468 case away: | |
469 closeAwayPopup(); | |
470 break; | |
471 } | |
472 } else { | |
473 set_applet_draw_open(); | |
474 switch( MRI_user_status ){ | |
475 case offline: | |
476 createOfflinePopup(); | |
477 break; | |
478 case signing_on: | |
479 createSignonPopup(); | |
480 break; | |
481 case online: | |
482 createOnlinePopup(); | |
483 break; | |
484 case unread_message_pending: | |
485 createPendingPopup(); | |
486 break; | |
487 case away: | |
488 createAwayPopup(); | |
489 break; | |
490 } | |
491 | |
492 | |
493 } | |
494 } | |
495 | |
496 | |
497 /*************************************************************** | |
498 ** | |
499 ** Initialize GNOME stuff | |
500 ** | |
501 ****************************************************************/ | |
502 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
503 gint init_applet_mgr(int argc, char *argv[]) { |
1 | 504 GtkWidget *vbox; |
505 | |
506 GtkStyle *label_style; | |
507 GdkFont *label_font = NULL; | |
508 | |
509 applet_widget_init("GAIM",VERSION,argc,argv,NULL,0,NULL); | |
510 | |
511 /*init imlib for graphics*/ | |
512 gdk_imlib_init(); | |
513 gtk_widget_push_visual(gdk_imlib_get_visual()); | |
514 gtk_widget_push_colormap(gdk_imlib_get_colormap()); | |
515 | |
516 applet=applet_widget_new("gaim_applet"); | |
517 if(!applet) g_error(_("Can't create GAIM applet!")); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
518 gtk_widget_set_events(applet, gtk_widget_get_events(applet) | |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
519 GDK_BUTTON_PRESS_MASK); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
520 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
521 appletframe = gtk_frame_new(NULL); |
1 | 522 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
523 gtk_widget_set_usize(appletframe, 48, 48); |
1 | 524 |
525 | |
526 /*load offline icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
527 load_applet_icon( GAIM_GNOME_OFFLINE_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
528 &icon_offline_pm, &icon_offline_bm ); |
1 | 529 |
530 /*load connecting icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
531 load_applet_icon( GAIM_GNOME_CONNECT_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
532 &icon_connect_pm, &icon_connect_bm ); |
1 | 533 |
534 /*load online icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
535 load_applet_icon( GAIM_GNOME_ONLINE_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
536 &icon_online_pm, &icon_online_bm ); |
1 | 537 |
538 /*icon_away and icon_msg_pennding need to be implemented*/ | |
539 | |
540 icon=gtk_pixmap_new(icon_offline_pm,icon_offline_bm); | |
541 | |
542 gtk_timeout_add( 1500, (GtkFunction)update_applet, NULL ); | |
543 | |
544 vbox = gtk_vbox_new(FALSE,0); | |
545 | |
546 gtk_box_pack_start(GTK_BOX(vbox), icon, FALSE, TRUE, 0); | |
547 | |
548 status_label = gtk_label_new("Offline"); | |
549 /*set this label's font*/ | |
550 label_style = gtk_widget_get_style( status_label ); | |
551 | |
552 label_font = gdk_font_load( _MSG_FONT_ ); | |
553 | |
554 | |
555 if( label_font != NULL ){ | |
556 label_style->font = label_font; | |
557 gtk_widget_set_style( status_label, label_style ); | |
558 } else { | |
559 sprintf(debug_buff, "Font does not exist" ); | |
560 debug_print(debug_buff); | |
561 } | |
562 | |
563 gtk_box_pack_start(GTK_BOX(vbox), status_label, FALSE, TRUE, 0); | |
564 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
565 gtk_container_add( GTK_CONTAINER(appletframe), vbox ); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
566 applet_widget_add(APPLET_WIDGET(applet), appletframe); |
1 | 567 |
568 gtk_widget_show( status_label ); | |
569 gtk_widget_show( vbox ); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
570 gtk_widget_show( appletframe ); |
1 | 571 |
572 applet_widget_set_tooltip(APPLET_WIDGET(applet),"GAIM"); | |
573 | |
574 applet_widget_register_stock_callback(APPLET_WIDGET(applet), | |
575 "about", | |
576 GNOME_STOCK_MENU_ABOUT, | |
577 _("About..."), | |
578 applet_show_about, | |
579 NULL); | |
580 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
581 gtk_signal_connect( GTK_OBJECT(applet), "button_press_event", GTK_SIGNAL_FUNC( AppletClicked), NULL); |
1 | 582 |
583 gtk_widget_show(icon); | |
584 gtk_widget_show(applet); | |
585 return 0; | |
586 } | |
587 | |
588 void setUserState( enum gaim_user_states state ){ | |
589 MRI_user_status = state; | |
82 | 590 update_applet(NULL); |
1 | 591 } |
592 | |
593 enum gaim_user_states getUserState(){ | |
594 return MRI_user_status; | |
595 } | |
596 | |
597 void set_applet_draw_open(){ | |
598 applet_draw_open = TRUE; | |
599 } | |
600 | |
601 void set_applet_draw_closed(){ | |
602 applet_draw_open = FALSE; | |
603 } | |
604 | |
605 #endif /*USE_APPLET*/ |