| 65 |
64 |
| 66 GdkPixmap *icon_away_pm=NULL; |
65 GdkPixmap *icon_away_pm=NULL; |
| 67 GdkPixmap *icon_away_bm=NULL; |
66 GdkPixmap *icon_away_bm=NULL; |
| 68 |
67 |
| 69 static GtkAllocation get_applet_pos(gboolean); |
68 static GtkAllocation get_applet_pos(gboolean); |
| 70 |
|
| 71 gint sizehint=48; |
69 gint sizehint=48; |
| 72 |
70 |
| 73 /*************************************************************** |
71 static gboolean load_applet_icon(const char *name, int height, int width, |
| 74 ** |
72 GdkPixmap **pm, GdkBitmap **bm) |
| 75 ** function load_applet_icon |
73 { |
| 76 ** visibility - private |
|
| 77 ** |
|
| 78 ** input: |
|
| 79 ** name - the name of the file to load |
|
| 80 ** height, width - the height and width |
|
| 81 ** that the icon should be |
|
| 82 ** scaled to. |
|
| 83 ** |
|
| 84 ** output: |
|
| 85 ** TRUE - success |
|
| 86 ** FALSE - failure |
|
| 87 ** pm - a GdkPixmap structure that the icon is loaded into |
|
| 88 ** bm - a GdkBitmap structure that the icon's transparancy |
|
| 89 ** mask is loaded into |
|
| 90 ** |
|
| 91 ** description - loads an icon from |
|
| 92 ** /usr/share/pixmap/gaim/gnome/ |
|
| 93 ** and scales it using imlib |
|
| 94 ** |
|
| 95 ****************************************************************/ |
|
| 96 |
|
| 97 gboolean load_applet_icon( const char *name, int height, int width, GdkPixmap **pm, GdkBitmap **bm ){ |
|
| 98 gboolean result = TRUE; |
74 gboolean result = TRUE; |
| 99 char *path; |
75 char *path; |
| 100 GdkImlibImage *im; |
76 GdkImlibImage *im; |
| 101 |
77 |
| 102 path = gnome_pixmap_file(name); |
78 path = gnome_pixmap_file(name); |
| 119 } |
95 } |
| 120 |
96 |
| 121 free(path); |
97 free(path); |
| 122 return result; |
98 return result; |
| 123 } |
99 } |
| 124 /*************************************************************** |
100 |
| 125 ** |
|
| 126 ** function applet_change_pixel_size |
|
| 127 ** visibility - private |
|
| 128 ** |
|
| 129 ** input: |
|
| 130 ** w - applet that called the signal |
|
| 131 ** size - size of panel |
|
| 132 ** data - extra data (in this case NULL) |
|
| 133 ** |
|
| 134 ** description - changes the size of the applet when the panel size |
|
| 135 ** changes |
|
| 136 ** |
|
| 137 ***************************************************************/ |
|
| 138 #ifdef HAVE_PANEL_PIXEL_SIZE |
101 #ifdef HAVE_PANEL_PIXEL_SIZE |
| 139 void applet_change_pixel_size(GtkWidget *w, int size, gpointer data) |
102 static void applet_change_pixel_size(GtkWidget *w, int size, gpointer data) |
| 140 { |
103 { |
| 141 sizehint = size; |
104 sizehint = size; |
| 142 update_pixmaps(); |
105 update_pixmaps(); |
| 143 } |
106 } |
| 144 #endif |
107 #endif |
| 145 |
108 |
| 146 /*************************************************************** |
109 static gboolean update_applet(gboolean force_update){ |
| 147 ** |
110 static enum gaim_user_states old_user_status = offline; |
| 148 ** function update_applet |
111 |
| 149 ** visibility - private |
112 if( MRI_user_status != old_user_status || force_update) { |
| 150 ** |
113 |
| 151 ** input: |
114 switch( MRI_user_status ){ |
| 152 ** ap - if not NULL, was called from update_pixmaps, and |
115 case offline: |
| 153 ** should update them |
116 gtk_pixmap_set( GTK_PIXMAP(icon), |
| 154 ** |
117 icon_offline_pm, |
| 155 ** description - takes care of swapping status icons and |
118 icon_offline_bm ); |
| 156 ** updating the status label |
119 gtk_label_set( GTK_LABEL(status_label), _MSG_OFFLINE_ ); |
| 157 ** |
120 applet_set_tooltips(_("Offilne. Click to bring up login box.")); |
| 158 ****************************************************************/ |
121 break; |
| 159 |
122 case signing_on: |
| 160 gboolean update_applet( gpointer *ap ){ |
123 gtk_pixmap_set( GTK_PIXMAP(icon), |
| 161 static enum gaim_user_states old_user_status = offline; |
124 icon_connect_pm, |
| 162 |
125 icon_connect_bm ); |
| 163 if( MRI_user_status != old_user_status || ap){ |
126 gtk_label_set( GTK_LABEL(status_label), _MSG_CONNECT_ ); |
| 164 |
|
| 165 switch( MRI_user_status ){ |
|
| 166 case offline: |
|
| 167 gtk_pixmap_set( GTK_PIXMAP(icon), |
|
| 168 icon_offline_pm, |
|
| 169 icon_offline_bm ); |
|
| 170 gtk_label_set( GTK_LABEL(status_label), _MSG_OFFLINE_ ); |
|
| 171 applet_set_tooltips(_("Offilne. Click to bring up login box.")); |
|
| 172 break; |
|
| 173 case signing_on: |
|
| 174 gtk_pixmap_set( GTK_PIXMAP(icon), |
|
| 175 icon_connect_pm, |
|
| 176 icon_connect_bm ); |
|
| 177 gtk_label_set( GTK_LABEL(status_label), _MSG_CONNECT_ ); |
|
| 178 applet_set_tooltips(_("Attempting to sign on....")); |
127 applet_set_tooltips(_("Attempting to sign on....")); |
| 179 break; |
128 break; |
| 180 case online: |
129 case online: |
| 181 gtk_pixmap_set( GTK_PIXMAP(icon), |
130 gtk_pixmap_set( GTK_PIXMAP(icon), |
| 182 icon_online_pm, |
131 icon_online_pm, |
| 183 icon_online_bm ); |
132 icon_online_bm ); |
| 184 |
133 gtk_label_set( GTK_LABEL(status_label), _MSG_ONLINE_ ); |
| 185 gtk_label_set( GTK_LABEL(status_label), _MSG_ONLINE_ ); |
|
| 186 update_num_groups(); |
134 update_num_groups(); |
| 187 break; |
135 break; |
| 188 |
136 case away: |
| 189 case unread_message_pending: |
137 gtk_pixmap_set( GTK_PIXMAP(icon), |
| 190 gtk_pixmap_set( GTK_PIXMAP(icon), |
138 icon_online_pm, |
| 191 icon_msg_pending_pm, |
139 icon_online_bm ); |
| 192 icon_msg_pending_bm ); |
140 gtk_label_set( GTK_LABEL(status_label), _("Away") ); |
| 193 gtk_label_set( GTK_LABEL(status_label), "msg" ); |
141 break; |
| 194 break; |
142 } |
| 195 case away: |
143 old_user_status = MRI_user_status; |
| 196 gtk_pixmap_set( GTK_PIXMAP(icon), |
144 } |
| 197 icon_online_pm, |
145 return TRUE; |
| 198 icon_online_bm ); |
|
| 199 gtk_label_set( GTK_LABEL(status_label), _("Away") ); |
|
| 200 break; |
|
| 201 } |
|
| 202 old_user_status = MRI_user_status; |
|
| 203 } |
|
| 204 return TRUE; |
|
| 205 |
|
| 206 } |
146 } |
| 207 |
147 |
| 208 void update_pixmaps() { |
148 void update_pixmaps() { |
| 209 if (display_options & OPT_DISP_DEVIL_PIXMAPS) { |
149 if (display_options & OPT_DISP_DEVIL_PIXMAPS) { |
| 210 sprintf(GAIM_GNOME_OFFLINE_ICON, "%s", GAIM_GNOME_DEVIL_OFFLINE); |
150 sprintf(GAIM_GNOME_OFFLINE_ICON, "%s", GAIM_GNOME_DEVIL_OFFLINE); |
| 219 &icon_offline_pm, &icon_offline_bm ); |
159 &icon_offline_pm, &icon_offline_bm ); |
| 220 load_applet_icon( GAIM_GNOME_CONNECT_ICON, (sizehint-16), (sizehint-12), |
160 load_applet_icon( GAIM_GNOME_CONNECT_ICON, (sizehint-16), (sizehint-12), |
| 221 &icon_connect_pm, &icon_connect_bm ); |
161 &icon_connect_pm, &icon_connect_bm ); |
| 222 load_applet_icon( GAIM_GNOME_ONLINE_ICON, (sizehint-16), (sizehint-12), |
162 load_applet_icon( GAIM_GNOME_ONLINE_ICON, (sizehint-16), (sizehint-12), |
| 223 &icon_online_pm, &icon_online_bm ); |
163 &icon_online_pm, &icon_online_bm ); |
| 224 update_applet((gpointer *)applet); |
164 update_applet(TRUE); |
| 225 gtk_widget_set_usize(appletframe, sizehint, sizehint); |
165 gtk_widget_set_usize(appletframe, sizehint, sizehint); |
| 226 } |
166 } |
| 227 |
167 |
| 228 |
168 |
| 229 /*************************************************************** |
|
| 230 ** |
|
| 231 ** function make_buddy |
|
| 232 ** visibility - private |
|
| 233 ** |
|
| 234 ** description - If buddylist is not created create it |
|
| 235 ** else show the buddy list |
|
| 236 ** |
|
| 237 ****************************************************************/ |
|
| 238 void make_buddy(void) { |
|
| 239 set_applet_draw_open(); |
|
| 240 if( !buddy_created ){ |
|
| 241 show_buddy_list(); |
|
| 242 buddy_created = TRUE; |
|
| 243 } else { |
|
| 244 gnome_buddy_show(); |
|
| 245 } |
|
| 246 build_edit_tree(); |
|
| 247 build_permit_tree(); |
|
| 248 |
|
| 249 } |
|
| 250 |
|
| 251 /*************************************************************** |
|
| 252 ** |
|
| 253 ** function applet_show_login |
|
| 254 ** visibility - private |
|
| 255 ** |
|
| 256 ** input: |
|
| 257 ** |
|
| 258 ** |
|
| 259 ** description - I guess it shows the login dialog |
|
| 260 ** |
|
| 261 ****************************************************************/ |
|
| 262 extern GtkWidget *mainwindow; |
169 extern GtkWidget *mainwindow; |
| 263 void applet_show_login(AppletWidget *widget, gpointer data) { |
170 void applet_show_login(AppletWidget *widget, gpointer data) { |
| 264 show_login(); |
171 show_login(); |
| 265 if (general_options & OPT_GEN_NEAR_APPLET) { |
172 if (general_options & OPT_GEN_NEAR_APPLET) { |
| 266 GtkAllocation a = get_applet_pos(FALSE); |
173 GtkAllocation a = get_applet_pos(FALSE); |
| 267 gtk_widget_set_uposition(mainwindow, a.x, a.y); |
174 gtk_widget_set_uposition(mainwindow, a.x, a.y); |
| 268 } |
175 } |
| 269 } |
176 } |
| 270 |
177 |
| 271 void applet_do_signon(AppletWidget *widget, gpointer data) { |
178 void applet_do_signon(AppletWidget *widget, gpointer data) { |
| 272 show_login(); |
179 applet_show_login(NULL, 0); |
| 273 if (general_options & OPT_GEN_REMEMBER_PASS) |
180 if (general_options & OPT_GEN_REMEMBER_PASS) |
| 274 dologin(0, 0); |
181 dologin(0, 0); |
| 275 } |
182 } |
| 276 |
183 |
| 277 void insert_applet_away() { |
184 void insert_applet_away() { |
| 327 } |
234 } |
| 328 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/"); |
235 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/"); |
| 329 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); |
236 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); |
| 330 } |
237 } |
| 331 |
238 |
| 332 /*************************************************************** |
239 static void applet_show_about(AppletWidget *widget, gpointer data) { |
| 333 ** |
|
| 334 ** function applet_show_about |
|
| 335 ** visibility - public |
|
| 336 ** |
|
| 337 ** |
|
| 338 ** description - takes care of creating and |
|
| 339 ** displaying the about box |
|
| 340 ** |
|
| 341 ****************************************************************/ |
|
| 342 void applet_show_about(AppletWidget *widget, gpointer data) { |
|
| 343 |
240 |
| 344 const gchar *authors[] = {"Mark Spencer <markster@marko.net>", |
241 const gchar *authors[] = {"Mark Spencer <markster@marko.net>", |
| 345 "Jim Duchek <jimduchek@ou.edu>", |
242 "Jim Duchek <jimduchek@ou.edu>", |
| 346 "Rob Flynn <rflynn@blueridge.net>", |
243 "Rob Flynn <rflynn@blueridge.net>", |
| 347 "Eric Warmenhoven <warmenhoven@yahoo.com>", |
244 "Eric Warmenhoven <warmenhoven@yahoo.com>", |
| 355 "", |
252 "", |
| 356 NULL); |
253 NULL); |
| 357 gtk_widget_show(about); |
254 gtk_widget_show(about); |
| 358 } |
255 } |
| 359 |
256 |
| 360 /*************************************************************** |
257 static GtkAllocation get_applet_pos(gboolean for_blist) { |
| 361 ** |
258 gint x,y,pad; |
| 362 ** function AppletCancelLogin (name should be changed to |
259 GtkRequisition buddy_req, applet_req; |
| 363 ** applet_cancel_login) |
260 GtkAllocation result; |
| 364 ** visibility - public |
261 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient( APPLET_WIDGET(applet) ); |
| 365 ** |
262 pad = 5; |
| 366 ** description - called when user cancels login |
263 |
| 367 ** |
264 gdk_window_get_position(gtk_widget_get_parent_window(appletframe), &x, &y); |
| 368 ****************************************************************/ |
265 if (for_blist) { |
| 369 void AppletCancelLogon(){ |
266 if (general_options & OPT_GEN_SAVED_WINDOWS) { |
| 370 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signoff"); |
267 buddy_req.width = blist_pos.width; |
| 371 applet_widget_register_callback(APPLET_WIDGET(applet), |
268 buddy_req.height = blist_pos.height; |
| 372 "signon", |
269 } else { |
| 373 _("Signon"), |
270 buddy_req = blist->requisition; |
| 374 applet_do_signon, |
271 } |
| 375 NULL); |
272 } else { |
| 376 } |
273 buddy_req = mainwindow->requisition; |
| 377 |
274 } |
| 378 /*************************************************************** |
275 applet_req = appletframe->requisition; |
| 379 ** |
276 |
| 380 ** function get_applet_pos |
277 /* FIXME : we need to be smarter here */ |
| 381 ** visibility - private |
278 switch( orient ){ |
| 382 ** |
279 case ORIENT_UP: |
| 383 ** output: |
280 result.x=x; |
| 384 ** GtKAllocation - a Gtk struct that holds the |
281 result.y=y-(buddy_req.height+pad); |
| 385 ** position of the dialog |
282 break; |
| 386 ** |
|
| 387 ** description - returns the x,y position the buddy list should |
|
| 388 ** should be placed based on the position |
|
| 389 ** of the applet and the orientation |
|
| 390 ** of the Gnome panel. |
|
| 391 ** |
|
| 392 ****************************************************************/ |
|
| 393 GtkAllocation get_applet_pos(gboolean for_blist) { |
|
| 394 gint x,y,pad; |
|
| 395 GtkRequisition buddy_req, applet_req; |
|
| 396 GtkAllocation result; |
|
| 397 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient( APPLET_WIDGET(applet) ); |
|
| 398 pad = 5; |
|
| 399 gdk_window_get_position(gtk_widget_get_parent_window(appletframe), &x, &y); |
|
| 400 if (for_blist) |
|
| 401 buddy_req = gnome_buddy_get_dimentions(); |
|
| 402 else |
|
| 403 buddy_req = mainwindow->requisition; |
|
| 404 applet_req = appletframe->requisition; |
|
| 405 switch( orient ){ |
|
| 406 case ORIENT_UP: |
|
| 407 result.x=x; |
|
| 408 result.y=y-(buddy_req.height+pad); |
|
| 409 break; |
|
| 410 case ORIENT_DOWN: |
283 case ORIENT_DOWN: |
| 411 result.x=x; |
284 result.x=x; |
| 412 result.y=y+applet_req.height+pad; |
285 result.y=y+applet_req.height+pad; |
| 413 |
286 break; |
| 414 break; |
287 case ORIENT_LEFT: |
| 415 case ORIENT_LEFT: |
288 result.x=x-(buddy_req.width + pad ); |
| 416 result.x=x-(buddy_req.width + pad ); |
289 result.y=y; |
| 417 result.y=y; |
290 break; |
| 418 break; |
291 case ORIENT_RIGHT: |
| 419 case ORIENT_RIGHT: |
292 result.x=x+applet_req.width+pad; |
| 420 result.x=x+applet_req.width+pad; |
293 result.y=y; |
| 421 result.y=y; |
294 break; |
| 422 break; |
295 } |
| 423 } |
296 return result; |
| 424 |
297 } |
| 425 |
|
| 426 return result; |
|
| 427 } |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 void createOfflinePopup(){ |
|
| 432 applet_show_login( APPLET_WIDGET(applet), NULL ); |
|
| 433 } |
|
| 434 |
|
| 435 |
|
| 436 void createSignonPopup(){ |
|
| 437 applet_draw_open = FALSE; |
|
| 438 } |
|
| 439 |
|
| 440 |
298 |
| 441 void createOnlinePopup(){ |
299 void createOnlinePopup(){ |
| 442 GtkAllocation al; |
300 GtkAllocation al; |
| 443 make_buddy(); |
301 if (blist) gtk_widget_show(blist); |
| 444 al = get_applet_pos(TRUE); |
302 al = get_applet_pos(TRUE); |
| 445 gnome_buddy_set_pos( al.x, al.y ); |
303 if (general_options & OPT_GEN_NEAR_APPLET) |
| 446 } |
304 gtk_widget_set_uposition ( blist, al.x, al.y ); |
| 447 |
305 else if (general_options & OPT_GEN_SAVED_WINDOWS) |
| 448 |
306 gtk_widget_set_uposition(blist, blist_pos.x - blist_pos.xoff, blist_pos.y - blist_pos.yoff); |
| 449 void createPendingPopup(){ |
|
| 450 applet_draw_open = FALSE; |
|
| 451 } |
|
| 452 |
|
| 453 |
|
| 454 void createAwayPopup(){ |
|
| 455 createOnlinePopup(); |
|
| 456 } |
|
| 457 |
|
| 458 |
|
| 459 void closeOfflinePopup(){ |
|
| 460 cancel_logon(); |
|
| 461 set_applet_draw_closed(); |
|
| 462 } |
|
| 463 |
|
| 464 |
|
| 465 void closeSignonPopup(){ |
|
| 466 |
|
| 467 } |
|
| 468 |
|
| 469 |
|
| 470 void closeOnlinePopup(){ |
|
| 471 set_applet_draw_closed(); |
|
| 472 applet_destroy_buddy(0, 0, 0); |
|
| 473 } |
|
| 474 |
|
| 475 |
|
| 476 void closePendingPopup(){ |
|
| 477 applet_draw_open = FALSE; |
|
| 478 } |
|
| 479 |
|
| 480 |
|
| 481 void closeAwayPopup(){ |
|
| 482 closeOnlinePopup(); |
|
| 483 } |
307 } |
| 484 |
308 |
| 485 void AppletClicked( GtkWidget *sender, GdkEventButton *ev, gpointer data ){ |
309 void AppletClicked( GtkWidget *sender, GdkEventButton *ev, gpointer data ){ |
| 486 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS) |
310 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS) |
| 487 return; |
311 return; |
| 488 |
312 |
| 489 if( applet_draw_open ){ |
313 if(applet_buddy_show) { |
| |
314 applet_buddy_show = FALSE; |
| 490 switch( MRI_user_status ){ |
315 switch( MRI_user_status ){ |
| 491 case offline: |
316 case offline: |
| 492 closeOfflinePopup(); |
317 gtk_widget_hide(mainwindow); |
| 493 break; |
318 break; |
| 494 case signing_on: |
|
| 495 closeSignonPopup(); |
|
| 496 break; |
|
| 497 case online: |
319 case online: |
| 498 closeOnlinePopup(); |
|
| 499 |
|
| 500 break; |
|
| 501 case unread_message_pending: |
|
| 502 closePendingPopup(); |
|
| 503 break; |
|
| 504 case away: |
320 case away: |
| 505 closeAwayPopup(); |
321 applet_destroy_buddy(0, 0, 0); |
| 506 break; |
322 break; |
| 507 } |
323 } |
| 508 } else { |
324 } else { |
| 509 set_applet_draw_open(); |
325 applet_buddy_show = TRUE; |
| 510 switch( MRI_user_status ){ |
326 switch( MRI_user_status ){ |
| 511 case offline: |
327 case offline: |
| 512 createOfflinePopup(); |
328 applet_show_login( APPLET_WIDGET(applet), NULL ); |
| 513 break; |
329 break; |
| 514 case signing_on: |
|
| 515 createSignonPopup(); |
|
| 516 break; |
|
| 517 case online: |
330 case online: |
| |
331 case away: |
| 518 createOnlinePopup(); |
332 createOnlinePopup(); |
| 519 break; |
333 break; |
| 520 case unread_message_pending: |
|
| 521 createPendingPopup(); |
|
| 522 break; |
|
| 523 case away: |
|
| 524 createAwayPopup(); |
|
| 525 break; |
|
| 526 } |
334 } |
| 527 |
|
| 528 |
|
| 529 } |
335 } |
| 530 } |
336 } |
| 531 |
337 |
| 532 |
338 |
| 533 /*************************************************************** |
339 /*************************************************************** |