Mercurial > pidgin
annotate src/applet.c @ 2991:9d11dbb33b6f
[gaim-migrate @ 3004]
KingAnt says: SSI SSI SSI
I say! HI HI HI!
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Sat, 02 Mar 2002 01:36:01 +0000 |
parents | 32c78c57b351 |
children | 22c84cbcd5a6 |
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 static void make_background(guchar *dest) |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
58 { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
59 guchar *p; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
60 int r,g,b,i; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
61 |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
62 if (backcolor && (backtype == PANEL_BACK_COLOR)) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
63 guchar *p; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
64 int r,g,b,i; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
65 |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
66 r = backcolor->red>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
67 g = backcolor->green>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
68 b = backcolor->blue>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
69 p = dest; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
70 for (i = 0; i < sizehint * sizehint; i++) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
71 *p++ = r; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
72 *p++ = g; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
73 *p++ = b; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
74 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
75 return; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
76 } else if (backfile && (backtype == PANEL_BACK_PIXMAP)) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
77 GdkPixbuf *pb = gdk_pixbuf_new_from_file(backfile); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
78 if (pb) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
79 int dw = sizehint; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
80 int dh = sizehint; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
81 int offx = applet->allocation.x; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
82 int offy = applet->allocation.y; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
83 int drs = dw * 3; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
84 guchar *tile = gdk_pixbuf_get_pixels(pb); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
85 int w = gdk_pixbuf_get_width(pb); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
86 int h = gdk_pixbuf_get_height(pb); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
87 int rowstride = gdk_pixbuf_get_rowstride(pb); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
88 int has_alpha = gdk_pixbuf_get_has_alpha(pb); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
89 |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
90 guchar *p; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
91 int i,j,x,y,a; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
92 guchar *imgrow; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
93 int off; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
94 |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
95 p = dest; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
96 y = offy % h; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
97 off = drs - (dw*3); /*the space after width ends until next row*/ |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
98 for(j=0;j<dh;j++) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
99 x = offx % w; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
100 imgrow = tile + y * rowstride + (has_alpha?/*x*4*/x<<2:x*3); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
101 for(i=0;i<dw;i++) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
102 *(p++) = *(imgrow++); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
103 *(p++) = *(imgrow++); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
104 *(p++) = *(imgrow++); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
105 if(has_alpha) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
106 a = *(imgrow++); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
107 if(a!=255) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
108 guchar *pp = p-3; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
109 pp[0] = (pp[0]*a)>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
110 pp[1] = (pp[1]*a)>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
111 pp[2] = (pp[2]*a)>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
112 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
113 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
114 x++; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
115 if(x>=w) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
116 x = 0; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
117 imgrow = tile + y * rowstride; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
118 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
119 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
120 p += off; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
121 y++; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
122 if(y>=h) |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
123 y = 0; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
124 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
125 gdk_pixbuf_unref(pb); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
126 return; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
127 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
128 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
129 |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
130 r = applet->style->bg[GTK_WIDGET_STATE(applet)].red>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
131 g = applet->style->bg[GTK_WIDGET_STATE(applet)].green>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
132 b = applet->style->bg[GTK_WIDGET_STATE(applet)].blue>>8; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
133 p = dest; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
134 for (i = 0; i < sizehint * sizehint; i++) { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
135 *p++ = r; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
136 *p++ = g; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
137 *p++ = b; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
138 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
139 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
140 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
141 static GdkPixmap *get_applet_icon(const char *name) |
1261 | 142 { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
143 GdkPixmap *cache; |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
144 GdkGC *gc; |
1261 | 145 char *path; |
2843
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2731
diff
changeset
|
146 GdkPixbuf *pb, *scale = NULL; |
2629
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
147 guchar *dst; |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
148 double affine[6]; |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
149 |
2567 | 150 if (!applet) |
151 return NULL; | |
152 | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
153 cache = gdk_pixmap_new(applet->window, sizehint, sizehint, |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
154 gtk_widget_get_visual(applet)->depth); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
155 gc = gdk_gc_new(cache); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
156 gdk_gc_copy(gc, applet->style->bg_gc[GTK_WIDGET_STATE(applet)]); |
1261 | 157 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
158 path = gnome_pixmap_file(name); |
2843
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2731
diff
changeset
|
159 if (path) |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2731
diff
changeset
|
160 scale = gdk_pixbuf_new_from_file(path); |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
161 g_free(path); |
2486
cf3218cd9f94
[gaim-migrate @ 2499]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2484
diff
changeset
|
162 if (!scale) |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
163 return NULL; |
2486
cf3218cd9f94
[gaim-migrate @ 2499]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2484
diff
changeset
|
164 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
|
165 gdk_pixbuf_unref(scale); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
166 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
167 dst = g_new0(guchar, sizehint*sizehint*3); |
2629
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
168 make_background(dst); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
169 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
170 art_affine_identity(affine); |
2497
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
171 if (gdk_pixbuf_get_has_alpha(pb)) |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
172 art_rgb_rgba_affine(dst, 0, 0, sizehint, sizehint, sizehint * 3, |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
173 gdk_pixbuf_get_pixels(pb), gdk_pixbuf_get_width(pb), |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
174 gdk_pixbuf_get_height(pb), gdk_pixbuf_get_rowstride(pb), |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
175 affine, ART_FILTER_NEAREST, NULL); |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
176 else |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
177 art_rgb_affine(dst, 0, 0, sizehint, sizehint, sizehint * 3, |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
178 gdk_pixbuf_get_pixels(pb), gdk_pixbuf_get_width(pb), |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
179 gdk_pixbuf_get_height(pb), gdk_pixbuf_get_rowstride(pb), |
be88e02789e0
[gaim-migrate @ 2510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2492
diff
changeset
|
180 affine, ART_FILTER_NEAREST, NULL); |
1261 | 181 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
182 gdk_pixbuf_unref(pb); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
183 gdk_draw_rgb_image(cache, gc, 0, 0, sizehint, sizehint, |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
184 GDK_RGB_DITHER_NORMAL, dst, sizehint * 3); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
185 g_free(dst); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
186 |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
187 gdk_gc_unref(gc); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
188 return cache; |
1261 | 189 } |
190 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
191 static gboolean update_applet() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
192 { |
1261 | 193 char buf[BUF_LONG]; |
194 GSList *c = connections; | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
195 GdkPixmap *newpix; |
1261 | 196 |
197 if (connecting) { | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
198 newpix = get_applet_icon(GAIM_GNOME_CONNECT_ICON); |
1261 | 199 applet_set_tooltips(_("Attempting to sign on....")); |
200 } else if (!connections) { | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
201 newpix = get_applet_icon(GAIM_GNOME_OFFLINE_ICON); |
1815
f15d449b3167
[gaim-migrate @ 1825]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1689
diff
changeset
|
202 applet_set_tooltips(_("Offline. Click to bring up login box.")); |
2468
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
203 } else if (awaymessage) { |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
204 int dsr = 0; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
205 |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
206 if ((away_options & OPT_AWAY_QUEUE) && message_queue) { |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
207 GSList *m = message_queue; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
208 while (m) { |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
209 struct queued_message *qm = m->data; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
210 if (qm->flags & WFLAG_RECV) |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
211 dsr++; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
212 m = m->next; |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
213 } |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
214 } |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
215 |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
216 if (dsr) { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
217 newpix = get_applet_icon(GAIM_GNOME_MSG_PENDING_ICON); |
2468
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
218 g_snprintf(buf, sizeof(buf), _("Away: %d pending."), dsr); |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
219 } else { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
220 newpix = get_applet_icon(GAIM_GNOME_AWAY_ICON); |
2468
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
221 g_snprintf(buf, sizeof(buf), _("Away.")); |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
222 } |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
223 |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
224 applet_set_tooltips(buf); |
16e8b83b10a2
[gaim-migrate @ 2481]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
225 } else { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
226 newpix = get_applet_icon(GAIM_GNOME_ONLINE_ICON); |
1261 | 227 g_snprintf(buf, sizeof buf, "Online: "); |
228 while (c) { | |
229 strcat(buf, ((struct gaim_connection *)c->data)->username); | |
230 c = g_slist_next(c); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
231 if (c) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
232 strcat(buf, ", "); |
1261 | 233 } |
234 applet_set_tooltips(buf); | |
235 } | |
236 | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
237 if (newpix) { |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
238 gtk_pixmap_set(GTK_PIXMAP(icon), newpix, NULL); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
239 gdk_pixmap_unref(newpix); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
240 } |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
241 |
1261 | 242 return TRUE; |
243 } | |
244 | |
2629
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
245 static void back_changed(AppletWidget *applet, PanelBackType type, char *file, GdkColor *clr) |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
246 { |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
247 backtype = type; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
248 if (backfile) |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
249 g_free(backfile); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
250 if (file) |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
251 backfile = g_strdup(file); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
252 else |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
253 backfile = NULL; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
254 if (backcolor) |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
255 gdk_color_free(backcolor); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
256 if (clr) |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
257 backcolor = gdk_color_copy(clr); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
258 else |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
259 backcolor = NULL; |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
260 update_applet(); |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
261 } |
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
262 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
263 #ifdef HAVE_PANEL_PIXEL_SIZE |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
264 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
|
265 { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
266 sizehint = size; |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
267 gtk_widget_set_usize(icon, sizehint, sizehint); |
1261 | 268 update_applet(); |
269 } | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
270 #endif |
1261 | 271 |
272 extern GtkWidget *mainwindow; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
273 void applet_show_login(AppletWidget *widget, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
274 { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
275 show_login(); |
2314
64b4c69c1c5e
[gaim-migrate @ 2324]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
276 if (blist_options & OPT_BLIST_NEAR_APPLET) { |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
277 GtkAllocation *a = get_applet_pos(FALSE); |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
278 gtk_widget_set_uposition(mainwindow, a->x, a->y); |
1261 | 279 } |
280 } | |
281 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
282 void applet_do_signon(AppletWidget *widget, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
283 { |
1261 | 284 applet_show_login(NULL, 0); |
285 } | |
286 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
287 void insert_applet_away() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
288 { |
1261 | 289 GSList *awy = away_messages; |
290 struct away_message *a; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
291 char *awayname; |
1261 | 292 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
293 applet_widget_register_callback_dir(APPLET_WIDGET(applet), "away/", _("Away")); |
1261 | 294 applet_widget_register_callback(APPLET_WIDGET(applet), |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
295 "away/new", |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
296 _("New Away Message"), |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
297 (AppletCallbackFunc)create_away_mess, NULL); |
1261 | 298 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
299 while (awy) { |
1261 | 300 a = (struct away_message *)awy->data; |
301 | |
302 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); | |
303 awayname[0] = '\0'; | |
304 strcat(awayname, "away/"); | |
305 strcat(awayname, a->name); | |
306 applet_widget_register_callback(APPLET_WIDGET(applet), | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
307 awayname, |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
308 a->name, (AppletCallbackFunc)do_away_message, a); |
1261 | 309 |
2731
e9e624d8803e
[gaim-migrate @ 2744]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2729
diff
changeset
|
310 awy = awy->next; |
1421
13a34fb4abb0
[gaim-migrate @ 1431]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1420
diff
changeset
|
311 g_free(awayname); |
1261 | 312 } |
313 } | |
314 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
315 void remove_applet_away() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
316 { |
1261 | 317 GSList *awy = away_messages; |
318 struct away_message *a; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
319 char *awayname; |
1261 | 320 |
1591
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
321 if (!applet) |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
322 return; |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
323 |
1261 | 324 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new"); |
325 | |
326 while (awy) { | |
327 a = (struct away_message *)awy->data; | |
328 | |
329 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name))); | |
330 awayname[0] = '\0'; | |
331 strcat(awayname, "away/"); | |
332 strcat(awayname, a->name); | |
333 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname); | |
334 | |
335 awy = g_slist_next(awy); | |
2492
1a25e4869e7d
[gaim-migrate @ 2505]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2489
diff
changeset
|
336 g_free(awayname); |
1261 | 337 } |
338 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/"); | |
339 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); | |
340 } | |
341 | |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
342 static GtkAllocation *get_applet_pos(gboolean for_blist) |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
343 { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
344 gint x, y, pad; |
1261 | 345 GtkRequisition buddy_req, applet_req; |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
346 GtkAllocation *result = g_new0(GtkAllocation, 1); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
347 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient(APPLET_WIDGET(applet)); |
1261 | 348 pad = 5; |
349 | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
350 gdk_window_get_position(gtk_widget_get_parent_window(icon), &x, &y); |
1261 | 351 if (for_blist) { |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
352 if (blist_options & OPT_BLIST_SAVED_WINDOWS) { |
1261 | 353 buddy_req.width = blist_pos.width; |
354 buddy_req.height = blist_pos.height; | |
355 } else { | |
356 buddy_req = blist->requisition; | |
357 } | |
358 } else { | |
359 buddy_req = mainwindow->requisition; | |
360 } | |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
361 applet_req = icon->requisition; |
1261 | 362 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
363 switch (orient) { |
1261 | 364 case ORIENT_UP: |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
365 result->x = x; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
366 result->y = y - (buddy_req.height + pad); |
1261 | 367 break; |
368 case ORIENT_DOWN: | |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
369 result->x = x; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
370 result->y = y + applet_req.height + pad; |
1261 | 371 break; |
372 case ORIENT_LEFT: | |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
373 result->x = x - (buddy_req.width + pad); |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
374 result->y = y; |
1261 | 375 break; |
376 case ORIENT_RIGHT: | |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
377 result->x = x + applet_req.width + pad; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
378 result->y = y; |
1261 | 379 break; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
380 } |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
381 |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
382 if (result->x < 0) |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
383 result->x = 0; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
384 if (result->y < 0) |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
385 result->y = 0; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
386 if (result->x > gdk_screen_width() - buddy_req.width) |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
387 result->x = gdk_screen_width() - buddy_req.width; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
388 if (result->y > gdk_screen_height() - buddy_req.height) |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
389 result->y = gdk_screen_height() - buddy_req.height; |
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
390 |
1261 | 391 return result; |
392 } | |
393 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
394 void createOnlinePopup() |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
395 { |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
396 GtkAllocation *al; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
397 if (blist) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
398 gtk_widget_show(blist); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
399 al = get_applet_pos(TRUE); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
400 if (blist_options & OPT_BLIST_NEAR_APPLET) |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
401 gtk_widget_set_uposition(blist, al->x, al->y); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
402 else if (blist_options & OPT_BLIST_SAVED_WINDOWS) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
403 gtk_widget_set_uposition(blist, blist_pos.x - blist_pos.xoff, |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
404 blist_pos.y - blist_pos.yoff); |
2549
7c64b3ad0c3d
[gaim-migrate @ 2562]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2534
diff
changeset
|
405 g_free(al); |
1261 | 406 } |
407 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
408 void AppletClicked(GtkWidget *sender, GdkEventButton *ev, gpointer data) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
409 { |
1261 | 410 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS) |
411 return; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
412 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
413 if (applet_buddy_show) { |
1261 | 414 applet_buddy_show = FALSE; |
415 if (!connections && mainwindow) | |
416 gtk_widget_hide(mainwindow); | |
417 else | |
418 gtk_widget_hide(blist); | |
419 } else { | |
420 applet_buddy_show = TRUE; | |
421 if (!connections) | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
422 applet_show_login(APPLET_WIDGET(applet), NULL); |
1261 | 423 else |
424 createOnlinePopup(); | |
425 } | |
426 } | |
427 | |
428 | |
429 /*************************************************************** | |
430 ** | |
431 ** Initialize GNOME stuff | |
432 ** | |
433 ****************************************************************/ | |
434 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
435 gint init_applet_mgr(int argc, char *argv[]) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
436 { |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
437 GdkPixmap *pm; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
438 |
2534 | 439 applet_widget_init("Gaim", VERSION, argc, argv, NULL, 0, NULL); |
1261 | 440 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
441 applet = applet_widget_new("gaim_applet"); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
442 if (!applet) |
2534 | 443 g_error(_("Can't create Gaim applet!")); |
2629
b74421e92d55
[gaim-migrate @ 2642]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2567
diff
changeset
|
444 gtk_signal_connect(GTK_OBJECT(applet), "back_change", GTK_SIGNAL_FUNC(back_changed), NULL); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
445 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
|
446 gtk_widget_realize(applet); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
447 |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
448 pm = get_applet_icon(GAIM_GNOME_OFFLINE_ICON); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
449 if (!pm) |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
450 pm = gdk_pixmap_create_from_xpm_d(applet->window, NULL, |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
451 &applet->style->bg[GTK_WIDGET_STATE(applet)], aimicon_xpm); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
452 icon = gtk_pixmap_new(pm, NULL); |
2716
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
453 #ifdef HAVE_PANEL_PIXEL_SIZE |
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
454 gtk_widget_set_usize(icon, 5, 5); |
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
455 #else |
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
456 gtk_widget_set_usize(icon, 48, 48); |
48274976c79b
[gaim-migrate @ 2729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2629
diff
changeset
|
457 #endif |
2484
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
458 gdk_pixmap_unref(pm); |
a4647b25dbf1
[gaim-migrate @ 2497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2468
diff
changeset
|
459 applet_widget_add(APPLET_WIDGET(applet), icon); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
460 |
1261 | 461 applet_widget_register_stock_callback(APPLET_WIDGET(applet), |
462 "about", | |
463 GNOME_STOCK_MENU_ABOUT, | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
464 _("About..."), (AppletCallbackFunc)show_about, NULL); |
1261 | 465 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
466 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
|
467 NULL); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
468 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
469 gtk_signal_connect(GTK_OBJECT(applet), "destroy", GTK_SIGNAL_FUNC(do_quit), NULL); |
1261 | 470 |
471 #ifdef HAVE_PANEL_PIXEL_SIZE | |
472 gtk_signal_connect(GTK_OBJECT(applet), "change_pixel_size", | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
473 GTK_SIGNAL_FUNC(applet_change_pixel_size), NULL); |
1261 | 474 #endif |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
475 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
476 gtk_widget_show(icon); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
477 gtk_widget_show(applet); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
478 return 0; |
1261 | 479 } |
480 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
481 void set_user_state(enum gaim_user_states state) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
482 { |
1261 | 483 if (state == signing_on) |
484 connecting++; | |
2985 | 485 else if ((state == offline || state == away || state == online) && connecting > 0) |
1261 | 486 connecting--; |
487 update_applet(); | |
488 } | |
489 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
490 void applet_set_tooltips(char *msg) |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
491 { |
1591
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
492 if (!applet) |
5c74d8b6cb57
[gaim-migrate @ 1601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
493 return; |
1261 | 494 applet_widget_set_tooltip(APPLET_WIDGET(applet), msg); |
495 } | |
496 | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2314
diff
changeset
|
497 #endif /*USE_APPLET */ |