comparison pidgin/gtkdnd-hints.c @ 32672:3828a61c44da

A boring and large patch so I can merge heads.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 23 Dec 2011 08:21:58 +0000
parents a3bd979c9ce4
children
comparison
equal deleted inserted replaced
32671:0e69949b3e61 32672:3828a61c44da
55 }; 55 };
56 56
57 static GtkWidget * 57 static GtkWidget *
58 dnd_hints_init_window(const gchar *fname) 58 dnd_hints_init_window(const gchar *fname)
59 { 59 {
60 /* TODO: this is likely very broken right now, I think this needs to be
61 Cairo-ified */
62 GdkPixbuf *pixbuf; 60 GdkPixbuf *pixbuf;
63 /*GdkPixmap *pixmap;*/ 61 GdkPixmap *pixmap;
64 /*GdkBitmap *bitmap;*/ 62 GdkBitmap *bitmap;
65 GtkWidget *pix; 63 GtkWidget *pix;
66 GtkWidget *win; 64 GtkWidget *win;
65 GdkColormap *colormap;
67 66
68 pixbuf = gdk_pixbuf_new_from_file(fname, NULL); 67 pixbuf = gdk_pixbuf_new_from_file(fname, NULL);
69 g_return_val_if_fail(pixbuf, NULL); 68 g_return_val_if_fail(pixbuf, NULL);
70 69
71 /* 70 win = gtk_window_new(GTK_WINDOW_POPUP);
72 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &bitmap, 128); 71 colormap = gtk_widget_get_colormap(win);
72 gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, colormap,
73 &pixmap, &bitmap, 128);
73 g_object_unref(G_OBJECT(pixbuf)); 74 g_object_unref(G_OBJECT(pixbuf));
74 */ 75
75 76 pix = gtk_image_new_from_pixmap(pixmap, bitmap);
76 /*gtk_widget_push_colormap(gdk_rgb_get_colormap());*/
77 win = gtk_window_new(GTK_WINDOW_POPUP);
78 pix = gtk_image_new_from_pixbuf(pixbuf);
79 gtk_container_add(GTK_CONTAINER(win), pix); 77 gtk_container_add(GTK_CONTAINER(win), pix);
80 /*gtk_widget_shape_combine_mask(win, bitmap, 0, 0); 78 gtk_widget_shape_combine_mask(win, bitmap, 0, 0);
81 gtk_widget_pop_colormap();*/ 79
82
83 /*
84 g_object_unref(G_OBJECT(pixmap)); 80 g_object_unref(G_OBJECT(pixmap));
85 g_object_unref(G_OBJECT(bitmap)); 81 g_object_unref(G_OBJECT(bitmap));
86 */ 82
87
88 gtk_widget_show_all(pix); 83 gtk_widget_show_all(pix);
89 84
90 return win; 85 return win;
91 } 86 }
92 87
93 static void 88 static void
94 get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2) 89 get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2)
95 { 90 {
96 gint ox, oy, width, height; 91 gint ox, oy, width, height;
97 GtkWidget *parent = gtk_widget_get_parent(w); 92
98 93 if (w->parent && w->parent->window == w->window)
99 if (parent && gtk_widget_get_window(parent) == gtk_widget_get_window(w)) 94 {
100 { 95 get_widget_coords(w->parent, &ox, &oy, NULL, NULL);
101 GtkAllocation allocation; 96 height = w->allocation.height;
102 97 width = w->allocation.width;
103 gtk_widget_get_allocation(w, &allocation);
104 get_widget_coords(parent, &ox, &oy, NULL, NULL);
105 height = allocation.height;
106 width = allocation.width;
107 } 98 }
108 else 99 else
109 { 100 {
110 gdk_window_get_origin(gtk_widget_get_window(w), &ox, &oy); 101 gdk_window_get_origin(w->window, &ox, &oy);
111 width = gdk_window_get_width(gtk_widget_get_window(w)); 102 gdk_drawable_get_size(w->window, &width, &height);
112 height = gdk_window_get_height(gtk_widget_get_window(w));
113 } 103 }
114 104
115 if (x1) *x1 = ox; 105 if (x1) *x1 = ox;
116 if (y1) *y1 = oy; 106 if (y1) *y1 = oy;
117 if (x2) *x2 = ox + width; 107 if (x2) *x2 = ox + width;
180 dnd_hints_show_relative(DndHintWindowId id, GtkWidget *widget, 170 dnd_hints_show_relative(DndHintWindowId id, GtkWidget *widget,
181 DndHintPosition horiz, DndHintPosition vert) 171 DndHintPosition horiz, DndHintPosition vert)
182 { 172 {
183 gint x1, x2, y1, y2; 173 gint x1, x2, y1, y2;
184 gint x = 0, y = 0; 174 gint x = 0, y = 0;
185 GtkAllocation allocation;
186
187 gtk_widget_get_allocation(widget, &allocation);
188 175
189 get_widget_coords(widget, &x1, &y1, &x2, &y2); 176 get_widget_coords(widget, &x1, &y1, &x2, &y2);
190 x1 += allocation.x; x2 += allocation.x; 177 x1 += widget->allocation.x; x2 += widget->allocation.x;
191 y1 += allocation.y; y2 += allocation.y; 178 y1 += widget->allocation.y; y2 += widget->allocation.y;
192 179
193 switch (horiz) 180 switch (horiz)
194 { 181 {
195 case HINT_POSITION_RIGHT: x = x2; break; 182 case HINT_POSITION_RIGHT: x = x2; break;
196 case HINT_POSITION_LEFT: x = x1; break; 183 case HINT_POSITION_LEFT: x = x1; break;