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