annotate src/gtkdnd-hints.c @ 11425:54fa445aff32

[gaim-migrate @ 13662] most stupid bug ever. thanks to datallah for noticing committer: Tailor Script <tailor@pidgin.im>
author Thomas Butter <tbutter>
date Fri, 02 Sep 2005 18:05:40 +0000
parents 6240d7fd5b2c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10298
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /*
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * @file gtkdnd-hints.c GTK+ Drag-and-Drop arrow hints
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 * @ingroup gtkui
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
4 *
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 * gaim
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 *
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * source distribution.
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 *
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2, or(at your option)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * any later version.
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 *
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 *
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 */
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26 #include "gtkdnd-hints.h"
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28 #include <gtk/gtk.h>
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29 #include <gdk/gdk.h>
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30 #include <gdk-pixbuf/gdk-pixbuf.h>
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
31
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32 #ifdef _WIN32
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33 #include "win32dep.h"
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
34 #endif
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36 typedef struct
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
37 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38 GtkWidget *widget;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
39 gchar *filename;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
40 gint ox;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
41 gint oy;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
42
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
43 } HintWindowInfo;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
44
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
45 /**
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
46 * Info about each hint widget. See DndHintWindowId enum.
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
47 */
10871
6240d7fd5b2c [gaim-migrate @ 12558]
Mark Doliner <mark@kingant.net>
parents: 10298
diff changeset
48 static HintWindowInfo hint_windows[] = {
10298
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
49 { NULL, "tb_drag_arrow_up.xpm", -13/2, 0 },
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
50 { NULL, "tb_drag_arrow_down.xpm", -13/2, -16 },
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
51 { NULL, "tb_drag_arrow_left.xpm", 0, -13/2 },
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
52 { NULL, "tb_drag_arrow_right.xpm", -16, -13/2 },
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
53 { NULL, NULL, 0, 0 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
54 };
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
55
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
56 static GtkWidget *
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
57 dnd_hints_init_window(const gchar *fname)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
58 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
59 GdkPixbuf *pixbuf;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
60 GdkPixmap *pixmap;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
61 GdkBitmap *bitmap;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
62 GtkWidget *pix;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
63 GtkWidget *win;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
64
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
65 pixbuf = gdk_pixbuf_new_from_file(fname, NULL);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
66 g_return_val_if_fail(pixbuf, NULL);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
68 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &bitmap, 128);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
69 g_object_unref(G_OBJECT(pixbuf));
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
70
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
71 gtk_widget_push_colormap(gdk_rgb_get_colormap());
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
72 win = gtk_window_new(GTK_WINDOW_POPUP);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
73 pix = gtk_image_new_from_pixmap(pixmap, bitmap);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
74 gtk_container_add(GTK_CONTAINER(win), pix);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
75 gtk_widget_shape_combine_mask(win, bitmap, 0, 0);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76 gtk_widget_pop_colormap();
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
77
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78 g_object_unref(G_OBJECT(pixmap));
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79 g_object_unref(G_OBJECT(bitmap));
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
81 gtk_widget_show_all(pix);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
82
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
83 return win;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
84 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
86 static void
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
87 get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
88 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89 gint ox, oy, width, height;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
90
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 if (w->parent && w->parent->window == w->window)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
93 get_widget_coords(w->parent, &ox, &oy, NULL, NULL);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
94 ox += w->allocation.x;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95 oy += w->allocation.y;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96 height = w->allocation.height;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97 width = w->allocation.width;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
98 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99 else
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101 gdk_window_get_origin(w->window, &ox, &oy);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102 gdk_drawable_get_size(w->window, &width, &height);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 if (x1) *x1 = ox;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 if (y1) *y1 = oy;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 if (x2) *x2 = ox + width;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108 if (y2) *y2 = oy + height;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111 static void
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112 dnd_hints_init(void)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114 static gboolean done = FALSE;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 gint i;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 if (done)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 return;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120 done = TRUE;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122 for (i = 0; hint_windows[i].filename != NULL; i++) {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123 gchar *fname;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
125 fname = g_build_filename(DATADIR, "pixmaps", "gaim",
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
126 hint_windows[i].filename, NULL);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128 hint_windows[i].widget = dnd_hints_init_window(fname);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
130 g_free(fname);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
131 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
132 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
133
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134 void
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 dnd_hints_hide_all(void)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
136 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
137 gint i;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
138
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
139 for (i = 0; hint_windows[i].filename != NULL; i++)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
140 dnd_hints_hide(i);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
142
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143 void
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
144 dnd_hints_hide(DndHintWindowId i)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 GtkWidget *w = hint_windows[i].widget;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
147
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148 if (w && GTK_IS_WIDGET(w))
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
149 gtk_widget_hide(w);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
150 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
151
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
152 void
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
153 dnd_hints_show(DndHintWindowId id, gint x, gint y)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
154 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
155 GtkWidget *w;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
156
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
157 dnd_hints_init();
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
158
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159 w = hint_windows[id].widget;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
160
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
161 if (w && GTK_IS_WIDGET(w))
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 gtk_window_move(GTK_WINDOW(w), hint_windows[id].ox + x,
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164 hint_windows[id].oy + y);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 gtk_widget_show(w);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 void
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170 dnd_hints_show_relative(DndHintWindowId id, GtkWidget *widget,
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 DndHintPosition horiz, DndHintPosition vert)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173 gint x1, x2, y1, y2;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 gint x = 0, y = 0;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 get_widget_coords(widget, &x1, &y1, &x2, &y2);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 switch (horiz)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
180 case HINT_POSITION_RIGHT: x = x2; break;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
181 case HINT_POSITION_LEFT: x = x1; break;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182 case HINT_POSITION_CENTER: x = (x1 + x2) / 2; break;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183 default:
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
184 /* should not happen */
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
185 g_warning("Invalid parameter to dnd_hints_show_relative");
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
186 break;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
187 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
188
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
189 switch (vert)
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
190 {
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
191 case HINT_POSITION_TOP: y = y1; break;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
192 case HINT_POSITION_BOTTOM: y = y2; break;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
193 case HINT_POSITION_CENTER: y = (y1 + y2) / 2; break;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
194 default:
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
195 /* should not happen */
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
196 g_warning("Invalid parameter to dnd_hints_show_relative");
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197 break;
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
198 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
199
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
200 dnd_hints_show(id, x, y);
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201 }
02b95a0b88e2 [gaim-migrate @ 11481]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
202