Mercurial > pidgin
annotate src/gnome_applet_mgr.c @ 762:977048924ce1
[gaim-migrate @ 772]
bad placement.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 25 Aug 2000 01:02:17 +0000 |
parents | 5a908dd5cfc4 |
children | 626975d79bff |
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 | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
41 gboolean applet_buddy_show = FALSE; |
1 | 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; |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
49 GtkWidget *appletframe; |
1 | 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 | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
68 static GtkAllocation get_applet_pos(gboolean); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
69 gint sizehint=48; |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
70 |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
71 static gboolean load_applet_icon(const char *name, int height, int width, |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
72 GdkPixmap **pm, GdkBitmap **bm) |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
73 { |
1 | 74 gboolean result = TRUE; |
82 | 75 char *path; |
1 | 76 GdkImlibImage *im; |
82 | 77 |
78 path = gnome_pixmap_file(name); | |
79 | |
1 | 80 im=gdk_imlib_load_image( path ); |
81 | |
82 if ((*pm)!=NULL) | |
83 gdk_imlib_free_pixmap((*pm)); | |
84 | |
85 if( im!= NULL ){ | |
86 gdk_imlib_render(im,width,height); | |
87 | |
88 (*pm) = gdk_imlib_move_image(im); | |
89 (*bm) = gdk_imlib_move_mask(im); | |
90 | |
91 } else { | |
92 result = FALSE; | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
93 sprintf(debug_buff,_("file not found: %s\n"),path); |
1 | 94 debug_print(debug_buff); |
95 } | |
96 | |
82 | 97 free(path); |
1 | 98 return result; |
99 } | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
100 |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
101 #ifdef HAVE_PANEL_PIXEL_SIZE |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
102 static void applet_change_pixel_size(GtkWidget *w, int size, gpointer data) |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
103 { |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
104 sizehint = size; |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
105 update_pixmaps(); |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
106 } |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
107 #endif |
1 | 108 |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
109 static gboolean update_applet(gboolean force_update){ |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
110 static enum gaim_user_states old_user_status = offline; |
1 | 111 |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
112 if( MRI_user_status != old_user_status || force_update) { |
1 | 113 |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
114 switch( MRI_user_status ){ |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
115 case offline: |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
116 gtk_pixmap_set( GTK_PIXMAP(icon), |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
117 icon_offline_pm, |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
118 icon_offline_bm ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
119 gtk_label_set( GTK_LABEL(status_label), _MSG_OFFLINE_ ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
120 applet_set_tooltips(_("Offilne. Click to bring up login box.")); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
121 break; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
122 case signing_on: |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
123 gtk_pixmap_set( GTK_PIXMAP(icon), |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
124 icon_connect_pm, |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
125 icon_connect_bm ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
126 gtk_label_set( GTK_LABEL(status_label), _MSG_CONNECT_ ); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
127 applet_set_tooltips(_("Attempting to sign on....")); |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
128 break; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
129 case online: |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
130 gtk_pixmap_set( GTK_PIXMAP(icon), |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
131 icon_online_pm, |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
132 icon_online_bm ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
133 gtk_label_set( GTK_LABEL(status_label), _MSG_ONLINE_ ); |
399
98bbfae58fa2
[gaim-migrate @ 409]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
374
diff
changeset
|
134 update_num_groups(); |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
135 break; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
136 case away: |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
137 gtk_pixmap_set( GTK_PIXMAP(icon), |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
138 icon_online_pm, |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
139 icon_online_bm ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
140 gtk_label_set( GTK_LABEL(status_label), _("Away") ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
141 break; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
142 } |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
143 old_user_status = MRI_user_status; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
144 } |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
145 return TRUE; |
1 | 146 } |
147 | |
82 | 148 void update_pixmaps() { |
149 if (display_options & OPT_DISP_DEVIL_PIXMAPS) { | |
150 sprintf(GAIM_GNOME_OFFLINE_ICON, "%s", GAIM_GNOME_DEVIL_OFFLINE); | |
151 sprintf(GAIM_GNOME_CONNECT_ICON, "%s", GAIM_GNOME_DEVIL_CONNECT); | |
152 sprintf(GAIM_GNOME_ONLINE_ICON, "%s", GAIM_GNOME_DEVIL_ONLINE); | |
153 } else { | |
154 sprintf(GAIM_GNOME_OFFLINE_ICON, "%s", GAIM_GNOME_PENGUIN_OFFLINE); | |
155 sprintf(GAIM_GNOME_CONNECT_ICON, "%s", GAIM_GNOME_PENGUIN_CONNECT); | |
156 sprintf(GAIM_GNOME_ONLINE_ICON, "%s", GAIM_GNOME_PENGUIN_ONLINE); | |
157 } | |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
158 load_applet_icon( GAIM_GNOME_OFFLINE_ICON, (sizehint-16), (sizehint-12), |
82 | 159 &icon_offline_pm, &icon_offline_bm ); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
160 load_applet_icon( GAIM_GNOME_CONNECT_ICON, (sizehint-16), (sizehint-12), |
82 | 161 &icon_connect_pm, &icon_connect_bm ); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
162 load_applet_icon( GAIM_GNOME_ONLINE_ICON, (sizehint-16), (sizehint-12), |
82 | 163 &icon_online_pm, &icon_online_bm ); |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
164 update_applet(TRUE); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
165 gtk_widget_set_usize(appletframe, sizehint, sizehint); |
82 | 166 } |
167 | |
1 | 168 |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
169 extern GtkWidget *mainwindow; |
1 | 170 void applet_show_login(AppletWidget *widget, gpointer data) { |
171 show_login(); | |
340
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
172 if (general_options & OPT_GEN_NEAR_APPLET) { |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
173 GtkAllocation a = get_applet_pos(FALSE); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
174 gtk_widget_set_uposition(mainwindow, a.x, a.y); |
0d9cfc3579a5
[gaim-migrate @ 350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
175 } |
1 | 176 } |
177 | |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
178 void applet_do_signon(AppletWidget *widget, gpointer data) { |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
179 applet_show_login(NULL, 0); |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
180 if (general_options & OPT_GEN_REMEMBER_PASS) |
411
a330017b3aa4
[gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
399
diff
changeset
|
181 dologin(0, 0); |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
182 } |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
183 |
18 | 184 void insert_applet_away() { |
185 GList *awy = away_messages; | |
186 struct away_message *a; | |
187 char *awayname; | |
188 | |
189 applet_widget_register_callback_dir(APPLET_WIDGET(applet), | |
46 | 190 "away/", |
18 | 191 _("Away")); |
192 applet_widget_register_callback(APPLET_WIDGET(applet), | |
193 "away/new", | |
194 _("New Away Message"), | |
195 (AppletCallbackFunc)create_away_mess, | |
196 NULL); | |
197 | |
198 while(awy) { | |
199 a = (struct away_message *)awy->data; | |
200 | |
79 | 201 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); |
18 | 202 awayname[0] = '\0'; |
203 strcat(awayname, "away/"); | |
204 strcat(awayname, a->name); | |
205 applet_widget_register_callback(APPLET_WIDGET(applet), | |
206 awayname, | |
207 a->name, | |
208 (AppletCallbackFunc)do_away_message, | |
209 a); | |
210 | |
211 awy = awy->next; | |
23 | 212 free(awayname); |
18 | 213 } |
214 } | |
215 | |
216 void remove_applet_away() { | |
217 GList *awy = away_messages; | |
218 struct away_message *a; | |
219 char *awayname; | |
220 | |
221 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new"); | |
222 | |
223 while (awy) { | |
224 a = (struct away_message *)awy->data; | |
225 | |
79 | 226 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); |
18 | 227 awayname[0] = '\0'; |
228 strcat(awayname, "away/"); | |
229 strcat(awayname, a->name); | |
230 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname); | |
231 | |
232 awy = awy->next; | |
23 | 233 free(awayname); |
18 | 234 } |
46 | 235 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/"); |
18 | 236 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); |
237 } | |
238 | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
239 static void applet_show_about(AppletWidget *widget, gpointer data) { |
1 | 240 |
241 const gchar *authors[] = {"Mark Spencer <markster@marko.net>", | |
242 "Jim Duchek <jimduchek@ou.edu>", | |
243 "Rob Flynn <rflynn@blueridge.net>", | |
82 | 244 "Eric Warmenhoven <warmenhoven@yahoo.com>", |
178
5d62a5d50c89
[gaim-migrate @ 188]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
245 "Syd Logan", |
1 | 246 NULL}; |
247 | |
248 GtkWidget *about=gnome_about_new(_("GAIM"), | |
249 _(VERSION), | |
250 _(""), | |
251 authors, | |
252 "", | |
253 NULL); | |
254 gtk_widget_show(about); | |
255 } | |
256 | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
257 static GtkAllocation get_applet_pos(gboolean for_blist) { |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
258 gint x,y,pad; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
259 GtkRequisition buddy_req, applet_req; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
260 GtkAllocation result; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
261 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient( APPLET_WIDGET(applet) ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
262 pad = 5; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
263 |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
264 gdk_window_get_position(gtk_widget_get_parent_window(appletframe), &x, &y); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
265 if (for_blist) { |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
266 if (general_options & OPT_GEN_SAVED_WINDOWS) { |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
267 buddy_req.width = blist_pos.width; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
268 buddy_req.height = blist_pos.height; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
269 } else { |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
270 buddy_req = blist->requisition; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
271 } |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
272 } else { |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
273 buddy_req = mainwindow->requisition; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
274 } |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
275 applet_req = appletframe->requisition; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
276 |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
277 /* FIXME : we need to be smarter here */ |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
278 switch( orient ){ |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
279 case ORIENT_UP: |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
280 result.x=x; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
281 result.y=y-(buddy_req.height+pad); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
282 break; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
283 case ORIENT_DOWN: |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
284 result.x=x; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
285 result.y=y+applet_req.height+pad; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
286 break; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
287 case ORIENT_LEFT: |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
288 result.x=x-(buddy_req.width + pad ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
289 result.y=y; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
290 break; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
291 case ORIENT_RIGHT: |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
292 result.x=x+applet_req.width+pad; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
293 result.y=y; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
294 break; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
295 } |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
296 return result; |
1 | 297 } |
298 | |
299 void createOnlinePopup(){ | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
300 GtkAllocation al; |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
301 if (blist) gtk_widget_show(blist); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
302 al = get_applet_pos(TRUE); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
303 if (general_options & OPT_GEN_NEAR_APPLET) |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
304 gtk_widget_set_uposition ( blist, al.x, al.y ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
305 else if (general_options & OPT_GEN_SAVED_WINDOWS) |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
306 gtk_widget_set_uposition(blist, blist_pos.x - blist_pos.xoff, blist_pos.y - blist_pos.yoff); |
1 | 307 } |
308 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
309 void AppletClicked( GtkWidget *sender, GdkEventButton *ev, gpointer data ){ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
310 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
311 return; |
1 | 312 |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
313 if(applet_buddy_show) { |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
314 applet_buddy_show = FALSE; |
1 | 315 switch( MRI_user_status ){ |
316 case offline: | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
317 gtk_widget_hide(mainwindow); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
318 break; |
1 | 319 case online: |
320 case away: | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
321 applet_destroy_buddy(0, 0, 0); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
322 break; |
1 | 323 } |
324 } else { | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
325 applet_buddy_show = TRUE; |
1 | 326 switch( MRI_user_status ){ |
327 case offline: | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
328 applet_show_login( APPLET_WIDGET(applet), NULL ); |
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
329 break; |
1 | 330 case online: |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
331 case away: |
1 | 332 createOnlinePopup(); |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
333 break; |
1 | 334 } |
335 } | |
336 } | |
337 | |
338 | |
339 /*************************************************************** | |
340 ** | |
341 ** Initialize GNOME stuff | |
342 ** | |
343 ****************************************************************/ | |
344 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
345 gint init_applet_mgr(int argc, char *argv[]) { |
1 | 346 GtkWidget *vbox; |
347 | |
348 GtkStyle *label_style; | |
349 GdkFont *label_font = NULL; | |
350 | |
351 applet_widget_init("GAIM",VERSION,argc,argv,NULL,0,NULL); | |
352 | |
353 /*init imlib for graphics*/ | |
354 gdk_imlib_init(); | |
355 gtk_widget_push_visual(gdk_imlib_get_visual()); | |
356 gtk_widget_push_colormap(gdk_imlib_get_colormap()); | |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
357 |
1 | 358 applet=applet_widget_new("gaim_applet"); |
359 if(!applet) g_error(_("Can't create GAIM applet!")); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
360 gtk_widget_set_events(applet, gtk_widget_get_events(applet) | |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
361 GDK_BUTTON_PRESS_MASK); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
362 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
363 appletframe = gtk_frame_new(NULL); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
364 #ifdef HAVE_PANEL_PIXEL_SIZE |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
365 gtk_widget_set_usize(appletframe, 5, 5); |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
366 #else |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
367 gtk_widget_set_usize(appletframe, 48, 48); |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
368 #endif |
1 | 369 |
370 /*load offline icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
371 load_applet_icon( GAIM_GNOME_OFFLINE_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
372 &icon_offline_pm, &icon_offline_bm ); |
1 | 373 |
374 /*load connecting icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
375 load_applet_icon( GAIM_GNOME_CONNECT_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
376 &icon_connect_pm, &icon_connect_bm ); |
1 | 377 |
378 /*load online icon*/ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
379 load_applet_icon( GAIM_GNOME_ONLINE_ICON, 32, 32, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
380 &icon_online_pm, &icon_online_bm ); |
1 | 381 |
382 /*icon_away and icon_msg_pennding need to be implemented*/ | |
383 | |
384 icon=gtk_pixmap_new(icon_offline_pm,icon_offline_bm); | |
385 | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
386 update_applet(FALSE); |
1 | 387 |
388 vbox = gtk_vbox_new(FALSE,0); | |
389 | |
390 gtk_box_pack_start(GTK_BOX(vbox), icon, FALSE, TRUE, 0); | |
391 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
392 status_label = gtk_label_new(_("Offline")); |
1 | 393 /*set this label's font*/ |
394 label_style = gtk_widget_get_style( status_label ); | |
395 | |
396 label_font = gdk_font_load( _MSG_FONT_ ); | |
397 | |
398 | |
399 if( label_font != NULL ){ | |
400 label_style->font = label_font; | |
401 gtk_widget_set_style( status_label, label_style ); | |
402 } else { | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
403 sprintf(debug_buff, _("Font does not exist") ); |
1 | 404 debug_print(debug_buff); |
405 } | |
406 | |
407 gtk_box_pack_start(GTK_BOX(vbox), status_label, FALSE, TRUE, 0); | |
408 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
409 gtk_container_add( GTK_CONTAINER(appletframe), vbox ); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
410 applet_widget_add(APPLET_WIDGET(applet), appletframe); |
1 | 411 |
412 gtk_widget_show( status_label ); | |
413 gtk_widget_show( vbox ); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
414 gtk_widget_show( appletframe ); |
1 | 415 |
416 applet_widget_register_stock_callback(APPLET_WIDGET(applet), | |
417 "about", | |
418 GNOME_STOCK_MENU_ABOUT, | |
419 _("About..."), | |
420 applet_show_about, | |
421 NULL); | |
422 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
246
diff
changeset
|
423 gtk_signal_connect( GTK_OBJECT(applet), "button_press_event", GTK_SIGNAL_FUNC( AppletClicked), NULL); |
1 | 424 |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
425 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
|
426 |
374
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
427 #ifdef HAVE_PANEL_PIXEL_SIZE |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
428 gtk_signal_connect(GTK_OBJECT(applet), "change_pixel_size", |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
429 GTK_SIGNAL_FUNC(applet_change_pixel_size), NULL); |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
430 #endif |
7493af3a4ce2
[gaim-migrate @ 384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
431 |
1 | 432 gtk_widget_show(icon); |
433 gtk_widget_show(applet); | |
434 return 0; | |
435 } | |
436 | |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
437 void set_user_state( enum gaim_user_states state ){ |
1 | 438 MRI_user_status = state; |
746
5a908dd5cfc4
[gaim-migrate @ 756]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
439 update_applet(FALSE); |
1 | 440 } |
441 | |
342
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
442 void applet_set_tooltips(char *msg) { |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
443 applet_widget_set_tooltip(APPLET_WIDGET(applet), msg); |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
444 } |
f4fba304b236
[gaim-migrate @ 352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
340
diff
changeset
|
445 |
1 | 446 #endif /*USE_APPLET*/ |