#include <gtk/gtkselection.h>
#include <gtk/gtkclipboard.h>
#include <gdk/gdkkeysyms.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include "ev-marshal.h"
#include "ev-view.h"
enum {
SIGNAL_BINDING_ACTIVATED,
SIGNAL_ZOOM_INVALID,
+ SIGNAL_HANDLE_LINK,
SIGNAL_EXTERNAL_LINK,
SIGNAL_POPUP_MENU,
N_SIGNALS,
view->current_page);
}
-void
+static void
ev_view_goto_dest (EvView *view, EvLinkDest *dest)
{
EvLinkDestType type;
action = ev_link_get_action (link);
if (!action)
return;
-
+
type = ev_link_action_get_action_type (action);
switch (type) {
case EV_LINK_ACTION_TYPE_GOTO_DEST: {
EvLinkDest *dest;
+ g_signal_emit (view, signals[SIGNAL_HANDLE_LINK], 0, link);
+
dest = ev_link_action_get_dest (action);
ev_view_goto_dest (view, dest);
}
}
}
-static gchar *
-page_label_from_dest (EvView *view, EvLinkDest *dest)
+gchar *
+ev_view_page_label_from_dest (EvView *view, EvLinkDest *dest)
{
EvLinkDestType type;
gchar *msg = NULL;
}
break;
+ case EV_LINK_DEST_TYPE_PAGE_LABEL: {
+ msg = g_strdup (ev_link_dest_get_page_label (dest));
+ }
+ break;
default:
msg = ev_page_cache_get_page_label (view->page_cache,
ev_link_dest_get_page (dest));
switch (type) {
case EV_LINK_ACTION_TYPE_GOTO_DEST:
- page_label = page_label_from_dest (view,
- ev_link_action_get_dest (action));
+ page_label = ev_view_page_label_from_dest (view,
+ ev_link_action_get_dest (action));
msg = g_strdup_printf (_("Go to page %s"), page_label);
g_free (page_label);
break;
default:
break;
}
- }
-
- if (view->loading) {
+ } else if (view->loading) {
GdkRectangle area = {0};
area.width = widget->allocation.width;
area.height = widget->allocation.height;
-
+
draw_loading_text (view,
&area,
&(event->area));
GdkEventButton *event)
{
EvView *view = EV_VIEW (widget);
+
+ if (!view->document)
+ return FALSE;
if (!GTK_WIDGET_HAS_FOCUS (widget)) {
gtk_widget_grab_focus (widget);
}
gtk_widget_queue_draw (widget);
- } else if ((image = ev_view_get_image_at_location (view, event->x, event->y))) {
+ } else if (!location_in_text (view, event->x + view->scroll_x, event->y + view->scroll_y) &&
+ (image = ev_view_get_image_at_location (view, event->x, event->y))) {
if (view->image_dnd_info.image)
g_object_unref (view->image_dnd_info.image);
view->image_dnd_info.image = g_object_ref (image);
ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL);
}
- if (view->document && view->pressed_button == 1) {
+ if (view->document && view->pressed_button != 3) {
link = ev_view_get_link_at_location (view, event->x, event->y);
} else {
link = NULL;
view->selection_info.in_drag = FALSE;
} else if (link) {
- ev_view_handle_link (view, link);
+ if (event->button == 2) {
+ EvLinkAction *action;
+ EvLinkActionType type;
+
+ action = ev_link_get_action (link);
+ if (!action)
+ return FALSE;
+
+ type = ev_link_action_get_action_type (action);
+ if (type == EV_LINK_ACTION_TYPE_GOTO_DEST) {
+ g_signal_emit (view,
+ signals[SIGNAL_EXTERNAL_LINK],
+ 0, action);
+ }
+ } else {
+ ev_view_handle_link (view, link);
+ }
} else if (view->presentation) {
switch (event->button) {
case 1:
EvView *view = EV_VIEW (widget);
EvPresentationState current;
+ if (!view->document)
+ return FALSE;
+
if (!view->presentation ||
view->presentation_state == EV_PRESENTATION_END)
return gtk_bindings_activate_event (GTK_OBJECT (widget), event);
GdkRectangle *page_area,
GdkRectangle *expose_area)
{
- const char *loading_text;
- PangoLayout *layout;
- PangoFontDescription *font_desc;
- PangoRectangle logical_rect;
- double real_scale;
- int target_width;
-
+ cairo_t *cr;
+ gint width, height;
+
/* Don't annoy users with loading messages during presentations.
* FIXME: Temporary "workaround" for
* http://bugzilla.gnome.org/show_bug.cgi?id=320352 */
if (view->presentation)
return;
- loading_text = _("Loading...");
-
- ev_document_fc_mutex_lock ();
-
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (view), loading_text);
-
- font_desc = pango_font_description_new ();
-
-
- /* We set the font to be 10 points, get the size, and scale appropriately */
- pango_font_description_set_size (font_desc, 10 * PANGO_SCALE);
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
-
- /* Make sure we fit the middle of the page */
- target_width = MAX (page_area->width / 2, 1);
- real_scale = ((double)target_width / (double) logical_rect.width) * (PANGO_SCALE * 10);
- pango_font_description_set_size (font_desc, (int)real_scale);
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
-
- gtk_paint_layout (GTK_WIDGET (view)->style,
- GTK_WIDGET (view)->window,
- GTK_WIDGET_STATE (view),
- FALSE,
- page_area,
- GTK_WIDGET (view),
- NULL,
- page_area->x + (target_width/2),
- page_area->y + (page_area->height - logical_rect.height) / 2,
- layout);
+ if (!view->loading_text) {
+ const gchar *loading_text;
+ PangoLayout *layout;
+ PangoFontDescription *font_desc;
+ PangoRectangle logical_rect;
+ gdouble real_scale;
+ gint target_width;
+
+ loading_text = _("Loading...");
- pango_font_description_free (font_desc);
- g_object_unref (layout);
+ ev_document_fc_mutex_lock ();
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (view), loading_text);
+
+ font_desc = pango_font_description_new ();
+
+ /* We set the font to be 10 points, get the size, and scale appropriately */
+ pango_font_description_set_size (font_desc, 10 * PANGO_SCALE);
+ pango_layout_set_font_description (layout, font_desc);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+
+ /* Make sure we fit the middle of the page */
+ target_width = MAX (page_area->width / 2, 1);
+ real_scale = ((double)target_width / (double) logical_rect.width) * (PANGO_SCALE * 10);
+ pango_font_description_set_size (font_desc, (int)real_scale);
+ pango_layout_set_font_description (layout, font_desc);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+
+ view->loading_text = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ logical_rect.width,
+ logical_rect.height);
+ cr = cairo_create (view->loading_text);
+ cairo_set_source_rgb (cr,
+ 155 / (double)255,
+ 155 / (double)255,
+ 155 / (double)255);
+ pango_cairo_show_layout (cr, layout);
+ cairo_destroy (cr);
+
+ pango_font_description_free (font_desc);
+ g_object_unref (layout);
+
+ ev_document_fc_mutex_unlock ();
+ }
- ev_document_fc_mutex_unlock ();
+ width = cairo_image_surface_get_width (view->loading_text) / 2;
+ height = (page_area->height - cairo_image_surface_get_height (view->loading_text)) / 2;
+
+ cr = gdk_cairo_create (GTK_WIDGET (view)->window);
+ cairo_set_source_surface (cr, view->loading_text,
+ page_area->x + width,
+ page_area->y + height);
+ cairo_paint (cr);
+ cairo_destroy (cr);
}
static void
real_page_area.height -= (border->top + border->bottom);
*page_ready = TRUE;
- ev_document_misc_paint_one_page (GTK_WIDGET(view)->window,
- GTK_WIDGET (view),
- page_area, border,
- page == current_page);
+ if (!view->presentation) {
+ ev_document_misc_paint_one_page (GTK_WIDGET(view)->window,
+ GTK_WIDGET (view),
+ page_area, border,
+ page == current_page);
+ }
if (gdk_rectangle_intersect (&real_page_area, expose_area, &overlap)) {
GdkPixbuf *selection_pixbuf = NULL;
view->selection_update_id = 0;
}
+ if (view->loading_text) {
+ cairo_surface_destroy (view->loading_text);
+ view->loading_text = NULL;
+ }
+
ev_view_presentation_transition_stop (view);
ev_view_set_scroll_adjustments (view, NULL, NULL);
NULL, NULL,
ev_marshal_VOID__VOID,
G_TYPE_NONE, 0, G_TYPE_NONE);
+ signals[SIGNAL_HANDLE_LINK] = g_signal_new ("handle-link",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EvViewClass, handle_link),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ G_TYPE_OBJECT);
signals[SIGNAL_EXTERNAL_LINK] = g_signal_new ("external-link",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
if (ABS (view->scale - scale) < EPSILON)
return;
+ if (view->loading_text) {
+ cairo_surface_destroy (view->loading_text);
+ view->loading_text = NULL;
+ }
+
view->scale = scale;
view->pending_resize = TRUE;
{
g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
+ if (view->presentation)
+ return;
+
view->pending_scroll = SCROLL_TO_CENTER;
ev_view_set_zoom (view, ZOOM_IN_FACTOR, TRUE);
}
{
g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
+ if (view->presentation)
+ return;
+
view->pending_scroll = SCROLL_TO_CENTER;
ev_view_set_zoom (view, ZOOM_OUT_FACTOR, TRUE);
}
{
GString *text;
GList *l;
+ gchar *normalized_text;
text = g_string_new (NULL);
ev_document_doc_mutex_unlock ();
- return g_string_free (text, FALSE);
+ normalized_text = g_utf8_normalize (text->str, text->len, G_NORMALIZE_NFKC);
+ g_string_free (text, TRUE);
+ return normalized_text;
}
void