Mercurial > pidgin
annotate src/applet.c @ 2407:2701aafc7baf
[gaim-migrate @ 2420]
argh
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 01 Oct 2001 18:14:22 +0000 |
parents | 2927c2c26fe6 |
children | 16e8b83b10a2 |
rev | line source |
---|---|
1261 | 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 HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
31 #include <config.h> |
1261 | 32 #endif |
33 #ifdef USE_APPLET | |
34 #include <string.h> | |
35 #include <gdk_imlib.h> | |
36 #include "gaim.h" | |
37 #include "applet.h" | |
38 | |
39 static int connecting = 0; | |
40 | |
41 gboolean applet_buddy_show = FALSE; | |
42 GtkWidget *applet_popup = NULL; | |
43 | |
44 GtkWidget *applet; | |
45 GtkWidget *appletframe; | |
46 | |
47 GtkWidget *icon; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
48 GdkPixmap *icon_offline_pm = NULL; |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
49 GdkPixmap *icon_offline_bm = NULL; |
1261 | 50 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
51 GdkPixmap *icon_online_pm = NULL; |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
52 GdkPixmap *icon_online_bm = NULL; |
1261 | 53 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
54 GdkPixmap *icon_connect_pm = NULL; |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
55 GdkPixmap *icon_connect_bm = NULL; |
1261 | 56 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
57 GdkPixmap *icon_msg_pending_pm = NULL; |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
58 GdkPixmap *icon_msg_pending_bm = NULL; |
1261 | 59 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
60 GdkPixmap *icon_away_pm = NULL; |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
61 GdkPixmap *icon_away_bm = NULL; |
1261 | 62 |
63 static GtkAllocation get_applet_pos(gboolean); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
64 gint sizehint = 48; |
1261 | 65 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
66 static gboolean load_applet_icon(const char *name, int height, int width, GdkPixmap **pm, GdkBitmap **bm) |
1261 | 67 { |
68 gboolean result = TRUE; | |
69 char *path; | |
70 GdkImlibImage *im; | |
71 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
72 path = gnome_pixmap_file(name); |
1261 | 73 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
74 im = gdk_imlib_load_image(path); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
75 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
76 if ((*pm) != NULL) |
1261 | 77 gdk_imlib_free_pixmap((*pm)); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
78 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
79 if (im != NULL) { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
80 gdk_imlib_render(im, width, height); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
81 |
1261 | 82 (*pm) = gdk_imlib_move_image(im); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
83 (*bm) = gdk_imlib_move_mask(im); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
84 |
1261 | 85 } else { |
86 result = FALSE; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
87 debug_printf(_("file not found: %s\n"), path); |
1261 | 88 } |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
89 |
1261 | 90 free(path); |
91 return result; | |
92 } | |
93 | |
94 #ifdef HAVE_PANEL_PIXEL_SIZE | |
95 static void applet_change_pixel_size(GtkWidget *w, int size, gpointer data) | |
96 { | |
97 sizehint = size; | |
98 update_pixmaps(); | |
99 } | |
100 #endif | |
101 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
102 static gboolean update_applet() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
103 { |
1261 | 104 char buf[BUF_LONG]; |
105 GSList *c = connections; | |
106 | |
107 if (connecting) { | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
108 gtk_pixmap_set(GTK_PIXMAP(icon), icon_connect_pm, icon_connect_bm); |
1261 | 109 applet_set_tooltips(_("Attempting to sign on....")); |
110 } else if (!connections) { | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
111 gtk_pixmap_set(GTK_PIXMAP(icon), icon_offline_pm, icon_offline_bm); |
1815
f15d449b3167
[gaim-migrate @ 1825]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1689
diff
changeset
|
112 applet_set_tooltips(_("Offline. Click to bring up login box.")); |
1281
83d8b2078f4c
[gaim-migrate @ 1291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1280
diff
changeset
|
113 } else if (!awaymessage) { |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
114 gtk_pixmap_set(GTK_PIXMAP(icon), icon_online_pm, icon_online_bm); |
1261 | 115 g_snprintf(buf, sizeof buf, "Online: "); |
116 while (c) { | |
117 strcat(buf, ((struct gaim_connection *)c->data)->username); | |
118 c = g_slist_next(c); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
119 if (c) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
120 strcat(buf, ", "); |
1261 | 121 } |
122 applet_set_tooltips(buf); | |
123 } else { | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
124 gtk_pixmap_set(GTK_PIXMAP(icon), icon_online_pm, icon_online_bm); |
1261 | 125 } |
126 | |
127 return TRUE; | |
128 } | |
129 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
130 void update_pixmaps() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
131 { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
132 load_applet_icon(GAIM_GNOME_OFFLINE_ICON, (sizehint - 1), (sizehint - 1), |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
133 &icon_offline_pm, &icon_offline_bm); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
134 load_applet_icon(GAIM_GNOME_CONNECT_ICON, (sizehint - 1), (sizehint - 1), |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
135 &icon_connect_pm, &icon_connect_bm); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
136 load_applet_icon(GAIM_GNOME_ONLINE_ICON, (sizehint - 1), (sizehint - 1), |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
137 &icon_online_pm, &icon_online_bm); |
1261 | 138 update_applet(); |
139 gtk_widget_set_usize(appletframe, sizehint, sizehint); | |
140 } | |
141 | |
142 | |
143 extern GtkWidget *mainwindow; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
144 void applet_show_login(AppletWidget *widget, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
145 { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
146 show_login(); |
2314
64b4c69c1c5e
[gaim-migrate @ 2324]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
147 if (blist_options & OPT_BLIST_NEAR_APPLET) { |
1261 | 148 GtkAllocation a = get_applet_pos(FALSE); |
149 gtk_widget_set_uposition(mainwindow, a.x, a.y); | |
150 } | |
151 } | |
152 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
153 void applet_do_signon(AppletWidget *widget, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
154 { |
1261 | 155 applet_show_login(NULL, 0); |
156 } | |
157 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
158 void insert_applet_away() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
159 { |
1261 | 160 GSList *awy = away_messages; |
161 struct away_message *a; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
162 char *awayname; |
1261 | 163 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
164 applet_widget_register_callback_dir(APPLET_WIDGET(applet), "away/", _("Away")); |
1261 | 165 applet_widget_register_callback(APPLET_WIDGET(applet), |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
166 "away/new", |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
167 _("New Away Message"), |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
168 (AppletCallbackFunc)create_away_mess, NULL); |
1261 | 169 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
170 while (awy) { |
1261 | 171 a = (struct away_message *)awy->data; |
172 | |
173 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); | |
174 awayname[0] = '\0'; | |
175 strcat(awayname, "away/"); | |
176 strcat(awayname, a->name); | |
177 applet_widget_register_callback(APPLET_WIDGET(applet), | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
178 awayname, |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
179 a->name, (AppletCallbackFunc)do_away_message, a); |
1261 | 180 |
181 awy = g_slist_next(awy); | |
1421
13a34fb4abb0
[gaim-migrate @ 1431]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1420
diff
changeset
|
182 g_free(awayname); |
1261 | 183 } |
184 } | |
185 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
186 void remove_applet_away() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
187 { |
1261 | 188 GSList *awy = away_messages; |
189 struct away_message *a; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
190 char *awayname; |
1261 | 191 |
1591
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
192 if (!applet) |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
193 return; |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
194 |
1261 | 195 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new"); |
196 | |
197 while (awy) { | |
198 a = (struct away_message *)awy->data; | |
199 | |
200 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); | |
201 awayname[0] = '\0'; | |
202 strcat(awayname, "away/"); | |
203 strcat(awayname, a->name); | |
204 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname); | |
205 | |
206 awy = g_slist_next(awy); | |
207 free(awayname); | |
208 } | |
209 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/"); | |
210 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); | |
211 } | |
212 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
213 static GtkAllocation get_applet_pos(gboolean for_blist) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
214 { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
215 gint x, y, pad; |
1261 | 216 GtkRequisition buddy_req, applet_req; |
217 GtkAllocation result; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
218 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient(APPLET_WIDGET(applet)); |
1261 | 219 pad = 5; |
220 | |
1420
9be6790092dc
[gaim-migrate @ 1430]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1413
diff
changeset
|
221 gdk_window_get_position(gtk_widget_get_parent_window(appletframe), &x, &y); |
1261 | 222 if (for_blist) { |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
223 if (blist_options & OPT_BLIST_SAVED_WINDOWS) { |
1261 | 224 buddy_req.width = blist_pos.width; |
225 buddy_req.height = blist_pos.height; | |
226 } else { | |
227 buddy_req = blist->requisition; | |
228 } | |
229 } else { | |
230 buddy_req = mainwindow->requisition; | |
231 } | |
232 applet_req = appletframe->requisition; | |
233 | |
234 /* FIXME : we need to be smarter here */ | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
235 switch (orient) { |
1261 | 236 case ORIENT_UP: |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
237 result.x = x; |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
238 result.y = y - (buddy_req.height + pad); |
1261 | 239 break; |
240 case ORIENT_DOWN: | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
241 result.x = x; |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
242 result.y = y + applet_req.height + pad; |
1261 | 243 break; |
244 case ORIENT_LEFT: | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
245 result.x = x - (buddy_req.width + pad); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
246 result.y = y; |
1261 | 247 break; |
248 case ORIENT_RIGHT: | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
249 result.x = x + applet_req.width + pad; |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
250 result.y = y; |
1261 | 251 break; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
252 } |
1261 | 253 return result; |
254 } | |
255 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
256 void createOnlinePopup() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
257 { |
1261 | 258 GtkAllocation al; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
259 if (blist) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
260 gtk_widget_show(blist); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
261 al = get_applet_pos(TRUE); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
262 if (blist_options & OPT_BLIST_NEAR_APPLET) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
263 gtk_widget_set_uposition(blist, al.x, al.y); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
264 else if (blist_options & OPT_BLIST_SAVED_WINDOWS) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
265 gtk_widget_set_uposition(blist, blist_pos.x - blist_pos.xoff, |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
266 blist_pos.y - blist_pos.yoff); |
1261 | 267 } |
268 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
269 void AppletClicked(GtkWidget *sender, GdkEventButton *ev, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
270 { |
1261 | 271 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS) |
272 return; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
273 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
274 if (applet_buddy_show) { |
1261 | 275 applet_buddy_show = FALSE; |
276 if (!connections && mainwindow) | |
277 gtk_widget_hide(mainwindow); | |
278 else | |
279 gtk_widget_hide(blist); | |
280 } else { | |
281 applet_buddy_show = TRUE; | |
282 if (!connections) | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
283 applet_show_login(APPLET_WIDGET(applet), NULL); |
1261 | 284 else |
285 createOnlinePopup(); | |
286 } | |
287 } | |
288 | |
289 | |
290 /*************************************************************** | |
291 ** | |
292 ** Initialize GNOME stuff | |
293 ** | |
294 ****************************************************************/ | |
295 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
296 gint init_applet_mgr(int argc, char *argv[]) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
297 { |
1261 | 298 GtkWidget *vbox; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
299 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
300 applet_widget_init("GAIM", VERSION, argc, argv, NULL, 0, NULL); |
1261 | 301 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
302 /*init imlib for graphics */ |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
303 gdk_imlib_init(); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
304 gtk_widget_push_visual(gdk_imlib_get_visual()); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
305 gtk_widget_push_colormap(gdk_imlib_get_colormap()); |
1261 | 306 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
307 applet = applet_widget_new("gaim_applet"); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
308 if (!applet) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
309 g_error(_("Can't create GAIM applet!")); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
310 gtk_widget_set_events(applet, gtk_widget_get_events(applet) | GDK_BUTTON_PRESS_MASK); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
311 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
312 appletframe = gtk_frame_new(NULL); |
1689
09017c023fcd
[gaim-migrate @ 1699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1591
diff
changeset
|
313 gtk_frame_set_shadow_type(GTK_FRAME(appletframe), GTK_SHADOW_NONE); |
1261 | 314 #ifdef HAVE_PANEL_PIXEL_SIZE |
315 gtk_widget_set_usize(appletframe, 5, 5); | |
316 #else | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
317 gtk_widget_set_usize(appletframe, 48, 48); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
318 #endif |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
319 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
320 /*load offline icon */ |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
321 load_applet_icon(GAIM_GNOME_OFFLINE_ICON, 32, 32, &icon_offline_pm, &icon_offline_bm); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
322 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
323 /*load connecting icon */ |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
324 load_applet_icon(GAIM_GNOME_CONNECT_ICON, 32, 32, &icon_connect_pm, &icon_connect_bm); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
325 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
326 /*load online icon */ |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
327 load_applet_icon(GAIM_GNOME_ONLINE_ICON, 32, 32, &icon_online_pm, &icon_online_bm); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
328 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
329 /*icon_away and icon_msg_pennding need to be implemented */ |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
330 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
331 icon = gtk_pixmap_new(icon_offline_pm, icon_offline_bm); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
332 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
333 vbox = gtk_vbox_new(FALSE, 0); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
334 |
1261 | 335 gtk_box_pack_start(GTK_BOX(vbox), icon, FALSE, TRUE, 0); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
336 |
1261 | 337 update_applet(); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
338 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
339 gtk_container_add(GTK_CONTAINER(appletframe), vbox); |
1261 | 340 applet_widget_add(APPLET_WIDGET(applet), appletframe); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
341 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
342 gtk_widget_show(vbox); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
343 gtk_widget_show(appletframe); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
344 |
1261 | 345 applet_widget_register_stock_callback(APPLET_WIDGET(applet), |
346 "about", | |
347 GNOME_STOCK_MENU_ABOUT, | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
348 _("About..."), (AppletCallbackFunc)show_about, NULL); |
1261 | 349 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
350 gtk_signal_connect(GTK_OBJECT(applet), "button_press_event", GTK_SIGNAL_FUNC(AppletClicked), |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
351 NULL); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
352 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
353 gtk_signal_connect(GTK_OBJECT(applet), "destroy", GTK_SIGNAL_FUNC(do_quit), NULL); |
1261 | 354 |
355 #ifdef HAVE_PANEL_PIXEL_SIZE | |
356 gtk_signal_connect(GTK_OBJECT(applet), "change_pixel_size", | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
357 GTK_SIGNAL_FUNC(applet_change_pixel_size), NULL); |
1261 | 358 #endif |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
359 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
360 gtk_widget_show(icon); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
361 gtk_widget_show(applet); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
362 return 0; |
1261 | 363 } |
364 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
365 void set_user_state(enum gaim_user_states state) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
366 { |
1261 | 367 if (state == signing_on) |
368 connecting++; | |
369 else if ((state == away || state == online) && connecting > 0) | |
370 connecting--; | |
371 update_applet(); | |
372 } | |
373 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
374 void applet_set_tooltips(char *msg) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
375 { |
1591
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
376 if (!applet) |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
377 return; |
1261 | 378 applet_widget_set_tooltip(APPLET_WIDGET(applet), msg); |
379 } | |
380 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
381 #endif /*USE_APPLET */ |