diff options
author | monsta <[email protected]> | 2017-04-13 13:51:20 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2017-04-13 13:51:20 +0300 |
commit | c5fb1fc9098e0f5a50f4cc1a8599c1d1809f116b (patch) | |
tree | c34881e2f7ecad5bb0bd49cb7a585d5d75815290 | |
parent | b8b8f3e1541e8492f747d31e0a96fe4076484874 (diff) | |
download | atril-c5fb1fc9098e0f5a50f4cc1a8599c1d1809f116b.tar.bz2 atril-c5fb1fc9098e0f5a50f4cc1a8599c1d1809f116b.tar.xz |
shell: remove unused code from utils
-rw-r--r-- | help/reference/shell/atril-sections.txt | 4 | ||||
-rw-r--r-- | shell/ev-utils.c | 213 | ||||
-rw-r--r-- | shell/ev-utils.h | 7 |
3 files changed, 0 insertions, 224 deletions
diff --git a/help/reference/shell/atril-sections.txt b/help/reference/shell/atril-sections.txt index 3bda389e..dec42bc1 100644 --- a/help/reference/shell/atril-sections.txt +++ b/help/reference/shell/atril-sections.txt @@ -447,11 +447,7 @@ ev_keyring_save_password <SECTION> <FILE>ev-utils</FILE> -ev_pixbuf_add_shadow -ev_print_region_contents ev_gui_menu_position_tree_selection -get_num_monitors -get_screen_dpi file_chooser_dialog_add_writable_pixbuf_formats get_gdk_pixbuf_format_by_extension </SECTION> diff --git a/shell/ev-utils.c b/shell/ev-utils.c index 8c9bae55..8789ef88 100644 --- a/shell/ev-utils.c +++ b/shell/ev-utils.c @@ -24,194 +24,8 @@ #include "ev-file-helpers.h" #include <string.h> -#include <math.h> #include <glib/gi18n.h> -typedef struct -{ - int size; - double *data; -} ConvFilter; - -static double -gaussian (double x, double y, double r) -{ - return ((1 / (2 * M_PI * r)) * - exp ((- (x * x + y * y)) / (2 * r * r))); -} - -static ConvFilter * -create_blur_filter (int radius) -{ - ConvFilter *filter; - int x, y; - double sum; - - filter = g_new0 (ConvFilter, 1); - filter->size = radius * 2 + 1; - filter->data = g_new (double, filter->size * filter->size); - - sum = 0.0; - - for (y = 0 ; y < filter->size; y++) - { - for (x = 0 ; x < filter->size; x++) - { - sum += filter->data[y * filter->size + x] = gaussian (x - (filter->size >> 1), - y - (filter->size >> 1), - radius); - } - } - - for (y = 0; y < filter->size; y++) - { - for (x = 0; x < filter->size; x++) - { - filter->data[y * filter->size + x] /= sum; - } - } - - return filter; - -} - -static GdkPixbuf * -create_shadow (GdkPixbuf *src, int blur_radius, - int x_offset, int y_offset, double opacity) -{ - int x, y, i, j; - int width, height; - GdkPixbuf *dest; - static ConvFilter *filter = NULL; - int src_rowstride, dest_rowstride; - int src_bpp, dest_bpp; - - guchar *src_pixels, *dest_pixels; - - if (!filter) - filter = create_blur_filter (blur_radius); - - if (x_offset < 0) - x_offset = (blur_radius * 4) / 5; - - if (y_offset < 0) - y_offset = (blur_radius * 4) / 5; - - - width = gdk_pixbuf_get_width (src) + blur_radius * 2 + x_offset; - height = gdk_pixbuf_get_height (src) + blur_radius * 2 + y_offset; - - dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), TRUE, - gdk_pixbuf_get_bits_per_sample (src), - width, height); - gdk_pixbuf_fill (dest, 0); - src_pixels = gdk_pixbuf_get_pixels (src); - src_rowstride = gdk_pixbuf_get_rowstride (src); - src_bpp = gdk_pixbuf_get_has_alpha (src) ? 4 : 3; - - dest_pixels = gdk_pixbuf_get_pixels (dest); - dest_rowstride = gdk_pixbuf_get_rowstride (dest); - dest_bpp = gdk_pixbuf_get_has_alpha (dest) ? 4 : 3; - - for (y = 0; y < height; y++) - { - for (x = 0; x < width; x++) - { - int sumr = 0, sumg = 0, sumb = 0, suma = 0; - - for (i = 0; i < filter->size; i++) - { - for (j = 0; j < filter->size; j++) - { - int src_x, src_y; - - src_y = -(blur_radius + x_offset) + y - (filter->size >> 1) + i; - src_x = -(blur_radius + y_offset) + x - (filter->size >> 1) + j; - - if (src_y < 0 || src_y > gdk_pixbuf_get_height (src) || - src_x < 0 || src_x > gdk_pixbuf_get_width (src)) - continue; - - sumr += src_pixels [src_y * src_rowstride + - src_x * src_bpp + 0] * - filter->data [i * filter->size + j]; - sumg += src_pixels [src_y * src_rowstride + - src_x * src_bpp + 1] * - filter->data [i * filter->size + j]; - - sumb += src_pixels [src_y * src_rowstride + - src_x * src_bpp + 2] * - filter->data [i * filter->size + j]; - - if (src_bpp == 4) - suma += src_pixels [src_y * src_rowstride + - src_x * src_bpp + 3] * - filter->data [i * filter->size + j]; - else - suma += 0xff; - - } - } - - if (dest_bpp == 4) - dest_pixels [y * dest_rowstride + - x * dest_bpp + 3] = (suma * opacity) / (filter->size * filter->size); - - } - } - - return dest; -} - -GdkPixbuf * -ev_pixbuf_add_shadow (GdkPixbuf *src, int size, - int x_offset, int y_offset, double opacity) -{ - GdkPixbuf *dest; - - dest = create_shadow (src, size, x_offset, y_offset, opacity); - - gdk_pixbuf_composite (src, dest, - size, size, - gdk_pixbuf_get_width (src), - gdk_pixbuf_get_height (src), - size, size, - 1.0, 1.0, - GDK_INTERP_NEAREST, 255); - - return dest; -} - - -/* Simple function to output the contents of a region. Used solely for testing - * the region code. - */ -void -ev_print_region_contents (cairo_region_t *region) -{ - gint n_rectangles, i; - - if (region == NULL) { - g_print ("<empty region>\n"); - return; - } - - g_print ("<region %p>\n", region); - n_rectangles = cairo_region_num_rectangles (region); - for (i = 0; i < n_rectangles; i++) { - GdkRectangle rect; - - cairo_region_get_rectangle (region, i, &rect); - g_print ("\t(%d %d, %d %d) [%dx%d]\n", - rect.x, - rect.y, - rect.x + rect.width, - rect.y + rect.height, - rect.width, - rect.height); - } -} - static void ev_gui_sanitise_popup_position (GtkMenu *menu, GtkWidget *widget, @@ -279,33 +93,6 @@ ev_gui_menu_position_tree_selection (GtkMenu *menu, ev_gui_sanitise_popup_position (menu, widget, x, y); } -/** - * get_num_monitors: Get the number of user monitors. - * @window: optional GtkWindow to look at. - * - * Returns: Number of monitors, -1 if uncertain situation (like multiple screens) - */ -gint -get_num_monitors (GtkWindow *window) -{ - GdkDisplay *display; - GdkScreen *screen; - gint num_screen; - - display = gdk_display_get_default (); - num_screen = gdk_display_get_n_screens (display); - - if (num_screen != 1) - return -1; - - if (window) - screen = gtk_window_get_screen (window); - else - screen = gdk_display_get_screen (display, 0); - - return gdk_screen_get_n_monitors (screen); -} - void file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser) { diff --git a/shell/ev-utils.h b/shell/ev-utils.h index 81acc463..f37f5af6 100644 --- a/shell/ev-utils.h +++ b/shell/ev-utils.h @@ -26,19 +26,12 @@ G_BEGIN_DECLS -GdkPixbuf* ev_pixbuf_add_shadow (GdkPixbuf *src, int size, - int x_offset, int y_offset, double opacity); - -void ev_print_region_contents (cairo_region_t *region); - void ev_gui_menu_position_tree_selection (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data); -gint get_num_monitors (GtkWindow * window); - void file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser); GdkPixbufFormat* get_gdk_pixbuf_format_by_extension (gchar *uri); |