Mercurial > pidgin
annotate src/dnd-hints.c @ 4617:858979ab3867
[gaim-migrate @ 4908]
Big Changes:
-Rewrote some of the perl stuff so perl scripts can change a few of their
parameters
-Receiving a file with AIM over oscar works pretty well
Now, the "nitty gritty":
Very minor change to prefs.c: In the plugins details tab, I changed "URL"
to "Web Site." I was just going to fix the tabbing, but silvestrij
suggested changing it to "Web site," and I thought that sounded good.
I think it fits better, too. I dunno, maybe that's just me.
"Get Capabilities" has stopped working for some reason. I'm just going to
blame AOL. It's really not important anyway, and some people wanted it
taken off. It is now #ifdef 0'ed out. I'll remove it completely if it
continues to no longer function.
I took out a few plugin_event calls from oscar.c and put them in core code.
"event_error" should be, uh, "evented" when there is an error signing on.
Hopefully no one was using this. It's really pretty useless. The parameter
is now the reason for not being able to connect rather than the archaic
toc error code.
I screwed around with how perl functions are called some. There was way the
hell too much malloc'ing going on here. I think all in all it's an
improvement, though I'm still not a big fan of how changes to parameters
propagate to the actual memory.
I really think it would be nice if the perl stuff was made into a C plugin.
It's just so much cleaner. Especially if someone wanted to write, say, a
python or tcl interpreter. That's how xchat2 does it. I just think that
would be really slick. Like butter. Or ice. Very unlike Velcro.
I added a "Change Password" Protocol Action for ICQ over oscar. This was
really pretty easy. I'd like to thank my housemate Andrew for complaining
a lot that having to use Windows ICQ to change his password was a pain.
I rewrote a lot of the oscar file transfer stuff to use Christian's new
xfer interface. This involved moving a few functions from ft.c to im.c,
where they belong. I also removed all the #if 0'ed getfile functions.
I'll be rewritting them soonish. Receiving a file should work perfectly,
aside from maybe a small memleak when stuff is canceled. Sending a file is
currently disabled. No ETA on when I'll have that working.
I renamed pretty much all of the functions in im.c so they have kind of a
scheme now. They should all be aim_im_bleh, since "im" is the family
name. There comes a time when you must break the crap out of any clients
that might be using libfaim in order to make stuff cleaner. Maybe.
I got rid of the snac destructor stuff for now. I'll probably add it back
later. I wasn't entirely comfortable with how it was done.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 26 Feb 2003 05:01:37 +0000 |
parents | 65d98b565fbe |
children | 42d53c416bb9 |
rev | line source |
---|---|
4359 | 1 /* |
2 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> | |
3 * | |
4 * Copyright (C) 2001 Ricardo Fernández Pascual | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2, or(at your option) | |
9 * any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
19 */ | |
20 | |
21 #include "dnd-hints.h" | |
22 | |
23 #include <gtk/gtk.h> | |
24 #include <gdk/gdk.h> | |
25 #include <gdk-pixbuf/gdk-pixbuf.h> | |
26 | |
4363
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
27 #ifdef _WIN32 |
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
28 #include "win32dep.h" |
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
29 #endif |
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
30 |
4359 | 31 typedef struct |
32 { | |
33 GtkWidget *widget; | |
34 gchar *filename; | |
35 gint ox; | |
36 gint oy; | |
37 | |
38 } HintWindowInfo; | |
39 | |
40 /** | |
41 * Info about each hint widget. See DndHintWindowId enum. | |
42 */ | |
43 HintWindowInfo hint_windows[] = { | |
44 { NULL, "tb_drag_arrow_up.xpm", -13/2, 0 }, | |
45 { NULL, "tb_drag_arrow_down.xpm", -13/2, -16 }, | |
46 { NULL, "tb_drag_arrow_left.xpm", 0, -13/2 }, | |
47 { NULL, "tb_drag_arrow_right.xpm", -16, -13/2 }, | |
48 { NULL, NULL, 0, 0 } | |
49 }; | |
50 | |
51 static GtkWidget * | |
52 dnd_hints_init_window(const gchar *fname) | |
53 { | |
54 GdkPixbuf *pixbuf; | |
55 GdkPixmap *pixmap; | |
56 GdkBitmap *bitmap; | |
57 GtkWidget *pix; | |
58 GtkWidget *win; | |
59 | |
60 pixbuf = gdk_pixbuf_new_from_file(fname, NULL); | |
61 g_return_val_if_fail(pixbuf, NULL); | |
62 | |
63 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &bitmap, 128); | |
64 gdk_pixbuf_unref(pixbuf); | |
65 | |
66 gtk_widget_push_visual(gdk_rgb_get_visual()); | |
67 gtk_widget_push_colormap(gdk_rgb_get_cmap()); | |
68 win = gtk_window_new(GTK_WINDOW_POPUP); | |
69 pix = gtk_pixmap_new(pixmap, bitmap); | |
70 gtk_widget_realize(win); | |
71 gtk_container_add(GTK_CONTAINER(win), pix); | |
72 gtk_widget_shape_combine_mask(win, bitmap, 0, 0); | |
73 gtk_widget_pop_visual(); | |
74 gtk_widget_pop_colormap(); | |
75 | |
76 gdk_pixmap_unref(pixmap); | |
77 gdk_bitmap_unref(bitmap); | |
78 | |
79 gtk_widget_show_all(pix); | |
80 | |
81 return win; | |
82 } | |
83 | |
84 static void | |
85 get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2) | |
86 { | |
87 gint ox, oy, width, height; | |
88 | |
89 if (w->parent && w->parent->window == w->window) | |
90 { | |
91 get_widget_coords(w->parent, &ox, &oy, NULL, NULL); | |
92 ox += w->allocation.x; | |
93 oy += w->allocation.y; | |
94 height = w->allocation.height; | |
95 width = w->allocation.width; | |
96 } | |
97 else | |
98 { | |
99 gdk_window_get_origin(w->window, &ox, &oy); | |
100 gdk_window_get_size(w->window, &width, &height); | |
101 } | |
102 | |
103 if (x1) *x1 = ox; | |
104 if (y1) *y1 = oy; | |
105 if (x2) *x2 = ox + width; | |
106 if (y2) *y2 = oy + height; | |
107 } | |
108 | |
109 static void | |
110 dnd_hints_init(void) | |
111 { | |
112 static gboolean done = FALSE; | |
113 gint i; | |
114 | |
115 if (done) | |
116 return; | |
117 | |
118 done = TRUE; | |
119 | |
120 for (i = 0; hint_windows[i].filename != NULL; i++) { | |
121 gchar *fname; | |
122 | |
123 fname = g_build_filename(DATADIR, "pixmaps", "gaim", | |
124 hint_windows[i].filename, NULL); | |
125 | |
126 hint_windows[i].widget = dnd_hints_init_window(fname); | |
127 | |
128 g_free(fname); | |
129 } | |
130 } | |
131 | |
132 void | |
133 dnd_hints_hide_all(void) | |
134 { | |
135 gint i; | |
136 | |
137 for (i = 0; hint_windows[i].filename != NULL; i++) | |
138 dnd_hints_hide(i); | |
139 } | |
140 | |
141 void | |
142 dnd_hints_hide(DndHintWindowId i) | |
143 { | |
144 GtkWidget *w = hint_windows[i].widget; | |
145 | |
146 if (w && GTK_IS_WIDGET(w)) | |
147 gtk_widget_hide(w); | |
148 } | |
149 | |
150 void | |
151 dnd_hints_show(DndHintWindowId id, gint x, gint y) | |
152 { | |
153 GtkWidget *w; | |
154 | |
155 dnd_hints_init(); | |
156 | |
157 w = hint_windows[id].widget; | |
158 | |
159 if (w && GTK_IS_WIDGET(w)) | |
160 { | |
161 gtk_widget_set_uposition(w, hint_windows[id].ox + x, | |
162 hint_windows[id].oy + y); | |
163 gtk_widget_show(w); | |
164 } | |
165 } | |
166 | |
167 void | |
168 dnd_hints_show_relative(DndHintWindowId id, GtkWidget *widget, | |
169 DndHintPosition horiz, DndHintPosition vert) | |
170 { | |
171 gint x1, x2, y1, y2; | |
172 gint x = 0, y = 0; | |
173 | |
174 get_widget_coords(widget, &x1, &y1, &x2, &y2); | |
175 | |
176 switch (horiz) | |
177 { | |
178 case HINT_POSITION_RIGHT: x = x2; break; | |
179 case HINT_POSITION_LEFT: x = x1; break; | |
180 case HINT_POSITION_CENTER: x = (x1 + x2) / 2; break; | |
181 default: | |
182 /* should not happen */ | |
183 g_warning("Invalid parameter to dnd_hints_show_relative"); | |
184 break; | |
185 } | |
186 | |
187 switch (vert) | |
188 { | |
189 case HINT_POSITION_TOP: y = y1; break; | |
190 case HINT_POSITION_BOTTOM: y = y2; break; | |
191 case HINT_POSITION_CENTER: y = (y1 + y2) / 2; break; | |
192 default: | |
193 /* should not happen */ | |
194 g_warning("Invalid parameter to dnd_hints_show_relative"); | |
195 break; | |
196 } | |
197 | |
198 dnd_hints_show(id, x, y); | |
199 } | |
200 |