28 #include <glib/gi18n.h>
39 return ((1 / (2 * M_PI * r)) *
40 exp ((- (x * x + y * y)) / (2 * r * r)));
51 filter->
size = radius * 2 + 1;
52 filter->
data = g_new (
double, filter->
size * filter->
size);
56 for (y = 0 ; y < filter->
size; y++)
58 for (x = 0 ; x < filter->
size; x++)
61 y - (filter->
size >> 1),
66 for (y = 0; y < filter->
size; y++)
68 for (x = 0; x < filter->
size; x++)
70 filter->
data[y * filter->
size + x] /= sum;
80 int x_offset,
int y_offset,
double opacity)
86 int src_rowstride, dest_rowstride;
87 int src_bpp, dest_bpp;
89 guchar *src_pixels, *dest_pixels;
95 x_offset = (blur_radius * 4) / 5;
98 y_offset = (blur_radius * 4) / 5;
101 width = gdk_pixbuf_get_width (src) + blur_radius * 2 + x_offset;
102 height = gdk_pixbuf_get_height (src) + blur_radius * 2 + y_offset;
104 dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src),
TRUE,
105 gdk_pixbuf_get_bits_per_sample (src),
107 gdk_pixbuf_fill (dest, 0);
108 src_pixels = gdk_pixbuf_get_pixels (src);
109 src_rowstride = gdk_pixbuf_get_rowstride (src);
110 src_bpp = gdk_pixbuf_get_has_alpha (src) ? 4 : 3;
112 dest_pixels = gdk_pixbuf_get_pixels (dest);
113 dest_rowstride = gdk_pixbuf_get_rowstride (dest);
114 dest_bpp = gdk_pixbuf_get_has_alpha (dest) ? 4 : 3;
116 for (y = 0; y < height; y++)
118 for (x = 0; x < width; x++)
120 int sumr = 0, sumg = 0, sumb = 0, suma = 0;
122 for (i = 0; i < filter->
size; i++)
124 for (j = 0; j < filter->
size; j++)
128 src_y = -(blur_radius + x_offset) + y - (filter->
size >> 1) + i;
129 src_x = -(blur_radius + y_offset) + x - (filter->
size >> 1) + j;
131 if (src_y < 0 || src_y > gdk_pixbuf_get_height (src) ||
132 src_x < 0 || src_x > gdk_pixbuf_get_width (src))
135 sumr += src_pixels [src_y * src_rowstride +
136 src_x * src_bpp + 0] *
137 filter->
data [i * filter->
size + j];
138 sumg += src_pixels [src_y * src_rowstride +
139 src_x * src_bpp + 1] *
140 filter->
data [i * filter->
size + j];
142 sumb += src_pixels [src_y * src_rowstride +
143 src_x * src_bpp + 2] *
144 filter->
data [i * filter->
size + j];
147 suma += src_pixels [src_y * src_rowstride +
148 src_x * src_bpp + 3] *
149 filter->
data [i * filter->
size + j];
157 dest_pixels [y * dest_rowstride +
158 x * dest_bpp + 3] = (suma * opacity) / (filter->
size * filter->
size);
168 int x_offset,
int y_offset,
double opacity)
172 dest =
create_shadow (src, size, x_offset, y_offset, opacity);
174 gdk_pixbuf_composite (src, dest,
176 gdk_pixbuf_get_width (src),
177 gdk_pixbuf_get_height (src),
180 GDK_INTERP_NEAREST, 255);
192 gint n_rectangles, i;
194 if (region == NULL) {
195 g_print (
"<empty region>\n");
199 g_print (
"<region %p>\n", region);
200 n_rectangles = cairo_region_num_rectangles (region);
201 for (i = 0; i < n_rectangles; i++) {
204 cairo_region_get_rectangle (region, i, &rect);
205 g_print (
"\t(%d %d, %d %d) [%dx%d]\n",
209 rect.y + rect.height,
221 GdkScreen *screen = gtk_widget_get_screen (widget);
223 GdkRectangle monitor;
226 g_return_if_fail (widget != NULL);
228 gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
230 monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
231 gtk_menu_set_monitor (menu, monitor_num);
232 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
234 *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
235 *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
245 GtkTreeSelection *selection;
246 GList *selected_rows;
248 GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
249 GtkWidget *widget = GTK_WIDGET (user_data);
251 GtkAllocation allocation;
252 GdkRectangle visible;
254 gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
255 gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
256 gtk_widget_get_allocation (widget, &allocation);
258 *x += (allocation.width - req.width) / 2;
261 gtk_tree_view_get_visible_rect (tree_view, &visible);
262 *y += allocation.height - visible.height;
264 selection = gtk_tree_view_get_selection (tree_view);
265 selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
268 GdkRectangle cell_rect;
270 gtk_tree_view_get_cell_area (tree_view, selected_rows->data,
273 *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height);
275 g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
276 g_list_free (selected_rows);
284 GtkFileFilter *supported_filter)
289 mime_types = gdk_pixbuf_format_get_mime_types (format);
290 for (i = 0; mime_types[i] != 0; i++) {
291 gtk_file_filter_add_mime_type (filter, mime_types[i]);
292 gtk_file_filter_add_mime_type (supported_filter, mime_types[i]);
294 g_strfreev (mime_types);
300 GSList *pixbuf_formats = NULL;
302 GtkFileFilter *filter, *supported_filter;
304 supported_filter = gtk_file_filter_new ();
305 gtk_file_filter_set_name (supported_filter,
_(
"Supported Image Files"));
306 gtk_file_chooser_add_filter (chooser, supported_filter);
308 filter = gtk_file_filter_new ();
309 gtk_file_filter_set_name (filter,
_(
"All Files"));
310 gtk_file_filter_add_pattern (filter,
"*");
311 gtk_file_chooser_add_filter (chooser, filter);
313 pixbuf_formats = gdk_pixbuf_get_formats ();
315 for (iter = pixbuf_formats; iter; iter = iter->next) {
316 GdkPixbufFormat *format = iter->data;
319 if (gdk_pixbuf_format_is_disabled (format) ||
320 !gdk_pixbuf_format_is_writable (format))
323 filter = gtk_file_filter_new ();
324 name = gdk_pixbuf_format_get_description (format);
325 gtk_file_filter_set_name (filter, name);
328 g_object_set_data (G_OBJECT(filter),
"pixbuf-format", format);
329 gtk_file_chooser_add_filter (chooser, filter);
332 g_slist_free (pixbuf_formats);
338 GSList *pixbuf_formats = NULL;
342 pixbuf_formats = gdk_pixbuf_get_formats ();
344 for (iter = pixbuf_formats; iter; iter = iter->next) {
345 gchar **extension_list;
346 GdkPixbufFormat *format = iter->data;
348 if (gdk_pixbuf_format_is_disabled (format) ||
349 !gdk_pixbuf_format_is_writable (format))
352 extension_list = gdk_pixbuf_format_get_extensions (format);
354 for (i = 0; extension_list[i] != 0; i++) {
355 if (g_str_has_suffix (uri, extension_list[i])) {
356 g_slist_free (pixbuf_formats);
357 g_strfreev (extension_list);
361 g_strfreev (extension_list);
364 g_slist_free (pixbuf_formats);