Mercurial > pidgin
annotate src/gnome_applet_mgr.c @ 438:881f5d538f15
[gaim-migrate @ 448]
Added hit detection on ticker -- clicking on a name is like double clicking
in the online buddy list, and brings up an IM window.
committer: Tailor Script <tailor@pidgin.im>
author | Syd Logan <slogan> |
---|---|
date | Sun, 25 Jun 2000 17:00:24 +0000 |
parents | ae7c762775cd |
children | 5a908dd5cfc4 |
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 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
342
diff
changeset
|
30 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
342
diff
changeset
|
31 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
342
diff
changeset
|
32 #endif |
1 | 33 #ifdef USE_APPLET |
34 #include <string.h> | |
35 #include <gdk_imlib.h> | |
36 #include "gaim.h" | |
37 #include "gnome_applet_mgr.h" | |
38 | |
39 enum gaim_user_states MRI_user_status; | |
40 | |
41 gboolean buddy_created = FALSE; | |
42 gboolean applet_draw_open = FALSE; | |
43 GtkWidget *applet_popup = NULL; | |
44 | |
82 | 45 gchar GAIM_GNOME_OFFLINE_ICON[255] = GAIM_GNOME_PENGUIN_OFFLINE; |
46 gchar GAIM_GNOME_CONNECT_ICON[255] = GAIM_GNOME_PENGUIN_CONNECT; | |
47 gchar GAIM_GNOME_ONLINE_ICON[255] = GAIM_GNOME_PENGUIN_ONLINE; | |
48 | |
1 | 49 GtkWidget *applet; |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
50 GtkWidget *appletframe; |
1 | 51 GtkWidget *status_label; |
52 | |
53 GtkWidget *icon; | |
54 GdkPixmap *icon_offline_pm=NULL; | |
55 GdkPixmap *icon_offline_bm=NULL; | |
56 | |
57 GdkPixmap *icon_online_pm=NULL; | |
58 GdkPixmap *icon_online_bm=NULL; | |
59 | |
60 GdkPixmap *icon_connect_pm=NULL; | |
61 GdkPixmap *icon_connect_bm=NULL; | |
62 | |
63 GdkPixmap *icon_msg_pending_pm=NULL; | |
64 GdkPixmap *icon_msg_pending_bm=NULL; | |
65 | |
66 GdkPixmap *icon_away_pm=NULL; | |
67 GdkPixmap *icon_away_bm=NULL; | |
68 | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
69 static GtkAllocation get_applet_pos(gboolean); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
70 |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
71 gint sizehint=48; |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
72 |
1 | 73 /*************************************************************** |
74 ** | |
75 ** function load_applet_icon | |
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; | |
82 | 99 char *path; |
1 | 100 GdkImlibImage *im; |
82 | 101 |
102 path = gnome_pixmap_file(name); | |
103 | |
1 | 104 im=gdk_imlib_load_image( path ); |
105 | |
106 if ((*pm)!=NULL) | |
107 gdk_imlib_free_pixmap((*pm)); | |
108 | |
109 if( im!= NULL ){ | |
110 gdk_imlib_render(im,width,height); | |
111 | |
112 (*pm) = gdk_imlib_move_image(im); | |
113 (*bm) = gdk_imlib_move_mask(im); | |
114 | |
115 } else { | |
116 result = FALSE; | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
117 sprintf(debug_buff,_("file not found: %s\n"),path); |
1 | 118 debug_print(debug_buff); |
119 } | |
120 | |
82 | 121 free(path); |
1 | 122 return result; |
123 } | |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
124 /*************************************************************** |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
125 ** |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
126 ** function applet_change_pixel_size |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
127 ** visibility - private |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
128 ** |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
129 ** input: |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
130 ** w - applet that called the signal |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
131 ** size - size of panel |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
132 ** data - extra data (in this case NULL) |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
133 ** |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
134 ** description - changes the size of the applet when the panel size |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
135 ** changes |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
136 ** |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
137 ***************************************************************/ |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
138 #ifdef HAVE_PANEL_PIXEL_SIZE |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
139 void applet_change_pixel_size(GtkWidget *w, int size, gpointer data) |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
140 { |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
141 sizehint = size; |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
142 update_pixmaps(); |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
143 } |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
144 #endif |
1 | 145 |
146 /*************************************************************** | |
147 ** | |
148 ** function update_applet | |
149 ** visibility - private | |
150 ** | |
151 ** input: | |
82 | 152 ** ap - if not NULL, was called from update_pixmaps, and |
153 ** should update them | |
1 | 154 ** |
155 ** description - takes care of swapping status icons and | |
156 ** updating the status label | |
157 ** | |
158 ****************************************************************/ | |
159 | |
160 gboolean update_applet( gpointer *ap ){ | |
161 static enum gaim_user_states old_user_status = offline; | |
162 | |
82 | 163 if( MRI_user_status != old_user_status || ap){ |
1 | 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_ ); | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
171 applet_set_tooltips(_("Offilne. Click to bring up login box.")); |
1 | 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_ ); | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
178 applet_set_tooltips(_("Attempting to sign on....")); |
1 | 179 break; |
180 case online: | |
181 gtk_pixmap_set( GTK_PIXMAP(icon), | |
182 icon_online_pm, | |
183 icon_online_bm ); | |
184 | |
185 gtk_label_set( GTK_LABEL(status_label), _MSG_ONLINE_ ); | |
399
98bbfae58fa2
[gaim-migrate @ 409]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
374
diff
changeset
|
186 update_num_groups(); |
1 | 187 break; |
188 | |
189 case unread_message_pending: | |
190 gtk_pixmap_set( GTK_PIXMAP(icon), | |
191 icon_msg_pending_pm, | |
192 icon_msg_pending_bm ); | |
193 gtk_label_set( GTK_LABEL(status_label), "msg" ); | |
194 break; | |
195 case away: | |
196 gtk_pixmap_set( GTK_PIXMAP(icon), | |
82 | 197 icon_online_pm, |
198 icon_online_bm ); | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
199 gtk_label_set( GTK_LABEL(status_label), _("Away") ); |
1 | 200 break; |
201 } | |
202 old_user_status = MRI_user_status; | |
203 } | |
204 return TRUE; | |
205 | |
206 } | |
207 | |
82 | 208 void update_pixmaps() { |
209 if (display_options & OPT_DISP_DEVIL_PIXMAPS) { | |
210 sprintf(GAIM_GNOME_OFFLINE_ICON, "%s", GAIM_GNOME_DEVIL_OFFLINE); | |
211 sprintf(GAIM_GNOME_CONNECT_ICON, "%s", GAIM_GNOME_DEVIL_CONNECT); | |
212 sprintf(GAIM_GNOME_ONLINE_ICON, "%s", GAIM_GNOME_DEVIL_ONLINE); | |
213 } else { | |
214 sprintf(GAIM_GNOME_OFFLINE_ICON, "%s", GAIM_GNOME_PENGUIN_OFFLINE); | |
215 sprintf(GAIM_GNOME_CONNECT_ICON, "%s", GAIM_GNOME_PENGUIN_CONNECT); | |
216 sprintf(GAIM_GNOME_ONLINE_ICON, "%s", GAIM_GNOME_PENGUIN_ONLINE); | |
217 } | |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
218 load_applet_icon( GAIM_GNOME_OFFLINE_ICON, (sizehint-16), (sizehint-12), |
82 | 219 &icon_offline_pm, &icon_offline_bm ); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
220 load_applet_icon( GAIM_GNOME_CONNECT_ICON, (sizehint-16), (sizehint-12), |
82 | 221 &icon_connect_pm, &icon_connect_bm ); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
222 load_applet_icon( GAIM_GNOME_ONLINE_ICON, (sizehint-16), (sizehint-12), |
82 | 223 &icon_online_pm, &icon_online_bm ); |
224 update_applet((gpointer *)applet); | |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
225 gtk_widget_set_usize(appletframe, sizehint, sizehint); |
82 | 226 } |
227 | |
1 | 228 |
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 } | |
16 | 246 build_edit_tree(); |
246
2c5713cd9d8c
[gaim-migrate @ 256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
247 build_permit_tree(); |
1 | 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 ****************************************************************/ | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
262 extern GtkWidget *mainwindow; |
1 | 263 void applet_show_login(AppletWidget *widget, gpointer data) { |
264 show_login(); | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
265 if (general_options & OPT_GEN_NEAR_APPLET) { |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
266 GtkAllocation a = get_applet_pos(FALSE); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
267 gtk_widget_set_uposition(mainwindow, a.x, a.y); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
268 } |
1 | 269 } |
270 | |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
271 void applet_do_signon(AppletWidget *widget, gpointer data) { |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
272 show_login(); |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
273 if (general_options & OPT_GEN_REMEMBER_PASS) |
411
a330017b3aa4
[gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
399
diff
changeset
|
274 dologin(0, 0); |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
275 } |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
276 |
18 | 277 void insert_applet_away() { |
278 GList *awy = away_messages; | |
279 struct away_message *a; | |
280 char *awayname; | |
281 | |
282 applet_widget_register_callback_dir(APPLET_WIDGET(applet), | |
46 | 283 "away/", |
18 | 284 _("Away")); |
285 applet_widget_register_callback(APPLET_WIDGET(applet), | |
286 "away/new", | |
287 _("New Away Message"), | |
288 (AppletCallbackFunc)create_away_mess, | |
289 NULL); | |
290 | |
291 while(awy) { | |
292 a = (struct away_message *)awy->data; | |
293 | |
79 | 294 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); |
18 | 295 awayname[0] = '\0'; |
296 strcat(awayname, "away/"); | |
297 strcat(awayname, a->name); | |
298 applet_widget_register_callback(APPLET_WIDGET(applet), | |
299 awayname, | |
300 a->name, | |
301 (AppletCallbackFunc)do_away_message, | |
302 a); | |
303 | |
304 awy = awy->next; | |
23 | 305 free(awayname); |
18 | 306 } |
307 } | |
308 | |
309 void remove_applet_away() { | |
310 GList *awy = away_messages; | |
311 struct away_message *a; | |
312 char *awayname; | |
313 | |
314 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new"); | |
315 | |
316 while (awy) { | |
317 a = (struct away_message *)awy->data; | |
318 | |
79 | 319 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); |
18 | 320 awayname[0] = '\0'; |
321 strcat(awayname, "away/"); | |
322 strcat(awayname, a->name); | |
323 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname); | |
324 | |
325 awy = awy->next; | |
23 | 326 free(awayname); |
18 | 327 } |
46 | 328 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/"); |
18 | 329 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); |
330 } | |
331 | |
1 | 332 /*************************************************************** |
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 | |
344 const gchar *authors[] = {"Mark Spencer <markster@marko.net>", | |
345 "Jim Duchek <jimduchek@ou.edu>", | |
346 "Rob Flynn <rflynn@blueridge.net>", | |
82 | 347 "Eric Warmenhoven <warmenhoven@yahoo.com>", |
178
5d62a5d50c89
[gaim-migrate @ 188]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
348 "Syd Logan", |
1 | 349 NULL}; |
350 | |
351 GtkWidget *about=gnome_about_new(_("GAIM"), | |
352 _(VERSION), | |
353 _(""), | |
354 authors, | |
355 "", | |
356 NULL); | |
357 gtk_widget_show(about); | |
358 } | |
359 | |
360 /*************************************************************** | |
361 ** | |
362 ** function AppletCancelLogin (name should be changed to | |
363 ** applet_cancel_login) | |
364 ** visibility - public | |
365 ** | |
366 ** description - called when user cancels login | |
367 ** | |
368 ****************************************************************/ | |
369 void AppletCancelLogon(){ | |
370 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signoff"); | |
371 applet_widget_register_callback(APPLET_WIDGET(applet), | |
372 "signon", | |
373 _("Signon"), | |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
374 applet_do_signon, |
1 | 375 NULL); |
376 } | |
377 | |
378 /*************************************************************** | |
379 ** | |
380 ** function get_applet_pos | |
381 ** visibility - private | |
382 ** | |
383 ** output: | |
384 ** GtKAllocation - a Gtk struct that holds the | |
385 ** position of the dialog | |
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 ****************************************************************/ | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
393 GtkAllocation get_applet_pos(gboolean for_blist) { |
1 | 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; | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
399 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
|
400 if (for_blist) |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
401 buddy_req = gnome_buddy_get_dimentions(); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
402 else |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
403 buddy_req = mainwindow->requisition; |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
404 applet_req = appletframe->requisition; |
1 | 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: | |
411 result.x=x; | |
412 result.y=y+applet_req.height+pad; | |
413 | |
414 break; | |
415 case ORIENT_LEFT: | |
416 result.x=x-(buddy_req.width + pad ); | |
417 result.y=y; | |
418 break; | |
419 case ORIENT_RIGHT: | |
420 result.x=x+applet_req.width+pad; | |
421 result.y=y; | |
422 break; | |
423 } | |
424 | |
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 | |
441 void createOnlinePopup(){ | |
442 GtkAllocation al; | |
443 make_buddy(); | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
444 al = get_applet_pos(TRUE); |
1 | 445 gnome_buddy_set_pos( al.x, al.y ); |
446 } | |
447 | |
448 | |
449 void createPendingPopup(){ | |
450 applet_draw_open = FALSE; | |
451 } | |
452 | |
453 | |
454 void createAwayPopup(){ | |
83 | 455 createOnlinePopup(); |
1 | 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(); | |
411
a330017b3aa4
[gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
399
diff
changeset
|
472 applet_destroy_buddy(0, 0, 0); |
1 | 473 } |
474 | |
475 | |
476 void closePendingPopup(){ | |
477 applet_draw_open = FALSE; | |
478 } | |
479 | |
480 | |
481 void closeAwayPopup(){ | |
83 | 482 closeOnlinePopup(); |
1 | 483 } |
484 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
485 void AppletClicked( GtkWidget *sender, GdkEventButton *ev, gpointer data ){ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
486 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
487 return; |
1 | 488 |
489 if( applet_draw_open ){ | |
490 switch( MRI_user_status ){ | |
491 case offline: | |
492 closeOfflinePopup(); | |
493 break; | |
494 case signing_on: | |
495 closeSignonPopup(); | |
496 break; | |
497 case online: | |
498 closeOnlinePopup(); | |
499 | |
500 break; | |
501 case unread_message_pending: | |
502 closePendingPopup(); | |
503 break; | |
504 case away: | |
505 closeAwayPopup(); | |
506 break; | |
507 } | |
508 } else { | |
509 set_applet_draw_open(); | |
510 switch( MRI_user_status ){ | |
511 case offline: | |
512 createOfflinePopup(); | |
513 break; | |
514 case signing_on: | |
515 createSignonPopup(); | |
516 break; | |
517 case online: | |
518 createOnlinePopup(); | |
519 break; | |
520 case unread_message_pending: | |
521 createPendingPopup(); | |
522 break; | |
523 case away: | |
524 createAwayPopup(); | |
525 break; | |
526 } | |
527 | |
528 | |
529 } | |
530 } | |
531 | |
532 | |
533 /*************************************************************** | |
534 ** | |
535 ** Initialize GNOME stuff | |
536 ** | |
537 ****************************************************************/ | |
538 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
539 gint init_applet_mgr(int argc, char *argv[]) { |
1 | 540 GtkWidget *vbox; |
541 | |
542 GtkStyle *label_style; | |
543 GdkFont *label_font = NULL; | |
544 | |
545 applet_widget_init("GAIM",VERSION,argc,argv,NULL,0,NULL); | |
546 | |
547 /*init imlib for graphics*/ | |
548 gdk_imlib_init(); | |
549 gtk_widget_push_visual(gdk_imlib_get_visual()); | |
550 gtk_widget_push_colormap(gdk_imlib_get_colormap()); | |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
551 |
1 | 552 applet=applet_widget_new("gaim_applet"); |
553 if(!applet) g_error(_("Can't create GAIM applet!")); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
554 gtk_widget_set_events(applet, gtk_widget_get_events(applet) | |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
555 GDK_BUTTON_PRESS_MASK); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
556 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
557 appletframe = gtk_frame_new(NULL); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
558 #ifdef HAVE_PANEL_PIXEL_SIZE |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
559 gtk_widget_set_usize(appletframe, 5, 5); |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
560 #else |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
561 gtk_widget_set_usize(appletframe, 48, 48); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
562 #endif |
1 | 563 |
564 /*load offline icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
565 load_applet_icon( GAIM_GNOME_OFFLINE_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
566 &icon_offline_pm, &icon_offline_bm ); |
1 | 567 |
568 /*load connecting icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
569 load_applet_icon( GAIM_GNOME_CONNECT_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
570 &icon_connect_pm, &icon_connect_bm ); |
1 | 571 |
572 /*load online icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
573 load_applet_icon( GAIM_GNOME_ONLINE_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
574 &icon_online_pm, &icon_online_bm ); |
1 | 575 |
576 /*icon_away and icon_msg_pennding need to be implemented*/ | |
577 | |
578 icon=gtk_pixmap_new(icon_offline_pm,icon_offline_bm); | |
579 | |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
580 update_applet(NULL); |
1 | 581 gtk_timeout_add( 1500, (GtkFunction)update_applet, NULL ); |
582 | |
583 vbox = gtk_vbox_new(FALSE,0); | |
584 | |
585 gtk_box_pack_start(GTK_BOX(vbox), icon, FALSE, TRUE, 0); | |
586 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
587 status_label = gtk_label_new(_("Offline")); |
1 | 588 /*set this label's font*/ |
589 label_style = gtk_widget_get_style( status_label ); | |
590 | |
591 label_font = gdk_font_load( _MSG_FONT_ ); | |
592 | |
593 | |
594 if( label_font != NULL ){ | |
595 label_style->font = label_font; | |
596 gtk_widget_set_style( status_label, label_style ); | |
597 } else { | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
598 sprintf(debug_buff, _("Font does not exist") ); |
1 | 599 debug_print(debug_buff); |
600 } | |
601 | |
602 gtk_box_pack_start(GTK_BOX(vbox), status_label, FALSE, TRUE, 0); | |
603 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
604 gtk_container_add( GTK_CONTAINER(appletframe), vbox ); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
605 applet_widget_add(APPLET_WIDGET(applet), appletframe); |
1 | 606 |
607 gtk_widget_show( status_label ); | |
608 gtk_widget_show( vbox ); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
609 gtk_widget_show( appletframe ); |
1 | 610 |
611 applet_widget_register_stock_callback(APPLET_WIDGET(applet), | |
612 "about", | |
613 GNOME_STOCK_MENU_ABOUT, | |
614 _("About..."), | |
615 applet_show_about, | |
616 NULL); | |
617 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
618 gtk_signal_connect( GTK_OBJECT(applet), "button_press_event", GTK_SIGNAL_FUNC( AppletClicked), NULL); |
1 | 619 |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
620 gtk_signal_connect( GTK_OBJECT(applet), "destroy", GTK_SIGNAL_FUNC( do_quit), NULL); |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
621 |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
622 #ifdef HAVE_PANEL_PIXEL_SIZE |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
623 gtk_signal_connect(GTK_OBJECT(applet), "change_pixel_size", |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
624 GTK_SIGNAL_FUNC(applet_change_pixel_size), NULL); |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
625 #endif |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
626 |
1 | 627 gtk_widget_show(icon); |
628 gtk_widget_show(applet); | |
629 return 0; | |
630 } | |
631 | |
632 void setUserState( enum gaim_user_states state ){ | |
633 MRI_user_status = state; | |
82 | 634 update_applet(NULL); |
1 | 635 } |
636 | |
637 enum gaim_user_states getUserState(){ | |
638 return MRI_user_status; | |
639 } | |
640 | |
641 void set_applet_draw_open(){ | |
642 applet_draw_open = TRUE; | |
643 } | |
644 | |
645 void set_applet_draw_closed(){ | |
646 applet_draw_open = FALSE; | |
647 } | |
648 | |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
649 void applet_set_tooltips(char *msg) { |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
650 applet_widget_set_tooltip(APPLET_WIDGET(applet), msg); |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
651 } |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
652 |
1 | 653 #endif /*USE_APPLET*/ |