Merge lp:~ochosi/evince/show_titlebar into lp:ubuntu/vivid/evince
- show_titlebar
- Merge into vivid
Proposed by
Simon Steinbeiß
on 2015-02-20
| Status: | Rejected |
|---|---|
| Rejected by: | Sebastien Bacher on 2015-02-23 |
| Proposed branch: | lp:~ochosi/evince/show_titlebar |
| Merge into: | lp:ubuntu/vivid/evince |
| Diff against target: |
46851 lines (+28/-46681) 24 files modified
.pc/11_grip_gestures.patch/configure.ac (+0/-948) .pc/11_grip_gestures.patch/libview/ev-view-private.h (+0/-312) .pc/11_grip_gestures.patch/libview/ev-view.c (+0/-8917) .pc/11_grip_gestures.patch/libview/ev-view.h (+0/-139) .pc/11_grip_gestures.patch/shell/ev-application.c (+0/-1327) .pc/11_grip_gestures.patch/shell/ev-application.h (+0/-81) .pc/11_grip_gestures.patch/shell/ev-window.c (+0/-7292) .pc/11_grip_gestures.patch/shell/main.c (+0/-324) .pc/applied-patches (+0/-5) .pc/gnome_icon_theme.patch/configure.ac (+0/-960) .pc/gtk_no_gesture.patch/libview/ev-view-private.h (+0/-324) .pc/gtk_no_gesture.patch/libview/ev-view.c (+0/-9148) .pc/traditional_menu_bar.patch/shell/Makefile.am (+0/-198) .pc/traditional_menu_bar.patch/shell/ev-application.c (+0/-1344) .pc/traditional_menu_bar.patch/shell/ev-application.h (+0/-86) .pc/traditional_menu_bar.patch/shell/ev-toolbar.c (+0/-415) .pc/traditional_menu_bar.patch/shell/ev-window.c (+0/-7296) .pc/traditional_menu_bar.patch/shell/evince.gresource.xml (+0/-24) .pc/unity_normal_titlebar.patch/shell/ev-window-title.c (+0/-243) .pc/unity_normal_titlebar.patch/shell/ev-window.c (+0/-7297) debian/changelog (+6/-0) debian/patches/series (+1/-0) debian/patches/show_titlebar_maximized.patch (+21/-0) shell/ev-window.c (+0/-1) |
| To merge this branch: | bzr merge lp:~ochosi/evince/show_titlebar |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Ubuntu branches | 2015-02-20 | Pending | |
|
Review via email:
|
|||
Commit Message
Description of the Change
This commit adds a patch to resolve https:/
At the moment when maximizing Evince, its titlebar isn't shown anymore. This is not a problem for DEs that use CSD, but for those with traditional WM borders (like Xfce) it's not desirable.
To post a comment you must log in.
lp:~ochosi/evince/show_titlebar
updated
on 2015-02-20
- 208. By Simon Steinbeiß on 2015-02-20
-
Remove .pc dir
| Sebastien Bacher (seb128) wrote : | # |
Unmerged revisions
- 208. By Simon Steinbeiß on 2015-02-20
-
Remove .pc dir
- 207. By Simon Steinbeiß on 2015-02-20
-
Show the titlebar when the window is maximized
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === removed directory '.pc/11_grip_gestures.patch' |
| 2 | === removed file '.pc/11_grip_gestures.patch/configure.ac' |
| 3 | --- .pc/11_grip_gestures.patch/configure.ac 2014-09-15 12:46:26 +0000 |
| 4 | +++ .pc/11_grip_gestures.patch/configure.ac 1970-01-01 00:00:00 +0000 |
| 5 | @@ -1,948 +0,0 @@ |
| 6 | -# ***************************************************************************** |
| 7 | -# Versioning |
| 8 | -# ***************************************************************************** |
| 9 | - |
| 10 | -m4_define([ev_major_version],[3]) |
| 11 | -m4_define([ev_minor_version],[13]) |
| 12 | -m4_define([ev_micro_version],[91]) |
| 13 | -m4_define([ev_extra_version],[]) |
| 14 | -m4_define([ev_version],[ev_major_version.ev_minor_version.ev_micro_version()ev_extra_version]) |
| 15 | - |
| 16 | -# The evince API version |
| 17 | -m4_define([ev_api_version], [3.0]) |
| 18 | - |
| 19 | -# Libtool versioning. The backend and view libraries have separate versions. |
| 20 | -# Before making a release, the libtool version should be modified. |
| 21 | -# The string is of the form C:R:A. |
| 22 | -# - If interfaces have been changed or added, but binary compatibility has |
| 23 | -# been preserved, change to C+1:0:A+1 |
| 24 | -# - If binary compatibility has been broken (eg removed or changed interfaces) |
| 25 | -# change to C+1:0:0 |
| 26 | -# - If the interface is the same as the previous version, change to C:R+1:A |
| 27 | - |
| 28 | -# Libtool version of the backend library |
| 29 | -m4_define([ev_document_lt_current],[4]) |
| 30 | -m4_define([ev_document_lt_revision],[0]) |
| 31 | -m4_define([ev_document_lt_age],[0]) |
| 32 | -m4_define([ev_document_lt_version_info],[ev_document_lt_current:ev_document_lt_revision:ev_document_lt_age]) |
| 33 | -m4_define([ev_document_lt_current_minus_age],[m4_eval(ev_document_lt_current - ev_document_lt_age)]) |
| 34 | - |
| 35 | -# Libtool version of the view library |
| 36 | -m4_define([ev_view_lt_current],[3]) |
| 37 | -m4_define([ev_view_lt_revision],[0]) |
| 38 | -m4_define([ev_view_lt_age],[0]) |
| 39 | -m4_define([ev_view_lt_version_info],[ev_view_lt_current:ev_view_lt_revision:ev_view_lt_age]) |
| 40 | -m4_define([ev_view_lt_current_minus_age],[m4_eval(ev_view_lt_current - ev_view_lt_age)]) |
| 41 | - |
| 42 | -# Binary version for the document backends |
| 43 | -m4_define([ev_binary_version],[ev_document_lt_current]) |
| 44 | - |
| 45 | -# ***************************************************************************** |
| 46 | - |
| 47 | -AC_PREREQ([2.57]) |
| 48 | -AC_INIT([Evince],[ev_version],[http://bugzilla.gnome.org/enter_bug.cgi?product=evince],[evince]) |
| 49 | -AM_INIT_AUTOMAKE([1.10 foreign dist-xz no-dist-gzip tar-ustar]) |
| 50 | - |
| 51 | -AC_CONFIG_HEADERS([config.h]) |
| 52 | -AC_CONFIG_MACRO_DIR([m4]) |
| 53 | - |
| 54 | -if test -z "$enable_maintainer_mode"; then |
| 55 | - enable_maintainer_mode=yes |
| 56 | -fi |
| 57 | -AM_MAINTAINER_MODE([enable]) |
| 58 | - |
| 59 | -m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
| 60 | - |
| 61 | -AC_PROG_CC |
| 62 | -AM_PROG_CC_C_O |
| 63 | -AC_PROG_CXX |
| 64 | - |
| 65 | -AC_PROG_SED |
| 66 | - |
| 67 | -# Initialize libtool |
| 68 | -LT_PREREQ([2.2]) |
| 69 | -LT_INIT |
| 70 | -LT_LIB_M |
| 71 | - |
| 72 | -GNOME_CXX_WARNINGS |
| 73 | - |
| 74 | -IT_PROG_INTLTOOL([0.35.0]) |
| 75 | - |
| 76 | -GETTEXT_PACKAGE=evince |
| 77 | -AC_SUBST(GETTEXT_PACKAGE) |
| 78 | -AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package]) |
| 79 | -AM_GLIB_GNU_GETTEXT |
| 80 | - |
| 81 | -m4_pattern_allow([AM_V_GEN])dnl Make autoconf not complain about the rule below |
| 82 | -EV_INTLTOOL_EVINCE_BACKEND_RULE='%.evince-backend: %.evince-backend.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(AM_V_GEN) LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@' |
| 83 | -AC_SUBST([EV_INTLTOOL_EVINCE_BACKEND_RULE]) |
| 84 | - |
| 85 | -GLIB_GSETTINGS |
| 86 | - |
| 87 | -# Check which platform to use |
| 88 | - |
| 89 | -AC_MSG_CHECKING([for which platform to build]) |
| 90 | -AC_ARG_WITH([platform], |
| 91 | - [AS_HELP_STRING([--with-platform=gnome|win32], |
| 92 | - [Setting platform (default: gnome)])], |
| 93 | - [case "$withval" in |
| 94 | - gnome|win32) ;; |
| 95 | - *) AC_MSG_ERROR([invalid argument "$withval" for --with-platform]) ;; |
| 96 | - esac], |
| 97 | - [case "$host" in |
| 98 | - *-*-mingw*|*-*-cygwin*) with_platform="win32" ;; |
| 99 | - *) with_platform=gnome ;; |
| 100 | - esac]) |
| 101 | - |
| 102 | -AC_MSG_RESULT([$with_platform]) |
| 103 | - |
| 104 | -if test "$with_platform" = "win32"; then |
| 105 | - AC_CHECK_TOOL([WINDRES],[windres]) |
| 106 | - AC_MSG_CHECKING([for native Win32]) |
| 107 | - case "$host" in |
| 108 | - *-*-mingw*) |
| 109 | - os_win32=yes |
| 110 | - ;; |
| 111 | - *) |
| 112 | - os_win32=no |
| 113 | - ;; |
| 114 | - esac |
| 115 | - AC_MSG_RESULT([$os_win32]) |
| 116 | - |
| 117 | - AM_CFLAGS="$AM_CFLAGS -D_WIN32_WINNT=0x0500" |
| 118 | -fi |
| 119 | - |
| 120 | -AM_CONDITIONAL([PLATFORM_WIN32],[test "$with_platform" = "win32"]) |
| 121 | - |
| 122 | -dnl Specify required versions of dependencies |
| 123 | -CAIRO_REQUIRED=1.10.0 |
| 124 | -GLIB_REQUIRED=2.36.0 |
| 125 | -LIBSECRET_REQUIRED=0.5 |
| 126 | -GTK_REQUIRED=3.12.0 |
| 127 | -NAUTILUS_REQUIRED=2.91.4 |
| 128 | - |
| 129 | -AC_SUBST([GLIB_REQUIRED]) |
| 130 | -AC_SUBST([GTK_REQUIRED]) |
| 131 | - |
| 132 | -AC_DEFINE([GDK_VERSION_MIN_REQUIRED], [GDK_VERSION_3_8], [Minimum GTK/GDK version required]) |
| 133 | - |
| 134 | -ADWAITA_ICON_THEME_REQUIRED=2.17.1 |
| 135 | -LIBXML_REQUIRED=2.5.0 |
| 136 | - |
| 137 | -dnl Check dependencies |
| 138 | - |
| 139 | -# LIB_CFLAGS for helpers and generic widgets. (libdocument, cut-and-paste) |
| 140 | -# BACKEND_CFLAGS for backend implementations. |
| 141 | -# FRONTEND_CFLAGS for frontend implementations. (properties, thumbnailer) |
| 142 | -# FRONTEND_LIBS |
| 143 | -# SHELL_CFLAGS for shell implementation. |
| 144 | -# SHELL_LIBS |
| 145 | - |
| 146 | -have_zlib=yes |
| 147 | -AC_CHECK_HEADERS([zlib.h], |
| 148 | - [AC_CHECK_LIB([z], [inflate], |
| 149 | - [AC_CHECK_LIB([z], [crc32], [have_zlib=yes], [have_zlib=no])], |
| 150 | - [have_zlib=no])], |
| 151 | - [have_zlib=no]) |
| 152 | - |
| 153 | -if test x$have_zlib = xno; then |
| 154 | - AC_MSG_ERROR([No sufficient zlib library found on your system.]) |
| 155 | -fi |
| 156 | - |
| 157 | -ZLIB_LIBS=-lz |
| 158 | -AC_SUBST(ZLIB_LIBS) |
| 159 | - |
| 160 | -PKG_CHECK_MODULES(LIBDOCUMENT, gtk+-3.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gmodule-no-export-2.0 >= $GLIB_REQUIRED gmodule-2.0) |
| 161 | -PKG_CHECK_MODULES(LIBVIEW, gtk+-3.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED) |
| 162 | -PKG_CHECK_MODULES(BACKEND, cairo >= $CAIRO_REQUIRED gtk+-3.0 >= $GTK_REQUIRED) |
| 163 | -PKG_CHECK_MODULES(FRONTEND_CORE, gtk+-3.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED gmodule-no-export-2.0 >= $GLIB_REQUIRED) |
| 164 | - |
| 165 | -# Although GTK+ 3.10 includes hi-dpi functionality, it does not require a cairo with |
| 166 | -# cairo_surface_set_device_scale(), which we also need if we're to support hi-dpi, |
| 167 | -# so we need check for that explicity. |
| 168 | - |
| 169 | -evince_save_LIBS=$LIBS |
| 170 | -LIBS="$LIBS $LIBVIEW_LIBS" |
| 171 | -AC_CHECK_FUNCS(cairo_surface_set_device_scale) |
| 172 | -LIBS=$evince_save_LIBS |
| 173 | - |
| 174 | -AC_MSG_CHECKING([for hi-dpi support]) |
| 175 | -if test "$ac_cv_func_cairo_surface_set_device_scale" = yes ; then |
| 176 | - AC_DEFINE([HAVE_HIDPI_SUPPORT], [1], [Define if cairo and GTK+ have necessary functions for hi-dpi]) |
| 177 | - AC_MSG_RESULT([yes]) |
| 178 | -else |
| 179 | - AC_MSG_RESULT([no]) |
| 180 | -fi |
| 181 | - |
| 182 | -SHELL_PLATFORM_PKGS= |
| 183 | -case "$with_platform" in |
| 184 | - gnome) |
| 185 | - # Evince has a rather soft run-time dependency on hicolor-icon-theme. |
| 186 | - # If the hicolor theme is not available, Evince fails to display some |
| 187 | - # icons. Because we cannot check for it at run-time, we instead |
| 188 | - # would like to require the icon theme at compile-time. But, because |
| 189 | - # the hicolor-icon-theme does not have a pkgconfig file, on gnome we |
| 190 | - # require the gnome icon theme instead. |
| 191 | - SHELL_PLATFORM_PKGS="adwaita-icon-theme >= $ADWAITA_ICON_THEME_REQUIRED" |
| 192 | - ;; |
| 193 | - *) |
| 194 | - # On all other platforms we issue a warning about the runtime |
| 195 | - # dependency. |
| 196 | - AC_MSG_WARN([Evince has a soft run-time dependency on hicolor-icon-theme. You are advised to have this theme installed when running Evince.]); |
| 197 | - SHELL_PLATFORM_PKGS="" |
| 198 | - ;; |
| 199 | -esac |
| 200 | - |
| 201 | -PKG_CHECK_MODULES([SHELL_CORE],[libxml-2.0 >= $LIBXML_REQUIRED gtk+-3.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gmodule-no-export-2.0 >= $GLIB_REQUIRED gthread-2.0 $SHELL_PLATFORM_PKGS]) |
| 202 | - |
| 203 | -# *************** |
| 204 | -# Build utilities |
| 205 | -# *************** |
| 206 | - |
| 207 | -AC_ARG_VAR([GLIB_GENMARSHAL],[the glib-genmarschal programme]) |
| 208 | -AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal],[]) |
| 209 | -if test -z "$GLIB_GENMARSHAL"; then |
| 210 | - AC_MSG_ERROR([glib-genmarshal not found]) |
| 211 | -fi |
| 212 | - |
| 213 | -AC_ARG_VAR([GLIB_MKENUMS],[the glib-mkenums programme]) |
| 214 | -AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums],[]) |
| 215 | -if test -z "$GLIB_MKENUMS"; then |
| 216 | - AC_MSG_ERROR([glib-mkenums not found]) |
| 217 | -fi |
| 218 | - |
| 219 | -AC_ARG_VAR([GLIB_COMPILE_RESOURCES],[the glib-compile-resources programme]) |
| 220 | -AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources],[]) |
| 221 | -if test -z "$GLIB_COMPILE_RESOURCES"; then |
| 222 | - AC_MSG_ERROR([glib-compile-resources not found]) |
| 223 | -fi |
| 224 | - |
| 225 | -AC_ARG_VAR([XMLLINT],[the xmllint programme]) |
| 226 | -AC_PATH_PROG([XMLLINT],[xmllint],[]) |
| 227 | -if test -z "$XMLLINT"; then |
| 228 | - AC_MSG_ERROR([xmllint not found]) |
| 229 | -fi |
| 230 | - |
| 231 | -AC_ARG_VAR([GDBUS_CODEGEN],[the gdbus-codegen programme]) |
| 232 | -AC_PATH_PROG([GDBUS_CODEGEN],[gdbus-codegen],[]) |
| 233 | -if test -z "$GDBUS_CODEGEN"; then |
| 234 | - AC_MSG_ERROR([gdbus-codegen not found]) |
| 235 | -fi |
| 236 | - |
| 237 | -# *** |
| 238 | - |
| 239 | -BACKEND_LIBTOOL_FLAGS="-module -avoid-version -no-undefined -export-symbols \$(top_srcdir)/backend/backend.symbols" |
| 240 | -AC_SUBST(BACKEND_LIBTOOL_FLAGS) |
| 241 | - |
| 242 | -dnl ===== Check special functions |
| 243 | -evince_save_LIBS=$LIBS |
| 244 | -LIBS="$LIBS $BACKEND_LIBS" |
| 245 | -AC_CHECK_FUNCS(cairo_format_stride_for_width) |
| 246 | -LIBS=$evince_save_LIBS |
| 247 | - |
| 248 | -# ****************** |
| 249 | -# GKT+ Unix Printing |
| 250 | -# ****************** |
| 251 | - |
| 252 | -AC_MSG_CHECKING([whether gtk+-unix-print support is requested]) |
| 253 | -AC_ARG_WITH([gtk-unix-print], |
| 254 | - [AS_HELP_STRING([--without-gtk-unix-print], |
| 255 | - [Disable the use of gtk-unix-print])], |
| 256 | - [],[case "$os_win32" in |
| 257 | - yes) with_gtk_unix_print=no ;; |
| 258 | - *) with_gtk_unix_print=yes ;; |
| 259 | - esac]) |
| 260 | - |
| 261 | -AC_MSG_RESULT([$with_gtk_unix_print]) |
| 262 | - |
| 263 | -if test "$with_gtk_unix_print" = "yes"; then |
| 264 | - PKG_CHECK_MODULES(GTKUNIXPRINT, [gtk+-unix-print-3.0 >= $GTK_REQUIRED]) |
| 265 | - AC_DEFINE([GTKUNIXPRINT_ENABLED], [1], [Define if gtk+-unix-print is enabled.]) |
| 266 | -fi |
| 267 | - |
| 268 | -# ********************* |
| 269 | -# GNOME Keyring support |
| 270 | -# ********************* |
| 271 | - |
| 272 | -AC_ARG_WITH(keyring, |
| 273 | - [AS_HELP_STRING([--without-keyring], |
| 274 | - [Disable the use of gnome-keyring])], |
| 275 | - [], |
| 276 | - [case "$with_platform" in |
| 277 | - gnome) with_keyring=yes ;; |
| 278 | - win32) with_keyring=no ;; |
| 279 | - esac]) |
| 280 | - |
| 281 | -AM_CONDITIONAL([WITH_KEYRING],[test "$with_keyring" = "yes"]) |
| 282 | - |
| 283 | -if test "$with_keyring" = "yes"; then |
| 284 | - PKG_CHECK_MODULES(LIBSECRET, libsecret-1 >= $LIBSECRET_REQUIRED) |
| 285 | - AC_DEFINE([WITH_KEYRING],[1],[Define if KEYRING support is enabled]) |
| 286 | -fi |
| 287 | - |
| 288 | -# **** |
| 289 | -# DBUS |
| 290 | -# **** |
| 291 | - |
| 292 | -AC_ARG_ENABLE([dbus], |
| 293 | - [AS_HELP_STRING([--disable-dbus], [Disable support for dbus])], |
| 294 | - [], |
| 295 | - [case "$with_platform" in |
| 296 | - gnome) enable_dbus=yes ;; |
| 297 | - esac]) |
| 298 | - |
| 299 | -if test "$enable_dbus" = "yes"; then |
| 300 | - AC_DEFINE([ENABLE_DBUS],[1],[Define if DBUS support is enabled]) |
| 301 | - |
| 302 | - PKG_CHECK_MODULES([EV_DAEMON], [gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0]) |
| 303 | -fi |
| 304 | - |
| 305 | -AM_CONDITIONAL([ENABLE_DBUS], [test "$enable_dbus" = "yes"]) |
| 306 | - |
| 307 | -# ******************************* |
| 308 | -# GNOME Desktop (Thumbnail cache) |
| 309 | -# ******************************* |
| 310 | - |
| 311 | -AC_ARG_ENABLE([libgnome-desktop], |
| 312 | - [AS_HELP_STRING([--disable-libgnome-desktop], [Disable GNOME Desktop (Thumbnail cache)])], |
| 313 | - [enable_gnome_desktop=$enableval], |
| 314 | - [enable_gnome_desktop=auto]) |
| 315 | - |
| 316 | -if test "$enable_gnome_desktop" != "no"; then |
| 317 | - if test "$enable_gnome_desktop" = "auto"; then |
| 318 | - PKG_CHECK_MODULES([LIBGNOME_DESKTOP], [gnome-desktop-3.0], has_libgnome_desktop=yes, has_libgnome_desktop=no) |
| 319 | - else |
| 320 | - PKG_CHECK_MODULES([LIBGNOME_DESKTOP], [gnome-desktop-3.0]) |
| 321 | - has_libgnome_desktop = yes |
| 322 | - fi |
| 323 | - |
| 324 | - if test x$has_libgnome_desktop = xyes; then |
| 325 | - AC_DEFINE([HAVE_LIBGNOME_DESKTOP], [1], [Whether GNOME Desktop (Thumbnail cache) is available]) |
| 326 | - enable_gnome_desktop=yes |
| 327 | - else |
| 328 | - enable_gnome_desktop=no |
| 329 | - fi |
| 330 | -fi |
| 331 | - |
| 332 | -dnl ========= Check for Desktop Schemas |
| 333 | -PKG_CHECK_MODULES([DESKTOP_SCHEMAS], [gsettings-desktop-schemas], |
| 334 | - has_desktop_schemas=yes, has_desktop_schemas=no) |
| 335 | -if test x$has_desktop_schemas = xyes; then |
| 336 | - AC_DEFINE([HAVE_DESKTOP_SCHEMAS], [1], [Whether GSettings Desktop Schemas are available]) |
| 337 | -fi |
| 338 | - |
| 339 | -dnl Debug mode |
| 340 | - |
| 341 | -AC_ARG_ENABLE([debug], |
| 342 | - AS_HELP_STRING([--enable-debug], |
| 343 | - [Turn on evince debug mode]), |
| 344 | - [enable_debug=$enableval], |
| 345 | - [enable_debug=no]) |
| 346 | - |
| 347 | -if test "x$enable_debug" = "xyes"; then |
| 348 | - DEBUG_FLAGS="-DEV_ENABLE_DEBUG" |
| 349 | -fi |
| 350 | - |
| 351 | -LIBDOCUMENT_CFLAGS="$LIBDOCUMENT_CFLAGS $DEBUG_FLAGS" |
| 352 | -LIBDOCUMENT_LIBS="$LIBDOCUMENT_LIBS" |
| 353 | -AC_SUBST(LIBDOCUMENT_CFLAGS) |
| 354 | -AC_SUBST(LIBDOCUMENT_LIBS) |
| 355 | - |
| 356 | -LIBVIEW_CFLAGS="$LIBVIEW_CFLAGS $GTKUNIXPRINT_CFLAGS $DEBUG_FLAGS" |
| 357 | -LIBVIEW_LIBS="$LIBVIEW_LIBS $GTKUNIXPRINT_LIBS -lm" |
| 358 | -AC_SUBST(LIBVIEW_CFLAGS) |
| 359 | -AC_SUBST(LIBVIEW_LIBS) |
| 360 | - |
| 361 | -BACKEND_CFLAGS="$BACKEND_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS" |
| 362 | -BACKEND_LIBS="$BACKEND_LIBS -lm" |
| 363 | -AC_SUBST(BACKEND_CFLAGS) |
| 364 | -AC_SUBST(BACKEND_LIBS) |
| 365 | - |
| 366 | -SHELL_CFLAGS="$SHELL_CORE_CFLAGS $LIBSECRET_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS $LIBGNOME_DESKTOP_CFLAGS" |
| 367 | -SHELL_LIBS="$SHELL_CORE_LIBS $LIBSECRET_LIBS $LIBGNOME_DESKTOP_LIBS -lz -lm" |
| 368 | -AC_SUBST(SHELL_CFLAGS) |
| 369 | -AC_SUBST(SHELL_LIBS) |
| 370 | - |
| 371 | -FRONTEND_CFLAGS="$FRONTEND_CORE_CFLAGS $DEBUG_FLAGS" |
| 372 | -FRONTEND_LIBS="$FRONTEND_CORE_LIBS -lz" |
| 373 | -AC_SUBST(FRONTEND_CFLAGS) |
| 374 | -AC_SUBST(FRONTEND_LIBS) |
| 375 | - |
| 376 | -EV_DAEMON_CFLAGS="$EV_DAEMON_CFLAGS $DEBUG_FLAGS" |
| 377 | -AC_SUBST([EV_DAEMON_CFLAGS]) |
| 378 | -AC_SUBST([EV_DAEMON_LIBS]) |
| 379 | - |
| 380 | -# Check for Nautilus property page build |
| 381 | -AC_ARG_ENABLE([nautilus], |
| 382 | - [AS_HELP_STRING([--disable-nautilus], |
| 383 | - [Disable build of nautilus extensions])], |
| 384 | - [], |
| 385 | - [case "$with_platform" in |
| 386 | - gnome) enable_nautilus=yes ;; |
| 387 | - *) enable_nautilus=no ;; |
| 388 | - esac]) |
| 389 | - |
| 390 | -if test "$enable_nautilus" = "yes" ; then |
| 391 | - PKG_CHECK_MODULES([NAUTILUS],[gtk+-x11-3.0 $MM gthread-2.0 libnautilus-extension >= $NAUTILUS_REQUIRED], |
| 392 | - [],[AC_MSG_ERROR([libnautilus-extension not found; use --disable-nautilus to disable the nautilus extensions])]) |
| 393 | - NAUTILUS_EXTENSION_DIR=`$PKG_CONFIG --variable=extensiondir libnautilus-extension` |
| 394 | - NAUTILUS_EXTENSION_DIR=${NAUTILUS_EXTENSION_DIR#`$PKG_CONFIG --variable=libdir libnautilus-extension`} |
| 395 | - NAUTILUS_EXTENSION_DIR=${NAUTILUS_EXTENSION_DIR#/} |
| 396 | - AC_SUBST(NAUTILUS_EXTENSION_DIR) |
| 397 | - AC_SUBST(NAUTILUS_CFLAGS) |
| 398 | - AC_SUBST(NAUTILUS_LIBS) |
| 399 | - |
| 400 | - AC_DEFINE([HAVE_NAUTILUS],[1], [defined if you build the nautilus plugin]) |
| 401 | -fi |
| 402 | - |
| 403 | -AM_CONDITIONAL([ENABLE_NAUTILUS],[test "$enable_nautilus" = "yes"]) |
| 404 | - |
| 405 | -# *************** |
| 406 | -# Document Viewer |
| 407 | -# *************** |
| 408 | - |
| 409 | -AC_ARG_ENABLE( |
| 410 | - [viewer], |
| 411 | - [AS_HELP_STRING([--disable-viewer], [Disable GNOME Document viewer])], |
| 412 | - [], |
| 413 | - [enable_viewer=yes] |
| 414 | -) |
| 415 | -AM_CONDITIONAL([ENABLE_VIEWER],[test "$enable_viewer" = "yes"]) |
| 416 | - |
| 417 | -# *************** |
| 418 | -# Thumbnailer |
| 419 | -# *************** |
| 420 | - |
| 421 | -AC_ARG_ENABLE([thumbnailer], |
| 422 | - [AS_HELP_STRING([--disable-thumbnailer], |
| 423 | - [Disable GNOME thumbnailer])], |
| 424 | - [], |
| 425 | - [enable_thumbnailer=yes]) |
| 426 | - |
| 427 | -AM_CONDITIONAL([ENABLE_THUMBNAILER],[test "$enable_thumbnailer" = "yes"]) |
| 428 | - |
| 429 | -# *************** |
| 430 | -# Print Previewer |
| 431 | -# *************** |
| 432 | - |
| 433 | -AC_ARG_ENABLE([previewer], |
| 434 | - [AS_HELP_STRING([--disable-previewer], |
| 435 | - [Disable the GNOME Document Previewer])], |
| 436 | - [], |
| 437 | - [enable_previewer=yes]) |
| 438 | - |
| 439 | -if test x$enable_previewer = "xyes" ; then |
| 440 | - PKG_CHECK_MODULES([PREVIEWER],[gtk+-3.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED gmodule-no-export-2.0 >= $GLIB_REQUIRED]) |
| 441 | -fi |
| 442 | - |
| 443 | -AM_CONDITIONAL([ENABLE_PREVIEWER],[test "$enable_previewer" = "yes"]) |
| 444 | -PREVIEWER_CFLAGS="$PREVIEWER_CFLAGS $GTKUNIXPRINT_CFLAGS $DEBUG_FLAGS" |
| 445 | -PREVIEWER_LIBS="$PREVIEWER_LIBS $GTKUNIXPRINT_LIBS -lz" |
| 446 | -AC_SUBST(PREVIEWER_CFLAGS) |
| 447 | -AC_SUBST(PREVIEWER_LIBS) |
| 448 | - |
| 449 | - |
| 450 | -# ************** |
| 451 | -# Browser Plugin |
| 452 | -# ************** |
| 453 | - |
| 454 | -AC_ARG_ENABLE([browser-plugin], |
| 455 | - [AS_HELP_STRING([--disable-browser-plugin], |
| 456 | - [Disable the Browser Plugin])], |
| 457 | - [], |
| 458 | - [enable_browser_plugin=yes]) |
| 459 | - |
| 460 | -if test x$enable_browser_plugin = "xyes" ; then |
| 461 | - PKG_CHECK_MODULES([BROWSER_PLUGIN],[gtk+-3.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED]) |
| 462 | - |
| 463 | - BROWSER_PLUGIN_DIR="${BROWSER_PLUGIN_DIR:-"\${libdir}/mozilla/plugins"}" |
| 464 | - AC_ARG_VAR([BROWSER_PLUGIN_DIR],[Where to install the plugin to]) |
| 465 | -fi |
| 466 | - |
| 467 | -AM_CONDITIONAL([ENABLE_BROWSER_PLUGIN],[test "$enable_browser_plugin" = "yes"]) |
| 468 | -BROWSER_PLUGIN_CFLAGS="$BROWSER_PLUGIN_CFLAGS $DEBUG_FLAGS" |
| 469 | -AC_SUBST(BROWSER_PLUGIN_CFLAGS) |
| 470 | -AC_SUBST(BROWSER_PLUGIN_LIBS) |
| 471 | - |
| 472 | -# *** |
| 473 | -# GIR |
| 474 | -# *** |
| 475 | - |
| 476 | -# No automagic please! |
| 477 | -if test -z "$enable_introspection"; then |
| 478 | - enable_introspection=no |
| 479 | -fi |
| 480 | - |
| 481 | -GOBJECT_INTROSPECTION_CHECK([1.0]) |
| 482 | - |
| 483 | -dnl ================== portability checks =========================================== |
| 484 | - |
| 485 | -dnl for backtrace() |
| 486 | -AC_CHECK_HEADERS([execinfo.h]) |
| 487 | - |
| 488 | -AC_CHECK_DECL([_NL_MEASUREMENT_MEASUREMENT],[ |
| 489 | - AC_DEFINE([HAVE__NL_MEASUREMENT_MEASUREMENT],[1],[Define if _NL_MEASUREMENT_MEASUREMENT is available]) |
| 490 | - ],[],[#include <langinfo.h>]) |
| 491 | - |
| 492 | -dnl ================== pdf checks =================================================== |
| 493 | -AC_ARG_ENABLE([pdf], |
| 494 | - [AS_HELP_STRING([--disable-pdf], |
| 495 | - [Disable the PDF support])], |
| 496 | - [enable_pdf=$enableval], |
| 497 | - [enable_pdf=yes]) |
| 498 | - |
| 499 | -if test "x$enable_pdf" = "xyes"; then |
| 500 | - POPPLER_REQUIRED=0.24.0 |
| 501 | - PKG_CHECK_MODULES(POPPLER, poppler-glib >= $POPPLER_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED,enable_pdf=yes,enable_pdf=no) |
| 502 | - |
| 503 | - if test "x$enable_pdf" = "xyes"; then |
| 504 | - PKG_CHECK_MODULES(CAIRO_PDF, cairo-pdf, enable_cairo_pdf=yes, enable_cairo_pdf=no) |
| 505 | - if test x$enable_cairo_pdf = xyes; then |
| 506 | - AC_DEFINE([HAVE_CAIRO_PDF], [1], [defined if cairo-pdf is available]) |
| 507 | - fi |
| 508 | - |
| 509 | - PKG_CHECK_MODULES(CAIRO_PS, cairo-ps, enable_cairo_ps=yes, enable_cairo_ps=no) |
| 510 | - if test x$enable_cairo_ps = xyes; then |
| 511 | - AC_DEFINE([HAVE_CAIRO_PS], [1], [defined if cairo-ps is available]) |
| 512 | - fi |
| 513 | - else |
| 514 | - AC_MSG_ERROR("PDF support is disabled since poppler-glib library version $POPPLER_REQUIRED or newer not found") |
| 515 | - fi |
| 516 | -fi |
| 517 | - |
| 518 | -AM_CONDITIONAL(ENABLE_PDF, test x$enable_pdf = xyes) |
| 519 | -dnl ================== end of pdf checks ============================================ |
| 520 | - |
| 521 | -dnl libspectre (used by ps and dvi backends) |
| 522 | -SPECTRE_REQUIRED=0.2.0 |
| 523 | -PKG_CHECK_MODULES(SPECTRE, libspectre >= $SPECTRE_REQUIRED,have_spectre=yes,have_spectre=no) |
| 524 | -AM_CONDITIONAL(HAVE_SPECTRE, test x$have_spectre = xyes) |
| 525 | -if test "x$have_spectre" = "xyes"; then |
| 526 | - AC_DEFINE([HAVE_SPECTRE], [1], [Have libspectre]) |
| 527 | -fi |
| 528 | - |
| 529 | -dnl ================== ps checks ==================================================== |
| 530 | -AC_ARG_ENABLE(ps, |
| 531 | - [AS_HELP_STRING([--disable-ps], |
| 532 | - [Disable the PostScript backend])], |
| 533 | - [enable_ps=$enableval], |
| 534 | - [enable_ps=yes]) |
| 535 | - |
| 536 | -if test "x$enable_ps" = "xyes"; then |
| 537 | - if test "x$have_spectre" = "xyes"; then |
| 538 | - AC_DEFINE([ENABLE_PS], [1], [Enable support for PostScript files.]) |
| 539 | - else |
| 540 | - enable_ps="no" |
| 541 | - AC_MSG_WARN([PS support is disabled since libspectre (version >= $SPECTRE_REQUIRED) is needed]) |
| 542 | - fi |
| 543 | -fi |
| 544 | -AM_CONDITIONAL(ENABLE_PS, test x$enable_ps = xyes) |
| 545 | -dnl ======================== End of ps checks =================================== |
| 546 | - |
| 547 | -dnl ================== tiff checks =================================================== |
| 548 | -AC_ARG_ENABLE(tiff, |
| 549 | - [AS_HELP_STRING([--disable-tiff], |
| 550 | - [Disable the support of multipage tiff])], |
| 551 | - [enable_tiff=$enableval], |
| 552 | - [enable_tiff=yes]) |
| 553 | - |
| 554 | -if test "x$enable_tiff" = "xyes"; then |
| 555 | - AC_CHECK_HEADERS([tiff.h],enable_tiff=yes,enable_tiff=no,) |
| 556 | - if test "x$enable_tiff" = "xyes"; then |
| 557 | - AC_CHECK_LIB([tiff],TIFFOpen,enable_tiff=yes,enable_tiff=no,"-lz") |
| 558 | - AC_CHECK_LIB([tiff],TIFFReadRGBAImageOriented,enable_tiff=yes,enable_tiff=no,"-lz") |
| 559 | - fi |
| 560 | - if test "x$enable_tiff" = "xyes"; then |
| 561 | - AC_DEFINE([ENABLE_TIFF], [1], [Enable multipage tiff support.]) |
| 562 | - else |
| 563 | - AC_MSG_WARN("Tiff support is disabled since tiff library version 3.6 or newer not found") |
| 564 | - fi |
| 565 | -fi |
| 566 | - |
| 567 | -AM_CONDITIONAL(ENABLE_TIFF, test x$enable_tiff = xyes) |
| 568 | -dnl ================== end of tiff checks ============================================ |
| 569 | - |
| 570 | -dnl ================== djvu checks =================================================== |
| 571 | - |
| 572 | -AC_ARG_ENABLE(djvu, |
| 573 | - [AS_HELP_STRING([--disable-djvu], |
| 574 | - [Disable the support of djvu viewer])], |
| 575 | - [enable_djvu=$enableval], |
| 576 | - [enable_djvu=yes]) |
| 577 | - |
| 578 | -if test "x$enable_djvu" = "xyes"; then |
| 579 | - DJVULIBRE_REQUIRED=3.5.17 |
| 580 | - PKG_CHECK_MODULES(DJVU, ddjvuapi >= $DJVULIBRE_REQUIRED, enable_djvu=yes, enable_djvu=no) |
| 581 | - |
| 582 | - if test "x$enable_djvu" = "xyes"; then |
| 583 | - AC_DEFINE([ENABLE_DJVU], [1], [Enable djvu viewer support.]) |
| 584 | - else |
| 585 | - AC_MSG_WARN([ |
| 586 | -** Djvu support is disabled since a recent version of the djvulibre |
| 587 | -** library was not found. You need at least djvulibre-3.5.17 which |
| 588 | -** can be found on http://djvulibre.djvuzone.org |
| 589 | -]) |
| 590 | - fi |
| 591 | -fi |
| 592 | - |
| 593 | -AM_CONDITIONAL(ENABLE_DJVU, test x$enable_djvu = xyes) |
| 594 | - |
| 595 | -dnl ================== End of djvu checks =================================================== |
| 596 | - |
| 597 | -dnl ================== dvi checks =================================================== |
| 598 | - |
| 599 | -AC_ARG_ENABLE(dvi, |
| 600 | - [AS_HELP_STRING([--disable-dvi], |
| 601 | - [Disable the support of dvi viewer])], |
| 602 | - [enable_dvi=$enableval], |
| 603 | - [enable_dvi=yes]) |
| 604 | - |
| 605 | -AC_ARG_ENABLE(t1lib, |
| 606 | - [AS_HELP_STRING([--enable-t1lib], |
| 607 | - [Compile with support of t1lib for type1 fonts in dvi])], |
| 608 | - [enable_type1_fonts=$enableval], |
| 609 | - [enable_type1_fonts=no]) |
| 610 | - |
| 611 | -if test "x$enable_dvi" = "xyes"; then |
| 612 | - AC_C_CONST |
| 613 | - AC_C_INLINE |
| 614 | - AC_TYPE_SIZE_T |
| 615 | - AC_CHECK_SIZEOF(long, 4) |
| 616 | - AC_CHECK_SIZEOF(int, 4) |
| 617 | - AC_CHECK_SIZEOF(short, 2) |
| 618 | - AC_CHECK_SIZEOF(long long, 4) |
| 619 | - AC_CHECK_SIZEOF(void *, 4) |
| 620 | - AC_CHECK_LIB([kpathsea],[kpse_init_prog],[enable_dvi=yes],[enable_dvi=no]) |
| 621 | - |
| 622 | - if test "x$enable_dvi" = "xyes"; then |
| 623 | - AC_DEFINE([ENABLE_DVI], [1], [Enable dvi viewer support.]) |
| 624 | - else |
| 625 | - AC_MSG_WARN("Dvi support is disabled since kpathsea library is not found. Check your TeX installation.") |
| 626 | - fi |
| 627 | -fi |
| 628 | -AM_CONDITIONAL(ENABLE_DVI, test x$enable_dvi = xyes) |
| 629 | - |
| 630 | -if test "x$enable_dvi" = "xyes"; then |
| 631 | - if test "x$enable_type1_fonts" = "xyes"; then |
| 632 | - AC_CHECK_LIB([t1],T1_InitLib,enable_type1_fonts=yes,enable_type1_fonts=no,[-lm]) |
| 633 | - fi |
| 634 | - |
| 635 | - if test "x$enable_type1_fonts" = xyes; then |
| 636 | - AC_DEFINE([WITH_TYPE1_FONTS], [1], [Enable t1lib support in dvi.]) |
| 637 | - fi |
| 638 | -else |
| 639 | - enable_type1_fonts=no |
| 640 | -fi |
| 641 | -AM_CONDITIONAL(WITH_TYPE1_FONTS, test x$enable_type1_fonts = xyes) |
| 642 | - |
| 643 | -dnl ================== End of dvi checks =================================================== |
| 644 | - |
| 645 | -dnl ================== comic book checks =================================================== |
| 646 | - |
| 647 | -AC_ARG_ENABLE(comics, |
| 648 | - [AS_HELP_STRING([--enable-comics], |
| 649 | - [Compile with support for comic book archives])], |
| 650 | - [enable_comics=$enableval], |
| 651 | - [enable_comics=yes]) |
| 652 | - |
| 653 | -if test "x$enable_comics" = "xyes"; then |
| 654 | - AC_DEFINE([ENABLE_COMICS], [1], [Enable support for comics.]) |
| 655 | -fi |
| 656 | -AM_CONDITIONAL(ENABLE_COMICS, test x$enable_comics = xyes) |
| 657 | - |
| 658 | -dnl ================== End of comic book checks ============================================ |
| 659 | - |
| 660 | -dnl ================== XPS checks =================================================== |
| 661 | - |
| 662 | -AC_ARG_ENABLE(xps, |
| 663 | - [AS_HELP_STRING([--enable-xps], |
| 664 | - [Compile with support for XPS documents.])], |
| 665 | - [enable_xps=$enableval], |
| 666 | - [enable_xps=yes]) |
| 667 | - |
| 668 | -if test "x$enable_xps" = "xyes"; then |
| 669 | - GXPS_REQUIRED=0.2.1 |
| 670 | - PKG_CHECK_MODULES(GXPS, libgxps >= $GXPS_REQUIRED,enable_xps=yes,enable_xps=no) |
| 671 | - |
| 672 | - if test "x$enable_xps" = "xyes"; then |
| 673 | - AC_DEFINE([ENABLE_XPS], [1], [Enable support for XPS documents.]) |
| 674 | - else |
| 675 | - enable_xps="no" |
| 676 | - AC_MSG_WARN(["XPS support is disabled since libgxps (version >= $GXPS_REQUIRED) is needed]) |
| 677 | - fi |
| 678 | -fi |
| 679 | - |
| 680 | -AM_CONDITIONAL(ENABLE_XPS, test x$enable_xps = xyes) |
| 681 | - |
| 682 | -dnl ================== End of XPS checks =================================================== |
| 683 | - |
| 684 | -dnl =================== Compile warnings =================================================== |
| 685 | - |
| 686 | -GNOME_COMPILE_WARNINGS |
| 687 | - |
| 688 | -CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \ |
| 689 | -]) |
| 690 | - |
| 691 | -AM_CFLAGS="$AM_CFLAGS $WARN_CFLAGS" |
| 692 | -AM_CXXFLAGS="$AM_CXXFLAGS $WARN_CXXFLAGS" |
| 693 | - |
| 694 | -dnl =================== End of compile warnings============================================= |
| 695 | - |
| 696 | -dnl =================== Mime types list ==================================================== |
| 697 | - |
| 698 | -if test "x$enable_pdf" = "xyes" ; then |
| 699 | - PDF_MIME_TYPES="application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-xzpdf;application/x-ext-pdf" |
| 700 | - APPDATA_PDF_MIME_TYPES=$(echo "<mimetype>$PDF_MIME_TYPES</mimetype>" | sed -e 's/;/<\/mimetype>\n <mimetype>/g') |
| 701 | - if test -z "$EVINCE_MIME_TYPES"; then |
| 702 | - EVINCE_MIME_TYPES="${PDF_MIME_TYPES}" |
| 703 | - else |
| 704 | - EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES};${PDF_MIME_TYPES}" |
| 705 | - fi |
| 706 | -fi |
| 707 | -AC_SUBST(PDF_MIME_TYPES) |
| 708 | -AC_SUBST(APPDATA_PDF_MIME_TYPES) |
| 709 | -AM_SUBST_NOTMAKE(APPDATA_PDF_MIME_TYPES) |
| 710 | -if test "x$enable_ps" = "xyes" ; then |
| 711 | - PS_MIME_TYPES="application/postscript;application/x-bzpostscript;application/x-gzpostscript;image/x-eps;image/x-bzeps;image/x-gzeps;application/x-ext-ps;application/x-ext-eps" |
| 712 | - APPDATA_PS_MIME_TYPES=$(echo "<mimetype>$PS_MIME_TYPES</mimetype>" | sed -e 's/;/<\/mimetype>\n <mimetype>/g') |
| 713 | - if test -z "$EVINCE_MIME_TYPES"; then |
| 714 | - EVINCE_MIME_TYPES="${PS_MIME_TYPES}" |
| 715 | - else |
| 716 | - EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES};${PS_MIME_TYPES}" |
| 717 | - fi |
| 718 | -fi |
| 719 | -AC_SUBST(PS_MIME_TYPES) |
| 720 | -AC_SUBST(APPDATA_PS_MIME_TYPES) |
| 721 | -AM_SUBST_NOTMAKE(APPDATA_PS_MIME_TYPES) |
| 722 | -if test "x$enable_dvi" = "xyes"; then |
| 723 | - DVI_MIME_TYPES="application/x-dvi;application/x-bzdvi;application/x-gzdvi;application/x-ext-dvi" |
| 724 | - APPDATA_DVI_MIME_TYPES=$(echo "<mimetype>$DVI_MIME_TYPES</mimetype>" | sed -e 's/;/<\/mimetype>\n <mimetype>/g') |
| 725 | - if test -z "$EVINCE_MIME_TYPES"; then |
| 726 | - EVINCE_MIME_TYPES="${DVI_MIME_TYPES}" |
| 727 | - else |
| 728 | - EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES};${DVI_MIME_TYPES}" |
| 729 | - fi |
| 730 | -fi |
| 731 | -AC_SUBST(DVI_MIME_TYPES) |
| 732 | -AC_SUBST(APPDATA_DVI_MIME_TYPES) |
| 733 | -AM_SUBST_NOTMAKE(APPDATA_DVI_MIME_TYPES) |
| 734 | -if test "x$enable_djvu" = "xyes"; then |
| 735 | - DJVU_MIME_TYPES="image/vnd.djvu;application/x-ext-djv;application/x-ext-djvu" |
| 736 | - APPDATA_DJVU_MIME_TYPES=$(echo "<mimetype>$DJVU_MIME_TYPES</mimetype>" | sed -e 's/;/<\/mimetype>\n <mimetype>/g') |
| 737 | - if test -z "$EVINCE_MIME_TYPES"; then |
| 738 | - EVINCE_MIME_TYPES="${DJVU_MIME_TYPES}" |
| 739 | - else |
| 740 | - EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES};${DJVU_MIME_TYPES}" |
| 741 | - fi |
| 742 | -fi |
| 743 | -AC_SUBST(DJVU_MIME_TYPES) |
| 744 | -AC_SUBST(APPDATA_DJVU_MIME_TYPES) |
| 745 | -AM_SUBST_NOTMAKE(APPDATA_DJVU_MIME_TYPES) |
| 746 | -if test "x$enable_tiff" = "xyes"; then |
| 747 | - TIFF_MIME_TYPES="image/tiff" |
| 748 | - APPDATA_TIFF_MIME_TYPES=$(echo "<mimetype>$TIFF_MIME_TYPES</mimetype>" | sed -e 's/;/<\/mimetype>\n <mimetype>/g') |
| 749 | - if test -z "$EVINCE_MIME_TYPES"; then |
| 750 | - EVINCE_MIME_TYPES="${TIFF_MIME_TYPES}" |
| 751 | - else |
| 752 | - EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES};${TIFF_MIME_TYPES}" |
| 753 | - fi |
| 754 | -fi |
| 755 | -AC_SUBST(TIFF_MIME_TYPES) |
| 756 | -AC_SUBST(APPDATA_TIFF_MIME_TYPES) |
| 757 | -AM_SUBST_NOTMAKE(APPDATA_TIFF_MIME_TYPES) |
| 758 | -if test "x$enable_comics" = "xyes"; then |
| 759 | - COMICS_MIME_TYPES="application/x-cbr;application/x-cbz;application/x-cb7;application/x-cbt;application/x-ext-cbr;application/x-ext-cbz;application/x-ext-cb7;application/x-ext-cbt" |
| 760 | - APPDATA_COMICS_MIME_TYPES=$(echo "<mimetype>$COMICS_MIME_TYPES</mimetype>" | sed -e 's/;/<\/mimetype>\n <mimetype>/g') |
| 761 | - if test -z "$EVINCE_MIME_TYPES"; then |
| 762 | - EVINCE_MIME_TYPES="${COMICS_MIME_TYPES}" |
| 763 | - else |
| 764 | - EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES};${COMICS_MIME_TYPES}" |
| 765 | - fi |
| 766 | -fi |
| 767 | -AC_SUBST(COMICS_MIME_TYPES) |
| 768 | -AC_SUBST(APPDATA_COMICS_MIME_TYPES) |
| 769 | -AM_SUBST_NOTMAKE(APPDATA_COMICS_MIME_TYPES) |
| 770 | -if test "x$enable_xps" = "xyes"; then |
| 771 | - XPS_MIME_TYPES="application/oxps;application/vnd.ms-xpsdocument" |
| 772 | - APPDATA_XPS_MIME_TYPES=$(echo "<mimetype>$XPS_MIME_TYPES</mimetype>" | sed -e 's/;/<\/mimetype>\n <mimetype>/g') |
| 773 | - if test -z "$EVINCE_MIME_TYPES"; then |
| 774 | - EVINCE_MIME_TYPES="${XPS_MIME_TYPES}" |
| 775 | - else |
| 776 | - EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES};${XPS_MIME_TYPES}" |
| 777 | - fi |
| 778 | -fi |
| 779 | -AC_SUBST(XPS_MIME_TYPES) |
| 780 | -AC_SUBST(APPDATA_XPS_MIME_TYPES) |
| 781 | -AM_SUBST_NOTMAKE(APPDATA_XPS_MIME_TYPES) |
| 782 | - |
| 783 | -AC_SUBST(EVINCE_MIME_TYPES) |
| 784 | - |
| 785 | -AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system])) |
| 786 | - |
| 787 | -# ***************** |
| 788 | -# Help files |
| 789 | -# ***************** |
| 790 | - |
| 791 | -YELP_HELP_INIT |
| 792 | - |
| 793 | -# ***************** |
| 794 | -# API documentation |
| 795 | -# ***************** |
| 796 | - |
| 797 | -GTK_DOC_CHECK([1.13],[--flavour no-tmpl]) |
| 798 | - |
| 799 | -AC_SUBST([GLIB_PREFIX],[$($PKG_CONFIG --variable=prefix glib-2.0)]) |
| 800 | -AC_SUBST([GTK_PREFIX],[$($PKG_CONFIG --variable=prefix gtk+-3.0)]) |
| 801 | - |
| 802 | -# ****************** |
| 803 | -# Backends directory |
| 804 | -# ****************** |
| 805 | - |
| 806 | -AC_SUBST([backenddir],"\$(libdir)/evince/ev_binary_version/backends") |
| 807 | -AC_SUBST([backend_binary_version],"ev_binary_version") |
| 808 | - |
| 809 | -# ********** |
| 810 | -# Versioning |
| 811 | -# ********** |
| 812 | - |
| 813 | -AC_SUBST([EV_MAJOR_VERSION],[ev_major_version]) |
| 814 | -AC_SUBST([EV_MINOR_VERSION],[ev_minor_version]) |
| 815 | -AC_SUBST([EV_MICRO_VERSION],[ev_micro_version]) |
| 816 | - |
| 817 | -AC_SUBST([EV_API_VERSION],[ev_api_version]) |
| 818 | -AC_SUBST([EV_API_VERSION_U],[AS_TR_SH([ev_api_version])]) |
| 819 | -AC_SUBST([EV_BINARY_VERSION],[ev_binary_version]) |
| 820 | - |
| 821 | -AC_SUBST([EV_DOCUMENT_LT_VERSION_INFO],[ev_document_lt_version_info]) |
| 822 | -AC_SUBST([EV_DOCUMENT_LT_CURRENT_MINUS_AGE],[ev_document_lt_current_minus_age]) |
| 823 | -AC_SUBST([EV_VIEW_LT_VERSION_INFO],[ev_view_lt_version_info]) |
| 824 | -AC_SUBST([EV_VIEW_LT_CURRENT_MINUS_AGE],[ev_view_lt_current_minus_age]) |
| 825 | - |
| 826 | -AC_SUBST([AM_CPPFLAGS]) |
| 827 | -AC_SUBST([AM_CFLAGS]) |
| 828 | -AC_SUBST([AM_CXXFLAGS]) |
| 829 | -AC_SUBST([AM_LDFLAGS]) |
| 830 | - |
| 831 | -# ***************************************************************************** |
| 832 | -# ***************************************************************************** |
| 833 | - |
| 834 | -AC_CONFIG_FILES([ |
| 835 | -backend/Makefile |
| 836 | -backend/comics/comicsdocument.evince-backend.in |
| 837 | -backend/comics/evince-comicsdocument.metainfo.xml.in |
| 838 | -backend/comics/Makefile |
| 839 | -backend/djvu/djvudocument.evince-backend.in |
| 840 | -backend/djvu/evince-djvudocument.metainfo.xml.in |
| 841 | -backend/djvu/Makefile |
| 842 | -backend/dvi/dvidocument.evince-backend.in |
| 843 | -backend/dvi/evince-dvidocument.metainfo.xml.in |
| 844 | -backend/dvi/Makefile |
| 845 | -backend/dvi/mdvi-lib/Makefile |
| 846 | -backend/pdf/evince-pdfdocument.metainfo.xml.in |
| 847 | -backend/pdf/pdfdocument.evince-backend.in |
| 848 | -backend/pdf/Makefile |
| 849 | -backend/ps/evince-psdocument.metainfo.xml.in |
| 850 | -backend/ps/psdocument.evince-backend.in |
| 851 | -backend/ps/Makefile |
| 852 | -backend/tiff/evince-tiffdocument.metainfo.xml.in |
| 853 | -backend/tiff/tiffdocument.evince-backend.in |
| 854 | -backend/tiff/Makefile |
| 855 | -backend/xps/evince-xpsdocument.metainfo.xml.in |
| 856 | -backend/xps/xpsdocument.evince-backend.in |
| 857 | -backend/xps/Makefile |
| 858 | -browser-plugin/Makefile |
| 859 | -cut-n-paste/Makefile |
| 860 | -cut-n-paste/gimpcellrenderertoggle/Makefile |
| 861 | -cut-n-paste/synctex/Makefile |
| 862 | -cut-n-paste/libgd/Makefile |
| 863 | -data/evince.desktop.in |
| 864 | -data/evince-previewer.desktop.in |
| 865 | -data/Makefile |
| 866 | -data/icons/Makefile |
| 867 | -data/icons/16x16/Makefile |
| 868 | -data/icons/16x16/apps/Makefile |
| 869 | -data/icons/16x16/actions/Makefile |
| 870 | -data/icons/16x16/mimetypes/Makefile |
| 871 | -data/icons/22x22/Makefile |
| 872 | -data/icons/22x22/apps/Makefile |
| 873 | -data/icons/22x22/actions/Makefile |
| 874 | -data/icons/22x22/mimetypes/Makefile |
| 875 | -data/icons/24x24/Makefile |
| 876 | -data/icons/24x24/apps/Makefile |
| 877 | -data/icons/24x24/actions/Makefile |
| 878 | -data/icons/24x24/mimetypes/Makefile |
| 879 | -data/icons/32x32/Makefile |
| 880 | -data/icons/32x32/actions/Makefile |
| 881 | -data/icons/32x32/mimetypes/Makefile |
| 882 | -data/icons/48x48/Makefile |
| 883 | -data/icons/48x48/apps/Makefile |
| 884 | -data/icons/48x48/actions/Makefile |
| 885 | -data/icons/256x256/Makefile |
| 886 | -data/icons/256x256/apps/Makefile |
| 887 | -data/icons/scalable/Makefile |
| 888 | -data/icons/scalable/actions/Makefile |
| 889 | -data/icons/scalable/mimetypes/Makefile |
| 890 | -help/Makefile |
| 891 | -help/reference/Makefile |
| 892 | -help/reference/libdocument/Makefile |
| 893 | -help/reference/libdocument/version.xml |
| 894 | -help/reference/libview/Makefile |
| 895 | -help/reference/libview/version.xml |
| 896 | -help/reference/shell/Makefile |
| 897 | -help/reference/shell/version.xml |
| 898 | -libdocument/Makefile |
| 899 | -libdocument/ev-version.h |
| 900 | -libmisc/Makefile |
| 901 | -libview/Makefile |
| 902 | -Makefile |
| 903 | -po/Makefile.in |
| 904 | -previewer/Makefile |
| 905 | -properties/Makefile |
| 906 | -shell/Makefile |
| 907 | -thumbnailer/Makefile |
| 908 | -]) |
| 909 | - |
| 910 | -AC_CONFIG_FILES(evince-document-[]ev_api_version[].pc:evince-document.pc.in) |
| 911 | -AC_CONFIG_FILES(evince-view-[]ev_api_version[].pc:evince-view.pc.in) |
| 912 | - |
| 913 | -AC_OUTPUT |
| 914 | - |
| 915 | -AC_MSG_NOTICE([ |
| 916 | - |
| 917 | -Evince configure summary |
| 918 | -======================== |
| 919 | - |
| 920 | -Platform .................: $with_platform |
| 921 | -Debug mode ...............: $enable_debug |
| 922 | - |
| 923 | - |
| 924 | -FRONTENDS |
| 925 | - |
| 926 | -Viewer ...................: $enable_viewer |
| 927 | -Previewer ................: $enable_previewer |
| 928 | -Thumbnailer ..............: $enable_thumbnailer |
| 929 | -Nautilus Extensions.......: $enable_nautilus |
| 930 | -Browser Plugin............: $enable_browser_plugin |
| 931 | - |
| 932 | - |
| 933 | -BACKENDS |
| 934 | - |
| 935 | -PDF ......................: $enable_pdf |
| 936 | -PostScript ...............: $enable_ps |
| 937 | -TIFF .....................: $enable_tiff |
| 938 | -DJVU .....................: $enable_djvu |
| 939 | -DVI ......................: $enable_dvi |
| 940 | -Comics ...................: $enable_comics |
| 941 | -XPS ......................: $enable_xps |
| 942 | - |
| 943 | - |
| 944 | -FEATURES |
| 945 | - |
| 946 | -GTK Doc reference ........: $enable_gtk_doc |
| 947 | -GObject Introspection ....: $enable_introspection |
| 948 | -DBUS communication .......: $enable_dbus |
| 949 | -Keyring integration ......: $with_keyring |
| 950 | -GTK+ Unix Print ..........: $with_gtk_unix_print |
| 951 | -Thumbnail cache ..........: $enable_gnome_desktop |
| 952 | - |
| 953 | -]) |
| 954 | |
| 955 | === removed directory '.pc/11_grip_gestures.patch/libview' |
| 956 | === removed file '.pc/11_grip_gestures.patch/libview/ev-view-private.h' |
| 957 | --- .pc/11_grip_gestures.patch/libview/ev-view-private.h 2014-09-15 12:46:26 +0000 |
| 958 | +++ .pc/11_grip_gestures.patch/libview/ev-view-private.h 1970-01-01 00:00:00 +0000 |
| 959 | @@ -1,312 +0,0 @@ |
| 960 | -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ |
| 961 | -/* this file is part of evince, a gnome document viewer |
| 962 | - * |
| 963 | - * Copyright (C) 2004 Red Hat, Inc |
| 964 | - * |
| 965 | - * Evince is free software; you can redistribute it and/or modify it |
| 966 | - * under the terms of the GNU General Public License as published by |
| 967 | - * the Free Software Foundation; either version 2 of the License, or |
| 968 | - * (at your option) any later version. |
| 969 | - * |
| 970 | - * Evince is distributed in the hope that it will be useful, but |
| 971 | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 972 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 973 | - * General Public License for more details. |
| 974 | - * |
| 975 | - * You should have received a copy of the GNU General Public License |
| 976 | - * along with this program; if not, write to the Free Software |
| 977 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 978 | - */ |
| 979 | - |
| 980 | -#if !defined (EVINCE_COMPILATION) |
| 981 | -#error "This is a private header." |
| 982 | -#endif |
| 983 | - |
| 984 | -#ifndef __EV_VIEW_PRIVATE_H__ |
| 985 | -#define __EV_VIEW_PRIVATE_H__ |
| 986 | - |
| 987 | -#include "ev-view.h" |
| 988 | -#include "ev-document-model.h" |
| 989 | -#include "ev-pixbuf-cache.h" |
| 990 | -#include "ev-page-cache.h" |
| 991 | -#include "ev-jobs.h" |
| 992 | -#include "ev-image.h" |
| 993 | -#include "ev-form-field.h" |
| 994 | -#include "ev-selection.h" |
| 995 | -#include "ev-view-cursor.h" |
| 996 | - |
| 997 | -#define DRAG_HISTORY 10 |
| 998 | - |
| 999 | -/* Information for middle clicking and moving around the doc */ |
| 1000 | -typedef struct { |
| 1001 | - gboolean in_drag; |
| 1002 | - GdkPoint start; |
| 1003 | - gdouble hadj; |
| 1004 | - gdouble vadj; |
| 1005 | - guint drag_timeout_id; |
| 1006 | - guint release_timeout_id; |
| 1007 | - GdkPoint buffer[DRAG_HISTORY]; |
| 1008 | - GdkPoint momentum; |
| 1009 | -} DragInfo; |
| 1010 | - |
| 1011 | -/* Autoscrolling */ |
| 1012 | -typedef struct { |
| 1013 | - gboolean autoscrolling; |
| 1014 | - guint last_y; |
| 1015 | - guint start_y; |
| 1016 | - guint timeout_id; |
| 1017 | -} AutoScrollInfo; |
| 1018 | - |
| 1019 | -/* Information for handling selection */ |
| 1020 | -typedef struct { |
| 1021 | - gboolean in_drag; |
| 1022 | - GdkPoint start; |
| 1023 | - GList *selections; |
| 1024 | - EvSelectionStyle style; |
| 1025 | -} SelectionInfo; |
| 1026 | - |
| 1027 | -/* Information for handling images DND */ |
| 1028 | -typedef struct { |
| 1029 | - gboolean in_drag; |
| 1030 | - GdkPoint start; |
| 1031 | - EvImage *image; |
| 1032 | -} ImageDNDInfo; |
| 1033 | - |
| 1034 | -typedef enum { |
| 1035 | - EV_PAN_ACTION_NONE, |
| 1036 | - EV_PAN_ACTION_NEXT, |
| 1037 | - EV_PAN_ACTION_PREV |
| 1038 | -} EvPanAction; |
| 1039 | - |
| 1040 | -/* Annotation popup windows */ |
| 1041 | -typedef struct { |
| 1042 | - GtkWidget *window; |
| 1043 | - guint page; |
| 1044 | - |
| 1045 | - /* Current position */ |
| 1046 | - gint x; |
| 1047 | - gint y; |
| 1048 | - |
| 1049 | - /* EvView root position */ |
| 1050 | - gint parent_x; |
| 1051 | - gint parent_y; |
| 1052 | - |
| 1053 | - /* Document coords */ |
| 1054 | - gdouble orig_x; |
| 1055 | - gdouble orig_y; |
| 1056 | - |
| 1057 | - gboolean visible; |
| 1058 | - gboolean moved; |
| 1059 | -} EvViewWindowChild; |
| 1060 | - |
| 1061 | -typedef enum { |
| 1062 | - SCROLL_TO_KEEP_POSITION, |
| 1063 | - SCROLL_TO_PAGE_POSITION, |
| 1064 | - SCROLL_TO_CENTER, |
| 1065 | - SCROLL_TO_FIND_LOCATION, |
| 1066 | -} PendingScroll; |
| 1067 | - |
| 1068 | -typedef struct _EvHeightToPageCache { |
| 1069 | - gint rotation; |
| 1070 | - gboolean dual_even_left; |
| 1071 | - gdouble *height_to_page; |
| 1072 | - gdouble *dual_height_to_page; |
| 1073 | -} EvHeightToPageCache; |
| 1074 | - |
| 1075 | -struct _EvView { |
| 1076 | - GtkContainer layout; |
| 1077 | - |
| 1078 | - /* Container */ |
| 1079 | - GList *children; |
| 1080 | - |
| 1081 | - EvDocument *document; |
| 1082 | - |
| 1083 | - /* Find */ |
| 1084 | - EvJobFind *find_job; |
| 1085 | - GList **find_pages; /* Backwards compatibility */ |
| 1086 | - gint find_page; |
| 1087 | - gint find_result; |
| 1088 | - gboolean jump_to_find_result; |
| 1089 | - gboolean highlight_find_results; |
| 1090 | - |
| 1091 | - EvDocumentModel *model; |
| 1092 | - EvPixbufCache *pixbuf_cache; |
| 1093 | - gsize pixbuf_cache_size; |
| 1094 | - EvPageCache *page_cache; |
| 1095 | - EvHeightToPageCache *height_to_page_cache; |
| 1096 | - EvViewCursor cursor; |
| 1097 | - EvJobRender *current_job; |
| 1098 | - |
| 1099 | - GtkRequisition requisition; |
| 1100 | - gboolean internal_size_request; |
| 1101 | - |
| 1102 | - /* Scrolling */ |
| 1103 | - GtkAdjustment *hadjustment; |
| 1104 | - GtkAdjustment *vadjustment; |
| 1105 | - /* GtkScrollablePolicy needs to be checked when |
| 1106 | - * driving the scrollable adjustment values */ |
| 1107 | - guint hscroll_policy : 1; |
| 1108 | - guint vscroll_policy : 1; |
| 1109 | - |
| 1110 | - gint scroll_x; |
| 1111 | - gint scroll_y; |
| 1112 | - |
| 1113 | - /* Delta sum for emulating normal scrolling */ |
| 1114 | - gdouble total_delta; |
| 1115 | - PendingScroll pending_scroll; |
| 1116 | - gboolean pending_resize; |
| 1117 | - EvPoint pending_point; |
| 1118 | - |
| 1119 | - /* Current geometry */ |
| 1120 | - |
| 1121 | - gint start_page; |
| 1122 | - gint end_page; |
| 1123 | - gint current_page; |
| 1124 | - |
| 1125 | - gint rotation; |
| 1126 | - gdouble scale; |
| 1127 | - gint spacing; |
| 1128 | - |
| 1129 | - gboolean loading; |
| 1130 | - gboolean can_zoom_in; |
| 1131 | - gboolean can_zoom_out; |
| 1132 | - gboolean continuous; |
| 1133 | - gboolean dual_even_left; |
| 1134 | - gboolean fullscreen; |
| 1135 | - EvSizingMode sizing_mode; |
| 1136 | - EvPageLayout page_layout; |
| 1137 | - GtkWidget *loading_window; |
| 1138 | - guint loading_timeout; |
| 1139 | - gboolean allow_links_change_zoom; |
| 1140 | - |
| 1141 | - /* Common for button press handling */ |
| 1142 | - int pressed_button; |
| 1143 | - |
| 1144 | - /* Key bindings propagation */ |
| 1145 | - gboolean key_binding_handled; |
| 1146 | - |
| 1147 | - /* Information for middle clicking and dragging around. */ |
| 1148 | - DragInfo drag_info; |
| 1149 | - |
| 1150 | - /* Autoscrolling */ |
| 1151 | - AutoScrollInfo scroll_info; |
| 1152 | - |
| 1153 | - /* Selection */ |
| 1154 | - GdkPoint motion; |
| 1155 | - guint selection_update_id; |
| 1156 | - guint selection_scroll_id; |
| 1157 | - |
| 1158 | - SelectionInfo selection_info; |
| 1159 | - |
| 1160 | - /* Copy link address selection */ |
| 1161 | - EvLinkAction *link_selected; |
| 1162 | - |
| 1163 | - /* Image DND */ |
| 1164 | - ImageDNDInfo image_dnd_info; |
| 1165 | - |
| 1166 | - /* Annotations */ |
| 1167 | - GList *window_children; |
| 1168 | - EvViewWindowChild *window_child_focus; |
| 1169 | - gboolean adding_annot; |
| 1170 | - EvAnnotationType adding_annot_type; |
| 1171 | - |
| 1172 | - /* Focus */ |
| 1173 | - EvMapping *focused_element; |
| 1174 | - guint focused_element_page; |
| 1175 | - guint child_focus_idle_id; |
| 1176 | - |
| 1177 | - /* Synctex */ |
| 1178 | - EvMapping *synctex_result; |
| 1179 | - |
| 1180 | - /* Accessibility */ |
| 1181 | - AtkObject *accessible; |
| 1182 | - |
| 1183 | - /* Caret navigation */ |
| 1184 | - gboolean caret_enabled; |
| 1185 | - gint cursor_offset; |
| 1186 | - gint cursor_page; |
| 1187 | - gdouble cursor_line_offset; |
| 1188 | - gboolean cursor_visible; |
| 1189 | - guint cursor_blink_timeout_id; |
| 1190 | - guint cursor_blink_time; |
| 1191 | - |
| 1192 | - /* Gestures */ |
| 1193 | - GtkGesture *pan_gesture; |
| 1194 | - GtkGesture *zoom_gesture; |
| 1195 | - gdouble prev_zoom_gesture_scale; |
| 1196 | - EvPanAction pan_action; |
| 1197 | -}; |
| 1198 | - |
| 1199 | -struct _EvViewClass { |
| 1200 | - GtkContainerClass parent_class; |
| 1201 | - |
| 1202 | - void (*scroll) (EvView *view, |
| 1203 | - GtkScrollType scroll, |
| 1204 | - GtkOrientation orientation); |
| 1205 | - void (*handle_link) (EvView *view, |
| 1206 | - EvLink *link); |
| 1207 | - void (*external_link) (EvView *view, |
| 1208 | - EvLinkAction *action); |
| 1209 | - void (*popup_menu) (EvView *view, |
| 1210 | - GList *items); |
| 1211 | - void (*selection_changed) (EvView *view); |
| 1212 | - void (*sync_source) (EvView *view, |
| 1213 | - EvSourceLink *link); |
| 1214 | - void (*annot_added) (EvView *view, |
| 1215 | - EvAnnotation *annot); |
| 1216 | - void (*annot_removed) (EvView *view, |
| 1217 | - EvAnnotation *annot); |
| 1218 | - void (*layers_changed) (EvView *view); |
| 1219 | - gboolean (*move_cursor) (EvView *view, |
| 1220 | - GtkMovementStep step, |
| 1221 | - gint count, |
| 1222 | - gboolean extend_selection); |
| 1223 | - void (*activate) (EvView *view); |
| 1224 | -}; |
| 1225 | - |
| 1226 | -void _get_page_size_for_scale_and_rotation (EvDocument *document, |
| 1227 | - gint page, |
| 1228 | - gdouble scale, |
| 1229 | - gint rotation, |
| 1230 | - gint *page_width, |
| 1231 | - gint *page_height); |
| 1232 | -void _ev_view_transform_view_point_to_doc_point (EvView *view, |
| 1233 | - GdkPoint *view_point, |
| 1234 | - GdkRectangle *page_area, |
| 1235 | - GtkBorder *border, |
| 1236 | - double *doc_point_x, |
| 1237 | - double *doc_point_y); |
| 1238 | -void _ev_view_transform_view_rect_to_doc_rect (EvView *view, |
| 1239 | - GdkRectangle *view_rect, |
| 1240 | - GdkRectangle *page_area, |
| 1241 | - GtkBorder *border, |
| 1242 | - EvRectangle *doc_rect); |
| 1243 | -void _ev_view_transform_doc_point_to_view_point (EvView *view, |
| 1244 | - int page, |
| 1245 | - EvPoint *doc_point, |
| 1246 | - GdkPoint *view_point); |
| 1247 | -void _ev_view_transform_doc_rect_to_view_rect (EvView *view, |
| 1248 | - int page, |
| 1249 | - EvRectangle *doc_rect, |
| 1250 | - GdkRectangle *view_rect); |
| 1251 | -void _ev_view_get_selection_colors (EvView *view, |
| 1252 | - GdkRGBA *bg_color, |
| 1253 | - GdkRGBA *fg_color); |
| 1254 | -gint _ev_view_get_caret_cursor_offset_at_doc_point (EvView *view, |
| 1255 | - gint page, |
| 1256 | - gdouble doc_x, |
| 1257 | - gdouble doc_y); |
| 1258 | - |
| 1259 | -void _ev_view_clear_selection (EvView *view); |
| 1260 | -void _ev_view_set_selection (EvView *view, |
| 1261 | - GdkPoint *start_point, |
| 1262 | - GdkPoint *end_point); |
| 1263 | - |
| 1264 | -void _ev_view_set_focused_element (EvView *view, |
| 1265 | - EvMapping *element_mapping, |
| 1266 | - gint page); |
| 1267 | -void _ev_view_focus_form_field (EvView *view, |
| 1268 | - EvFormField *field); |
| 1269 | - |
| 1270 | -#endif /* __EV_VIEW_PRIVATE_H__ */ |
| 1271 | - |
| 1272 | |
| 1273 | === removed file '.pc/11_grip_gestures.patch/libview/ev-view.c' |
| 1274 | --- .pc/11_grip_gestures.patch/libview/ev-view.c 2014-09-15 12:46:26 +0000 |
| 1275 | +++ .pc/11_grip_gestures.patch/libview/ev-view.c 1970-01-01 00:00:00 +0000 |
| 1276 | @@ -1,8917 +0,0 @@ |
| 1277 | -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ |
| 1278 | -/* this file is part of evince, a gnome document viewer |
| 1279 | - * |
| 1280 | - * Copyright (C) 2004 Red Hat, Inc |
| 1281 | - * |
| 1282 | - * Evince is free software; you can redistribute it and/or modify it |
| 1283 | - * under the terms of the GNU General Public License as published by |
| 1284 | - * the Free Software Foundation; either version 2 of the License, or |
| 1285 | - * (at your option) any later version. |
| 1286 | - * |
| 1287 | - * Evince is distributed in the hope that it will be useful, but |
| 1288 | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1289 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 1290 | - * General Public License for more details. |
| 1291 | - * |
| 1292 | - * You should have received a copy of the GNU General Public License |
| 1293 | - * along with this program; if not, write to the Free Software |
| 1294 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 1295 | - */ |
| 1296 | - |
| 1297 | -#include "config.h" |
| 1298 | - |
| 1299 | -#include <stdlib.h> |
| 1300 | -#include <math.h> |
| 1301 | -#include <string.h> |
| 1302 | - |
| 1303 | -#include <glib/gi18n-lib.h> |
| 1304 | -#include <gtk/gtk.h> |
| 1305 | -#include <gdk/gdkkeysyms.h> |
| 1306 | - |
| 1307 | -#include "ev-mapping-list.h" |
| 1308 | -#include "ev-document-forms.h" |
| 1309 | -#include "ev-document-images.h" |
| 1310 | -#include "ev-document-links.h" |
| 1311 | -#include "ev-document-layers.h" |
| 1312 | -#include "ev-document-misc.h" |
| 1313 | -#include "ev-pixbuf-cache.h" |
| 1314 | -#include "ev-page-cache.h" |
| 1315 | -#include "ev-view-marshal.h" |
| 1316 | -#include "ev-document-annotations.h" |
| 1317 | -#include "ev-annotation-window.h" |
| 1318 | -#include "ev-view.h" |
| 1319 | -#include "ev-view-accessible.h" |
| 1320 | -#include "ev-view-private.h" |
| 1321 | -#include "ev-view-type-builtins.h" |
| 1322 | -#include "ev-debug.h" |
| 1323 | - |
| 1324 | -enum { |
| 1325 | - SIGNAL_SCROLL, |
| 1326 | - SIGNAL_HANDLE_LINK, |
| 1327 | - SIGNAL_EXTERNAL_LINK, |
| 1328 | - SIGNAL_POPUP_MENU, |
| 1329 | - SIGNAL_SELECTION_CHANGED, |
| 1330 | - SIGNAL_SYNC_SOURCE, |
| 1331 | - SIGNAL_ANNOT_ADDED, |
| 1332 | - SIGNAL_ANNOT_REMOVED, |
| 1333 | - SIGNAL_LAYERS_CHANGED, |
| 1334 | - SIGNAL_MOVE_CURSOR, |
| 1335 | - SIGNAL_CURSOR_MOVED, |
| 1336 | - SIGNAL_ACTIVATE, |
| 1337 | - N_SIGNALS |
| 1338 | -}; |
| 1339 | - |
| 1340 | -enum { |
| 1341 | - TARGET_DND_URI, |
| 1342 | - TARGET_DND_TEXT, |
| 1343 | - TARGET_DND_IMAGE |
| 1344 | -}; |
| 1345 | - |
| 1346 | -enum { |
| 1347 | - PROP_0, |
| 1348 | - PROP_IS_LOADING, |
| 1349 | - PROP_HADJUSTMENT, |
| 1350 | - PROP_VADJUSTMENT, |
| 1351 | - PROP_HSCROLL_POLICY, |
| 1352 | - PROP_VSCROLL_POLICY, |
| 1353 | - PROP_CAN_ZOOM_IN, |
| 1354 | - PROP_CAN_ZOOM_OUT |
| 1355 | -}; |
| 1356 | - |
| 1357 | -static guint signals[N_SIGNALS]; |
| 1358 | - |
| 1359 | -typedef enum { |
| 1360 | - EV_VIEW_FIND_NEXT, |
| 1361 | - EV_VIEW_FIND_PREV |
| 1362 | -} EvViewFindDirection; |
| 1363 | - |
| 1364 | -typedef struct { |
| 1365 | - GtkWidget *widget; |
| 1366 | - |
| 1367 | - /* View coords */ |
| 1368 | - gint x; |
| 1369 | - gint y; |
| 1370 | - |
| 1371 | - /* Document */ |
| 1372 | - guint page; |
| 1373 | - EvRectangle doc_rect; |
| 1374 | -} EvViewChild; |
| 1375 | - |
| 1376 | -#define MIN_SCALE 0.2 |
| 1377 | -#define ZOOM_IN_FACTOR 1.2 |
| 1378 | -#define ZOOM_OUT_FACTOR (1.0/ZOOM_IN_FACTOR) |
| 1379 | - |
| 1380 | -#define SCROLL_TIME 150 |
| 1381 | - |
| 1382 | -#define DEFAULT_PIXBUF_CACHE_SIZE 52428800 /* 50MB */ |
| 1383 | - |
| 1384 | -#define EV_STYLE_CLASS_DOCUMENT_PAGE "document-page" |
| 1385 | -#define EV_STYLE_CLASS_INVERTED "inverted" |
| 1386 | - |
| 1387 | -/*** Scrolling ***/ |
| 1388 | -static void view_update_range_and_current_page (EvView *view); |
| 1389 | -static void ensure_rectangle_is_visible (EvView *view, |
| 1390 | - GdkRectangle *rect); |
| 1391 | - |
| 1392 | -/*** Geometry computations ***/ |
| 1393 | -static void compute_border (EvView *view, |
| 1394 | - GtkBorder *border); |
| 1395 | -static void get_page_y_offset (EvView *view, |
| 1396 | - int page, |
| 1397 | - int *y_offset); |
| 1398 | -static void find_page_at_location (EvView *view, |
| 1399 | - gdouble x, |
| 1400 | - gdouble y, |
| 1401 | - gint *page, |
| 1402 | - gint *x_offset, |
| 1403 | - gint *y_offset); |
| 1404 | -/*** Hyperrefs ***/ |
| 1405 | -static EvLink * ev_view_get_link_at_location (EvView *view, |
| 1406 | - gdouble x, |
| 1407 | - gdouble y); |
| 1408 | -static char* tip_from_link (EvView *view, |
| 1409 | - EvLink *link); |
| 1410 | -/*** Forms ***/ |
| 1411 | -static EvFormField *ev_view_get_form_field_at_location (EvView *view, |
| 1412 | - gdouble x, |
| 1413 | - gdouble y); |
| 1414 | - |
| 1415 | -/*** Annotations ***/ |
| 1416 | -static EvAnnotation *ev_view_get_annotation_at_location (EvView *view, |
| 1417 | - gdouble x, |
| 1418 | - gdouble y); |
| 1419 | -static void show_annotation_windows (EvView *view, |
| 1420 | - gint page); |
| 1421 | -static void hide_annotation_windows (EvView *view, |
| 1422 | - gint page); |
| 1423 | -/*** GtkWidget implementation ***/ |
| 1424 | -static void ev_view_size_request_continuous_dual_page (EvView *view, |
| 1425 | - GtkRequisition *requisition); |
| 1426 | -static void ev_view_size_request_continuous (EvView *view, |
| 1427 | - GtkRequisition *requisition); |
| 1428 | -static void ev_view_size_request_dual_page (EvView *view, |
| 1429 | - GtkRequisition *requisition); |
| 1430 | -static void ev_view_size_request_single_page (EvView *view, |
| 1431 | - GtkRequisition *requisition); |
| 1432 | -static void ev_view_size_request (GtkWidget *widget, |
| 1433 | - GtkRequisition *requisition); |
| 1434 | -static void ev_view_size_allocate (GtkWidget *widget, |
| 1435 | - GtkAllocation *allocation); |
| 1436 | -static gboolean ev_view_scroll_event (GtkWidget *widget, |
| 1437 | - GdkEventScroll *event); |
| 1438 | -static gboolean ev_view_draw (GtkWidget *widget, |
| 1439 | - cairo_t *cr); |
| 1440 | -static gboolean ev_view_popup_menu (GtkWidget *widget); |
| 1441 | -static gboolean ev_view_button_press_event (GtkWidget *widget, |
| 1442 | - GdkEventButton *event); |
| 1443 | -static gboolean ev_view_motion_notify_event (GtkWidget *widget, |
| 1444 | - GdkEventMotion *event); |
| 1445 | -static gboolean ev_view_button_release_event (GtkWidget *widget, |
| 1446 | - GdkEventButton *event); |
| 1447 | -static gboolean ev_view_enter_notify_event (GtkWidget *widget, |
| 1448 | - GdkEventCrossing *event); |
| 1449 | -static gboolean ev_view_leave_notify_event (GtkWidget *widget, |
| 1450 | - GdkEventCrossing *event); |
| 1451 | -static void ev_view_style_updated (GtkWidget *widget); |
| 1452 | -static void ev_view_remove_all (EvView *view); |
| 1453 | - |
| 1454 | -static AtkObject *ev_view_get_accessible (GtkWidget *widget); |
| 1455 | - |
| 1456 | -/*** Drawing ***/ |
| 1457 | -static void highlight_find_results (EvView *view, |
| 1458 | - cairo_t *cr, |
| 1459 | - int page); |
| 1460 | -static void highlight_forward_search_results (EvView *view, |
| 1461 | - cairo_t *cr, |
| 1462 | - int page); |
| 1463 | -static void draw_one_page (EvView *view, |
| 1464 | - gint page, |
| 1465 | - cairo_t *cr, |
| 1466 | - GdkRectangle *page_area, |
| 1467 | - GtkBorder *border, |
| 1468 | - GdkRectangle *expose_area, |
| 1469 | - gboolean *page_ready); |
| 1470 | -static void ev_view_reload_page (EvView *view, |
| 1471 | - gint page, |
| 1472 | - cairo_region_t *region); |
| 1473 | -/*** Callbacks ***/ |
| 1474 | -static void ev_view_change_page (EvView *view, |
| 1475 | - gint new_page); |
| 1476 | -static void job_finished_cb (EvPixbufCache *pixbuf_cache, |
| 1477 | - cairo_region_t *region, |
| 1478 | - EvView *view); |
| 1479 | -static void ev_view_page_changed_cb (EvDocumentModel *model, |
| 1480 | - gint old_page, |
| 1481 | - gint new_page, |
| 1482 | - EvView *view); |
| 1483 | -static void on_adjustment_value_changed (GtkAdjustment *adjustment, |
| 1484 | - EvView *view); |
| 1485 | -/*** GObject ***/ |
| 1486 | -static void ev_view_finalize (GObject *object); |
| 1487 | -static void ev_view_dispose (GObject *object); |
| 1488 | -static void ev_view_class_init (EvViewClass *class); |
| 1489 | -static void ev_view_init (EvView *view); |
| 1490 | - |
| 1491 | -/*** Zoom and sizing ***/ |
| 1492 | -static double zoom_for_size_fit_width (gdouble doc_width, |
| 1493 | - gdouble doc_height, |
| 1494 | - int target_width, |
| 1495 | - int target_height); |
| 1496 | -static double zoom_for_size_fit_height (gdouble doc_width, |
| 1497 | - gdouble doc_height, |
| 1498 | - int target_width, |
| 1499 | - int target_height); |
| 1500 | -static double zoom_for_size_fit_page (gdouble doc_width, |
| 1501 | - gdouble doc_height, |
| 1502 | - int target_width, |
| 1503 | - int target_height); |
| 1504 | -static double zoom_for_size_automatic (GdkScreen *screen, |
| 1505 | - gdouble doc_width, |
| 1506 | - gdouble doc_height, |
| 1507 | - int target_width, |
| 1508 | - int target_height); |
| 1509 | -static void ev_view_zoom (EvView *view, |
| 1510 | - gdouble factor); |
| 1511 | -static void ev_view_zoom_for_size (EvView *view, |
| 1512 | - int width, |
| 1513 | - int height); |
| 1514 | -static void ev_view_zoom_for_size_continuous_and_dual_page (EvView *view, |
| 1515 | - int width, |
| 1516 | - int height); |
| 1517 | -static void ev_view_zoom_for_size_continuous (EvView *view, |
| 1518 | - int width, |
| 1519 | - int height); |
| 1520 | -static void ev_view_zoom_for_size_dual_page (EvView *view, |
| 1521 | - int width, |
| 1522 | - int height); |
| 1523 | -static void ev_view_zoom_for_size_single_page (EvView *view, |
| 1524 | - int width, |
| 1525 | - int height); |
| 1526 | -/*** Cursors ***/ |
| 1527 | -static void ev_view_set_cursor (EvView *view, |
| 1528 | - EvViewCursor new_cursor); |
| 1529 | -static void ev_view_handle_cursor_over_xy (EvView *view, |
| 1530 | - gint x, |
| 1531 | - gint y); |
| 1532 | - |
| 1533 | -/*** Find ***/ |
| 1534 | -static gint ev_view_find_get_n_results (EvView *view, |
| 1535 | - gint page); |
| 1536 | -static EvRectangle *ev_view_find_get_result (EvView *view, |
| 1537 | - gint page, |
| 1538 | - gint result); |
| 1539 | -static void jump_to_find_result (EvView *view); |
| 1540 | -static void jump_to_find_page (EvView *view, |
| 1541 | - EvViewFindDirection direction, |
| 1542 | - gint shift); |
| 1543 | -/*** Selection ***/ |
| 1544 | -static void compute_selections (EvView *view, |
| 1545 | - EvSelectionStyle style, |
| 1546 | - GdkPoint *start, |
| 1547 | - GdkPoint *stop); |
| 1548 | -static void extend_selection (EvView *view, |
| 1549 | - GdkPoint *start, |
| 1550 | - GdkPoint *stop); |
| 1551 | -static void clear_selection (EvView *view); |
| 1552 | -static void clear_link_selected (EvView *view); |
| 1553 | -static void selection_free (EvViewSelection *selection); |
| 1554 | -static char* get_selected_text (EvView *ev_view); |
| 1555 | -static void ev_view_primary_get_cb (GtkClipboard *clipboard, |
| 1556 | - GtkSelectionData *selection_data, |
| 1557 | - guint info, |
| 1558 | - gpointer data); |
| 1559 | -static void ev_view_primary_clear_cb (GtkClipboard *clipboard, |
| 1560 | - gpointer data); |
| 1561 | -static void ev_view_update_primary_selection (EvView *ev_view); |
| 1562 | - |
| 1563 | -/*** Caret navigation ***/ |
| 1564 | -static void ev_view_check_cursor_blink (EvView *ev_view); |
| 1565 | - |
| 1566 | -G_DEFINE_TYPE_WITH_CODE (EvView, ev_view, GTK_TYPE_CONTAINER, |
| 1567 | - G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL)) |
| 1568 | - |
| 1569 | -/* HeightToPage cache */ |
| 1570 | -#define EV_HEIGHT_TO_PAGE_CACHE_KEY "ev-height-to-page-cache" |
| 1571 | - |
| 1572 | -static void |
| 1573 | -ev_view_build_height_to_page_cache (EvView *view, |
| 1574 | - EvHeightToPageCache *cache) |
| 1575 | -{ |
| 1576 | - gboolean swap, uniform; |
| 1577 | - int i; |
| 1578 | - double uniform_height, page_height, next_page_height; |
| 1579 | - double saved_height; |
| 1580 | - gdouble u_width, u_height; |
| 1581 | - gint n_pages; |
| 1582 | - EvDocument *document = view->document; |
| 1583 | - |
| 1584 | - swap = (view->rotation == 90 || view->rotation == 270); |
| 1585 | - |
| 1586 | - uniform = ev_document_is_page_size_uniform (document); |
| 1587 | - n_pages = ev_document_get_n_pages (document); |
| 1588 | - |
| 1589 | - g_free (cache->height_to_page); |
| 1590 | - g_free (cache->dual_height_to_page); |
| 1591 | - |
| 1592 | - cache->rotation = view->rotation; |
| 1593 | - cache->dual_even_left = view->dual_even_left; |
| 1594 | - cache->height_to_page = g_new0 (gdouble, n_pages + 1); |
| 1595 | - cache->dual_height_to_page = g_new0 (gdouble, n_pages + 2); |
| 1596 | - |
| 1597 | - if (uniform) |
| 1598 | - ev_document_get_page_size (document, 0, &u_width, &u_height); |
| 1599 | - |
| 1600 | - saved_height = 0; |
| 1601 | - for (i = 0; i <= n_pages; i++) { |
| 1602 | - if (uniform) { |
| 1603 | - uniform_height = swap ? u_width : u_height; |
| 1604 | - cache->height_to_page[i] = i * uniform_height; |
| 1605 | - } else { |
| 1606 | - if (i < n_pages) { |
| 1607 | - gdouble w, h; |
| 1608 | - |
| 1609 | - ev_document_get_page_size (document, i, &w, &h); |
| 1610 | - page_height = swap ? w : h; |
| 1611 | - } else { |
| 1612 | - page_height = 0; |
| 1613 | - } |
| 1614 | - cache->height_to_page[i] = saved_height; |
| 1615 | - saved_height += page_height; |
| 1616 | - } |
| 1617 | - } |
| 1618 | - |
| 1619 | - if (cache->dual_even_left && !uniform) { |
| 1620 | - gdouble w, h; |
| 1621 | - |
| 1622 | - ev_document_get_page_size (document, 0, &w, &h); |
| 1623 | - saved_height = swap ? w : h; |
| 1624 | - } else { |
| 1625 | - saved_height = 0; |
| 1626 | - } |
| 1627 | - |
| 1628 | - for (i = cache->dual_even_left; i < n_pages + 2; i += 2) { |
| 1629 | - if (uniform) { |
| 1630 | - uniform_height = swap ? u_width : u_height; |
| 1631 | - cache->dual_height_to_page[i] = ((i + cache->dual_even_left) / 2) * uniform_height; |
| 1632 | - if (i + 1 < n_pages + 2) |
| 1633 | - cache->dual_height_to_page[i + 1] = ((i + cache->dual_even_left) / 2) * uniform_height; |
| 1634 | - } else { |
| 1635 | - if (i + 1 < n_pages) { |
| 1636 | - gdouble w, h; |
| 1637 | - |
| 1638 | - ev_document_get_page_size (document, i + 1, &w, &h); |
| 1639 | - next_page_height = swap ? w : h; |
| 1640 | - } else { |
| 1641 | - next_page_height = 0; |
| 1642 | - } |
| 1643 | - |
| 1644 | - if (i < n_pages) { |
| 1645 | - gdouble w, h; |
| 1646 | - |
| 1647 | - ev_document_get_page_size (document, i, &w, &h); |
| 1648 | - page_height = swap ? w : h; |
| 1649 | - } else { |
| 1650 | - page_height = 0; |
| 1651 | - } |
| 1652 | - |
| 1653 | - if (i + 1 < n_pages + 2) { |
| 1654 | - cache->dual_height_to_page[i] = saved_height; |
| 1655 | - cache->dual_height_to_page[i + 1] = saved_height; |
| 1656 | - saved_height += MAX(page_height, next_page_height); |
| 1657 | - } else { |
| 1658 | - cache->dual_height_to_page[i] = saved_height; |
| 1659 | - } |
| 1660 | - } |
| 1661 | - } |
| 1662 | -} |
| 1663 | - |
| 1664 | -static void |
| 1665 | -ev_height_to_page_cache_free (EvHeightToPageCache *cache) |
| 1666 | -{ |
| 1667 | - if (cache->height_to_page) { |
| 1668 | - g_free (cache->height_to_page); |
| 1669 | - cache->height_to_page = NULL; |
| 1670 | - } |
| 1671 | - |
| 1672 | - if (cache->dual_height_to_page) { |
| 1673 | - g_free (cache->dual_height_to_page); |
| 1674 | - cache->dual_height_to_page = NULL; |
| 1675 | - } |
| 1676 | - g_free (cache); |
| 1677 | -} |
| 1678 | - |
| 1679 | -static EvHeightToPageCache * |
| 1680 | -ev_view_get_height_to_page_cache (EvView *view) |
| 1681 | -{ |
| 1682 | - EvHeightToPageCache *cache; |
| 1683 | - |
| 1684 | - if (!view->document) |
| 1685 | - return NULL; |
| 1686 | - |
| 1687 | - cache = g_object_get_data (G_OBJECT (view->document), EV_HEIGHT_TO_PAGE_CACHE_KEY); |
| 1688 | - if (!cache) { |
| 1689 | - cache = g_new0 (EvHeightToPageCache, 1); |
| 1690 | - ev_view_build_height_to_page_cache (view, cache); |
| 1691 | - g_object_set_data_full (G_OBJECT (view->document), |
| 1692 | - EV_HEIGHT_TO_PAGE_CACHE_KEY, |
| 1693 | - cache, |
| 1694 | - (GDestroyNotify)ev_height_to_page_cache_free); |
| 1695 | - } |
| 1696 | - |
| 1697 | - return cache; |
| 1698 | -} |
| 1699 | - |
| 1700 | -static void |
| 1701 | -ev_view_get_height_to_page (EvView *view, |
| 1702 | - gint page, |
| 1703 | - gint *height, |
| 1704 | - gint *dual_height) |
| 1705 | -{ |
| 1706 | - EvHeightToPageCache *cache = NULL; |
| 1707 | - gdouble h, dh; |
| 1708 | - |
| 1709 | - if (!view->height_to_page_cache) |
| 1710 | - return; |
| 1711 | - |
| 1712 | - cache = view->height_to_page_cache; |
| 1713 | - if (cache->rotation != view->rotation || |
| 1714 | - cache->dual_even_left != view->dual_even_left) { |
| 1715 | - ev_view_build_height_to_page_cache (view, cache); |
| 1716 | - } |
| 1717 | - h = cache->height_to_page[page]; |
| 1718 | - dh = cache->dual_height_to_page[page]; |
| 1719 | - |
| 1720 | - if (height) |
| 1721 | - *height = (gint)(h * view->scale + 0.5); |
| 1722 | - |
| 1723 | - if (dual_height) |
| 1724 | - *dual_height = (gint)(dh * view->scale + 0.5); |
| 1725 | -} |
| 1726 | - |
| 1727 | -static gint |
| 1728 | -ev_view_get_scrollbar_size (EvView *view, |
| 1729 | - GtkOrientation orientation) |
| 1730 | -{ |
| 1731 | - GtkWidget *widget = GTK_WIDGET (view); |
| 1732 | - GtkWidget *sb; |
| 1733 | - GtkWidget *swindow = gtk_widget_get_parent (GTK_WIDGET (view)); |
| 1734 | - GtkAllocation allocation; |
| 1735 | - GtkRequisition req; |
| 1736 | - gint spacing; |
| 1737 | - |
| 1738 | - if (!GTK_IS_SCROLLED_WINDOW (swindow)) |
| 1739 | - return 0; |
| 1740 | - |
| 1741 | - gtk_widget_get_allocation (widget, &allocation); |
| 1742 | - |
| 1743 | - if (orientation == GTK_ORIENTATION_VERTICAL) { |
| 1744 | - if (allocation.height >= view->requisition.height) |
| 1745 | - sb = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (swindow)); |
| 1746 | - else |
| 1747 | - return 0; |
| 1748 | - } else { |
| 1749 | - if (allocation.width >= view->requisition.width) |
| 1750 | - sb = gtk_scrolled_window_get_hscrollbar (GTK_SCROLLED_WINDOW (swindow)); |
| 1751 | - else |
| 1752 | - return 0; |
| 1753 | - } |
| 1754 | - |
| 1755 | - gtk_widget_style_get (swindow, "scrollbar_spacing", &spacing, NULL); |
| 1756 | - gtk_widget_get_preferred_size (sb, &req, NULL); |
| 1757 | - |
| 1758 | - return (orientation == GTK_ORIENTATION_VERTICAL ? req.width : req.height) + spacing; |
| 1759 | -} |
| 1760 | - |
| 1761 | -static gboolean |
| 1762 | -is_dual_page (EvView *view, |
| 1763 | - gboolean *odd_left_out) |
| 1764 | -{ |
| 1765 | - gboolean dual = FALSE; |
| 1766 | - gboolean odd_left = FALSE; |
| 1767 | - |
| 1768 | - switch (view->page_layout) { |
| 1769 | - case EV_PAGE_LAYOUT_AUTOMATIC: { |
| 1770 | - GdkScreen *screen; |
| 1771 | - double scale; |
| 1772 | - double doc_width; |
| 1773 | - double doc_height; |
| 1774 | - GtkAllocation allocation; |
| 1775 | - |
| 1776 | - screen = gtk_widget_get_screen (GTK_WIDGET (view)); |
| 1777 | - scale = ev_document_misc_get_screen_dpi (screen) / 72.0; |
| 1778 | - |
| 1779 | - ev_document_get_max_page_size (view->document, &doc_width, &doc_height); |
| 1780 | - gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); |
| 1781 | - |
| 1782 | - /* If the width is ok and the height is pretty close, try to fit it in */ |
| 1783 | - if (ev_document_get_n_pages (view->document) > 1 && |
| 1784 | - doc_width < doc_height && |
| 1785 | - allocation.width > (2 * doc_width * scale) && |
| 1786 | - allocation.height > (doc_height * scale * 0.9)) { |
| 1787 | - odd_left = !view->dual_even_left; |
| 1788 | - dual = TRUE; |
| 1789 | - } |
| 1790 | - } |
| 1791 | - break; |
| 1792 | - case EV_PAGE_LAYOUT_DUAL: |
| 1793 | - odd_left = !view->dual_even_left; |
| 1794 | - dual = TRUE; |
| 1795 | - break; |
| 1796 | - case EV_PAGE_LAYOUT_SINGLE: |
| 1797 | - break; |
| 1798 | - default: |
| 1799 | - g_assert_not_reached (); |
| 1800 | - } |
| 1801 | - |
| 1802 | - if (odd_left_out) |
| 1803 | - *odd_left_out = odd_left; |
| 1804 | - |
| 1805 | - return dual; |
| 1806 | -} |
| 1807 | - |
| 1808 | -static void |
| 1809 | -scroll_to_point (EvView *view, |
| 1810 | - gdouble x, |
| 1811 | - gdouble y, |
| 1812 | - GtkOrientation orientation) |
| 1813 | -{ |
| 1814 | - gdouble page_size; |
| 1815 | - gdouble upper, lower; |
| 1816 | - |
| 1817 | - if (orientation == GTK_ORIENTATION_VERTICAL) { |
| 1818 | - page_size = gtk_adjustment_get_page_size (view->vadjustment); |
| 1819 | - upper = gtk_adjustment_get_upper (view->vadjustment); |
| 1820 | - lower = gtk_adjustment_get_lower (view->vadjustment); |
| 1821 | - |
| 1822 | - if (view->continuous) { |
| 1823 | - gtk_adjustment_clamp_page (view->vadjustment, |
| 1824 | - y, y + page_size); |
| 1825 | - } else { |
| 1826 | - gtk_adjustment_set_value (view->vadjustment, |
| 1827 | - CLAMP (y, lower, upper - page_size)); |
| 1828 | - } |
| 1829 | - } else { |
| 1830 | - page_size = gtk_adjustment_get_page_size (view->hadjustment); |
| 1831 | - upper = gtk_adjustment_get_upper (view->hadjustment); |
| 1832 | - lower = gtk_adjustment_get_lower (view->hadjustment); |
| 1833 | - |
| 1834 | - if (is_dual_page (view, NULL)) { |
| 1835 | - gtk_adjustment_clamp_page (view->hadjustment, x, |
| 1836 | - x + page_size); |
| 1837 | - } else { |
| 1838 | - gtk_adjustment_set_value (view->hadjustment, |
| 1839 | - CLAMP (x, lower, upper - page_size)); |
| 1840 | - } |
| 1841 | - } |
| 1842 | -} |
| 1843 | - |
| 1844 | -static void |
| 1845 | -ev_view_scroll_to_page_position (EvView *view, GtkOrientation orientation) |
| 1846 | -{ |
| 1847 | - gdouble x, y; |
| 1848 | - |
| 1849 | - if (!view->document) |
| 1850 | - return; |
| 1851 | - |
| 1852 | - if ((orientation == GTK_ORIENTATION_VERTICAL && view->pending_point.y == 0) || |
| 1853 | - (orientation == GTK_ORIENTATION_HORIZONTAL && view->pending_point.x == 0)) { |
| 1854 | - GdkRectangle page_area; |
| 1855 | - GtkBorder border; |
| 1856 | - |
| 1857 | - ev_view_get_page_extents (view, view->current_page, &page_area, &border); |
| 1858 | - x = page_area.x; |
| 1859 | - y = page_area.y; |
| 1860 | - } else { |
| 1861 | - GdkPoint view_point; |
| 1862 | - |
| 1863 | - _ev_view_transform_doc_point_to_view_point (view, view->current_page, |
| 1864 | - &view->pending_point, &view_point); |
| 1865 | - x = view_point.x; |
| 1866 | - y = view_point.y; |
| 1867 | - } |
| 1868 | - |
| 1869 | - scroll_to_point (view, x, y, orientation); |
| 1870 | -} |
| 1871 | - |
| 1872 | -static void |
| 1873 | -ev_view_set_adjustment_values (EvView *view, |
| 1874 | - GtkOrientation orientation) |
| 1875 | -{ |
| 1876 | - GtkWidget *widget = GTK_WIDGET (view); |
| 1877 | - GtkAdjustment *adjustment; |
| 1878 | - GtkAllocation allocation; |
| 1879 | - int req_size; |
| 1880 | - int alloc_size; |
| 1881 | - gdouble page_size; |
| 1882 | - gdouble value; |
| 1883 | - gdouble upper; |
| 1884 | - double factor; |
| 1885 | - gint new_value; |
| 1886 | - |
| 1887 | - gtk_widget_get_allocation (widget, &allocation); |
| 1888 | - |
| 1889 | - if (orientation == GTK_ORIENTATION_HORIZONTAL) { |
| 1890 | - req_size = view->requisition.width; |
| 1891 | - alloc_size = allocation.width; |
| 1892 | - adjustment = view->hadjustment; |
| 1893 | - } else { |
| 1894 | - req_size = view->requisition.height; |
| 1895 | - alloc_size = allocation.height; |
| 1896 | - adjustment = view->vadjustment; |
| 1897 | - } |
| 1898 | - |
| 1899 | - if (!adjustment) |
| 1900 | - return; |
| 1901 | - |
| 1902 | - factor = 1.0; |
| 1903 | - value = gtk_adjustment_get_value (adjustment); |
| 1904 | - upper = gtk_adjustment_get_upper (adjustment); |
| 1905 | - page_size = gtk_adjustment_get_page_size (adjustment); |
| 1906 | - |
| 1907 | - if (upper != .0) { |
| 1908 | - switch (view->pending_scroll) { |
| 1909 | - case SCROLL_TO_KEEP_POSITION: |
| 1910 | - case SCROLL_TO_FIND_LOCATION: |
| 1911 | - factor = value / upper; |
| 1912 | - break; |
| 1913 | - case SCROLL_TO_PAGE_POSITION: |
| 1914 | - break; |
| 1915 | - case SCROLL_TO_CENTER: |
| 1916 | - factor = (value + page_size * 0.5) / upper; |
| 1917 | - break; |
| 1918 | - } |
| 1919 | - } |
| 1920 | - |
| 1921 | - upper = MAX (alloc_size, req_size); |
| 1922 | - page_size = alloc_size; |
| 1923 | - |
| 1924 | - gtk_adjustment_set_page_size (adjustment, page_size); |
| 1925 | - gtk_adjustment_set_step_increment (adjustment, alloc_size * 0.1); |
| 1926 | - gtk_adjustment_set_page_increment (adjustment, alloc_size * 0.9); |
| 1927 | - gtk_adjustment_set_lower (adjustment, 0); |
| 1928 | - gtk_adjustment_set_upper (adjustment, upper); |
| 1929 | - |
| 1930 | - /* |
| 1931 | - * We add 0.5 to the values before to average out our rounding errors. |
| 1932 | - */ |
| 1933 | - switch (view->pending_scroll) { |
| 1934 | - case SCROLL_TO_KEEP_POSITION: |
| 1935 | - case SCROLL_TO_FIND_LOCATION: |
| 1936 | - new_value = CLAMP (upper * factor + 0.5, 0, upper - page_size); |
| 1937 | - gtk_adjustment_set_value (adjustment, (int)new_value); |
| 1938 | - break; |
| 1939 | - case SCROLL_TO_PAGE_POSITION: |
| 1940 | - ev_view_scroll_to_page_position (view, orientation); |
| 1941 | - break; |
| 1942 | - case SCROLL_TO_CENTER: |
| 1943 | - new_value = CLAMP (upper * factor - page_size * 0.5 + 0.5, |
| 1944 | - 0, upper - page_size); |
| 1945 | - gtk_adjustment_set_value (adjustment, (int)new_value); |
| 1946 | - break; |
| 1947 | - } |
| 1948 | - |
| 1949 | - gtk_adjustment_changed (adjustment); |
| 1950 | -} |
| 1951 | - |
| 1952 | -static void |
| 1953 | -view_update_range_and_current_page (EvView *view) |
| 1954 | -{ |
| 1955 | - gint start = view->start_page; |
| 1956 | - gint end = view->end_page; |
| 1957 | - gboolean odd_left; |
| 1958 | - |
| 1959 | - if (ev_document_get_n_pages (view->document) <= 0 || |
| 1960 | - !ev_document_check_dimensions (view->document)) |
| 1961 | - return; |
| 1962 | - |
| 1963 | - if (view->continuous) { |
| 1964 | - GdkRectangle current_area, unused, page_area; |
| 1965 | - GtkBorder border; |
| 1966 | - gboolean found = FALSE; |
| 1967 | - gint area_max = -1, area; |
| 1968 | - gint best_current_page = -1; |
| 1969 | - int i, j = 0; |
| 1970 | - |
| 1971 | - if (!(view->vadjustment && view->hadjustment)) |
| 1972 | - return; |
| 1973 | - |
| 1974 | - current_area.x = gtk_adjustment_get_value (view->hadjustment); |
| 1975 | - current_area.width = gtk_adjustment_get_page_size (view->hadjustment); |
| 1976 | - current_area.y = gtk_adjustment_get_value (view->vadjustment); |
| 1977 | - current_area.height = gtk_adjustment_get_page_size (view->vadjustment); |
| 1978 | - |
| 1979 | - for (i = 0; i < ev_document_get_n_pages (view->document); i++) { |
| 1980 | - |
| 1981 | - ev_view_get_page_extents (view, i, &page_area, &border); |
| 1982 | - |
| 1983 | - if (gdk_rectangle_intersect (¤t_area, &page_area, &unused)) { |
| 1984 | - area = unused.width * unused.height; |
| 1985 | - |
| 1986 | - if (!found) { |
| 1987 | - area_max = area; |
| 1988 | - view->start_page = i; |
| 1989 | - found = TRUE; |
| 1990 | - best_current_page = i; |
| 1991 | - } |
| 1992 | - if (area > area_max) { |
| 1993 | - best_current_page = (area == area_max) ? MIN (i, best_current_page) : i; |
| 1994 | - area_max = area; |
| 1995 | - } |
| 1996 | - |
| 1997 | - view->end_page = i; |
| 1998 | - j = 0; |
| 1999 | - } else if (found && view->current_page <= view->end_page) { |
| 2000 | - if (is_dual_page (view, NULL) && j < 1) { |
| 2001 | - /* In dual mode we stop searching |
| 2002 | - * after two consecutive non-visible pages. |
| 2003 | - */ |
| 2004 | - j++; |
| 2005 | - continue; |
| 2006 | - } |
| 2007 | - break; |
| 2008 | - } |
| 2009 | - } |
| 2010 | - |
| 2011 | - if (view->pending_scroll == SCROLL_TO_KEEP_POSITION || |
| 2012 | - view->pending_scroll == SCROLL_TO_FIND_LOCATION) { |
| 2013 | - best_current_page = MAX (best_current_page, view->start_page); |
| 2014 | - |
| 2015 | - if (best_current_page >= 0 && view->current_page != best_current_page) { |
| 2016 | - view->current_page = best_current_page; |
| 2017 | - ev_view_set_loading (view, FALSE); |
| 2018 | - ev_document_model_set_page (view->model, best_current_page); |
| 2019 | - } |
| 2020 | - } |
| 2021 | - } else if (is_dual_page (view, &odd_left)) { |
| 2022 | - if (view->current_page % 2 == !odd_left) { |
| 2023 | - view->start_page = view->current_page; |
| 2024 | - if (view->current_page + 1 < ev_document_get_n_pages (view->document)) |
| 2025 | - view->end_page = view->start_page + 1; |
| 2026 | - else |
| 2027 | - view->end_page = view->start_page; |
| 2028 | - } else { |
| 2029 | - if (view->current_page < 1) |
| 2030 | - view->start_page = view->current_page; |
| 2031 | - else |
| 2032 | - view->start_page = view->current_page - 1; |
| 2033 | - view->end_page = view->current_page; |
| 2034 | - } |
| 2035 | - } else { |
| 2036 | - view->start_page = view->current_page; |
| 2037 | - view->end_page = view->current_page; |
| 2038 | - } |
| 2039 | - |
| 2040 | - if (view->start_page == -1 || view->end_page == -1) |
| 2041 | - return; |
| 2042 | - |
| 2043 | - if (start != view->start_page || end != view->end_page) { |
| 2044 | - gint i; |
| 2045 | - |
| 2046 | - for (i = start; i < view->start_page && start != -1; i++) { |
| 2047 | - hide_annotation_windows (view, i); |
| 2048 | - } |
| 2049 | - |
| 2050 | - for (i = end; i > view->end_page && end != -1; i--) { |
| 2051 | - hide_annotation_windows (view, i); |
| 2052 | - } |
| 2053 | - |
| 2054 | - ev_view_check_cursor_blink (view); |
| 2055 | - } |
| 2056 | - |
| 2057 | - ev_page_cache_set_page_range (view->page_cache, |
| 2058 | - view->start_page, |
| 2059 | - view->end_page); |
| 2060 | - ev_pixbuf_cache_set_page_range (view->pixbuf_cache, |
| 2061 | - view->start_page, |
| 2062 | - view->end_page, |
| 2063 | - view->selection_info.selections); |
| 2064 | - if (view->accessible) |
| 2065 | - ev_view_accessible_set_page_range (EV_VIEW_ACCESSIBLE (view->accessible), |
| 2066 | - view->start_page, |
| 2067 | - view->end_page); |
| 2068 | - |
| 2069 | - if (ev_pixbuf_cache_get_surface (view->pixbuf_cache, view->current_page)) |
| 2070 | - gtk_widget_queue_draw (GTK_WIDGET (view)); |
| 2071 | -} |
| 2072 | - |
| 2073 | -static void |
| 2074 | -ev_view_set_scroll_adjustment (EvView *view, |
| 2075 | - GtkOrientation orientation, |
| 2076 | - GtkAdjustment *adjustment) |
| 2077 | -{ |
| 2078 | - GtkAdjustment **to_set; |
| 2079 | - const gchar *prop_name; |
| 2080 | - |
| 2081 | - if (orientation == GTK_ORIENTATION_HORIZONTAL) { |
| 2082 | - to_set = &view->hadjustment; |
| 2083 | - prop_name = "hadjustment"; |
| 2084 | - } else { |
| 2085 | - to_set = &view->vadjustment; |
| 2086 | - prop_name = "vadjustment"; |
| 2087 | - } |
| 2088 | - |
| 2089 | - if (adjustment && adjustment == *to_set) |
| 2090 | - return; |
| 2091 | - |
| 2092 | - if (*to_set) { |
| 2093 | - g_signal_handlers_disconnect_by_func (*to_set, |
| 2094 | - (gpointer) on_adjustment_value_changed, |
| 2095 | - view); |
| 2096 | - g_object_unref (*to_set); |
| 2097 | - } |
| 2098 | - |
| 2099 | - if (!adjustment) |
| 2100 | - adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
| 2101 | - g_signal_connect (adjustment, "value_changed", |
| 2102 | - G_CALLBACK (on_adjustment_value_changed), |
| 2103 | - view); |
| 2104 | - *to_set = g_object_ref_sink (adjustment); |
| 2105 | - ev_view_set_adjustment_values (view, orientation); |
| 2106 | - |
| 2107 | - g_object_notify (G_OBJECT (view), prop_name); |
| 2108 | -} |
| 2109 | - |
| 2110 | -static void |
| 2111 | -add_scroll_binding_keypad (GtkBindingSet *binding_set, |
| 2112 | - guint keyval, |
| 2113 | - GdkModifierType modifiers, |
| 2114 | - GtkScrollType scroll, |
| 2115 | - GtkOrientation orientation) |
| 2116 | -{ |
| 2117 | - guint keypad_keyval = keyval - GDK_KEY_Left + GDK_KEY_KP_Left; |
| 2118 | - |
| 2119 | - gtk_binding_entry_add_signal (binding_set, keyval, modifiers, |
| 2120 | - "scroll", 2, |
| 2121 | - GTK_TYPE_SCROLL_TYPE, scroll, |
| 2122 | - GTK_TYPE_ORIENTATION, orientation); |
| 2123 | - gtk_binding_entry_add_signal (binding_set, keypad_keyval, modifiers, |
| 2124 | - "scroll", 2, |
| 2125 | - GTK_TYPE_SCROLL_TYPE, scroll, |
| 2126 | - GTK_TYPE_ORIENTATION, orientation); |
| 2127 | -} |
| 2128 | - |
| 2129 | -static gdouble |
| 2130 | -compute_scroll_increment (EvView *view, |
| 2131 | - GtkScrollType scroll) |
| 2132 | -{ |
| 2133 | - GtkWidget *widget = GTK_WIDGET (view); |
| 2134 | - GtkAdjustment *adjustment = view->vadjustment; |
| 2135 | - cairo_region_t *text_region, *region; |
| 2136 | - GtkAllocation allocation; |
| 2137 | - gint page; |
| 2138 | - GdkRectangle rect; |
| 2139 | - EvRectangle doc_rect; |
| 2140 | - GdkRectangle page_area; |
| 2141 | - GtkBorder border; |
| 2142 | - gdouble fraction = 1.0; |
| 2143 | - |
| 2144 | - if (scroll != GTK_SCROLL_PAGE_BACKWARD && scroll != GTK_SCROLL_PAGE_FORWARD) |
| 2145 | - return gtk_adjustment_get_page_size (adjustment); |
| 2146 | - |
| 2147 | - page = scroll == GTK_SCROLL_PAGE_BACKWARD ? view->start_page : view->end_page; |
| 2148 | - |
| 2149 | - text_region = ev_page_cache_get_text_mapping (view->page_cache, page); |
| 2150 | - if (!text_region || cairo_region_is_empty (text_region)) |
| 2151 | - return gtk_adjustment_get_page_size (adjustment); |
| 2152 | - |
| 2153 | - gtk_widget_get_allocation (widget, &allocation); |
| 2154 | - ev_view_get_page_extents (view, page, &page_area, &border); |
| 2155 | - rect.x = page_area.x + view->scroll_x; |
| 2156 | - rect.y = view->scroll_y + (scroll == GTK_SCROLL_PAGE_BACKWARD ? 5 : allocation.height - 5); |
| 2157 | - rect.width = page_area.width; |
| 2158 | - rect.height = 1; |
| 2159 | - _ev_view_transform_view_rect_to_doc_rect (view, &rect, &page_area, &border, &doc_rect); |
| 2160 | - |
| 2161 | - /* Convert the doc rectangle into a GdkRectangle */ |
| 2162 | - rect.x = doc_rect.x1; |
| 2163 | - rect.y = doc_rect.y1; |
| 2164 | - rect.width = doc_rect.x2 - doc_rect.x1; |
| 2165 | - rect.height = MAX (1, doc_rect.y2 - doc_rect.y1); |
| 2166 | - region = cairo_region_create_rectangle (&rect); |
| 2167 | - |
| 2168 | - cairo_region_intersect (region, text_region); |
| 2169 | - if (cairo_region_num_rectangles (region)) { |
| 2170 | - EvRenderContext *rc; |
| 2171 | - EvPage *ev_page; |
| 2172 | - cairo_region_t *sel_region; |
| 2173 | - |
| 2174 | - cairo_region_get_rectangle (region, 0, &rect); |
| 2175 | - ev_page = ev_document_get_page (view->document, page); |
| 2176 | - rc = ev_render_context_new (ev_page, view->rotation, 0.); |
| 2177 | - ev_render_context_set_target_size (rc, |
| 2178 | - page_area.width - (border.left + border.right), |
| 2179 | - page_area.height - (border.left + border.right)); |
| 2180 | - g_object_unref (ev_page); |
| 2181 | - /* Get the selection region to know the height of the line */ |
| 2182 | - doc_rect.x1 = doc_rect.x2 = rect.x + 0.5; |
| 2183 | - doc_rect.y1 = doc_rect.y2 = rect.y + 0.5; |
| 2184 | - |
| 2185 | - ev_document_doc_mutex_lock (); |
| 2186 | - sel_region = ev_selection_get_selection_region (EV_SELECTION (view->document), |
| 2187 | - rc, EV_SELECTION_STYLE_LINE, |
| 2188 | - &doc_rect); |
| 2189 | - ev_document_doc_mutex_unlock (); |
| 2190 | - |
| 2191 | - g_object_unref (rc); |
| 2192 | - |
| 2193 | - if (cairo_region_num_rectangles (sel_region) > 0) { |
| 2194 | - cairo_region_get_rectangle (sel_region, 0, &rect); |
| 2195 | - fraction = 1 - (rect.height / gtk_adjustment_get_page_size (adjustment)); |
| 2196 | - } |
| 2197 | - cairo_region_destroy (sel_region); |
| 2198 | - } |
| 2199 | - cairo_region_destroy (region); |
| 2200 | - |
| 2201 | - return gtk_adjustment_get_page_size (adjustment) * fraction; |
| 2202 | - |
| 2203 | -} |
| 2204 | - |
| 2205 | -static void |
| 2206 | -ev_view_first_page (EvView *view) |
| 2207 | -{ |
| 2208 | - ev_document_model_set_page (view->model, 0); |
| 2209 | -} |
| 2210 | - |
| 2211 | -static void |
| 2212 | -ev_view_last_page (EvView *view) |
| 2213 | -{ |
| 2214 | - gint n_pages; |
| 2215 | - |
| 2216 | - if (!view->document) |
| 2217 | - return; |
| 2218 | - |
| 2219 | - n_pages = ev_document_get_n_pages (view->document); |
| 2220 | - if (n_pages <= 1) |
| 2221 | - return; |
| 2222 | - |
| 2223 | - ev_document_model_set_page (view->model, n_pages - 1); |
| 2224 | -} |
| 2225 | - |
| 2226 | -/** |
| 2227 | - * ev_view_scroll: |
| 2228 | - * @view: a #EvView |
| 2229 | - * @scroll: |
| 2230 | - * @horizontal: |
| 2231 | - * |
| 2232 | - * Deprecated: 3.10 |
| 2233 | - */ |
| 2234 | -void |
| 2235 | -ev_view_scroll (EvView *view, |
| 2236 | - GtkScrollType scroll, |
| 2237 | - gboolean horizontal) |
| 2238 | -{ |
| 2239 | - GtkAdjustment *adjustment; |
| 2240 | - double value, increment; |
| 2241 | - gdouble upper, lower; |
| 2242 | - gdouble page_size; |
| 2243 | - gdouble step_increment; |
| 2244 | - gboolean first_page = FALSE; |
| 2245 | - gboolean last_page = FALSE; |
| 2246 | - |
| 2247 | - if (view->key_binding_handled) |
| 2248 | - return; |
| 2249 | - |
| 2250 | - view->jump_to_find_result = FALSE; |
| 2251 | - |
| 2252 | - if (view->sizing_mode == EV_SIZING_FIT_PAGE) { |
| 2253 | - switch (scroll) { |
| 2254 | - case GTK_SCROLL_PAGE_BACKWARD: |
| 2255 | - case GTK_SCROLL_STEP_BACKWARD: |
| 2256 | - ev_view_previous_page (view); |
| 2257 | - break; |
| 2258 | - case GTK_SCROLL_PAGE_FORWARD: |
| 2259 | - case GTK_SCROLL_STEP_FORWARD: |
| 2260 | - ev_view_next_page (view); |
| 2261 | - break; |
| 2262 | - default: |
| 2263 | - break; |
| 2264 | - } |
| 2265 | - return; |
| 2266 | - } |
| 2267 | - |
| 2268 | - /* Assign values for increment and vertical adjustment */ |
| 2269 | - adjustment = horizontal ? view->hadjustment : view->vadjustment; |
| 2270 | - value = gtk_adjustment_get_value (adjustment); |
| 2271 | - upper = gtk_adjustment_get_upper (adjustment); |
| 2272 | - lower = gtk_adjustment_get_lower (adjustment); |
| 2273 | - page_size = gtk_adjustment_get_page_size (adjustment); |
| 2274 | - step_increment = gtk_adjustment_get_step_increment (adjustment); |
| 2275 | - |
| 2276 | - /* Assign boolean for first and last page */ |
| 2277 | - if (view->current_page == 0) |
| 2278 | - first_page = TRUE; |
| 2279 | - if (view->current_page == ev_document_get_n_pages (view->document) - 1) |
| 2280 | - last_page = TRUE; |
| 2281 | - |
| 2282 | - switch (scroll) { |
| 2283 | - case GTK_SCROLL_PAGE_BACKWARD: |
| 2284 | - /* Do not jump backwards if at the first page */ |
| 2285 | - if (value == lower && first_page) { |
| 2286 | - /* Do nothing */ |
| 2287 | - /* At the top of a page, assign the upper bound limit of previous page */ |
| 2288 | - } else if (value == lower) { |
| 2289 | - value = upper - page_size; |
| 2290 | - ev_view_previous_page (view); |
| 2291 | - /* Jump to the top */ |
| 2292 | - } else { |
| 2293 | - increment = compute_scroll_increment (view, GTK_SCROLL_PAGE_BACKWARD); |
| 2294 | - value = MAX (value - increment, lower); |
| 2295 | - } |
| 2296 | - break; |
| 2297 | - case GTK_SCROLL_PAGE_FORWARD: |
| 2298 | - /* Do not jump forward if at the last page */ |
| 2299 | - if (value == (upper - page_size) && last_page) { |
| 2300 | - /* Do nothing */ |
| 2301 | - /* At the bottom of a page, assign the lower bound limit of next page */ |
| 2302 | - } else if (value == (upper - page_size)) { |
| 2303 | - value = 0; |
| 2304 | - ev_view_next_page (view); |
| 2305 | - /* Jump to the bottom */ |
| 2306 | - } else { |
| 2307 | - increment = compute_scroll_increment (view, GTK_SCROLL_PAGE_FORWARD); |
| 2308 | - value = MIN (value + increment, upper - page_size); |
| 2309 | - } |
| 2310 | - break; |
| 2311 | - case GTK_SCROLL_STEP_BACKWARD: |
| 2312 | - value -= step_increment; |
| 2313 | - break; |
| 2314 | - case GTK_SCROLL_STEP_FORWARD: |
| 2315 | - value += step_increment; |
| 2316 | - break; |
| 2317 | - case GTK_SCROLL_STEP_DOWN: |
| 2318 | - value -= step_increment / 10; |
| 2319 | - break; |
| 2320 | - case GTK_SCROLL_STEP_UP: |
| 2321 | - value += step_increment / 10; |
| 2322 | - break; |
| 2323 | - case GTK_SCROLL_START: |
| 2324 | - value = lower; |
| 2325 | - if (!first_page) |
| 2326 | - ev_view_first_page (view); |
| 2327 | - break; |
| 2328 | - case GTK_SCROLL_END: |
| 2329 | - value = upper - page_size; |
| 2330 | - if (!last_page) |
| 2331 | - ev_view_last_page (view); |
| 2332 | - /* Changing pages causes the top to be shown. Here we want the bottom shown. */ |
| 2333 | - view->pending_point.y = value; |
| 2334 | - break; |
| 2335 | - default: |
| 2336 | - break; |
| 2337 | - } |
| 2338 | - |
| 2339 | - value = CLAMP (value, lower, upper - page_size); |
| 2340 | - |
| 2341 | - gtk_adjustment_set_value (adjustment, value); |
| 2342 | -} |
| 2343 | - |
| 2344 | -static void |
| 2345 | -ev_view_scroll_internal (EvView *view, |
| 2346 | - GtkScrollType scroll, |
| 2347 | - GtkOrientation orientation) |
| 2348 | -{ |
| 2349 | - ev_view_scroll (view, scroll, orientation == GTK_ORIENTATION_HORIZONTAL); |
| 2350 | -} |
| 2351 | - |
| 2352 | -#define MARGIN 5 |
| 2353 | - |
| 2354 | -static void |
| 2355 | -ensure_rectangle_is_visible (EvView *view, GdkRectangle *rect) |
| 2356 | -{ |
| 2357 | - GtkWidget *widget = GTK_WIDGET (view); |
| 2358 | - GtkAdjustment *adjustment; |
| 2359 | - GtkAllocation allocation; |
| 2360 | - gdouble adj_value; |
| 2361 | - int value; |
| 2362 | - |
| 2363 | - view->pending_scroll = SCROLL_TO_FIND_LOCATION; |
| 2364 | - |
| 2365 | - gtk_widget_get_allocation (widget, &allocation); |
| 2366 | - |
| 2367 | - adjustment = view->vadjustment; |
| 2368 | - adj_value = gtk_adjustment_get_value (adjustment); |
| 2369 | - |
| 2370 | - if (rect->y < adj_value) { |
| 2371 | - value = MAX (gtk_adjustment_get_lower (adjustment), rect->y - MARGIN); |
| 2372 | - gtk_adjustment_set_value (view->vadjustment, value); |
| 2373 | - } else if (rect->y + rect->height > adj_value + allocation.height) { |
| 2374 | - value = MIN (gtk_adjustment_get_upper (adjustment), rect->y + rect->height - |
| 2375 | - allocation.height + MARGIN); |
| 2376 | - gtk_adjustment_set_value (view->vadjustment, value); |
| 2377 | - } |
| 2378 | - |
| 2379 | - adjustment = view->hadjustment; |
| 2380 | - adj_value = gtk_adjustment_get_value (adjustment); |
| 2381 | - |
| 2382 | - if (rect->x < adj_value) { |
| 2383 | - value = MAX (gtk_adjustment_get_lower (adjustment), rect->x - MARGIN); |
| 2384 | - gtk_adjustment_set_value (view->hadjustment, value); |
| 2385 | - } else if (rect->x + rect->height > adj_value + allocation.width) { |
| 2386 | - value = MIN (gtk_adjustment_get_upper (adjustment), rect->x + rect->width - |
| 2387 | - allocation.width + MARGIN); |
| 2388 | - gtk_adjustment_set_value (view->hadjustment, value); |
| 2389 | - } |
| 2390 | -} |
| 2391 | - |
| 2392 | -/*** Geometry computations ***/ |
| 2393 | - |
| 2394 | -static void |
| 2395 | -compute_border (EvView *view, GtkBorder *border) |
| 2396 | -{ |
| 2397 | - GtkWidget *widget = GTK_WIDGET (view); |
| 2398 | - GtkStyleContext *context = gtk_widget_get_style_context (widget); |
| 2399 | - GtkStateFlags state = gtk_widget_get_state_flags (widget); |
| 2400 | - |
| 2401 | - gtk_style_context_save (context); |
| 2402 | - gtk_style_context_add_class (context, EV_STYLE_CLASS_DOCUMENT_PAGE); |
| 2403 | - gtk_style_context_get_border (context, state, border); |
| 2404 | - gtk_style_context_restore (context); |
| 2405 | -} |
| 2406 | - |
| 2407 | -void |
| 2408 | -_get_page_size_for_scale_and_rotation (EvDocument *document, |
| 2409 | - gint page, |
| 2410 | - gdouble scale, |
| 2411 | - gint rotation, |
| 2412 | - gint *page_width, |
| 2413 | - gint *page_height) |
| 2414 | -{ |
| 2415 | - gdouble w, h; |
| 2416 | - gint width, height; |
| 2417 | - |
| 2418 | - ev_document_get_page_size (document, page, &w, &h); |
| 2419 | - |
| 2420 | - width = (gint)(w * scale + 0.5); |
| 2421 | - height = (gint)(h * scale + 0.5); |
| 2422 | - |
| 2423 | - if (page_width) |
| 2424 | - *page_width = (rotation == 0 || rotation == 180) ? width : height; |
| 2425 | - if (page_height) |
| 2426 | - *page_height = (rotation == 0 || rotation == 180) ? height : width; |
| 2427 | -} |
| 2428 | - |
| 2429 | -static void |
| 2430 | -ev_view_get_page_size (EvView *view, |
| 2431 | - gint page, |
| 2432 | - gint *page_width, |
| 2433 | - gint *page_height) |
| 2434 | -{ |
| 2435 | - _get_page_size_for_scale_and_rotation (view->document, |
| 2436 | - page, |
| 2437 | - view->scale, |
| 2438 | - view->rotation, |
| 2439 | - page_width, |
| 2440 | - page_height); |
| 2441 | -} |
| 2442 | - |
| 2443 | -static void |
| 2444 | -ev_view_get_max_page_size (EvView *view, |
| 2445 | - gint *max_width, |
| 2446 | - gint *max_height) |
| 2447 | -{ |
| 2448 | - double w, h; |
| 2449 | - gint width, height; |
| 2450 | - |
| 2451 | - ev_document_get_max_page_size (view->document, &w, &h); |
| 2452 | - |
| 2453 | - width = (gint)(w * view->scale + 0.5); |
| 2454 | - height = (gint)(h * view->scale + 0.5); |
| 2455 | - |
| 2456 | - if (max_width) |
| 2457 | - *max_width = (view->rotation == 0 || view->rotation == 180) ? width : height; |
| 2458 | - if (max_height) |
| 2459 | - *max_height = (view->rotation == 0 || view->rotation == 180) ? height : width; |
| 2460 | -} |
| 2461 | - |
| 2462 | -static void |
| 2463 | -get_page_y_offset (EvView *view, int page, int *y_offset) |
| 2464 | -{ |
| 2465 | - int offset = 0; |
| 2466 | - GtkBorder border; |
| 2467 | - gboolean odd_left; |
| 2468 | - |
| 2469 | - g_return_if_fail (y_offset != NULL); |
| 2470 | - |
| 2471 | - compute_border (view, &border); |
| 2472 | - |
| 2473 | - if (is_dual_page (view, &odd_left)) { |
| 2474 | - ev_view_get_height_to_page (view, page, NULL, &offset); |
| 2475 | - offset += ((page + !odd_left) / 2 + 1) * view->spacing + |
| 2476 | - ((page + !odd_left) / 2 ) * (border.top + border.bottom); |
| 2477 | - } else { |
| 2478 | - ev_view_get_height_to_page (view, page, &offset, NULL); |
| 2479 | - offset += (page + 1) * view->spacing + page * (border.top + border.bottom); |
| 2480 | - } |
| 2481 | - |
| 2482 | - *y_offset = offset; |
| 2483 | - return; |
| 2484 | -} |
| 2485 | - |
| 2486 | -gboolean |
| 2487 | -ev_view_get_page_extents (EvView *view, |
| 2488 | - gint page, |
| 2489 | - GdkRectangle *page_area, |
| 2490 | - GtkBorder *border) |
| 2491 | -{ |
| 2492 | - GtkWidget *widget; |
| 2493 | - int width, height; |
| 2494 | - GtkAllocation allocation; |
| 2495 | - |
| 2496 | - widget = GTK_WIDGET (view); |
| 2497 | - gtk_widget_get_allocation (widget, &allocation); |
| 2498 | - |
| 2499 | - /* Get the size of the page */ |
| 2500 | - ev_view_get_page_size (view, page, &width, &height); |
| 2501 | - compute_border (view, border); |
| 2502 | - page_area->width = width + border->left + border->right; |
| 2503 | - page_area->height = height + border->top + border->bottom; |
| 2504 | - |
| 2505 | - if (view->continuous) { |
| 2506 | - gint max_width; |
| 2507 | - gint x, y; |
| 2508 | - gboolean odd_left; |
| 2509 | - |
| 2510 | - ev_view_get_max_page_size (view, &max_width, NULL); |
| 2511 | - max_width = max_width + border->left + border->right; |
| 2512 | - /* Get the location of the bounding box */ |
| 2513 | - if (is_dual_page (view, &odd_left)) { |
| 2514 | - x = view->spacing + ((page % 2 == !odd_left) ? 0 : 1) * (max_width + view->spacing); |
| 2515 | - x = x + MAX (0, allocation.width - (max_width * 2 + view->spacing * 3)) / 2; |
| 2516 | - if (page % 2 == !odd_left) |
| 2517 | - x = x + (max_width - width - border->left - border->right); |
| 2518 | - } else { |
| 2519 | - x = view->spacing; |
| 2520 | - x = x + MAX (0, allocation.width - (width + border->left + border->right + view->spacing * 2)) / 2; |
| 2521 | - } |
| 2522 | - |
| 2523 | - get_page_y_offset (view, page, &y); |
| 2524 | - |
| 2525 | - page_area->x = x; |
| 2526 | - page_area->y = y; |
| 2527 | - } else { |
| 2528 | - gint x, y; |
| 2529 | - gboolean odd_left; |
| 2530 | - |
| 2531 | - if (is_dual_page (view, &odd_left)) { |
| 2532 | - gint width_2, height_2; |
| 2533 | - gint max_width = width; |
| 2534 | - gint max_height = height; |
| 2535 | - GtkBorder overall_border; |
| 2536 | - gint other_page; |
| 2537 | - |
| 2538 | - other_page = (page % 2 == !odd_left) ? page + 1: page - 1; |
| 2539 | - |
| 2540 | - /* First, we get the bounding box of the two pages */ |
| 2541 | - if (other_page < ev_document_get_n_pages (view->document) |
| 2542 | - && (0 <= other_page)) { |
| 2543 | - ev_view_get_page_size (view, other_page, |
| 2544 | - &width_2, &height_2); |
| 2545 | - if (width_2 > width) |
| 2546 | - max_width = width_2; |
| 2547 | - if (height_2 > height) |
| 2548 | - max_height = height_2; |
| 2549 | - } |
| 2550 | - compute_border (view, &overall_border); |
| 2551 | - |
| 2552 | - /* Find the offsets */ |
| 2553 | - x = view->spacing; |
| 2554 | - y = view->spacing; |
| 2555 | - |
| 2556 | - /* Adjust for being the left or right page */ |
| 2557 | - if (page % 2 == !odd_left) |
| 2558 | - x = x + max_width - width; |
| 2559 | - else |
| 2560 | - x = x + (max_width + overall_border.left + overall_border.right) + view->spacing; |
| 2561 | - |
| 2562 | - y = y + (max_height - height)/2; |
| 2563 | - |
| 2564 | - /* Adjust for extra allocation */ |
| 2565 | - x = x + MAX (0, allocation.width - |
| 2566 | - ((max_width + overall_border.left + overall_border.right) * 2 + view->spacing * 3))/2; |
| 2567 | - y = y + MAX (0, allocation.height - (height + view->spacing * 2))/2; |
| 2568 | - } else { |
| 2569 | - x = view->spacing; |
| 2570 | - y = view->spacing; |
| 2571 | - |
| 2572 | - /* Adjust for extra allocation */ |
| 2573 | - x = x + MAX (0, allocation.width - (width + border->left + border->right + view->spacing * 2))/2; |
| 2574 | - y = y + MAX (0, allocation.height - (height + border->top + border->bottom + view->spacing * 2))/2; |
| 2575 | - } |
| 2576 | - |
| 2577 | - page_area->x = x; |
| 2578 | - page_area->y = y; |
| 2579 | - } |
| 2580 | - |
| 2581 | - return TRUE; |
| 2582 | -} |
| 2583 | - |
| 2584 | -static void |
| 2585 | -get_doc_page_size (EvView *view, |
| 2586 | - gint page, |
| 2587 | - gdouble *width, |
| 2588 | - gdouble *height) |
| 2589 | -{ |
| 2590 | - double w, h; |
| 2591 | - |
| 2592 | - ev_document_get_page_size (view->document, page, &w, &h); |
| 2593 | - if (view->rotation == 0 || view->rotation == 180) { |
| 2594 | - if (width) *width = w; |
| 2595 | - if (height) *height = h; |
| 2596 | - } else { |
| 2597 | - if (width) *width = h; |
| 2598 | - if (height) *height = w; |
| 2599 | - } |
| 2600 | -} |
| 2601 | - |
| 2602 | -void |
| 2603 | -_ev_view_transform_view_point_to_doc_point (EvView *view, |
| 2604 | - GdkPoint *view_point, |
| 2605 | - GdkRectangle *page_area, |
| 2606 | - GtkBorder *border, |
| 2607 | - double *doc_point_x, |
| 2608 | - double *doc_point_y) |
| 2609 | -{ |
| 2610 | - *doc_point_x = MAX ((double) (view_point->x - page_area->x - border->left) / view->scale, 0); |
| 2611 | - *doc_point_y = MAX ((double) (view_point->y - page_area->y - border->right) / view->scale, 0); |
| 2612 | -} |
| 2613 | - |
| 2614 | -void |
| 2615 | -_ev_view_transform_view_rect_to_doc_rect (EvView *view, |
| 2616 | - GdkRectangle *view_rect, |
| 2617 | - GdkRectangle *page_area, |
| 2618 | - GtkBorder *border, |
| 2619 | - EvRectangle *doc_rect) |
| 2620 | -{ |
| 2621 | - doc_rect->x1 = MAX ((double) (view_rect->x - page_area->x - border->left) / view->scale, 0); |
| 2622 | - doc_rect->y1 = MAX ((double) (view_rect->y - page_area->y - border->right) / view->scale, 0); |
| 2623 | - doc_rect->x2 = doc_rect->x1 + (double) view_rect->width / view->scale; |
| 2624 | - doc_rect->y2 = doc_rect->y1 + (double) view_rect->height / view->scale; |
| 2625 | -} |
| 2626 | - |
| 2627 | -void |
| 2628 | -_ev_view_transform_doc_point_to_view_point (EvView *view, |
| 2629 | - int page, |
| 2630 | - EvPoint *doc_point, |
| 2631 | - GdkPoint *view_point) |
| 2632 | -{ |
| 2633 | - GdkRectangle page_area; |
| 2634 | - GtkBorder border; |
| 2635 | - double x, y, view_x, view_y; |
| 2636 | - |
| 2637 | - switch (view->rotation) { |
| 2638 | - case 0: |
| 2639 | - x = doc_point->x; |
| 2640 | - y = doc_point->y; |
| 2641 | - |
| 2642 | - break; |
| 2643 | - case 90: { |
| 2644 | - gdouble width; |
| 2645 | - |
| 2646 | - get_doc_page_size (view, page, &width, NULL); |
| 2647 | - x = width - doc_point->y; |
| 2648 | - y = doc_point->x; |
| 2649 | - } |
| 2650 | - break; |
| 2651 | - case 180: { |
| 2652 | - gdouble width, height; |
| 2653 | - |
| 2654 | - get_doc_page_size (view, page, &width, &height); |
| 2655 | - x = width - doc_point->x; |
| 2656 | - y = height - doc_point->y; |
| 2657 | - } |
| 2658 | - break; |
| 2659 | - case 270: { |
| 2660 | - gdouble height; |
| 2661 | - |
| 2662 | - get_doc_page_size (view, page, NULL, &height); |
| 2663 | - x = doc_point->y; |
| 2664 | - y = height - doc_point->x; |
| 2665 | - } |
| 2666 | - break; |
| 2667 | - default: |
| 2668 | - g_assert_not_reached (); |
| 2669 | - } |
| 2670 | - |
| 2671 | - ev_view_get_page_extents (view, page, &page_area, &border); |
| 2672 | - |
| 2673 | - view_x = CLAMP ((gint)(x * view->scale + 0.5), 0, page_area.width); |
| 2674 | - view_y = CLAMP ((gint)(y * view->scale + 0.5), 0, page_area.height); |
| 2675 | - view_point->x = view_x + page_area.x + border.left; |
| 2676 | - view_point->y = view_y + page_area.y + border.top; |
| 2677 | -} |
| 2678 | - |
| 2679 | -void |
| 2680 | -_ev_view_transform_doc_rect_to_view_rect (EvView *view, |
| 2681 | - int page, |
| 2682 | - EvRectangle *doc_rect, |
| 2683 | - GdkRectangle *view_rect) |
| 2684 | -{ |
| 2685 | - GdkRectangle page_area; |
| 2686 | - GtkBorder border; |
| 2687 | - double x, y, w, h; |
| 2688 | - |
| 2689 | - switch (view->rotation) { |
| 2690 | - case 0: |
| 2691 | - x = doc_rect->x1; |
| 2692 | - y = doc_rect->y1; |
| 2693 | - w = doc_rect->x2 - doc_rect->x1; |
| 2694 | - h = doc_rect->y2 - doc_rect->y1; |
| 2695 | - |
| 2696 | - break; |
| 2697 | - case 90: { |
| 2698 | - gdouble width; |
| 2699 | - |
| 2700 | - get_doc_page_size (view, page, &width, NULL); |
| 2701 | - x = width - doc_rect->y2; |
| 2702 | - y = doc_rect->x1; |
| 2703 | - w = doc_rect->y2 - doc_rect->y1; |
| 2704 | - h = doc_rect->x2 - doc_rect->x1; |
| 2705 | - } |
| 2706 | - break; |
| 2707 | - case 180: { |
| 2708 | - gdouble width, height; |
| 2709 | - |
| 2710 | - get_doc_page_size (view, page, &width, &height); |
| 2711 | - x = width - doc_rect->x2; |
| 2712 | - y = height - doc_rect->y2; |
| 2713 | - w = doc_rect->x2 - doc_rect->x1; |
| 2714 | - h = doc_rect->y2 - doc_rect->y1; |
| 2715 | - } |
| 2716 | - break; |
| 2717 | - case 270: { |
| 2718 | - gdouble height; |
| 2719 | - |
| 2720 | - get_doc_page_size (view, page, NULL, &height); |
| 2721 | - x = doc_rect->y1; |
| 2722 | - y = height - doc_rect->x2; |
| 2723 | - w = doc_rect->y2 - doc_rect->y1; |
| 2724 | - h = doc_rect->x2 - doc_rect->x1; |
| 2725 | - } |
| 2726 | - break; |
| 2727 | - default: |
| 2728 | - g_assert_not_reached (); |
| 2729 | - } |
| 2730 | - |
| 2731 | - ev_view_get_page_extents (view, page, &page_area, &border); |
| 2732 | - |
| 2733 | - view_rect->x = (gint)(x * view->scale + 0.5) + page_area.x + border.left; |
| 2734 | - view_rect->y = (gint)(y * view->scale + 0.5) + page_area.y + border.top; |
| 2735 | - view_rect->width = (gint)(w * view->scale + 0.5); |
| 2736 | - view_rect->height = (gint)(h * view->scale + 0.5); |
| 2737 | -} |
| 2738 | - |
| 2739 | -static void |
| 2740 | -find_page_at_location (EvView *view, |
| 2741 | - gdouble x, |
| 2742 | - gdouble y, |
| 2743 | - gint *page, |
| 2744 | - gint *x_offset, |
| 2745 | - gint *y_offset) |
| 2746 | -{ |
| 2747 | - int i; |
| 2748 | - |
| 2749 | - if (view->document == NULL) |
| 2750 | - return; |
| 2751 | - |
| 2752 | - g_assert (page); |
| 2753 | - g_assert (x_offset); |
| 2754 | - g_assert (y_offset); |
| 2755 | - |
| 2756 | - for (i = view->start_page; i >= 0 && i <= view->end_page; i++) { |
| 2757 | - GdkRectangle page_area; |
| 2758 | - GtkBorder border; |
| 2759 | - |
| 2760 | - if (! ev_view_get_page_extents (view, i, &page_area, &border)) |
| 2761 | - continue; |
| 2762 | - |
| 2763 | - if ((x >= page_area.x + border.left) && |
| 2764 | - (x < page_area.x + page_area.width - border.right) && |
| 2765 | - (y >= page_area.y + border.top) && |
| 2766 | - (y < page_area.y + page_area.height - border.bottom)) { |
| 2767 | - *page = i; |
| 2768 | - *x_offset = x - (page_area.x + border.left); |
| 2769 | - *y_offset = y - (page_area.y + border.top); |
| 2770 | - return; |
| 2771 | - } |
| 2772 | - } |
| 2773 | - |
| 2774 | - *page = -1; |
| 2775 | -} |
| 2776 | - |
| 2777 | -static gboolean |
| 2778 | -location_in_text (EvView *view, |
| 2779 | - gdouble x, |
| 2780 | - gdouble y) |
| 2781 | -{ |
| 2782 | - cairo_region_t *region; |
| 2783 | - gint page = -1; |
| 2784 | - gint x_offset = 0, y_offset = 0; |
| 2785 | - |
| 2786 | - find_page_at_location (view, x, y, &page, &x_offset, &y_offset); |
| 2787 | - |
| 2788 | - if (page == -1) |
| 2789 | - return FALSE; |
| 2790 | - |
| 2791 | - region = ev_page_cache_get_text_mapping (view->page_cache, page); |
| 2792 | - |
| 2793 | - if (region) |
| 2794 | - return cairo_region_contains_point (region, x_offset / view->scale, y_offset / view->scale); |
| 2795 | - else |
| 2796 | - return FALSE; |
| 2797 | -} |
| 2798 | - |
| 2799 | -static gboolean |
| 2800 | -location_in_selected_text (EvView *view, |
| 2801 | - gdouble x, |
| 2802 | - gdouble y) |
| 2803 | -{ |
| 2804 | - cairo_region_t *region; |
| 2805 | - gint page = -1; |
| 2806 | - gint x_offset = 0, y_offset = 0; |
| 2807 | - |
| 2808 | - find_page_at_location (view, x, y, &page, &x_offset, &y_offset); |
| 2809 | - |
| 2810 | - if (page == -1) |
| 2811 | - return FALSE; |
| 2812 | - |
| 2813 | - region = ev_pixbuf_cache_get_selection_region (view->pixbuf_cache, page, view->scale); |
| 2814 | - |
| 2815 | - if (region) |
| 2816 | - return cairo_region_contains_point (region, x_offset, y_offset); |
| 2817 | - else |
| 2818 | - return FALSE; |
| 2819 | -} |
| 2820 | - |
| 2821 | -static gboolean |
| 2822 | -get_doc_point_from_offset (EvView *view, |
| 2823 | - gint page, |
| 2824 | - gint x_offset, |
| 2825 | - gint y_offset, |
| 2826 | - gint *x_new, |
| 2827 | - gint *y_new) |
| 2828 | -{ |
| 2829 | - gdouble width, height; |
| 2830 | - double x, y; |
| 2831 | - |
| 2832 | - get_doc_page_size (view, page, &width, &height); |
| 2833 | - |
| 2834 | - x_offset = x_offset / view->scale; |
| 2835 | - y_offset = y_offset / view->scale; |
| 2836 | - |
| 2837 | - if (view->rotation == 0) { |
| 2838 | - x = x_offset; |
| 2839 | - y = y_offset; |
| 2840 | - } else if (view->rotation == 90) { |
| 2841 | - x = y_offset; |
| 2842 | - y = width - x_offset; |
| 2843 | - } else if (view->rotation == 180) { |
| 2844 | - x = width - x_offset; |
| 2845 | - y = height - y_offset; |
| 2846 | - } else if (view->rotation == 270) { |
| 2847 | - x = height - y_offset; |
| 2848 | - y = x_offset; |
| 2849 | - } else { |
| 2850 | - g_assert_not_reached (); |
| 2851 | - } |
| 2852 | - |
| 2853 | - *x_new = x; |
| 2854 | - *y_new = y; |
| 2855 | - |
| 2856 | - return TRUE; |
| 2857 | -} |
| 2858 | - |
| 2859 | -static gboolean |
| 2860 | -get_doc_point_from_location (EvView *view, |
| 2861 | - gdouble x, |
| 2862 | - gdouble y, |
| 2863 | - gint *page, |
| 2864 | - gint *x_new, |
| 2865 | - gint *y_new) |
| 2866 | -{ |
| 2867 | - gint x_offset = 0, y_offset = 0; |
| 2868 | - |
| 2869 | - x += view->scroll_x; |
| 2870 | - y += view->scroll_y; |
| 2871 | - find_page_at_location (view, x, y, page, &x_offset, &y_offset); |
| 2872 | - if (*page == -1) |
| 2873 | - return FALSE; |
| 2874 | - |
| 2875 | - return get_doc_point_from_offset (view, *page, x_offset, y_offset, x_new, y_new); |
| 2876 | -} |
| 2877 | - |
| 2878 | -static void |
| 2879 | -ev_view_get_area_from_mapping (EvView *view, |
| 2880 | - guint page, |
| 2881 | - EvMappingList *mapping_list, |
| 2882 | - gconstpointer data, |
| 2883 | - GdkRectangle *area) |
| 2884 | -{ |
| 2885 | - EvMapping *mapping; |
| 2886 | - |
| 2887 | - mapping = ev_mapping_list_find (mapping_list, data); |
| 2888 | - _ev_view_transform_doc_rect_to_view_rect (view, page, &mapping->area, area); |
| 2889 | - area->x -= view->scroll_x; |
| 2890 | - area->y -= view->scroll_y; |
| 2891 | -} |
| 2892 | - |
| 2893 | -static void |
| 2894 | -ev_view_put (EvView *view, |
| 2895 | - GtkWidget *child_widget, |
| 2896 | - gint x, |
| 2897 | - gint y, |
| 2898 | - guint page, |
| 2899 | - EvRectangle *doc_rect) |
| 2900 | -{ |
| 2901 | - EvViewChild *child; |
| 2902 | - |
| 2903 | - child = g_slice_new (EvViewChild); |
| 2904 | - |
| 2905 | - child->widget = child_widget; |
| 2906 | - child->x = x; |
| 2907 | - child->y = y; |
| 2908 | - child->page = page; |
| 2909 | - child->doc_rect = *doc_rect; |
| 2910 | - |
| 2911 | - gtk_widget_set_parent (child_widget, GTK_WIDGET (view)); |
| 2912 | - view->children = g_list_append (view->children, child); |
| 2913 | -} |
| 2914 | - |
| 2915 | -static void |
| 2916 | -ev_view_put_to_doc_rect (EvView *view, |
| 2917 | - GtkWidget *child_widget, |
| 2918 | - guint page, |
| 2919 | - EvRectangle *doc_rect) |
| 2920 | -{ |
| 2921 | - GdkRectangle area; |
| 2922 | - |
| 2923 | - _ev_view_transform_doc_rect_to_view_rect (view, page, doc_rect, &area); |
| 2924 | - area.x -= view->scroll_x; |
| 2925 | - area.y -= view->scroll_y; |
| 2926 | - ev_view_put (view, child_widget, area.x, area.y, page, doc_rect); |
| 2927 | -} |
| 2928 | - |
| 2929 | -/*** Hyperref ***/ |
| 2930 | -static EvMapping * |
| 2931 | -get_link_mapping_at_location (EvView *view, |
| 2932 | - gdouble x, |
| 2933 | - gdouble y, |
| 2934 | - gint *page) |
| 2935 | -{ |
| 2936 | - gint x_new = 0, y_new = 0; |
| 2937 | - EvMappingList *link_mapping; |
| 2938 | - |
| 2939 | - if (!EV_IS_DOCUMENT_LINKS (view->document)) |
| 2940 | - return NULL; |
| 2941 | - |
| 2942 | - if (!get_doc_point_from_location (view, x, y, page, &x_new, &y_new)) |
| 2943 | - return NULL; |
| 2944 | - |
| 2945 | - link_mapping = ev_page_cache_get_link_mapping (view->page_cache, *page); |
| 2946 | - if (link_mapping) |
| 2947 | - return ev_mapping_list_get (link_mapping, x_new, y_new); |
| 2948 | - |
| 2949 | - return NULL; |
| 2950 | -} |
| 2951 | - |
| 2952 | -static EvLink * |
| 2953 | -ev_view_get_link_at_location (EvView *view, |
| 2954 | - gdouble x, |
| 2955 | - gdouble y) |
| 2956 | -{ |
| 2957 | - EvMapping *mapping; |
| 2958 | - gint page; |
| 2959 | - |
| 2960 | - mapping = get_link_mapping_at_location (view, x, y, &page); |
| 2961 | - |
| 2962 | - return mapping ? mapping->data : NULL; |
| 2963 | -} |
| 2964 | - |
| 2965 | -static void |
| 2966 | -goto_fitr_dest (EvView *view, EvLinkDest *dest) |
| 2967 | -{ |
| 2968 | - EvPoint doc_point; |
| 2969 | - gdouble left, top; |
| 2970 | - gboolean change_left, change_top; |
| 2971 | - |
| 2972 | - left = ev_link_dest_get_left (dest, &change_left); |
| 2973 | - top = ev_link_dest_get_top (dest, &change_top); |
| 2974 | - |
| 2975 | - if (view->allow_links_change_zoom) { |
| 2976 | - gdouble doc_width, doc_height; |
| 2977 | - gdouble zoom; |
| 2978 | - GtkAllocation allocation; |
| 2979 | - |
| 2980 | - gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); |
| 2981 | - |
| 2982 | - doc_width = ev_link_dest_get_right (dest) - left; |
| 2983 | - doc_height = ev_link_dest_get_bottom (dest) - top; |
| 2984 | - |
| 2985 | - zoom = zoom_for_size_fit_page (doc_width, |
| 2986 | - doc_height, |
| 2987 | - allocation.width, |
| 2988 | - allocation.height); |
| 2989 | - |
| 2990 | - ev_document_model_set_sizing_mode (view->model, EV_SIZING_FREE); |
| 2991 | - ev_document_model_set_scale (view->model, zoom); |
| 2992 | - |
| 2993 | - /* center the target box within the view */ |
| 2994 | - left -= (allocation.width / zoom - doc_width) / 2; |
| 2995 | - top -= (allocation.height / zoom - doc_height) / 2; |
| 2996 | - } |
| 2997 | - |
| 2998 | - doc_point.x = change_left ? left : 0; |
| 2999 | - doc_point.y = change_top ? top : 0; |
| 3000 | - view->pending_point = doc_point; |
| 3001 | - |
| 3002 | - ev_view_change_page (view, ev_link_dest_get_page (dest)); |
| 3003 | -} |
| 3004 | - |
| 3005 | -static void |
| 3006 | -goto_fitv_dest (EvView *view, EvLinkDest *dest) |
| 3007 | -{ |
| 3008 | - EvPoint doc_point; |
| 3009 | - gint page; |
| 3010 | - double left; |
| 3011 | - gboolean change_left; |
| 3012 | - |
| 3013 | - page = ev_link_dest_get_page (dest); |
| 3014 | - |
| 3015 | - left = ev_link_dest_get_left (dest, &change_left); |
| 3016 | - doc_point.x = change_left ? left : 0; |
| 3017 | - doc_point.y = 0; |
| 3018 | - |
| 3019 | - if (view->allow_links_change_zoom) { |
| 3020 | - GtkAllocation allocation; |
| 3021 | - gdouble doc_width, doc_height; |
| 3022 | - double zoom; |
| 3023 | - |
| 3024 | - gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); |
| 3025 | - |
| 3026 | - ev_document_get_page_size (view->document, page, &doc_width, &doc_height); |
| 3027 | - |
| 3028 | - zoom = zoom_for_size_fit_height (doc_width - doc_point.x, doc_height, |
| 3029 | - allocation.width, |
| 3030 | - allocation.height); |
| 3031 | - |
| 3032 | - ev_document_model_set_sizing_mode (view->model, EV_SIZING_FREE); |
| 3033 | - ev_document_model_set_scale (view->model, zoom); |
| 3034 | - } |
| 3035 | - |
| 3036 | - view->pending_point = doc_point; |
| 3037 | - |
| 3038 | - ev_view_change_page (view, page); |
| 3039 | -} |
| 3040 | - |
| 3041 | -static void |
| 3042 | -goto_fith_dest (EvView *view, EvLinkDest *dest) |
| 3043 | -{ |
| 3044 | - EvPoint doc_point; |
| 3045 | - gint page; |
| 3046 | - gdouble top; |
| 3047 | - gboolean change_top; |
| 3048 | - |
| 3049 | - page = ev_link_dest_get_page (dest); |
| 3050 | - |
| 3051 | - top = ev_link_dest_get_top (dest, &change_top); |
| 3052 | - doc_point.x = 0; |
| 3053 | - doc_point.y = change_top ? top : 0; |
| 3054 | - |
| 3055 | - if (view->allow_links_change_zoom) { |
| 3056 | - GtkAllocation allocation; |
| 3057 | - gdouble doc_width; |
| 3058 | - gdouble zoom; |
| 3059 | - |
| 3060 | - gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); |
| 3061 | - |
| 3062 | - ev_document_get_page_size (view->document, page, &doc_width, NULL); |
| 3063 | - |
| 3064 | - zoom = zoom_for_size_fit_width (doc_width, top, |
| 3065 | - allocation.width, |
| 3066 | - allocation.height); |
| 3067 | - |
| 3068 | - ev_document_model_set_sizing_mode (view->model, EV_SIZING_FIT_WIDTH); |
| 3069 | - ev_document_model_set_scale (view->model, zoom); |
| 3070 | - } |
| 3071 | - |
| 3072 | - view->pending_point = doc_point; |
| 3073 | - |
| 3074 | - ev_view_change_page (view, page); |
| 3075 | -} |
| 3076 | - |
| 3077 | -static void |
| 3078 | -goto_fit_dest (EvView *view, EvLinkDest *dest) |
| 3079 | -{ |
| 3080 | - int page; |
| 3081 | - |
| 3082 | - page = ev_link_dest_get_page (dest); |
| 3083 | - |
| 3084 | - if (view->allow_links_change_zoom) { |
| 3085 | - double zoom; |
| 3086 | - gdouble doc_width, doc_height; |
| 3087 | - GtkAllocation allocation; |
| 3088 | - |
| 3089 | - gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); |
| 3090 | - |
| 3091 | - ev_document_get_page_size (view->document, page, &doc_width, &doc_height); |
| 3092 | - |
| 3093 | - zoom = zoom_for_size_fit_page (doc_width, doc_height, |
| 3094 | - allocation.width, |
| 3095 | - allocation.height); |
| 3096 | - |
| 3097 | - ev_document_model_set_sizing_mode (view->model, EV_SIZING_FIT_PAGE); |
| 3098 | - ev_document_model_set_scale (view->model, zoom); |
| 3099 | - } |
| 3100 | - |
| 3101 | - ev_view_change_page (view, page); |
| 3102 | -} |
| 3103 | - |
| 3104 | -static void |
| 3105 | -goto_xyz_dest (EvView *view, EvLinkDest *dest) |
| 3106 | -{ |
| 3107 | - EvPoint doc_point; |
| 3108 | - gint page; |
| 3109 | - gdouble zoom, left, top; |
| 3110 | - gboolean change_zoom, change_left, change_top; |
| 3111 | - |
| 3112 | - zoom = ev_link_dest_get_zoom (dest, &change_zoom); |
| 3113 | - page = ev_link_dest_get_page (dest); |
| 3114 | - |
| 3115 | - if (view->allow_links_change_zoom && change_zoom && zoom > 1) { |
| 3116 | - ev_document_model_set_sizing_mode (view->model, EV_SIZING_FREE); |
| 3117 | - ev_document_model_set_scale (view->model, zoom); |
| 3118 | - } |
| 3119 | - |
| 3120 | - left = ev_link_dest_get_left (dest, &change_left); |
| 3121 | - top = ev_link_dest_get_top (dest, &change_top); |
| 3122 | - |
| 3123 | - doc_point.x = change_left ? left : 0; |
| 3124 | - doc_point.y = change_top ? top : 0; |
| 3125 | - view->pending_point = doc_point; |
| 3126 | - |
| 3127 | - ev_view_change_page (view, page); |
| 3128 | -} |
| 3129 | - |
| 3130 | -static void |
| 3131 | -goto_dest (EvView *view, EvLinkDest *dest) |
| 3132 | -{ |
| 3133 | - EvLinkDestType type; |
| 3134 | - int page, n_pages, current_page; |
| 3135 | - |
| 3136 | - page = ev_link_dest_get_page (dest); |
| 3137 | - n_pages = ev_document_get_n_pages (view->document); |
| 3138 | - |
| 3139 | - if (page < 0 || page >= n_pages) |
| 3140 | - return; |
| 3141 | - |
| 3142 | - current_page = view->current_page; |
| 3143 | - |
| 3144 | - type = ev_link_dest_get_dest_type (dest); |
| 3145 | - |
| 3146 | - switch (type) { |
| 3147 | - case EV_LINK_DEST_TYPE_PAGE: |
| 3148 | - ev_document_model_set_page (view->model, page); |
| 3149 | - break; |
| 3150 | - case EV_LINK_DEST_TYPE_FIT: |
| 3151 | - goto_fit_dest (view, dest); |
| 3152 | - break; |
| 3153 | - case EV_LINK_DEST_TYPE_FITH: |
| 3154 | - goto_fith_dest (view, dest); |
| 3155 | - break; |
| 3156 | - case EV_LINK_DEST_TYPE_FITV: |
| 3157 | - goto_fitv_dest (view, dest); |
| 3158 | - break; |
| 3159 | - case EV_LINK_DEST_TYPE_FITR: |
| 3160 | - goto_fitr_dest (view, dest); |
| 3161 | - break; |
| 3162 | - case EV_LINK_DEST_TYPE_XYZ: |
| 3163 | - goto_xyz_dest (view, dest); |
| 3164 | - break; |
| 3165 | - case EV_LINK_DEST_TYPE_PAGE_LABEL: |
| 3166 | - ev_document_model_set_page_by_label (view->model, ev_link_dest_get_page_label (dest)); |
| 3167 | - break; |
| 3168 | - default: |
| 3169 | - g_assert_not_reached (); |
| 3170 | - } |
| 3171 | - |
| 3172 | - if (current_page != view->current_page) |
| 3173 | - ev_document_model_set_page (view->model, view->current_page); |
| 3174 | -} |
| 3175 | - |
| 3176 | -static void |
| 3177 | -ev_view_goto_dest (EvView *view, EvLinkDest *dest) |
| 3178 | -{ |
| 3179 | - EvLinkDestType type; |
| 3180 | - |
| 3181 | - type = ev_link_dest_get_dest_type (dest); |
| 3182 | - |
| 3183 | - if (type == EV_LINK_DEST_TYPE_NAMED) { |
| 3184 | - EvLinkDest *dest2; |
| 3185 | - const gchar *named_dest; |
| 3186 | - |
| 3187 | - named_dest = ev_link_dest_get_named_dest (dest); |
| 3188 | - dest2 = ev_document_links_find_link_dest (EV_DOCUMENT_LINKS (view->document), |
| 3189 | - named_dest); |
| 3190 | - if (dest2) { |
| 3191 | - goto_dest (view, dest2); |
| 3192 | - g_object_unref (dest2); |
| 3193 | - } |
| 3194 | - |
| 3195 | - return; |
| 3196 | - } |
| 3197 | - |
| 3198 | - goto_dest (view, dest); |
| 3199 | -} |
| 3200 | - |
| 3201 | -void |
| 3202 | -ev_view_handle_link (EvView *view, EvLink *link) |
| 3203 | -{ |
| 3204 | - EvLinkAction *action = NULL; |
| 3205 | - EvLinkActionType type; |
| 3206 | - |
| 3207 | - action = ev_link_get_action (link); |
| 3208 | - if (!action) |
| 3209 | - return; |
| 3210 | - |
| 3211 | - type = ev_link_action_get_action_type (action); |
| 3212 | - |
| 3213 | - switch (type) { |
| 3214 | - case EV_LINK_ACTION_TYPE_GOTO_DEST: { |
| 3215 | - EvLinkDest *dest; |
| 3216 | - |
| 3217 | - g_signal_emit (view, signals[SIGNAL_HANDLE_LINK], 0, link); |
| 3218 | - |
| 3219 | - dest = ev_link_action_get_dest (action); |
| 3220 | - ev_view_goto_dest (view, dest); |
| 3221 | - } |
| 3222 | - break; |
| 3223 | - case EV_LINK_ACTION_TYPE_LAYERS_STATE: { |
| 3224 | - GList *show, *hide, *toggle; |
| 3225 | - GList *l; |
| 3226 | - EvDocumentLayers *document_layers; |
| 3227 | - |
| 3228 | - document_layers = EV_DOCUMENT_LAYERS (view->document); |
| 3229 | - |
| 3230 | - show = ev_link_action_get_show_list (action); |
| 3231 | - for (l = show; l; l = g_list_next (l)) { |
| 3232 | - ev_document_layers_show_layer (document_layers, EV_LAYER (l->data)); |
| 3233 | - } |
| 3234 | - |
| 3235 | - hide = ev_link_action_get_hide_list (action); |
| 3236 | - for (l = hide; l; l = g_list_next (l)) { |
| 3237 | - ev_document_layers_hide_layer (document_layers, EV_LAYER (l->data)); |
| 3238 | - } |
| 3239 | - |
| 3240 | - toggle = ev_link_action_get_toggle_list (action); |
| 3241 | - for (l = toggle; l; l = g_list_next (l)) { |
| 3242 | - EvLayer *layer = EV_LAYER (l->data); |
| 3243 | - |
| 3244 | - if (ev_document_layers_layer_is_visible (document_layers, layer)) { |
| 3245 | - ev_document_layers_hide_layer (document_layers, layer); |
| 3246 | - } else { |
| 3247 | - ev_document_layers_show_layer (document_layers, layer); |
| 3248 | - } |
| 3249 | - } |
| 3250 | - |
| 3251 | - g_signal_emit (view, signals[SIGNAL_LAYERS_CHANGED], 0); |
| 3252 | - ev_view_reload_page (view, view->current_page, NULL); |
| 3253 | - } |
| 3254 | - break; |
| 3255 | - case EV_LINK_ACTION_TYPE_GOTO_REMOTE: |
| 3256 | - case EV_LINK_ACTION_TYPE_EXTERNAL_URI: |
| 3257 | - case EV_LINK_ACTION_TYPE_LAUNCH: |
| 3258 | - case EV_LINK_ACTION_TYPE_NAMED: |
| 3259 | - g_signal_emit (view, signals[SIGNAL_EXTERNAL_LINK], 0, action); |
| 3260 | - break; |
| 3261 | - } |
| 3262 | -} |
| 3263 | - |
| 3264 | -static char * |
| 3265 | -tip_from_action_named (EvLinkAction *action) |
| 3266 | -{ |
| 3267 | - const gchar *name = ev_link_action_get_name (action); |
| 3268 | - |
| 3269 | - if (g_ascii_strcasecmp (name, "FirstPage") == 0) { |
| 3270 | - return g_strdup (_("Go to first page")); |
| 3271 | - } else if (g_ascii_strcasecmp (name, "PrevPage") == 0) { |
| 3272 | - return g_strdup (_("Go to previous page")); |
| 3273 | - } else if (g_ascii_strcasecmp (name, "NextPage") == 0) { |
| 3274 | - return g_strdup (_("Go to next page")); |
| 3275 | - } else if (g_ascii_strcasecmp (name, "LastPage") == 0) { |
| 3276 | - return g_strdup (_("Go to last page")); |
| 3277 | - } else if (g_ascii_strcasecmp (name, "GoToPage") == 0) { |
| 3278 | - return g_strdup (_("Go to page")); |
| 3279 | - } else if (g_ascii_strcasecmp (name, "Find") == 0) { |
| 3280 | - return g_strdup (_("Find")); |
| 3281 | - } |
| 3282 | - |
| 3283 | - return NULL; |
| 3284 | -} |
| 3285 | - |
| 3286 | -static char * |
| 3287 | -tip_from_link (EvView *view, EvLink *link) |
| 3288 | -{ |
| 3289 | - EvLinkAction *action; |
| 3290 | - EvLinkActionType type; |
| 3291 | - char *msg = NULL; |
| 3292 | - char *page_label; |
| 3293 | - const char *title; |
| 3294 | - |
| 3295 | - action = ev_link_get_action (link); |
| 3296 | - title = ev_link_get_title (link); |
| 3297 | - |
| 3298 | - if (!action) |
| 3299 | - return title ? g_strdup (title) : NULL; |
| 3300 | - |
| 3301 | - type = ev_link_action_get_action_type (action); |
| 3302 | - |
| 3303 | - switch (type) { |
| 3304 | - case EV_LINK_ACTION_TYPE_GOTO_DEST: |
| 3305 | - page_label = ev_document_links_get_dest_page_label (EV_DOCUMENT_LINKS (view->document), |
| 3306 | - ev_link_action_get_dest (action)); |
| 3307 | - if (page_label) { |
| 3308 | - msg = g_strdup_printf (_("Go to page %s"), page_label); |
| 3309 | - g_free (page_label); |
| 3310 | - } |
| 3311 | - break; |
| 3312 | - case EV_LINK_ACTION_TYPE_GOTO_REMOTE: |
| 3313 | - if (title) { |
| 3314 | - msg = g_strdup_printf (_("Go to %s on file “%s”"), title, |
| 3315 | - ev_link_action_get_filename (action)); |
| 3316 | - } else { |
| 3317 | - msg = g_strdup_printf (_("Go to file “%s”"), |
| 3318 | - ev_link_action_get_filename (action)); |
| 3319 | - } |
| 3320 | - break; |
| 3321 | - case EV_LINK_ACTION_TYPE_EXTERNAL_URI: |
| 3322 | - msg = g_strdup (ev_link_action_get_uri (action)); |
| 3323 | - break; |
| 3324 | - case EV_LINK_ACTION_TYPE_LAUNCH: |
| 3325 | - msg = g_strdup_printf (_("Launch %s"), |
| 3326 | - ev_link_action_get_filename (action)); |
| 3327 | - break; |
| 3328 | - case EV_LINK_ACTION_TYPE_NAMED: |
| 3329 | - msg = tip_from_action_named (action); |
| 3330 | - break; |
| 3331 | - default: |
| 3332 | - if (title) |
| 3333 | - msg = g_strdup (title); |
| 3334 | - break; |
| 3335 | - } |
| 3336 | - |
| 3337 | - return msg; |
| 3338 | -} |
| 3339 | - |
| 3340 | -static void |
| 3341 | -ev_view_handle_cursor_over_xy (EvView *view, gint x, gint y) |
| 3342 | -{ |
| 3343 | - EvLink *link; |
| 3344 | - EvFormField *field; |
| 3345 | - EvAnnotation *annot = NULL; |
| 3346 | - |
| 3347 | - if (view->cursor == EV_VIEW_CURSOR_HIDDEN) |
| 3348 | - return; |
| 3349 | - |
| 3350 | - if (view->adding_annot) { |
| 3351 | - if (view->cursor != EV_VIEW_CURSOR_ADD) |
| 3352 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_ADD); |
| 3353 | - return; |
| 3354 | - } |
| 3355 | - |
| 3356 | - if (view->drag_info.in_drag) { |
| 3357 | - if (view->cursor != EV_VIEW_CURSOR_DRAG) |
| 3358 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_DRAG); |
| 3359 | - return; |
| 3360 | - } |
| 3361 | - |
| 3362 | - if (view->scroll_info.autoscrolling) { |
| 3363 | - if (view->cursor != EV_VIEW_CURSOR_AUTOSCROLL) |
| 3364 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_AUTOSCROLL); |
| 3365 | - return; |
| 3366 | - } |
| 3367 | - |
| 3368 | - link = ev_view_get_link_at_location (view, x, y); |
| 3369 | - if (link) { |
| 3370 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_LINK); |
| 3371 | - } else if ((field = ev_view_get_form_field_at_location (view, x, y))) { |
| 3372 | - if (field->is_read_only) { |
| 3373 | - if (view->cursor == EV_VIEW_CURSOR_LINK || |
| 3374 | - view->cursor == EV_VIEW_CURSOR_IBEAM || |
| 3375 | - view->cursor == EV_VIEW_CURSOR_DRAG) |
| 3376 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL); |
| 3377 | - } else if (EV_IS_FORM_FIELD_TEXT (field)) { |
| 3378 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_IBEAM); |
| 3379 | - } else { |
| 3380 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_LINK); |
| 3381 | - } |
| 3382 | - } else if ((annot = ev_view_get_annotation_at_location (view, x, y))) { |
| 3383 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_LINK); |
| 3384 | - } else if (location_in_text (view, x + view->scroll_x, y + view->scroll_y)) { |
| 3385 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_IBEAM); |
| 3386 | - } else { |
| 3387 | - if (view->cursor == EV_VIEW_CURSOR_LINK || |
| 3388 | - view->cursor == EV_VIEW_CURSOR_IBEAM || |
| 3389 | - view->cursor == EV_VIEW_CURSOR_DRAG || |
| 3390 | - view->cursor == EV_VIEW_CURSOR_AUTOSCROLL || |
| 3391 | - view->cursor == EV_VIEW_CURSOR_ADD) |
| 3392 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL); |
| 3393 | - } |
| 3394 | - |
| 3395 | - if (link || annot) |
| 3396 | - g_object_set (view, "has-tooltip", TRUE, NULL); |
| 3397 | -} |
| 3398 | - |
| 3399 | -/*** Images ***/ |
| 3400 | -static EvImage * |
| 3401 | -ev_view_get_image_at_location (EvView *view, |
| 3402 | - gdouble x, |
| 3403 | - gdouble y) |
| 3404 | -{ |
| 3405 | - gint page = -1; |
| 3406 | - gint x_new = 0, y_new = 0; |
| 3407 | - EvMappingList *image_mapping; |
| 3408 | - |
| 3409 | - if (!EV_IS_DOCUMENT_IMAGES (view->document)) |
| 3410 | - return NULL; |
| 3411 | - |
| 3412 | - if (!get_doc_point_from_location (view, x, y, &page, &x_new, &y_new)) |
| 3413 | - return NULL; |
| 3414 | - |
| 3415 | - image_mapping = ev_page_cache_get_image_mapping (view->page_cache, page); |
| 3416 | - |
| 3417 | - if (image_mapping) |
| 3418 | - return ev_mapping_list_get_data (image_mapping, x_new, y_new); |
| 3419 | - else |
| 3420 | - return NULL; |
| 3421 | -} |
| 3422 | - |
| 3423 | -/*** Focus ***/ |
| 3424 | -static gboolean |
| 3425 | -ev_view_get_focused_area (EvView *view, |
| 3426 | - GdkRectangle *area) |
| 3427 | -{ |
| 3428 | - if (!view->focused_element) |
| 3429 | - return FALSE; |
| 3430 | - |
| 3431 | - _ev_view_transform_doc_rect_to_view_rect (view, |
| 3432 | - view->focused_element_page, |
| 3433 | - &view->focused_element->area, |
| 3434 | - area); |
| 3435 | - area->x -= view->scroll_x + 1; |
| 3436 | - area->y -= view->scroll_y + 1; |
| 3437 | - area->width += 1; |
| 3438 | - area->height += 1; |
| 3439 | - |
| 3440 | - return TRUE; |
| 3441 | -} |
| 3442 | - |
| 3443 | -void |
| 3444 | -_ev_view_set_focused_element (EvView *view, |
| 3445 | - EvMapping *element_mapping, |
| 3446 | - gint page) |
| 3447 | -{ |
| 3448 | - GdkRectangle view_rect; |
| 3449 | - cairo_region_t *region = NULL; |
| 3450 | - |
| 3451 | - if (view->focused_element == element_mapping) |
| 3452 | - return; |
| 3453 | - |
| 3454 | - if (view->accessible) |
| 3455 | - ev_view_accessible_set_focused_element (EV_VIEW_ACCESSIBLE (view->accessible), element_mapping, page); |
| 3456 | - |
| 3457 | - if (ev_view_get_focused_area (view, &view_rect)) |
| 3458 | - region = cairo_region_create_rectangle (&view_rect); |
| 3459 | - |
| 3460 | - view->focused_element = element_mapping; |
| 3461 | - view->focused_element_page = page; |
| 3462 | - |
| 3463 | - if (ev_view_get_focused_area (view, &view_rect)) { |
| 3464 | - if (!region) |
| 3465 | - region = cairo_region_create_rectangle (&view_rect); |
| 3466 | - else |
| 3467 | - cairo_region_union_rectangle (region, &view_rect); |
| 3468 | - |
| 3469 | - ev_document_model_set_page (view->model, page); |
| 3470 | - view_rect.x += view->scroll_x; |
| 3471 | - view_rect.y += view->scroll_y; |
| 3472 | - ensure_rectangle_is_visible (view, &view_rect); |
| 3473 | - } |
| 3474 | - |
| 3475 | - if (region) { |
| 3476 | - gdk_window_invalidate_region (gtk_widget_get_window (GTK_WIDGET (view)), |
| 3477 | - region, TRUE); |
| 3478 | - cairo_region_destroy (region); |
| 3479 | - } |
| 3480 | -} |
| 3481 | - |
| 3482 | -/*** Forms ***/ |
| 3483 | -static EvMapping * |
| 3484 | -get_form_field_mapping_at_location (EvView *view, |
| 3485 | - gdouble x, |
| 3486 | - gdouble y, |
| 3487 | - gint *page) |
| 3488 | -{ |
| 3489 | - gint x_new = 0, y_new = 0; |
| 3490 | - EvMappingList *forms_mapping; |
| 3491 | - |
| 3492 | - if (!EV_IS_DOCUMENT_FORMS (view->document)) |
| 3493 | - return NULL; |
| 3494 | - |
| 3495 | - if (!get_doc_point_from_location (view, x, y, page, &x_new, &y_new)) |
| 3496 | - return NULL; |
| 3497 | - |
| 3498 | - forms_mapping = ev_page_cache_get_form_field_mapping (view->page_cache, *page); |
| 3499 | - |
| 3500 | - if (forms_mapping) |
| 3501 | - return ev_mapping_list_get (forms_mapping, x_new, y_new); |
| 3502 | - |
| 3503 | - return NULL; |
| 3504 | -} |
| 3505 | - |
| 3506 | -static EvFormField * |
| 3507 | -ev_view_get_form_field_at_location (EvView *view, |
| 3508 | - gdouble x, |
| 3509 | - gdouble y) |
| 3510 | -{ |
| 3511 | - EvMapping *field_mapping; |
| 3512 | - gint page; |
| 3513 | - |
| 3514 | - field_mapping = get_form_field_mapping_at_location (view, x, y, &page); |
| 3515 | - |
| 3516 | - return field_mapping ? field_mapping->data : NULL; |
| 3517 | -} |
| 3518 | - |
| 3519 | -static cairo_region_t * |
| 3520 | -ev_view_form_field_get_region (EvView *view, |
| 3521 | - EvFormField *field) |
| 3522 | -{ |
| 3523 | - GdkRectangle view_area; |
| 3524 | - EvMappingList *forms_mapping; |
| 3525 | - |
| 3526 | - forms_mapping = ev_page_cache_get_form_field_mapping (view->page_cache, |
| 3527 | - field->page->index); |
| 3528 | - ev_view_get_area_from_mapping (view, field->page->index, |
| 3529 | - forms_mapping, |
| 3530 | - field, &view_area); |
| 3531 | - |
| 3532 | - return cairo_region_create_rectangle (&view_area); |
| 3533 | -} |
| 3534 | - |
| 3535 | -static gboolean |
| 3536 | -ev_view_forms_remove_widgets (EvView *view) |
| 3537 | -{ |
| 3538 | - ev_view_remove_all (view); |
| 3539 | - |
| 3540 | - return FALSE; |
| 3541 | -} |
| 3542 | - |
| 3543 | -static void |
| 3544 | -ev_view_form_field_destroy (GtkWidget *widget, |
| 3545 | - EvView *view) |
| 3546 | -{ |
| 3547 | - g_idle_add ((GSourceFunc)ev_view_forms_remove_widgets, view); |
| 3548 | -} |
| 3549 | - |
| 3550 | -static void |
| 3551 | -ev_view_form_field_button_toggle (EvView *view, |
| 3552 | - EvFormField *field) |
| 3553 | -{ |
| 3554 | - EvMappingList *forms_mapping; |
| 3555 | - cairo_region_t *region; |
| 3556 | - gboolean state; |
| 3557 | - GList *l; |
| 3558 | - EvFormFieldButton *field_button = EV_FORM_FIELD_BUTTON (field); |
| 3559 | - |
| 3560 | - if (field_button->type == EV_FORM_FIELD_BUTTON_PUSH) |
| 3561 | - return; |
| 3562 | - |
| 3563 | - state = ev_document_forms_form_field_button_get_state (EV_DOCUMENT_FORMS (view->document), |
| 3564 | - field); |
| 3565 | - |
| 3566 | - /* FIXME: it actually depends on NoToggleToOff flags */ |
| 3567 | - if (field_button->type == EV_FORM_FIELD_BUTTON_RADIO && state && field_button->state) |
| 3568 | - return; |
| 3569 | - |
| 3570 | - region = ev_view_form_field_get_region (view, field); |
| 3571 | - |
| 3572 | - /* For radio buttons and checkbox buttons that are in a set |
| 3573 | - * we need to update also the region for the current selected item |
| 3574 | - */ |
| 3575 | - forms_mapping = ev_page_cache_get_form_field_mapping (view->page_cache, |
| 3576 | - field->page->index); |
| 3577 | - |
| 3578 | - for (l = ev_mapping_list_get_list (forms_mapping); l; l = g_list_next (l)) { |
| 3579 | - EvFormField *button = ((EvMapping *)(l->data))->data; |
| 3580 | - cairo_region_t *button_region; |
| 3581 | - |
| 3582 | - if (button->id == field->id) |
| 3583 | - continue; |
| 3584 | - |
| 3585 | - /* FIXME: only buttons in the same group should be updated */ |
| 3586 | - if (!EV_IS_FORM_FIELD_BUTTON (button) || |
| 3587 | - EV_FORM_FIELD_BUTTON (button)->type != field_button->type || |
| 3588 | - EV_FORM_FIELD_BUTTON (button)->state != TRUE) |
| 3589 | - continue; |
| 3590 | - |
| 3591 | - button_region = ev_view_form_field_get_region (view, button); |
| 3592 | - cairo_region_union (region, button_region); |
| 3593 | - cairo_region_destroy (button_region); |
| 3594 | - } |
| 3595 | - |
| 3596 | - /* Update state */ |
| 3597 | - ev_document_forms_form_field_button_set_state (EV_DOCUMENT_FORMS (view->document), |
| 3598 | - field, |
| 3599 | - !state); |
| 3600 | - field_button->state = !state; |
| 3601 | - |
| 3602 | - if (view->accessible) |
| 3603 | - ev_view_accessible_update_element_state (EV_VIEW_ACCESSIBLE (view->accessible), |
| 3604 | - ev_mapping_list_find (forms_mapping, field), |
| 3605 | - field->page->index); |
| 3606 | - |
| 3607 | - ev_view_reload_page (view, field->page->index, region); |
| 3608 | - cairo_region_destroy (region); |
| 3609 | -} |
| 3610 | - |
| 3611 | -static GtkWidget * |
| 3612 | -ev_view_form_field_button_create_widget (EvView *view, |
| 3613 | - EvFormField *field) |
| 3614 | -{ |
| 3615 | - EvMappingList *form_mapping; |
| 3616 | - EvMapping *mapping; |
| 3617 | - |
| 3618 | - /* We need to do this focus grab prior to setting the focused element for accessibility */ |
| 3619 | - if (!gtk_widget_has_focus (GTK_WIDGET (view))) |
| 3620 | - gtk_widget_grab_focus (GTK_WIDGET (view)); |
| 3621 | - |
| 3622 | - form_mapping = ev_page_cache_get_form_field_mapping (view->page_cache, |
| 3623 | - field->page->index); |
| 3624 | - mapping = ev_mapping_list_find (form_mapping, field); |
| 3625 | - _ev_view_set_focused_element (view, mapping, field->page->index); |
| 3626 | - |
| 3627 | - return NULL; |
| 3628 | -} |
| 3629 | - |
| 3630 | -static void |
| 3631 | -ev_view_form_field_text_save (EvView *view, |
| 3632 | - GtkWidget *widget) |
| 3633 | -{ |
| 3634 | - EvFormField *field; |
| 3635 | - |
| 3636 | - if (!view->document) |
| 3637 | - return; |
| 3638 | - |
| 3639 | - field = g_object_get_data (G_OBJECT (widget), "form-field"); |
| 3640 | - |
| 3641 | - if (field->changed) { |
| 3642 | - EvFormFieldText *field_text = EV_FORM_FIELD_TEXT (field); |
| 3643 | - cairo_region_t *field_region; |
| 3644 | - |
| 3645 | - field_region = ev_view_form_field_get_region (view, field); |
| 3646 | - |
| 3647 | - ev_document_forms_form_field_text_set_text (EV_DOCUMENT_FORMS (view->document), |
| 3648 | - field, field_text->text); |
| 3649 | - field->changed = FALSE; |
| 3650 | - ev_view_reload_page (view, field->page->index, field_region); |
| 3651 | - cairo_region_destroy (field_region); |
| 3652 | - } |
| 3653 | -} |
| 3654 | - |
| 3655 | -static void |
| 3656 | -ev_view_form_field_text_changed (GtkWidget *widget, |
| 3657 | - EvFormField *field) |
| 3658 | -{ |
| 3659 | - EvFormFieldText *field_text = EV_FORM_FIELD_TEXT (field); |
| 3660 | - gchar *text = NULL; |
| 3661 | - |
| 3662 | - if (GTK_IS_ENTRY (widget)) { |
| 3663 | - text = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget))); |
| 3664 | - } else if (GTK_IS_TEXT_BUFFER (widget)) { |
| 3665 | - GtkTextIter start, end; |
| 3666 | - |
| 3667 | - gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (widget), &start, &end); |
| 3668 | - text = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (widget), |
| 3669 | - &start, &end, FALSE); |
| 3670 | - } |
| 3671 | - |
| 3672 | - if (!field_text->text || |
| 3673 | - (field_text->text && g_ascii_strcasecmp (field_text->text, text) != 0)) { |
| 3674 | - g_free (field_text->text); |
| 3675 | - field_text->text = text; |
| 3676 | - field->changed = TRUE; |
| 3677 | - } |
| 3678 | -} |
| 3679 | - |
| 3680 | -static gboolean |
| 3681 | -ev_view_form_field_text_focus_out (GtkWidget *widget, |
| 3682 | - GdkEventFocus *event, |
| 3683 | - EvView *view) |
| 3684 | -{ |
| 3685 | - ev_view_form_field_text_save (view, widget); |
| 3686 | - |
| 3687 | - return FALSE; |
| 3688 | -} |
| 3689 | - |
| 3690 | -static GtkWidget * |
| 3691 | -ev_view_form_field_text_create_widget (EvView *view, |
| 3692 | - EvFormField *field) |
| 3693 | -{ |
| 3694 | - EvFormFieldText *field_text = EV_FORM_FIELD_TEXT (field); |
| 3695 | - GtkWidget *text = NULL; |
| 3696 | - gchar *txt; |
| 3697 | - |
| 3698 | - txt = ev_document_forms_form_field_text_get_text (EV_DOCUMENT_FORMS (view->document), |
| 3699 | - field); |
| 3700 | - |
| 3701 | - switch (field_text->type) { |
| 3702 | - case EV_FORM_FIELD_TEXT_FILE_SELECT: |
| 3703 | - /* TODO */ |
| 3704 | - case EV_FORM_FIELD_TEXT_NORMAL: |
| 3705 | - text = gtk_entry_new (); |
| 3706 | - gtk_entry_set_has_frame (GTK_ENTRY (text), FALSE); |
| 3707 | - gtk_entry_set_max_length (GTK_ENTRY (text), field_text->max_len); |
| 3708 | - gtk_entry_set_visibility (GTK_ENTRY (text), !field_text->is_password); |
| 3709 | - |
| 3710 | - if (txt) { |
| 3711 | - gtk_entry_set_text (GTK_ENTRY (text), txt); |
| 3712 | - g_free (txt); |
| 3713 | - } |
| 3714 | - |
| 3715 | - g_signal_connect (text, "focus-out-event", |
| 3716 | - G_CALLBACK (ev_view_form_field_text_focus_out), |
| 3717 | - view); |
| 3718 | - g_signal_connect (text, "changed", |
| 3719 | - G_CALLBACK (ev_view_form_field_text_changed), |
| 3720 | - field); |
| 3721 | - g_signal_connect_after (text, "activate", |
| 3722 | - G_CALLBACK (ev_view_form_field_destroy), |
| 3723 | - view); |
| 3724 | - break; |
| 3725 | - case EV_FORM_FIELD_TEXT_MULTILINE: { |
| 3726 | - GtkTextBuffer *buffer; |
| 3727 | - |
| 3728 | - text = gtk_text_view_new (); |
| 3729 | - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); |
| 3730 | - |
| 3731 | - if (txt) { |
| 3732 | - gtk_text_buffer_set_text (buffer, txt, -1); |
| 3733 | - g_free (txt); |
| 3734 | - } |
| 3735 | - |
| 3736 | - g_signal_connect (text, "focus-out-event", |
| 3737 | - G_CALLBACK (ev_view_form_field_text_focus_out), |
| 3738 | - view); |
| 3739 | - g_signal_connect (buffer, "changed", |
| 3740 | - G_CALLBACK (ev_view_form_field_text_changed), |
| 3741 | - field); |
| 3742 | - } |
| 3743 | - break; |
| 3744 | - } |
| 3745 | - |
| 3746 | - g_object_weak_ref (G_OBJECT (text), |
| 3747 | - (GWeakNotify)ev_view_form_field_text_save, |
| 3748 | - view); |
| 3749 | - |
| 3750 | - return text; |
| 3751 | -} |
| 3752 | - |
| 3753 | -static void |
| 3754 | -ev_view_form_field_choice_save (EvView *view, |
| 3755 | - GtkWidget *widget) |
| 3756 | -{ |
| 3757 | - EvFormField *field; |
| 3758 | - |
| 3759 | - if (!view->document) |
| 3760 | - return; |
| 3761 | - |
| 3762 | - field = g_object_get_data (G_OBJECT (widget), "form-field"); |
| 3763 | - |
| 3764 | - if (field->changed) { |
| 3765 | - GList *l; |
| 3766 | - EvFormFieldChoice *field_choice = EV_FORM_FIELD_CHOICE (field); |
| 3767 | - cairo_region_t *field_region; |
| 3768 | - |
| 3769 | - field_region = ev_view_form_field_get_region (view, field); |
| 3770 | - |
| 3771 | - if (field_choice->is_editable) { |
| 3772 | - ev_document_forms_form_field_choice_set_text (EV_DOCUMENT_FORMS (view->document), |
| 3773 | - field, field_choice->text); |
| 3774 | - } else { |
| 3775 | - ev_document_forms_form_field_choice_unselect_all (EV_DOCUMENT_FORMS (view->document), field); |
| 3776 | - for (l = field_choice->selected_items; l; l = g_list_next (l)) { |
| 3777 | - ev_document_forms_form_field_choice_select_item (EV_DOCUMENT_FORMS (view->document), |
| 3778 | - field, |
| 3779 | - GPOINTER_TO_INT (l->data)); |
| 3780 | - } |
| 3781 | - } |
| 3782 | - field->changed = FALSE; |
| 3783 | - ev_view_reload_page (view, field->page->index, field_region); |
| 3784 | - cairo_region_destroy (field_region); |
| 3785 | - } |
| 3786 | -} |
| 3787 | - |
| 3788 | -static void |
| 3789 | -ev_view_form_field_choice_changed (GtkWidget *widget, |
| 3790 | - EvFormField *field) |
| 3791 | -{ |
| 3792 | - EvFormFieldChoice *field_choice = EV_FORM_FIELD_CHOICE (field); |
| 3793 | - |
| 3794 | - if (GTK_IS_COMBO_BOX (widget)) { |
| 3795 | - gint item; |
| 3796 | - |
| 3797 | - item = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); |
| 3798 | - if (!field_choice->selected_items || |
| 3799 | - GPOINTER_TO_INT (field_choice->selected_items->data) != item) { |
| 3800 | - g_list_free (field_choice->selected_items); |
| 3801 | - field_choice->selected_items = NULL; |
| 3802 | - field_choice->selected_items = g_list_prepend (field_choice->selected_items, |
| 3803 | - GINT_TO_POINTER (item)); |
| 3804 | - field->changed = TRUE; |
| 3805 | - } |
| 3806 | - |
| 3807 | - if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget))) { |
| 3808 | - const gchar *text; |
| 3809 | - |
| 3810 | - text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget)))); |
| 3811 | - if (!field_choice->text || |
| 3812 | - (field_choice->text && g_ascii_strcasecmp (field_choice->text, text) != 0)) { |
| 3813 | - g_free (field_choice->text); |
| 3814 | - field_choice->text = g_strdup (text); |
| 3815 | - field->changed = TRUE; |
| 3816 | - } |
| 3817 | - } |
| 3818 | - } else if (GTK_IS_TREE_SELECTION (widget)) { |
| 3819 | - GtkTreeSelection *selection = GTK_TREE_SELECTION (widget); |
| 3820 | - GtkTreeModel *model; |
| 3821 | - GList *items, *l; |
| 3822 | - |
| 3823 | - items = gtk_tree_selection_get_selected_rows (selection, &model); |
| 3824 | - g_list_free (field_choice->selected_items); |
| 3825 | - field_choice->selected_items = NULL; |
| 3826 | - |
| 3827 | - for (l = items; l && l->data; l = g_list_next (l)) { |
| 3828 | - GtkTreeIter iter; |
| 3829 | - GtkTreePath *path = (GtkTreePath *)l->data; |
| 3830 | - gint item; |
| 3831 | - |
| 3832 | - gtk_tree_model_get_iter (model, &iter, path); |
| 3833 | - gtk_tree_model_get (model, &iter, 1, &item, -1); |
| 3834 | - |
| 3835 | - field_choice->selected_items = g_list_prepend (field_choice->selected_items, |
| 3836 | - GINT_TO_POINTER (item)); |
| 3837 | - |
| 3838 | - gtk_tree_path_free (path); |
| 3839 | - } |
| 3840 | - |
| 3841 | - g_list_free (items); |
| 3842 | - |
| 3843 | - field->changed = TRUE; |
| 3844 | - } |
| 3845 | -} |
| 3846 | - |
| 3847 | -static GtkWidget * |
| 3848 | -ev_view_form_field_choice_create_widget (EvView *view, |
| 3849 | - EvFormField *field) |
| 3850 | -{ |
| 3851 | - EvFormFieldChoice *field_choice = EV_FORM_FIELD_CHOICE (field); |
| 3852 | - GtkWidget *choice; |
| 3853 | - GtkTreeModel *model; |
| 3854 | - gint n_items, i; |
| 3855 | - gint selected_item = 0; |
| 3856 | - |
| 3857 | - n_items = ev_document_forms_form_field_choice_get_n_items (EV_DOCUMENT_FORMS (view->document), |
| 3858 | - field); |
| 3859 | - model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT)); |
| 3860 | - for (i = 0; i < n_items; i++) { |
| 3861 | - GtkTreeIter iter; |
| 3862 | - gchar *item; |
| 3863 | - |
| 3864 | - item = ev_document_forms_form_field_choice_get_item (EV_DOCUMENT_FORMS (view->document), |
| 3865 | - field, i); |
| 3866 | - if (ev_document_forms_form_field_choice_is_item_selected ( |
| 3867 | - EV_DOCUMENT_FORMS (view->document), field, i)) { |
| 3868 | - selected_item = i; |
| 3869 | - /* FIXME: we need a get_selected_items function in poppler */ |
| 3870 | - field_choice->selected_items = g_list_prepend (field_choice->selected_items, |
| 3871 | - GINT_TO_POINTER (i)); |
| 3872 | - } |
| 3873 | - |
| 3874 | - if (item) { |
| 3875 | - gtk_list_store_append (GTK_LIST_STORE (model), &iter); |
| 3876 | - gtk_list_store_set (GTK_LIST_STORE (model), &iter, |
| 3877 | - 0, item, |
| 3878 | - 1, i, |
| 3879 | - -1); |
| 3880 | - g_free (item); |
| 3881 | - } |
| 3882 | - } |
| 3883 | - |
| 3884 | - if (field_choice->type == EV_FORM_FIELD_CHOICE_LIST) { |
| 3885 | - GtkCellRenderer *renderer; |
| 3886 | - GtkWidget *tree_view; |
| 3887 | - GtkTreeSelection *selection; |
| 3888 | - |
| 3889 | - tree_view = gtk_tree_view_new_with_model (model); |
| 3890 | - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); |
| 3891 | - |
| 3892 | - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); |
| 3893 | - if (field_choice->multi_select) { |
| 3894 | - gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); |
| 3895 | - } |
| 3896 | - |
| 3897 | - /* TODO: set selected items */ |
| 3898 | - |
| 3899 | - renderer = gtk_cell_renderer_text_new (); |
| 3900 | - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
| 3901 | - 0, |
| 3902 | - "choix", renderer, |
| 3903 | - "text", 0, |
| 3904 | - NULL); |
| 3905 | - |
| 3906 | - choice = gtk_scrolled_window_new (NULL, NULL); |
| 3907 | - gtk_container_add (GTK_CONTAINER (choice), tree_view); |
| 3908 | - gtk_widget_show (tree_view); |
| 3909 | - |
| 3910 | - g_signal_connect (selection, "changed", |
| 3911 | - G_CALLBACK (ev_view_form_field_choice_changed), |
| 3912 | - field); |
| 3913 | - g_signal_connect_after (selection, "changed", |
| 3914 | - G_CALLBACK (ev_view_form_field_destroy), |
| 3915 | - view); |
| 3916 | - } else if (field_choice->is_editable) { /* ComboBoxEntry */ |
| 3917 | - gchar *text; |
| 3918 | - |
| 3919 | - choice = gtk_combo_box_new_with_model_and_entry (model); |
| 3920 | - gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (choice), 0); |
| 3921 | - |
| 3922 | - text = ev_document_forms_form_field_choice_get_text (EV_DOCUMENT_FORMS (view->document), field); |
| 3923 | - if (text) { |
| 3924 | - gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (choice))), text); |
| 3925 | - g_free (text); |
| 3926 | - } |
| 3927 | - |
| 3928 | - g_signal_connect (choice, "changed", |
| 3929 | - G_CALLBACK (ev_view_form_field_choice_changed), |
| 3930 | - field); |
| 3931 | - g_signal_connect_after (gtk_bin_get_child (GTK_BIN (choice)), |
| 3932 | - "activate", |
| 3933 | - G_CALLBACK (ev_view_form_field_destroy), |
| 3934 | - view); |
| 3935 | - } else { /* ComboBoxText */ |
| 3936 | - GtkCellRenderer *renderer; |
| 3937 | - |
| 3938 | - choice = gtk_combo_box_new_with_model (model); |
| 3939 | - renderer = gtk_cell_renderer_text_new (); |
| 3940 | - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (choice), |
| 3941 | - renderer, TRUE); |
| 3942 | - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (choice), |
| 3943 | - renderer, |
| 3944 | - "text", 0, |
| 3945 | - NULL); |
| 3946 | - gtk_combo_box_set_active (GTK_COMBO_BOX (choice), selected_item); |
| 3947 | - gtk_combo_box_popup (GTK_COMBO_BOX (choice)); |
| 3948 | - |
| 3949 | - g_signal_connect (choice, "changed", |
| 3950 | - G_CALLBACK (ev_view_form_field_choice_changed), |
| 3951 | - field); |
| 3952 | - g_signal_connect_after (choice, "changed", |
| 3953 | - G_CALLBACK (ev_view_form_field_destroy), |
| 3954 | - view); |
| 3955 | - } |
| 3956 | - |
| 3957 | - g_object_unref (model); |
| 3958 | - |
| 3959 | - g_object_weak_ref (G_OBJECT (choice), |
| 3960 | - (GWeakNotify)ev_view_form_field_choice_save, |
| 3961 | - view); |
| 3962 | - |
| 3963 | - return choice; |
| 3964 | -} |
| 3965 | - |
| 3966 | -void |
| 3967 | -_ev_view_focus_form_field (EvView *view, |
| 3968 | - EvFormField *field) |
| 3969 | -{ |
| 3970 | - GtkWidget *field_widget = NULL; |
| 3971 | - EvMappingList *form_field_mapping; |
| 3972 | - EvMapping *mapping; |
| 3973 | - |
| 3974 | - _ev_view_set_focused_element (view, NULL, -1); |
| 3975 | - |
| 3976 | - if (field->is_read_only) |
| 3977 | - return; |
| 3978 | - |
| 3979 | - if (EV_IS_FORM_FIELD_BUTTON (field)) { |
| 3980 | - field_widget = ev_view_form_field_button_create_widget (view, field); |
| 3981 | - } else if (EV_IS_FORM_FIELD_TEXT (field)) { |
| 3982 | - field_widget = ev_view_form_field_text_create_widget (view, field); |
| 3983 | - } else if (EV_IS_FORM_FIELD_CHOICE (field)) { |
| 3984 | - field_widget = ev_view_form_field_choice_create_widget (view, field); |
| 3985 | - } else if (EV_IS_FORM_FIELD_SIGNATURE (field)) { |
| 3986 | - /* TODO */ |
| 3987 | - } |
| 3988 | - |
| 3989 | - /* Form field doesn't require a widget */ |
| 3990 | - if (!field_widget) { |
| 3991 | - if (!gtk_widget_has_focus (GTK_WIDGET (view))) |
| 3992 | - gtk_widget_grab_focus (GTK_WIDGET (view)); |
| 3993 | - return; |
| 3994 | - } |
| 3995 | - |
| 3996 | - g_object_set_data_full (G_OBJECT (field_widget), "form-field", |
| 3997 | - g_object_ref (field), |
| 3998 | - (GDestroyNotify)g_object_unref); |
| 3999 | - |
| 4000 | - form_field_mapping = ev_page_cache_get_form_field_mapping (view->page_cache, |
| 4001 | - field->page->index); |
| 4002 | - mapping = ev_mapping_list_find (form_field_mapping, field); |
| 4003 | - _ev_view_set_focused_element (view, mapping, field->page->index); |
| 4004 | - ev_view_put_to_doc_rect (view, field_widget, field->page->index, &mapping->area); |
| 4005 | - gtk_widget_show (field_widget); |
| 4006 | - gtk_widget_grab_focus (field_widget); |
| 4007 | -} |
| 4008 | - |
| 4009 | -static void |
| 4010 | -ev_view_handle_form_field (EvView *view, |
| 4011 | - EvFormField *field) |
| 4012 | -{ |
| 4013 | - if (field->is_read_only) |
| 4014 | - return; |
| 4015 | - |
| 4016 | - _ev_view_focus_form_field (view, field); |
| 4017 | - |
| 4018 | - if (field->activation_link) |
| 4019 | - ev_view_handle_link (view, field->activation_link); |
| 4020 | - |
| 4021 | - if (EV_IS_FORM_FIELD_BUTTON (field)) |
| 4022 | - ev_view_form_field_button_toggle (view, field); |
| 4023 | - |
| 4024 | -} |
| 4025 | - |
| 4026 | -/* Annotations */ |
| 4027 | -static EvViewWindowChild * |
| 4028 | -ev_view_get_window_child (EvView *view, |
| 4029 | - GtkWidget *window) |
| 4030 | -{ |
| 4031 | - GList *children = view->window_children; |
| 4032 | - |
| 4033 | - while (children) { |
| 4034 | - EvViewWindowChild *child; |
| 4035 | - |
| 4036 | - child = (EvViewWindowChild *)children->data; |
| 4037 | - children = children->next; |
| 4038 | - |
| 4039 | - if (child->window == window) |
| 4040 | - return child; |
| 4041 | - } |
| 4042 | - |
| 4043 | - return NULL; |
| 4044 | -} |
| 4045 | - |
| 4046 | -static void |
| 4047 | -ev_view_window_child_move (EvView *view, |
| 4048 | - EvViewWindowChild *child, |
| 4049 | - gint x, |
| 4050 | - gint y) |
| 4051 | -{ |
| 4052 | - GtkAllocation allocation; |
| 4053 | - gint width, height; |
| 4054 | - |
| 4055 | - gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); |
| 4056 | - gtk_window_get_size (GTK_WINDOW (child->window), &width, &height); |
| 4057 | - |
| 4058 | - child->x = x; |
| 4059 | - child->y = y; |
| 4060 | - gtk_window_move (GTK_WINDOW (child->window), |
| 4061 | - CLAMP (x, child->parent_x, |
| 4062 | - child->parent_x + allocation.width - width), |
| 4063 | - CLAMP (y, child->parent_y, |
| 4064 | - child->parent_y + allocation.height - height)); |
| 4065 | -} |
| 4066 | - |
| 4067 | -static void |
| 4068 | -ev_view_window_child_move_with_parent (EvView *view, |
| 4069 | - GtkWidget *window) |
| 4070 | -{ |
| 4071 | - EvViewWindowChild *child; |
| 4072 | - gint root_x, root_y; |
| 4073 | - |
| 4074 | - child = ev_view_get_window_child (view, window); |
| 4075 | - gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (view)), |
| 4076 | - &root_x, &root_y); |
| 4077 | - if (root_x != child->parent_x || root_y != child->parent_y) { |
| 4078 | - gint dest_x, dest_y; |
| 4079 | - |
| 4080 | - dest_x = child->x + (root_x - child->parent_x); |
| 4081 | - dest_y = child->y + (root_y - child->parent_y); |
| 4082 | - child->parent_x = root_x; |
| 4083 | - child->parent_y = root_y; |
| 4084 | - ev_view_window_child_move (view, child, dest_x, dest_y); |
| 4085 | - } |
| 4086 | - |
| 4087 | - if (child->visible && !gtk_widget_get_visible (window)) |
| 4088 | - gtk_widget_show (window); |
| 4089 | -} |
| 4090 | - |
| 4091 | -static void |
| 4092 | -ev_view_window_child_put (EvView *view, |
| 4093 | - GtkWidget *window, |
| 4094 | - guint page, |
| 4095 | - gint x, |
| 4096 | - gint y, |
| 4097 | - gdouble orig_x, |
| 4098 | - gdouble orig_y) |
| 4099 | -{ |
| 4100 | - EvViewWindowChild *child; |
| 4101 | - gint root_x, root_y; |
| 4102 | - |
| 4103 | - gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (view)), |
| 4104 | - &root_x, &root_y); |
| 4105 | - |
| 4106 | - child = g_new0 (EvViewWindowChild, 1); |
| 4107 | - child->window = window; |
| 4108 | - child->page = page; |
| 4109 | - child->orig_x = orig_x; |
| 4110 | - child->orig_y = orig_y; |
| 4111 | - child->parent_x = root_x; |
| 4112 | - child->parent_y = root_y; |
| 4113 | - child->visible = ev_annotation_window_is_open (EV_ANNOTATION_WINDOW (window)); |
| 4114 | - ev_view_window_child_move (view, child, x + root_x, y + root_y); |
| 4115 | - |
| 4116 | - if (child->visible) |
| 4117 | - gtk_widget_show (window); |
| 4118 | - else |
| 4119 | - gtk_widget_hide (window); |
| 4120 | - |
| 4121 | - view->window_children = g_list_append (view->window_children, child); |
| 4122 | -} |
| 4123 | - |
| 4124 | -static EvViewWindowChild * |
| 4125 | -ev_view_find_window_child_for_annot (EvView *view, |
| 4126 | - guint page, |
| 4127 | - EvAnnotation *annot) |
| 4128 | -{ |
| 4129 | - GList *children = view->window_children; |
| 4130 | - |
| 4131 | - while (children) { |
| 4132 | - EvViewWindowChild *child; |
| 4133 | - EvAnnotation *wannot; |
| 4134 | - |
| 4135 | - child = (EvViewWindowChild *)children->data; |
| 4136 | - children = children->next; |
| 4137 | - |
| 4138 | - if (child->page != page) |
| 4139 | - continue; |
| 4140 | - |
| 4141 | - wannot = ev_annotation_window_get_annotation (EV_ANNOTATION_WINDOW (child->window)); |
| 4142 | - if (ev_annotation_equal (wannot, annot)) |
| 4143 | - return child; |
| 4144 | - } |
| 4145 | - |
| 4146 | - return NULL; |
| 4147 | -} |
| 4148 | - |
| 4149 | -static void |
| 4150 | -ev_view_window_children_free (EvView *view) |
| 4151 | -{ |
| 4152 | - GList *l; |
| 4153 | - |
| 4154 | - if (!view->window_children) |
| 4155 | - return; |
| 4156 | - |
| 4157 | - for (l = view->window_children; l && l->data; l = g_list_next (l)) { |
| 4158 | - EvViewWindowChild *child; |
| 4159 | - |
| 4160 | - child = (EvViewWindowChild *)l->data; |
| 4161 | - gtk_widget_destroy (GTK_WIDGET (child->window)); |
| 4162 | - g_free (child); |
| 4163 | - } |
| 4164 | - g_list_free (view->window_children); |
| 4165 | - view->window_children = NULL; |
| 4166 | - view->window_child_focus = NULL; |
| 4167 | -} |
| 4168 | - |
| 4169 | -static void |
| 4170 | -annotation_window_grab_focus (GtkWidget *widget, |
| 4171 | - EvView *view) |
| 4172 | -{ |
| 4173 | - if (view->window_child_focus) |
| 4174 | - ev_annotation_window_ungrab_focus (EV_ANNOTATION_WINDOW (view->window_child_focus->window)); |
| 4175 | - view->window_child_focus = ev_view_get_window_child (view, widget); |
| 4176 | -} |
| 4177 | - |
| 4178 | -static void |
| 4179 | -annotation_window_closed (EvAnnotationWindow *window, |
| 4180 | - EvView *view) |
| 4181 | -{ |
| 4182 | - EvViewWindowChild *child; |
| 4183 | - |
| 4184 | - child = ev_view_get_window_child (view, GTK_WIDGET (window)); |
| 4185 | - child->visible = FALSE; |
| 4186 | -} |
| 4187 | - |
| 4188 | -static void |
| 4189 | -annotation_window_moved (EvAnnotationWindow *window, |
| 4190 | - gint x, |
| 4191 | - gint y, |
| 4192 | - EvView *view) |
| 4193 | -{ |
| 4194 | - EvViewWindowChild *child; |
| 4195 | - GdkRectangle page_area; |
| 4196 | - GtkBorder border; |
| 4197 | - GdkRectangle view_rect; |
| 4198 | - EvRectangle doc_rect; |
| 4199 | - gint width, height; |
| 4200 | - |
| 4201 | - child = ev_view_get_window_child (view, GTK_WIDGET (window)); |
| 4202 | - if (child->x == x && child->y == y) |
| 4203 | - return; |
| 4204 | - |
| 4205 | - child->moved = TRUE; |
| 4206 | - child->x = x; |
| 4207 | - child->y = y; |
| 4208 | - |
| 4209 | - /* Window has been moved by the user, |
| 4210 | - * we have to set a new origin in doc coords |
| 4211 | - */ |
| 4212 | - gtk_window_get_size (GTK_WINDOW (window), &width, &height); |
| 4213 | - view_rect.x = (x - child->parent_x) + view->scroll_x; |
| 4214 | - view_rect.y = (y - child->parent_y) + view->scroll_y; |
| 4215 | - view_rect.width = width; |
| 4216 | - view_rect.height = height; |
| 4217 | - |
| 4218 | - ev_view_get_page_extents (view, child->page, &page_area, &border); |
| 4219 | - _ev_view_transform_view_rect_to_doc_rect (view, &view_rect, &page_area, &border, &doc_rect); |
| 4220 | - child->orig_x = doc_rect.x1; |
| 4221 | - child->orig_y = doc_rect.y1; |
| 4222 | -} |
| 4223 | - |
| 4224 | -static void |
| 4225 | -ev_view_annotation_save_contents (EvView *view, |
| 4226 | - GParamSpec *pspec, |
| 4227 | - EvAnnotation *annot) |
| 4228 | -{ |
| 4229 | - if (!view->document) |
| 4230 | - return; |
| 4231 | - |
| 4232 | - ev_document_doc_mutex_lock (); |
| 4233 | - ev_document_annotations_save_annotation (EV_DOCUMENT_ANNOTATIONS (view->document), |
| 4234 | - annot, EV_ANNOTATIONS_SAVE_CONTENTS); |
| 4235 | - ev_document_doc_mutex_unlock (); |
| 4236 | -} |
| 4237 | - |
| 4238 | -static GtkWidget * |
| 4239 | -ev_view_create_annotation_window (EvView *view, |
| 4240 | - EvAnnotation *annot, |
| 4241 | - GtkWindow *parent) |
| 4242 | -{ |
| 4243 | - GtkWidget *window; |
| 4244 | - EvRectangle doc_rect; |
| 4245 | - GdkRectangle view_rect; |
| 4246 | - guint page; |
| 4247 | - |
| 4248 | - window = ev_annotation_window_new (annot, parent); |
| 4249 | - g_signal_connect (window, "grab_focus", |
| 4250 | - G_CALLBACK (annotation_window_grab_focus), |
| 4251 | - view); |
| 4252 | - g_signal_connect (window, "closed", |
| 4253 | - G_CALLBACK (annotation_window_closed), |
| 4254 | - view); |
| 4255 | - g_signal_connect (window, "moved", |
| 4256 | - G_CALLBACK (annotation_window_moved), |
| 4257 | - view); |
| 4258 | - g_signal_connect_swapped (annot, "notify::contents", |
| 4259 | - G_CALLBACK (ev_view_annotation_save_contents), |
| 4260 | - view); |
| 4261 | - g_object_set_data (G_OBJECT (annot), "popup", window); |
| 4262 | - |
| 4263 | - page = ev_annotation_get_page_index (annot); |
| 4264 | - ev_annotation_window_get_rectangle (EV_ANNOTATION_WINDOW (window), &doc_rect); |
| 4265 | - _ev_view_transform_doc_rect_to_view_rect (view, page, &doc_rect, &view_rect); |
| 4266 | - view_rect.x -= view->scroll_x; |
| 4267 | - view_rect.y -= view->scroll_y; |
| 4268 | - |
| 4269 | - ev_view_window_child_put (view, window, page, |
| 4270 | - view_rect.x, view_rect.y, |
| 4271 | - doc_rect.x1, doc_rect.y1); |
| 4272 | - |
| 4273 | - return window; |
| 4274 | -} |
| 4275 | - |
| 4276 | -static void |
| 4277 | -show_annotation_windows (EvView *view, |
| 4278 | - gint page) |
| 4279 | -{ |
| 4280 | - EvMappingList *annots; |
| 4281 | - GList *l; |
| 4282 | - GtkWindow *parent; |
| 4283 | - |
| 4284 | - parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))); |
| 4285 | - |
| 4286 | - annots = ev_page_cache_get_annot_mapping (view->page_cache, page); |
| 4287 | - |
| 4288 | - for (l = ev_mapping_list_get_list (annots); l && l->data; l = g_list_next (l)) { |
| 4289 | - EvAnnotation *annot; |
| 4290 | - EvViewWindowChild *child; |
| 4291 | - GtkWidget *window; |
| 4292 | - |
| 4293 | - annot = ((EvMapping *)(l->data))->data; |
| 4294 | - |
| 4295 | - if (!EV_IS_ANNOTATION_MARKUP (annot)) |
| 4296 | - continue; |
| 4297 | - |
| 4298 | - if (!ev_annotation_markup_has_popup (EV_ANNOTATION_MARKUP (annot))) |
| 4299 | - continue; |
| 4300 | - |
| 4301 | - window = g_object_get_data (G_OBJECT (annot), "popup"); |
| 4302 | - if (window) { |
| 4303 | - ev_view_window_child_move_with_parent (view, window); |
| 4304 | - continue; |
| 4305 | - } |
| 4306 | - |
| 4307 | - /* Look if we already have a popup for this annot */ |
| 4308 | - child = ev_view_find_window_child_for_annot (view, page, annot); |
| 4309 | - window = child ? child->window : NULL; |
| 4310 | - if (window) { |
| 4311 | - ev_annotation_window_set_annotation (EV_ANNOTATION_WINDOW (window), annot); |
| 4312 | - g_object_set_data (G_OBJECT (annot), "popup", window); |
| 4313 | - ev_view_window_child_move_with_parent (view, window); |
| 4314 | - } else { |
| 4315 | - ev_view_create_annotation_window (view, annot, parent); |
| 4316 | - } |
| 4317 | - } |
| 4318 | -} |
| 4319 | - |
| 4320 | -static void |
| 4321 | -hide_annotation_windows (EvView *view, |
| 4322 | - gint page) |
| 4323 | -{ |
| 4324 | - EvMappingList *annots; |
| 4325 | - GList *l; |
| 4326 | - |
| 4327 | - annots = ev_page_cache_get_annot_mapping (view->page_cache, page); |
| 4328 | - |
| 4329 | - for (l = ev_mapping_list_get_list (annots); l && l->data; l = g_list_next (l)) { |
| 4330 | - EvAnnotation *annot; |
| 4331 | - GtkWidget *window; |
| 4332 | - |
| 4333 | - annot = ((EvMapping *)(l->data))->data; |
| 4334 | - |
| 4335 | - if (!EV_IS_ANNOTATION_MARKUP (annot)) |
| 4336 | - continue; |
| 4337 | - |
| 4338 | - window = g_object_get_data (G_OBJECT (annot), "popup"); |
| 4339 | - if (window) |
| 4340 | - gtk_widget_hide (window); |
| 4341 | - } |
| 4342 | -} |
| 4343 | - |
| 4344 | -static EvMapping * |
| 4345 | -get_annotation_mapping_at_location (EvView *view, |
| 4346 | - gdouble x, |
| 4347 | - gdouble y, |
| 4348 | - gint *page) |
| 4349 | -{ |
| 4350 | - gint x_new = 0, y_new = 0; |
| 4351 | - EvMappingList *annotations_mapping; |
| 4352 | - |
| 4353 | - if (!EV_IS_DOCUMENT_ANNOTATIONS (view->document)) |
| 4354 | - return NULL; |
| 4355 | - |
| 4356 | - if (!get_doc_point_from_location (view, x, y, page, &x_new, &y_new)) |
| 4357 | - return NULL; |
| 4358 | - |
| 4359 | - annotations_mapping = ev_page_cache_get_annot_mapping (view->page_cache, *page); |
| 4360 | - |
| 4361 | - if (annotations_mapping) |
| 4362 | - return ev_mapping_list_get (annotations_mapping, x_new, y_new); |
| 4363 | - |
| 4364 | - return NULL; |
| 4365 | -} |
| 4366 | - |
| 4367 | -static EvAnnotation * |
| 4368 | -ev_view_get_annotation_at_location (EvView *view, |
| 4369 | - gdouble x, |
| 4370 | - gdouble y) |
| 4371 | -{ |
| 4372 | - EvMapping *annotation_mapping; |
| 4373 | - gint page; |
| 4374 | - |
| 4375 | - annotation_mapping = get_annotation_mapping_at_location (view, x, y, &page); |
| 4376 | - |
| 4377 | - return annotation_mapping ? annotation_mapping->data : NULL; |
| 4378 | -} |
| 4379 | - |
| 4380 | -static void |
| 4381 | -ev_view_annotation_show_popup_window (EvView *view, |
| 4382 | - GtkWidget *window) |
| 4383 | -{ |
| 4384 | - EvViewWindowChild *child; |
| 4385 | - |
| 4386 | - if (!window) |
| 4387 | - return; |
| 4388 | - |
| 4389 | - child = ev_view_get_window_child (view, window); |
| 4390 | - if (!child->visible) { |
| 4391 | - child->visible = TRUE; |
| 4392 | - ev_view_window_child_move (view, child, child->x, child->y); |
| 4393 | - gtk_widget_show (window); |
| 4394 | - } |
| 4395 | -} |
| 4396 | - |
| 4397 | -static void |
| 4398 | -ev_view_handle_annotation (EvView *view, |
| 4399 | - EvAnnotation *annot, |
| 4400 | - gdouble x, |
| 4401 | - gdouble y, |
| 4402 | - guint32 timestamp) |
| 4403 | -{ |
| 4404 | - if (EV_IS_ANNOTATION_MARKUP (annot)) { |
| 4405 | - GtkWidget *window; |
| 4406 | - |
| 4407 | - window = g_object_get_data (G_OBJECT (annot), "popup"); |
| 4408 | - ev_view_annotation_show_popup_window (view, window); |
| 4409 | - } |
| 4410 | - |
| 4411 | - if (EV_IS_ANNOTATION_ATTACHMENT (annot)) { |
| 4412 | - EvAttachment *attachment; |
| 4413 | - |
| 4414 | - attachment = ev_annotation_attachment_get_attachment (EV_ANNOTATION_ATTACHMENT (annot)); |
| 4415 | - if (attachment) { |
| 4416 | - GError *error = NULL; |
| 4417 | - |
| 4418 | - ev_attachment_open (attachment, |
| 4419 | - gtk_widget_get_screen (GTK_WIDGET (view)), |
| 4420 | - timestamp, |
| 4421 | - &error); |
| 4422 | - |
| 4423 | - if (error) { |
| 4424 | - g_warning ("%s", error->message); |
| 4425 | - g_error_free (error); |
| 4426 | - } |
| 4427 | - } |
| 4428 | - } |
| 4429 | -} |
| 4430 | - |
| 4431 | -static void |
| 4432 | -ev_view_create_annotation (EvView *view, |
| 4433 | - EvAnnotationType annot_type, |
| 4434 | - gint x, |
| 4435 | - gint y) |
| 4436 | -{ |
| 4437 | - EvAnnotation *annot; |
| 4438 | - GdkPoint point; |
| 4439 | - GdkRectangle page_area; |
| 4440 | - GtkBorder border; |
| 4441 | - EvRectangle doc_rect, popup_rect; |
| 4442 | - EvPage *page; |
| 4443 | - GdkColor color = { 0, 65535, 65535, 0 }; |
| 4444 | - GdkRectangle view_rect; |
| 4445 | - cairo_region_t *region; |
| 4446 | - |
| 4447 | - point.x = x; |
| 4448 | - point.y = y; |
| 4449 | - ev_view_get_page_extents (view, view->current_page, &page_area, &border); |
| 4450 | - _ev_view_transform_view_point_to_doc_point (view, &point, &page_area, &border, |
| 4451 | - &doc_rect.x1, &doc_rect.y1); |
| 4452 | - doc_rect.x2 = doc_rect.x1 + 24; |
| 4453 | - doc_rect.y2 = doc_rect.y1 + 24; |
| 4454 | - |
| 4455 | - ev_document_doc_mutex_lock (); |
| 4456 | - page = ev_document_get_page (view->document, view->current_page); |
| 4457 | - switch (annot_type) { |
| 4458 | - case EV_ANNOTATION_TYPE_TEXT: |
| 4459 | - annot = ev_annotation_text_new (page); |
| 4460 | - break; |
| 4461 | - case EV_ANNOTATION_TYPE_ATTACHMENT: |
| 4462 | - /* TODO */ |
| 4463 | - g_object_unref (page); |
| 4464 | - ev_document_doc_mutex_unlock (); |
| 4465 | - return; |
| 4466 | - default: |
| 4467 | - g_assert_not_reached (); |
| 4468 | - } |
| 4469 | - g_object_unref (page); |
| 4470 | - |
| 4471 | - ev_annotation_set_color (annot, &color); |
| 4472 | - |
| 4473 | - if (EV_IS_ANNOTATION_MARKUP (annot)) { |
| 4474 | - popup_rect.x1 = doc_rect.x2; |
| 4475 | - popup_rect.x2 = popup_rect.x1 + 200; |
| 4476 | - popup_rect.y1 = doc_rect.y2; |
| 4477 | - popup_rect.y2 = popup_rect.y1 + 150; |
| 4478 | - g_object_set (annot, |
| 4479 | - "rectangle", &popup_rect, |
| 4480 | - "has_popup", TRUE, |
| 4481 | - "popup_is_open", FALSE, |
| 4482 | - "label", g_get_real_name (), |
| 4483 | - "opacity", 1.0, |
| 4484 | - NULL); |
| 4485 | - } |
| 4486 | - ev_document_annotations_add_annotation (EV_DOCUMENT_ANNOTATIONS (view->document), |
| 4487 | - annot, &doc_rect); |
| 4488 | - ev_document_doc_mutex_unlock (); |
| 4489 | - |
| 4490 | - /* If the page didn't have annots, mark the cache as dirty */ |
| 4491 | - if (!ev_page_cache_get_annot_mapping (view->page_cache, view->current_page)) |
| 4492 | - ev_page_cache_mark_dirty (view->page_cache, view->current_page, EV_PAGE_DATA_INCLUDE_ANNOTS); |
| 4493 | - |
| 4494 | - if (EV_IS_ANNOTATION_MARKUP (annot)) { |
| 4495 | - GtkWindow *parent; |
| 4496 | - GtkWidget *window; |
| 4497 | - |
| 4498 | - parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))); |
| 4499 | - window = ev_view_create_annotation_window (view, annot, parent); |
| 4500 | - |
| 4501 | - /* Show the annot window the first time */ |
| 4502 | - ev_view_annotation_show_popup_window (view, window); |
| 4503 | - } |
| 4504 | - |
| 4505 | - _ev_view_transform_doc_rect_to_view_rect (view, view->current_page, &doc_rect, &view_rect); |
| 4506 | - view_rect.x -= view->scroll_x; |
| 4507 | - view_rect.y -= view->scroll_y; |
| 4508 | - region = cairo_region_create_rectangle (&view_rect); |
| 4509 | - ev_view_reload_page (view, view->current_page, region); |
| 4510 | - cairo_region_destroy (region); |
| 4511 | - |
| 4512 | - g_signal_emit (view, signals[SIGNAL_ANNOT_ADDED], 0, annot); |
| 4513 | -} |
| 4514 | - |
| 4515 | -void |
| 4516 | -ev_view_focus_annotation (EvView *view, |
| 4517 | - EvMapping *annot_mapping) |
| 4518 | -{ |
| 4519 | - |
| 4520 | - if (!EV_IS_DOCUMENT_ANNOTATIONS (view->document)) |
| 4521 | - return; |
| 4522 | - |
| 4523 | - _ev_view_set_focused_element (view, annot_mapping, |
| 4524 | - ev_annotation_get_page_index (EV_ANNOTATION (annot_mapping->data))); |
| 4525 | -} |
| 4526 | - |
| 4527 | -void |
| 4528 | -ev_view_begin_add_annotation (EvView *view, |
| 4529 | - EvAnnotationType annot_type) |
| 4530 | -{ |
| 4531 | - if (annot_type == EV_ANNOTATION_TYPE_UNKNOWN) |
| 4532 | - return; |
| 4533 | - |
| 4534 | - if (view->adding_annot) |
| 4535 | - return; |
| 4536 | - |
| 4537 | - view->adding_annot = TRUE; |
| 4538 | - view->adding_annot_type = annot_type; |
| 4539 | - ev_view_set_cursor (view, EV_VIEW_CURSOR_ADD); |
| 4540 | -} |
| 4541 | - |
| 4542 | -void |
| 4543 | -ev_view_cancel_add_annotation (EvView *view) |
| 4544 | -{ |
| 4545 | - gint x, y; |
| 4546 | - |
| 4547 | - if (!view->adding_annot) |
| 4548 | - return; |
| 4549 | - |
| 4550 | - view->adding_annot = FALSE; |
| 4551 | - ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y); |
| 4552 | - ev_view_handle_cursor_over_xy (view, x, y); |
| 4553 | -} |
| 4554 | - |
| 4555 | -void |
| 4556 | -ev_view_remove_annotation (EvView *view, |
| 4557 | - EvAnnotation *annot) |
| 4558 | -{ |
| 4559 | - guint page; |
| 4560 | - |
| 4561 | - g_return_if_fail (EV_IS_VIEW (view)); |
| 4562 | - g_return_if_fail (EV_IS_ANNOTATION (annot)); |
| 4563 | - |
| 4564 | - g_object_ref (annot); |
| 4565 | - |
| 4566 | - page = ev_annotation_get_page_index (annot); |
| 4567 | - |
| 4568 | - if (EV_IS_ANNOTATION_MARKUP (annot)) { |
| 4569 | - EvViewWindowChild *child; |
| 4570 | - |
| 4571 | - child = ev_view_find_window_child_for_annot (view, page, annot); |
| 4572 | - if (child) { |
| 4573 | - view->window_children = g_list_remove (view->window_children, child); |
| 4574 | - gtk_widget_destroy (child->window); |
| 4575 | - g_free (child); |
| 4576 | - } |
| 4577 | - } |
| 4578 | - _ev_view_set_focused_element (view, NULL, -1); |
| 4579 | - |
| 4580 | - ev_document_doc_mutex_lock (); |
| 4581 | - ev_document_annotations_remove_annotation (EV_DOCUMENT_ANNOTATIONS (view->document), |
| 4582 | - annot); |
| 4583 | - ev_document_doc_mutex_unlock (); |
| 4584 | - |
| 4585 | - ev_page_cache_mark_dirty (view->page_cache, page, EV_PAGE_DATA_INCLUDE_ANNOTS); |
| 4586 | - |
| 4587 | - /* FIXME: only redraw the annot area */ |
| 4588 | - ev_view_reload_page (view, page, NULL); |
| 4589 | - |
| 4590 | - g_signal_emit (view, signals[SIGNAL_ANNOT_REMOVED], 0, annot); |
| 4591 | - g_object_unref (annot); |
| 4592 | -} |
| 4593 | - |
| 4594 | -static gboolean |
| 4595 | -ev_view_synctex_backward_search (EvView *view, |
| 4596 | - gdouble x, |
| 4597 | - gdouble y) |
| 4598 | -{ |
| 4599 | - gint page = -1; |
| 4600 | - gint x_new = 0, y_new = 0; |
| 4601 | - EvSourceLink *link; |
| 4602 | - |
| 4603 | - if (!ev_document_has_synctex (view->document)) |
| 4604 | - return FALSE; |
| 4605 | - |
| 4606 | - if (!get_doc_point_from_location (view, x, y, &page, &x_new, &y_new)) |
| 4607 | - return FALSE; |
| 4608 | - |
| 4609 | - link = ev_document_synctex_backward_search (view->document, page, x_new, y_new); |
| 4610 | - if (link) { |
| 4611 | - g_signal_emit (view, signals[SIGNAL_SYNC_SOURCE], 0, link); |
| 4612 | - ev_source_link_free (link); |
| 4613 | - |
| 4614 | - return TRUE; |
| 4615 | - } |
| 4616 | - |
| 4617 | - return FALSE; |
| 4618 | -} |
| 4619 | - |
| 4620 | -/* Caret navigation */ |
| 4621 | -#define CURSOR_ON_MULTIPLIER 2 |
| 4622 | -#define CURSOR_OFF_MULTIPLIER 1 |
| 4623 | -#define CURSOR_PEND_MULTIPLIER 3 |
| 4624 | -#define CURSOR_DIVIDER 3 |
| 4625 | - |
| 4626 | -static inline gboolean |
| 4627 | -cursor_is_in_visible_page (EvView *view) |
| 4628 | -{ |
| 4629 | - return (view->cursor_page == view->current_page || |
| 4630 | - (view->cursor_page >= view->start_page && |
| 4631 | - view->cursor_page <= view->end_page)); |
| 4632 | -} |
| 4633 | - |
| 4634 | -static gboolean |
| 4635 | -cursor_should_blink (EvView *view) |
| 4636 | -{ |
| 4637 | - if (view->caret_enabled && |
| 4638 | - view->rotation == 0 && |
| 4639 | - cursor_is_in_visible_page (view) && |
| 4640 | - gtk_widget_has_focus (GTK_WIDGET (view)) && |
| 4641 | - view->pixbuf_cache && |
| 4642 | - !ev_pixbuf_cache_get_selection_region (view->pixbuf_cache, view->cursor_page, view->scale)) { |
| 4643 | - GtkSettings *settings; |
| 4644 | - gboolean blink; |
| 4645 | - |
| 4646 | - settings = gtk_widget_get_settings (GTK_WIDGET (view)); |
| 4647 | - g_object_get (settings, "gtk-cursor-blink", &blink, NULL); |
| 4648 | - |
| 4649 | - return blink; |
| 4650 | - } |
| 4651 | - |
| 4652 | - return FALSE; |
| 4653 | -} |
| 4654 | - |
| 4655 | -static gint |
| 4656 | -get_cursor_blink_time (EvView *view) |
| 4657 | -{ |
| 4658 | - GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (view)); |
| 4659 | - gint time; |
| 4660 | - |
| 4661 | - g_object_get (settings, "gtk-cursor-blink-time", &time, NULL); |
| 4662 | - |
| 4663 | - return time; |
| 4664 | -} |
| 4665 | - |
| 4666 | -static gint |
| 4667 | -get_cursor_blink_timeout_id (EvView *view) |
| 4668 | -{ |
| 4669 | - GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (view)); |
| 4670 | - gint timeout; |
| 4671 | - |
| 4672 | - g_object_get (settings, "gtk-cursor-blink-timeout", &timeout, NULL); |
| 4673 | - |
| 4674 | - return timeout; |
| 4675 | -} |
| 4676 | - |
| 4677 | -static gboolean |
| 4678 | -get_caret_cursor_area (EvView *view, |
| 4679 | - gint page, |
| 4680 | - gint offset, |
| 4681 | - GdkRectangle *area) |
| 4682 | -{ |
| 4683 | - EvRectangle *areas = NULL; |
| 4684 | - EvRectangle *doc_rect; |
| 4685 | - guint n_areas = 0; |
| 4686 | - gfloat cursor_aspect_ratio; |
| 4687 | - gint stem_width; |
| 4688 | - |
| 4689 | - if (!view->caret_enabled || view->rotation != 0) |
| 4690 | - return FALSE; |
| 4691 | - |
| 4692 | - if (!view->page_cache) |
| 4693 | - return FALSE; |
| 4694 | - |
| 4695 | - ev_page_cache_get_text_layout (view->page_cache, page, &areas, &n_areas); |
| 4696 | - if (!areas) |
| 4697 | - return FALSE; |
| 4698 | - |
| 4699 | - if (offset > n_areas) |
| 4700 | - return FALSE; |
| 4701 | - |
| 4702 | - doc_rect = areas + offset; |
| 4703 | - if (offset == n_areas || |
| 4704 | - ((doc_rect->x1 == doc_rect->x2 || doc_rect->y1 == doc_rect->y2) && offset > 0)) { |
| 4705 | - EvRectangle *prev; |
| 4706 | - EvRectangle last_rect; |
| 4707 | - |
| 4708 | - /* Special characters like \n have an empty bounding box |
| 4709 | - * and the end of a page doesn't have any bounding box, |
| 4710 | - * use the size of the previous area. |
| 4711 | - */ |
| 4712 | - prev = areas + offset - 1; |
| 4713 | - last_rect.x1 = prev->x2; |
| 4714 | - last_rect.y1 = prev->y1; |
| 4715 | - last_rect.x2 = prev->x2 + (prev->x2 - prev->x1); |
| 4716 | - last_rect.y2 = prev->y2; |
| 4717 | - |
| 4718 | - _ev_view_transform_doc_rect_to_view_rect (view, page, &last_rect, area); |
| 4719 | - } else { |
| 4720 | - _ev_view_transform_doc_rect_to_view_rect (view, page, doc_rect, area); |
| 4721 | - } |
| 4722 | - |
| 4723 | - area->x -= view->scroll_x; |
| 4724 | - area->y -= view->scroll_y; |
| 4725 | - |
| 4726 | - gtk_style_context_get_style (gtk_widget_get_style_context (GTK_WIDGET (view)), |
| 4727 | - "cursor-aspect-ratio", &cursor_aspect_ratio, |
| 4728 | - NULL); |
| 4729 | - stem_width = area->height * cursor_aspect_ratio + 1; |
| 4730 | - area->x -= (stem_width / 2); |
| 4731 | - area->width = stem_width; |
| 4732 | - |
| 4733 | - return TRUE; |
| 4734 | -} |
| 4735 | - |
| 4736 | -static void |
| 4737 | -show_cursor (EvView *view) |
| 4738 | -{ |
| 4739 | - GtkWidget *widget; |
| 4740 | - GdkRectangle view_rect; |
| 4741 | - |
| 4742 | - if (view->cursor_visible) |
| 4743 | - return; |
| 4744 | - |
| 4745 | - widget = GTK_WIDGET (view); |
| 4746 | - view->cursor_visible = TRUE; |
| 4747 | - if (gtk_widget_has_focus (widget) && |
| 4748 | - get_caret_cursor_area (view, view->cursor_page, view->cursor_offset, &view_rect)) { |
| 4749 | - gtk_widget_queue_draw_area (widget, |
| 4750 | - view_rect.x, view_rect.y, |
| 4751 | - view_rect.width, view_rect.height); |
| 4752 | - } |
| 4753 | -} |
| 4754 | - |
| 4755 | -static void |
| 4756 | -hide_cursor (EvView *view) |
| 4757 | -{ |
| 4758 | - GtkWidget *widget; |
| 4759 | - GdkRectangle view_rect; |
| 4760 | - |
| 4761 | - if (!view->cursor_visible) |
| 4762 | - return; |
| 4763 | - |
| 4764 | - widget = GTK_WIDGET (view); |
| 4765 | - view->cursor_visible = FALSE; |
| 4766 | - if (gtk_widget_has_focus (widget) && |
| 4767 | - get_caret_cursor_area (view, view->cursor_page, view->cursor_offset, &view_rect)) { |
| 4768 | - gtk_widget_queue_draw_area (widget, |
| 4769 | - view_rect.x, view_rect.y, |
| 4770 | - view_rect.width, view_rect.height); |
| 4771 | - } |
| 4772 | -} |
| 4773 | - |
| 4774 | -static gboolean |
| 4775 | -blink_cb (EvView *view) |
| 4776 | -{ |
| 4777 | - gint blink_timeout; |
| 4778 | - guint blink_time; |
| 4779 | - |
| 4780 | - blink_timeout = get_cursor_blink_timeout_id (view); |
| 4781 | - if (view->cursor_blink_time > 1000 * blink_timeout && blink_timeout < G_MAXINT / 1000) { |
| 4782 | - /* We've blinked enough without the user doing anything, stop blinking */ |
| 4783 | - show_cursor (view); |
| 4784 | - view->cursor_blink_timeout_id = 0; |
| 4785 | - |
| 4786 | - return FALSE; |
| 4787 | - } |
| 4788 | - |
| 4789 | - blink_time = get_cursor_blink_time (view); |
| 4790 | - if (view->cursor_visible) { |
| 4791 | - hide_cursor (view); |
| 4792 | - blink_time *= CURSOR_OFF_MULTIPLIER; |
| 4793 | - } else { |
| 4794 | - show_cursor (view); |
| 4795 | - view->cursor_blink_time += blink_time; |
| 4796 | - blink_time *= CURSOR_ON_MULTIPLIER; |
| 4797 | - } |
| 4798 | - |
| 4799 | - view->cursor_blink_timeout_id = gdk_threads_add_timeout (blink_time / CURSOR_DIVIDER, (GSourceFunc)blink_cb, view); |
| 4800 | - |
| 4801 | - return FALSE; |
| 4802 | -} |
| 4803 | - |
| 4804 | -static void |
| 4805 | -ev_view_check_cursor_blink (EvView *view) |
| 4806 | -{ |
| 4807 | - if (cursor_should_blink (view)) { |
| 4808 | - if (view->cursor_blink_timeout_id == 0) { |
| 4809 | - show_cursor (view); |
| 4810 | - view->cursor_blink_timeout_id = gdk_threads_add_timeout (get_cursor_blink_time (view) * CURSOR_ON_MULTIPLIER / CURSOR_DIVIDER, |
| 4811 | - (GSourceFunc)blink_cb, view); |
| 4812 | - } |
| 4813 | - |
| 4814 | - return; |
| 4815 | - } |
| 4816 | - |
| 4817 | - if (view->cursor_blink_timeout_id > 0) { |
| 4818 | - g_source_remove (view->cursor_blink_timeout_id); |
| 4819 | - view->cursor_blink_timeout_id = 0; |
| 4820 | - } |
| 4821 | - |
| 4822 | - view->cursor_visible = TRUE; |
| 4823 | - view->cursor_blink_time = 0; |
| 4824 | -} |
| 4825 | - |
| 4826 | -static void |
| 4827 | -ev_view_pend_cursor_blink (EvView *view) |
| 4828 | -{ |
| 4829 | - if (!cursor_should_blink (view)) |
| 4830 | - return; |
| 4831 | - |
| 4832 | - if (view->cursor_blink_timeout_id > 0) |
| 4833 | - g_source_remove (view->cursor_blink_timeout_id); |
| 4834 | - |
| 4835 | - show_cursor (view); |
| 4836 | - view->cursor_blink_timeout_id = gdk_threads_add_timeout (get_cursor_blink_time (view) * CURSOR_PEND_MULTIPLIER / CURSOR_DIVIDER, |
| 4837 | - (GSourceFunc)blink_cb, view); |
| 4838 | -} |
| 4839 | - |
| 4840 | -static void |
| 4841 | -preload_pages_for_caret_navigation (EvView *view) |
| 4842 | -{ |
| 4843 | - gint n_pages; |
| 4844 | - |
| 4845 | - if (!view->document) |
| 4846 | - return; |
| 4847 | - |
| 4848 | - /* Upload to the cache the first and last pages, |
| 4849 | - * this information is needed to position the cursor |
| 4850 | - * in the beginning/end of the document, for example |
| 4851 | - * when pressing <Ctr>Home/End |
| 4852 | - */ |
| 4853 | - n_pages = ev_document_get_n_pages (view->document); |
| 4854 | - |
| 4855 | - /* For documents with at least 3 pages, those are already cached anyway */ |
| 4856 | - if (n_pages > 0 && n_pages <= 3) |
| 4857 | - return; |
| 4858 | - |
| 4859 | - ev_page_cache_ensure_page (view->page_cache, 0); |
| 4860 | - ev_page_cache_ensure_page (view->page_cache, n_pages - 1); |
| 4861 | -} |
| 4862 | - |
| 4863 | -/** |
| 4864 | - * ev_view_supports_caret_navigation: |
| 4865 | - * @view: a #EvView |
| 4866 | - * |
| 4867 | - * Returns: whether the document supports caret navigation |
| 4868 | - * |
| 4869 | - * Since: 3.10 |
| 4870 | - */ |
| 4871 | -gboolean |
| 4872 | -ev_view_supports_caret_navigation (EvView *view) |
| 4873 | -{ |
| 4874 | - EvDocumentTextInterface *iface; |
| 4875 | - |
| 4876 | - if (!view->document || !EV_IS_DOCUMENT_TEXT (view->document)) |
| 4877 | - return FALSE; |
| 4878 | - |
| 4879 | - iface = EV_DOCUMENT_TEXT_GET_IFACE (view->document); |
| 4880 | - if (!iface->get_text_layout || !iface->get_text) |
| 4881 | - return FALSE; |
| 4882 | - |
| 4883 | - return TRUE; |
| 4884 | -} |
| 4885 | - |
| 4886 | -/** |
| 4887 | - * ev_view_set_caret_navigation_enabled: |
| 4888 | - * @view: a #EvView |
| 4889 | - * @enabled: whether to enable caret navigation mode |
| 4890 | - * |
| 4891 | - * Enables or disables caret navigation mode for the document. |
| 4892 | - * |
| 4893 | - * Since: 3.10 |
| 4894 | - */ |
| 4895 | -void |
| 4896 | -ev_view_set_caret_navigation_enabled (EvView *view, |
| 4897 | - gboolean enabled) |
| 4898 | -{ |
| 4899 | - g_return_if_fail (EV_IS_VIEW (view)); |
| 4900 | - |
| 4901 | - if (view->caret_enabled != enabled) { |
| 4902 | - view->caret_enabled = enabled; |
| 4903 | - if (view->caret_enabled) |
| 4904 | - preload_pages_for_caret_navigation (view); |
| 4905 | - |
| 4906 | - ev_view_check_cursor_blink (view); |
| 4907 | - |
| 4908 | - if (cursor_is_in_visible_page (view)) |
| 4909 | - gtk_widget_queue_draw (GTK_WIDGET (view)); |
| 4910 | - } |
| 4911 | -} |
| 4912 | - |
| 4913 | -/** |
| 4914 | - * ev_view_get_caret_navigation_enabled: |
| 4915 | - * @view: a #EvView |
| 4916 | - * |
| 4917 | - * Returns: whether caret navigation mode is enabled for the document |
| 4918 | - * |
| 4919 | - * Since: 3.10 |
| 4920 | - */ |
| 4921 | -gboolean |
| 4922 | -ev_view_is_caret_navigation_enabled (EvView *view) |
| 4923 | -{ |
| 4924 | - g_return_val_if_fail (EV_IS_VIEW (view), FALSE); |
| 4925 | - |
| 4926 | - return view->caret_enabled; |
| 4927 | -} |
| 4928 | - |
| 4929 | -/** |
| 4930 | - * ev_view_set_caret_cursor_position: |
| 4931 | - * @view: a #EvView |
| 4932 | - * @page: |
| 4933 | - * @offset: |
| 4934 | - * |
| 4935 | - * Since: 3.10 |
| 4936 | - */ |
| 4937 | -void |
| 4938 | -ev_view_set_caret_cursor_position (EvView *view, |
| 4939 | - guint page, |
| 4940 | - guint offset) |
| 4941 | -{ |
| 4942 | - g_return_if_fail (EV_IS_VIEW (view)); |
| 4943 | - g_return_if_fail (EV_IS_DOCUMENT (view->document)); |
| 4944 | - g_return_if_fail (page < ev_document_get_n_pages (view->document)); |
| 4945 | - |
| 4946 | - if (view->cursor_page != page || view->cursor_offset != offset) { |
| 4947 | - view->cursor_page = page; |
| 4948 | - view->cursor_offset = offset; |
| 4949 | - |
| 4950 | - g_signal_emit (view, signals[SIGNAL_CURSOR_MOVED], 0, |
| 4951 | - view->cursor_page, view->cursor_offset); |
| 4952 | - |
| 4953 | - if (view->caret_enabled && cursor_is_in_visible_page (view)) |
| 4954 | - gtk_widget_queue_draw (GTK_WIDGET (view)); |
| 4955 | - } |
| 4956 | -} |
| 4957 | - |
| 4958 | -/*** GtkWidget implementation ***/ |
| 4959 | - |
| 4960 | -static void |
| 4961 | -ev_view_size_request_continuous_dual_page (EvView *view, |
| 4962 | - GtkRequisition *requisition) |
| 4963 | -{ |
| 4964 | - gint n_pages; |
| 4965 | - |
| 4966 | - n_pages = ev_document_get_n_pages (view->document) + 1; |
| 4967 | - get_page_y_offset (view, n_pages, &requisition->height); |
| 4968 | - |
| 4969 | - switch (view->sizing_mode) { |
| 4970 | - case EV_SIZING_FIT_WIDTH: |
| 4971 | - case EV_SIZING_FIT_PAGE: |
| 4972 | - case EV_SIZING_AUTOMATIC: |
| 4973 | - requisition->width = 1; |
| 4974 | - |
| 4975 | - break; |
| 4976 | - case EV_SIZING_FREE: { |
| 4977 | - gint max_width; |
| 4978 | - GtkBorder border; |
| 4979 | - |
| 4980 | - ev_view_get_max_page_size (view, &max_width, NULL); |
| 4981 | - compute_border (view, &border); |
| 4982 | - requisition->width = (max_width + border.left + border.right) * 2 + (view->spacing * 3); |
| 4983 | - } |
| 4984 | - break; |
| 4985 | - default: |
| 4986 | - g_assert_not_reached (); |
| 4987 | - } |
| 4988 | -} |
| 4989 | - |
| 4990 | -static void |
| 4991 | -ev_view_size_request_continuous (EvView *view, |
| 4992 | - GtkRequisition *requisition) |
| 4993 | -{ |
| 4994 | - gint n_pages; |
| 4995 | - |
| 4996 | - n_pages = ev_document_get_n_pages (view->document); |
| 4997 | - get_page_y_offset (view, n_pages, &requisition->height); |
| 4998 | - |
| 4999 | - switch (view->sizing_mode) { |
| 5000 | - case EV_SIZING_FIT_WIDTH: |
The diff has been truncated for viewing.


looks like that got uploaded to vivid by Laney already, but thanks for the work!