Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-utils.h File Reference
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
+ Include dependency graph for ev-utils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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)
 
void file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser)
 
GdkPixbufFormat * get_gdk_pixbuf_format_by_extension (const gchar *uri)
 

Function Documentation

void ev_gui_menu_position_tree_selection ( GtkMenu *  menu,
gint *  x,
gint *  y,
gboolean *  push_in,
gpointer  user_data 
)

Definition at line 239 of file ev-utils.c.

244 {
245  GtkTreeSelection *selection;
246  GList *selected_rows;
247  GtkTreeModel *model;
248  GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
249  GtkWidget *widget = GTK_WIDGET (user_data);
250  GtkRequisition req;
251  GtkAllocation allocation;
252  GdkRectangle visible;
253 
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);
257 
258  *x += (allocation.width - req.width) / 2;
259 
260  /* Add on height for the treeview title */
261  gtk_tree_view_get_visible_rect (tree_view, &visible);
262  *y += allocation.height - visible.height;
263 
264  selection = gtk_tree_view_get_selection (tree_view);
265  selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
266  if (selected_rows)
267  {
268  GdkRectangle cell_rect;
269 
270  gtk_tree_view_get_cell_area (tree_view, selected_rows->data,
271  NULL, &cell_rect);
272 
273  *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height);
274 
275  g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
276  g_list_free (selected_rows);
277  }
278 
279  ev_gui_sanitise_popup_position (menu, widget, x, y);
280 }

+ Here is the caller graph for this function:

G_BEGIN_DECLS GdkPixbuf* ev_pixbuf_add_shadow ( GdkPixbuf *  src,
int  size,
int  x_offset,
int  y_offset,
double  opacity 
)

Definition at line 167 of file ev-utils.c.

169 {
170  GdkPixbuf *dest;
171 
172  dest = create_shadow (src, size, x_offset, y_offset, opacity);
173 
174  gdk_pixbuf_composite (src, dest,
175  size, size,
176  gdk_pixbuf_get_width (src),
177  gdk_pixbuf_get_height (src),
178  size, size,
179  1.0, 1.0,
180  GDK_INTERP_NEAREST, 255);
181 
182  return dest;
183 }
void ev_print_region_contents ( cairo_region_t *  region)

Definition at line 190 of file ev-utils.c.

191 {
192  gint n_rectangles, i;
193 
194  if (region == NULL) {
195  g_print ("<empty region>\n");
196  return;
197  }
198 
199  g_print ("<region %p>\n", region);
200  n_rectangles = cairo_region_num_rectangles (region);
201  for (i = 0; i < n_rectangles; i++) {
202  GdkRectangle rect;
203 
204  cairo_region_get_rectangle (region, i, &rect);
205  g_print ("\t(%d %d, %d %d) [%dx%d]\n",
206  rect.x,
207  rect.y,
208  rect.x + rect.width,
209  rect.y + rect.height,
210  rect.width,
211  rect.height);
212  }
213 }
void file_chooser_dialog_add_writable_pixbuf_formats ( GtkFileChooser *  chooser)

Definition at line 298 of file ev-utils.c.

299 {
300  GSList *pixbuf_formats = NULL;
301  GSList *iter;
302  GtkFileFilter *filter, *supported_filter;
303 
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);
307 
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);
312 
313  pixbuf_formats = gdk_pixbuf_get_formats ();
314 
315  for (iter = pixbuf_formats; iter; iter = iter->next) {
316  GdkPixbufFormat *format = iter->data;
317  gchar *name;
318 
319  if (gdk_pixbuf_format_is_disabled (format) ||
320  !gdk_pixbuf_format_is_writable (format))
321  continue;
322 
323  filter = gtk_file_filter_new ();
324  name = gdk_pixbuf_format_get_description (format);
325  gtk_file_filter_set_name (filter, name);
326 
327  file_filter_add_mime_types (format, filter, supported_filter);
328  g_object_set_data (G_OBJECT(filter), "pixbuf-format", format);
329  gtk_file_chooser_add_filter (chooser, filter);
330  }
331 
332  g_slist_free (pixbuf_formats);
333 }

+ Here is the caller graph for this function:

GdkPixbufFormat* get_gdk_pixbuf_format_by_extension ( const gchar *  uri)

Definition at line 336 of file ev-utils.c.

337 {
338  GSList *pixbuf_formats = NULL;
339  GSList *iter;
340  int i;
341 
342  pixbuf_formats = gdk_pixbuf_get_formats ();
343 
344  for (iter = pixbuf_formats; iter; iter = iter->next) {
345  gchar **extension_list;
346  GdkPixbufFormat *format = iter->data;
347 
348  if (gdk_pixbuf_format_is_disabled (format) ||
349  !gdk_pixbuf_format_is_writable (format))
350  continue;
351 
352  extension_list = gdk_pixbuf_format_get_extensions (format);
353 
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);
358  return format;
359  }
360  }
361  g_strfreev (extension_list);
362  }
363 
364  g_slist_free (pixbuf_formats);
365  return NULL;
366 }

+ Here is the caller graph for this function: