Mercurial > pidgin.yaz
annotate src/applet.c @ 3187:01279615a5fe
[gaim-migrate @ 3204]
Better applet transparency for pixmap (and translucent, which is really the same thing)
panel backgrounds.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 27 Apr 2002 07:43:53 +0000 |
parents | 22c84cbcd5a6 |
children | a7c241854218 |
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> | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
35 #include <gdk-pixbuf/gdk-pixbuf.h> |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
36 #include <libart_lgpl/art_affine.h> |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
37 #include <libart_lgpl/art_rgb_affine.h> |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
38 #include <libart_lgpl/art_rgb_rgba_affine.h> |
1261 | 39 #include "gaim.h" |
40 #include "applet.h" | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
41 #include "pixmaps/aimicon.xpm" |
1261 | 42 |
43 static int connecting = 0; | |
44 | |
45 gboolean applet_buddy_show = FALSE; | |
46 | |
47 GtkWidget *applet; | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
48 static GtkWidget *icon; |
1261 | 49 |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
50 static GtkAllocation *get_applet_pos(gboolean); |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
51 static gint sizehint = 48; |
1261 | 52 |
2629
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
53 static PanelBackType backtype = PANEL_BACK_NONE; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
54 static GdkColor *backcolor = NULL; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
55 static char *backfile = NULL; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
56 |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
57 |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
58 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
59 static GdkPixmap *get_applet_icon(const char *name) |
1261 | 60 { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
61 GdkPixmap *cache; |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
62 GdkGC *gc; |
1261 | 63 char *path; |
2843
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2731
diff
changeset
|
64 GdkPixbuf *pb, *scale = NULL; |
2629
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
65 guchar *dst; |
3187 | 66 int w, h, rowstride; |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
67 double affine[6]; |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
68 |
2567 | 69 if (!applet) |
70 return NULL; | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
71 cache = gdk_pixmap_new(applet->window, sizehint, sizehint, |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
72 gtk_widget_get_visual(applet)->depth); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
73 gc = gdk_gc_new(cache); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
74 gdk_gc_copy(gc, applet->style->bg_gc[GTK_WIDGET_STATE(applet)]); |
1261 | 75 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
76 path = gnome_pixmap_file(name); |
2843
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2731
diff
changeset
|
77 if (path) |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2731
diff
changeset
|
78 scale = gdk_pixbuf_new_from_file(path); |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
79 g_free(path); |
2486
cf3218cd9f94
[gaim-migrate @ 2499]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2484
diff
changeset
|
80 if (!scale) |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
81 return NULL; |
2486
cf3218cd9f94
[gaim-migrate @ 2499]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2484
diff
changeset
|
82 pb = gdk_pixbuf_scale_simple(scale, sizehint, sizehint, GDK_INTERP_HYPER); |
2729
e70908d3e0c8
[gaim-migrate @ 2742]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2716
diff
changeset
|
83 gdk_pixbuf_unref(scale); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
84 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
85 dst = g_new0(guchar, sizehint*sizehint*3); |
3187 | 86 applet_widget_get_rgb_bg(applet, &dst, &w, &h, &rowstride); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
87 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
88 art_affine_identity(affine); |
3187 | 89 art_rgb_rgba_affine(dst, 0, 0, w, h, rowstride, |
90 gdk_pixbuf_get_pixels(pb), gdk_pixbuf_get_width(pb), | |
91 gdk_pixbuf_get_height(pb), gdk_pixbuf_get_rowstride(pb), | |
92 affine, ART_FILTER_NEAREST, NULL); | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
93 gdk_pixbuf_unref(pb); |
3187 | 94 gdk_draw_rgb_image(cache, gc, 0, 0, w, h, |
95 GDK_RGB_DITHER_NORMAL, dst, rowstride); | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
96 g_free(dst); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
97 |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
98 gdk_gc_unref(gc); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
99 return cache; |
1261 | 100 } |
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; | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
106 GdkPixmap *newpix; |
1261 | 107 |
108 if (connecting) { | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
109 newpix = get_applet_icon(GAIM_GNOME_CONNECT_ICON); |
1261 | 110 applet_set_tooltips(_("Attempting to sign on....")); |
111 } else if (!connections) { | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
112 newpix = get_applet_icon(GAIM_GNOME_OFFLINE_ICON); |
1815
f15d449b3167
[gaim-migrate @ 1825]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1689
diff
changeset
|
113 applet_set_tooltips(_("Offline. Click to bring up login box.")); |
2468
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
114 } else if (awaymessage) { |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
115 int dsr = 0; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
116 |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
117 if ((away_options & OPT_AWAY_QUEUE) && message_queue) { |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
118 GSList *m = message_queue; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
119 while (m) { |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
120 struct queued_message *qm = m->data; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
121 if (qm->flags & WFLAG_RECV) |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
122 dsr++; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
123 m = m->next; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
124 } |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
125 } |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
126 |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
127 if (dsr) { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
128 newpix = get_applet_icon(GAIM_GNOME_MSG_PENDING_ICON); |
2468
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
129 g_snprintf(buf, sizeof(buf), _("Away: %d pending."), dsr); |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
130 } else { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
131 newpix = get_applet_icon(GAIM_GNOME_AWAY_ICON); |
2468
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
132 g_snprintf(buf, sizeof(buf), _("Away.")); |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
133 } |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
134 |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
135 applet_set_tooltips(buf); |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
136 } else { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
137 newpix = get_applet_icon(GAIM_GNOME_ONLINE_ICON); |
1261 | 138 g_snprintf(buf, sizeof buf, "Online: "); |
139 while (c) { | |
140 strcat(buf, ((struct gaim_connection *)c->data)->username); | |
141 c = g_slist_next(c); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
142 if (c) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
143 strcat(buf, ", "); |
1261 | 144 } |
145 applet_set_tooltips(buf); | |
146 } | |
147 | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
148 if (newpix) { |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
149 gtk_pixmap_set(GTK_PIXMAP(icon), newpix, NULL); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
150 gdk_pixmap_unref(newpix); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
151 } |
3187 | 152 |
1261 | 153 return TRUE; |
154 } | |
155 | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
156 #ifdef HAVE_PANEL_PIXEL_SIZE |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
157 static void applet_change_pixel_size(GtkWidget *w, int size, gpointer data) |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
158 { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
159 sizehint = size; |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
160 gtk_widget_set_usize(icon, sizehint, sizehint); |
1261 | 161 update_applet(); |
162 } | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
163 #endif |
1261 | 164 |
165 extern GtkWidget *mainwindow; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
166 void applet_show_login(AppletWidget *widget, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
167 { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
168 show_login(); |
2314
64b4c69c1c5e
[gaim-migrate @ 2324]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
169 if (blist_options & OPT_BLIST_NEAR_APPLET) { |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
170 GtkAllocation *a = get_applet_pos(FALSE); |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
171 gtk_widget_set_uposition(mainwindow, a->x, a->y); |
1261 | 172 } |
173 } | |
174 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
175 void applet_do_signon(AppletWidget *widget, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
176 { |
1261 | 177 applet_show_login(NULL, 0); |
178 } | |
179 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
180 void insert_applet_away() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
181 { |
1261 | 182 GSList *awy = away_messages; |
183 struct away_message *a; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
184 char *awayname; |
1261 | 185 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
186 applet_widget_register_callback_dir(APPLET_WIDGET(applet), "away/", _("Away")); |
1261 | 187 applet_widget_register_callback(APPLET_WIDGET(applet), |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
188 "away/new", |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
189 _("New Away Message"), |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
190 (AppletCallbackFunc)create_away_mess, NULL); |
1261 | 191 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
192 while (awy) { |
1261 | 193 a = (struct away_message *)awy->data; |
194 | |
195 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); | |
196 awayname[0] = '\0'; | |
197 strcat(awayname, "away/"); | |
198 strcat(awayname, a->name); | |
199 applet_widget_register_callback(APPLET_WIDGET(applet), | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
200 awayname, |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
201 a->name, (AppletCallbackFunc)do_away_message, a); |
1261 | 202 |
2731
e9e624d8803e
[gaim-migrate @ 2744]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2729
diff
changeset
|
203 awy = awy->next; |
1421
13a34fb4abb0
[gaim-migrate @ 1431]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1420
diff
changeset
|
204 g_free(awayname); |
1261 | 205 } |
206 } | |
207 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
208 void remove_applet_away() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
209 { |
1261 | 210 GSList *awy = away_messages; |
211 struct away_message *a; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
212 char *awayname; |
1261 | 213 |
1591
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
214 if (!applet) |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
215 return; |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
216 |
1261 | 217 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new"); |
218 | |
219 while (awy) { | |
220 a = (struct away_message *)awy->data; | |
221 | |
222 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); | |
223 awayname[0] = '\0'; | |
224 strcat(awayname, "away/"); | |
225 strcat(awayname, a->name); | |
226 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname); | |
227 | |
228 awy = g_slist_next(awy); | |
2492
1a25e4869e7d
[gaim-migrate @ 2505]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2489
diff
changeset
|
229 g_free(awayname); |
1261 | 230 } |
231 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/"); | |
232 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); | |
233 } | |
234 | |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
235 static GtkAllocation *get_applet_pos(gboolean for_blist) |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
236 { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
237 gint x, y, pad; |
1261 | 238 GtkRequisition buddy_req, applet_req; |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
239 GtkAllocation *result = g_new0(GtkAllocation, 1); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
240 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient(APPLET_WIDGET(applet)); |
1261 | 241 pad = 5; |
242 | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
243 gdk_window_get_position(gtk_widget_get_parent_window(icon), &x, &y); |
1261 | 244 if (for_blist) { |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
245 if (blist_options & OPT_BLIST_SAVED_WINDOWS) { |
1261 | 246 buddy_req.width = blist_pos.width; |
247 buddy_req.height = blist_pos.height; | |
248 } else { | |
249 buddy_req = blist->requisition; | |
250 } | |
251 } else { | |
252 buddy_req = mainwindow->requisition; | |
253 } | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
254 applet_req = icon->requisition; |
1261 | 255 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
256 switch (orient) { |
1261 | 257 case ORIENT_UP: |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
258 result->x = x; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
259 result->y = y - (buddy_req.height + pad); |
1261 | 260 break; |
261 case ORIENT_DOWN: | |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
262 result->x = x; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
263 result->y = y + applet_req.height + pad; |
1261 | 264 break; |
265 case ORIENT_LEFT: | |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
266 result->x = x - (buddy_req.width + pad); |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
267 result->y = y; |
1261 | 268 break; |
269 case ORIENT_RIGHT: | |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
270 result->x = x + applet_req.width + pad; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
271 result->y = y; |
1261 | 272 break; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
273 } |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
274 |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
275 if (result->x < 0) |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
276 result->x = 0; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
277 if (result->y < 0) |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
278 result->y = 0; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
279 if (result->x > gdk_screen_width() - buddy_req.width) |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
280 result->x = gdk_screen_width() - buddy_req.width; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
281 if (result->y > gdk_screen_height() - buddy_req.height) |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
282 result->y = gdk_screen_height() - buddy_req.height; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
283 |
1261 | 284 return result; |
285 } | |
286 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
287 void createOnlinePopup() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
288 { |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
289 GtkAllocation *al; |
3063 | 290 if (!blist) |
291 return; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
292 al = get_applet_pos(TRUE); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
293 if (blist_options & OPT_BLIST_NEAR_APPLET) |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
294 gtk_widget_set_uposition(blist, al->x, al->y); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
295 else if (blist_options & OPT_BLIST_SAVED_WINDOWS) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
296 gtk_widget_set_uposition(blist, blist_pos.x - blist_pos.xoff, |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
297 blist_pos.y - blist_pos.yoff); |
3063 | 298 gtk_widget_show(blist); |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
299 g_free(al); |
1261 | 300 } |
301 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
302 void AppletClicked(GtkWidget *sender, GdkEventButton *ev, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
303 { |
1261 | 304 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS) |
305 return; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
306 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
307 if (applet_buddy_show) { |
1261 | 308 applet_buddy_show = FALSE; |
309 if (!connections && mainwindow) | |
310 gtk_widget_hide(mainwindow); | |
311 else | |
312 gtk_widget_hide(blist); | |
313 } else { | |
314 applet_buddy_show = TRUE; | |
315 if (!connections) | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
316 applet_show_login(APPLET_WIDGET(applet), NULL); |
1261 | 317 else |
318 createOnlinePopup(); | |
319 } | |
320 } | |
321 | |
322 | |
323 /*************************************************************** | |
324 ** | |
325 ** Initialize GNOME stuff | |
326 ** | |
327 ****************************************************************/ | |
328 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
329 gint init_applet_mgr(int argc, char *argv[]) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
330 { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
331 GdkPixmap *pm; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
332 |
2534 | 333 applet_widget_init("Gaim", VERSION, argc, argv, NULL, 0, NULL); |
1261 | 334 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
335 applet = applet_widget_new("gaim_applet"); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
336 if (!applet) |
2534 | 337 g_error(_("Can't create Gaim applet!")); |
3187 | 338 applet_widget_send_draw(applet, TRUE); |
339 gtk_signal_connect(GTK_OBJECT(applet), "do-draw", GTK_SIGNAL_FUNC(update_applet), NULL); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
340 gtk_widget_set_events(applet, gtk_widget_get_events(applet) | GDK_BUTTON_PRESS_MASK); |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
341 gtk_widget_realize(applet); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
342 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
343 pm = get_applet_icon(GAIM_GNOME_OFFLINE_ICON); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
344 if (!pm) |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
345 pm = gdk_pixmap_create_from_xpm_d(applet->window, NULL, |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
346 &applet->style->bg[GTK_WIDGET_STATE(applet)], aimicon_xpm); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
347 icon = gtk_pixmap_new(pm, NULL); |
2716
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
348 #ifdef HAVE_PANEL_PIXEL_SIZE |
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
349 gtk_widget_set_usize(icon, 5, 5); |
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
350 #else |
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
351 gtk_widget_set_usize(icon, 48, 48); |
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
352 #endif |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
353 gdk_pixmap_unref(pm); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
354 applet_widget_add(APPLET_WIDGET(applet), icon); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
355 |
1261 | 356 applet_widget_register_stock_callback(APPLET_WIDGET(applet), |
357 "about", | |
358 GNOME_STOCK_MENU_ABOUT, | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
359 _("About..."), (AppletCallbackFunc)show_about, NULL); |
1261 | 360 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
361 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
|
362 NULL); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
363 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
364 gtk_signal_connect(GTK_OBJECT(applet), "destroy", GTK_SIGNAL_FUNC(do_quit), NULL); |
1261 | 365 |
366 #ifdef HAVE_PANEL_PIXEL_SIZE | |
367 gtk_signal_connect(GTK_OBJECT(applet), "change_pixel_size", | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
368 GTK_SIGNAL_FUNC(applet_change_pixel_size), NULL); |
1261 | 369 #endif |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
370 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
371 gtk_widget_show(icon); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
372 gtk_widget_show(applet); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
373 return 0; |
1261 | 374 } |
375 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
376 void set_user_state(enum gaim_user_states state) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
377 { |
1261 | 378 if (state == signing_on) |
379 connecting++; | |
2985 | 380 else if ((state == offline || state == away || state == online) && connecting > 0) |
1261 | 381 connecting--; |
382 update_applet(); | |
383 } | |
384 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
385 void applet_set_tooltips(char *msg) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
386 { |
1591
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
387 if (!applet) |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
388 return; |
1261 | 389 applet_widget_set_tooltip(APPLET_WIDGET(applet), msg); |
390 } | |
391 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
392 #endif /*USE_APPLET */ |