Commit Graph

134 Commits

Author SHA1 Message Date
Moritz Lipp
f4ff19d965 pages-per-row must not be 0 2014-04-25 13:02:02 +02:00
Sebastian Ramacher
a85decc8cc Only copy selected text in normal and fullscreen mode
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2014-02-14 11:46:17 +01:00
Sebastian Ramacher
c2b35a02fe Don't try to change document settings if no document is open
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-11-17 18:36:22 +01:00
Abdo Roig-Maranges
9367d646d9 get rid of tracking adjustments
They are not used anywere, and do not seem to become useful anymore in
the light of the new separation of document and view.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
018e026e62 disable adjustment callbacks in index mode
Otherwise the document object gets updated with wrong position values,
because the adjustment belong to the index, not the document view.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
3634636227 adapt view_adjustment callbacks to new document/view separation
The adjustment callbacks act as an interface between position data in
the document object, and the adjustments.

We remove the horizontal centering code, as now it is done by
position_set. Those callbacks should not change the position read from
the document object in any way.

Also, we split the adjustment_value_changed callback into a vertical and
an horizontal version. Previously a single callback was reused for both,
horizontal and vertical. That lead to a subtle problem when coming out
of index mode. What happened was the following:

  1. horizontal adjustment bounds change coming out of index mode. This
     triggers an hadjustment changed signal.

  2. the hadjustment_changed callback handles it, and resets the
     hadjustment value, as the bound may have changed. This triggers a
     value_changed event.

  3. the value_changed callback handles the event, and captures the
     position for *BOTH*, horizontal and vertical adjustments, saving
     them to the document object.

  1..3 is repeated for the vertical adjustment.

  Now, if in 3. the horizontal adjustment bounds were not yet updated
  after the index mode, we got ourselves at the wrong vertical position.

This race condition is avoided now because both value_changed callbacks
*ONLY* handle their own direction, either vertical or horizontal, not
 both.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
c4245600c9 move adjustment code from sc_adjust_window to adjust_view
This new function adjust_view is in charge of recomputing the scale
according to adjustment settings and trigger a render_all.

adjust_view contains the old sc_adjust_window code, slightly simplified
thanks to the availability of the document_get_viewport_size.

Then it is used by sc_adjust_window, document_open and the
cb_view_resized callback. Makes slightly more sense this way than
calling the shortcut sc_adjust_window directly.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
692e72abd4 add a custom refresh-view signal
Now we can trigger a gtk page refresh calling refresh_view. This
function triggers a custom signal refresh-view, whose handler copies the
position from the document object to the adjustments.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
0da491f78b merge callbacks for pages-per-row, first-page-column and page-padding
All of those callbacks are conceptually related (change the page
layout), and depend from one another.

Now the single callback page_layout_value_changed defers to
page_widget_set_mode to change whatever is needed in the GTK widgets.
2013-10-26 16:02:21 +02:00
Abdo Roig-Maranges
c5930c900a page_widget_set_mode now sets the page-padding too
- fix the computation of the number of rows in the table. Doing a ceil
    of an integer division has no effect...

  - set the page_padding in page_widget_set_mode function, instead of
    doing it independently.

  - call zathura_document_set_layout after calling page_widget_set_mode
    to save the page layout settings into the document object.
2013-10-26 16:01:02 +02:00
Sebastian Ramacher
f27769d1b7 Fix format string not a string literal
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-21 14:19:28 +02:00
Sebastian Ramacher
157c9d6d53 girara_notify takes something the markup parser can understand
This should fix #347.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-21 14:16:38 +02:00
Sebastian Ramacher
c918c590ee Rename zathura_page_cache_add
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-20 16:06:15 +02:00
Sebastian Ramacher
5df5357fb0 Finish moving of the page cache
Add two more signals to ZathuraRenderRequest to notify pages if they are cached
or not. This allows us to move some logic away from
cb_view_vadjutment_value_changed to more appropriate places.

ZathuraPageWidget will now release the surface if
* it gets the signal that the page is no longer cached and the page is
  invisible,
* the page is not cached and the render request is aborted.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-19 17:45:12 +02:00
Sebastian Ramacher
e7cd4e5f8c Move page cache to ZathuraRenderer
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-18 20:00:04 +02:00
Sebastian Ramacher
2c9e34fa8a Merge branch 'feature/renderer-take-2' into develop 2013-10-18 16:12:50 +02:00
Sebastian Ramacher
2ad2b9e0c4 Use signals for selected images and text
The page widget shouldn't have to care what should be done with selected images
and text.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-08-31 13:12:41 +02:00
Sebastian Ramacher
7127a46033 Fix deprecated gdk thread function calls
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-08-30 19:25:24 +02:00
Sebastian Ramacher
16fbefa5cf Abort requests if the page becomes invisible
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-08-30 18:59:47 +02:00
Sebastian Ramacher
b02d3d4b8f Move recolor state to the renderer
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-08-24 00:07:32 +02:00
Sebastian Ramacher
b5237680f2 Don't store surface for invisible and uncached pages
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-07-27 16:25:20 +02:00
Sebastian Ramacher
03ea66c6ff Replace tabs with spaces
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-07-26 16:13:41 +02:00
Marwan Tanager
d9f8750c86 Move calls to zathura_jumplist_add surrounding zathura_link_evaluate to zathura_link_evaluate itself
This is just in case that zathura_link_evaluate returns without evaluating the
link, which would result in a new jump being added for the current position,
but without adding a corresponding jump for the target position (actually a
second one would be added but the check in zathura_jumplist_add would prevent
it from being appended on the linked list since it's position would be the same
as the current one, because the link haven't been evaluated).

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-06-21 10:56:08 +02:00
Marwan Tanager
afd008f466 Enhancements/Cleanups for the jumplist mechansim
- Don't delete the elements on the right of the current one, when
	  appending a new jump to the jumplist, because this makes no sense at
	  all; the point of the jumplist in the first place is to remember
	  previously jumped-to positions in the document, so there is no need
	  to delete anythings except to trim the oldest entries from the
	  beginning to maintain the maximum size. This also makes us compatible
	  with the Vim way of doing things.

	- Make the jumplist mechanism functional on the same page; if we
	  followed a link to a target on the same page, remember the
	  adjustments before and after following the link. The same holds for
	  navigating search results on the same page.

	- Implement position_set and use it instead of position_set_delayed
	  when following links in order to give zathura_jumplist_save a chance
	  to record the exact adjustments of the link target. Otherwise, it
	  will always record the adjustments after going to the target page,
	  but before going to the exact position within it.

	- Don't consider movements with ^i and ^o as jumps :)

	- Don't use page_set followed by setting the adjustments in
	  sc_jumplist, because this is redundant and causes clutter when using
	  ^i and ^o, as the adjustments is set twice this way (once in page_set
	  and again in position_set_delayed).  It's enough to only update the
	  page number on the statusbar and then set the adjustments.

	- Hide implementation details (zathura_jumplist_save and
	  zathura_jumplist_append), and make things more consistent by
	  exporting and using only zathura_jumplist_add for adding new entries.

The end result: A more slick jumping experience :-)

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-06-10 14:48:10 +02:00
Marwan Tanager
cc3b9aea18 More Vim-like search behavior
This patch activates the last aborted search when pressing the search shortcuts
('n' or 'N').

To avoid confusion, and to make things more predictable, I've chosen to always
reactivate an aborted search starting from the beginning (or end, in case of
'N' or '?') of the current page, as opposed to Vim which continues from the
next search term each time the search is reactivated.

Searching using '/' or '?' doesn't center the view at the current search term
like when using 'n' or 'N', so we fix this here.

Also, I managed to work around the issue of the thin rectangular margins that
show around the previously-highlighted search terms after the search is aborted
(either explicitly or as a result of following links), by redrawing the page
widget (only if it's visible) instead of redrawing the rectangles covering the
highlighted search terms.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-06-10 14:35:19 +02:00
Marwan Tanager
cd381c813d Don't set visibility, update view time, or lookup the cache, if the page is already visible.
This also has the side effect of not flooding the console with debug messages
on every change of the vertical adjustment as a result of redundant cache
lookups.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-29 18:33:15 +01:00
Marwan Tanager
cb18fe8603 Replace the periodic page reclaiming code with a LRU caching algorithm.
This patch implements a page cache that is invalidated in a LRU fashion.

Pages are added to the cache as soon as they become visible. When the cache is
full and a new page that isn't in the cache becomes visible, the least recently
viewed page in the cache is evicted from memory and the new one takes it's
place.

The cache size is configurable using the page-cache-size configuration
variable, with a default value of 15 pages. Very large values for the cache
size are not recommended, though, as it will stress the system memory out.

The old periodic page reclaiming code is no longer necessary with this patch,
so I removed it.

Special thanks to Ignas Anikevičius, and Sebastian Ramacher for the
inspirations.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-26 12:45:43 +01:00
Sebastian Ramacher
9c1503809a CS
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-23 16:12:38 +01:00
Benoît Knecht
1702fb620a Don't scroll the document when focusing the inputbar
Add a new adjust mode that is set when focusing the inputbar and
disables adjusting the vertical scrollbar. As a result, focusing the
inputbar doesn't scroll the document, leading to better results when
changing pages from the inputbar (e.g. using bookmarks).

Reported-by: Marwan Tanager <marwan.tngr@gmail.com>

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-23 16:03:11 +01:00
Benoît Knecht
c9eef95492 Use signals to readjust_view_after_zooming()
Instead of guesstimating the values of the scrollbars adjustments after
a change in zoom level, connect callbacks to the "changed" GtkAdjustment
event (which is emitted when the bounds or page_size of the adjustment
change, e.g. when the zoom level changes), and compute the new values
from there.

The previous adjustment values are tracked in zathura->ui.hadjustment
and zathura->ui.vadjustment (and updated by signal handlers as well), so
that the view's position can be maintained while zooming.

cb_view_hadjustment_changed() centers the page horizontally if a
"best-fit" or "width" zoom is being performed, or if "zoom-center" is
true; otherwise, it keeps the view horizontally centered around the same
area of the page.

cb_view_vadjustment_changed() always keeps the view vertically centered
around the same area of the page.

Many thanks to Marwan Tanager for thoroughly reviewing the various
stages of this patch, and actually coming up with a working solution.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-23 16:02:56 +01:00
Benoît Knecht
27c291758e Add a '--page' option to open at the specified page
If '--page [number]' (or '-P [number]') is given on the command-line,
the document is opened at the specified page number. Negative numbers
are allowed, and denote a page number starting from the end of the
document.

See issue 275 <http://bugs.pwmt.org/issue275>.

Reported-by: bob <sean258@gmail.com>
2013-03-17 11:30:22 +01:00
Benoît Knecht
ff305e6972 Initialize GdkRectangle structs in cb_view_vadjustment_value_changed
Initializing page_rect makes Valgrind happy; it was complaining before,
even though all the values were properly initialized, but it's more
obvious this way.

Initialize the other two structs in the same way for consitency.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2012-12-13 18:18:03 +01:00
Benoît Knecht
2192b7172c Add new shortcut function to display links
This is useful when the text of the link doesn't match its target. The
default key is set to 'F'.

See issue 266 <http://bugs.pwmt.org/issue266>.

Reported-by: Iron <o380770@rtrtr.com>

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2012-12-07 18:05:59 +01:00
Moritz Lipp
89e7832047 Update style 2012-10-09 01:12:18 +02:00
Abdó Roig-Maranges
eb67d97180 Implemented jumplist bound to ^o ^i
zathura records jumps through searches, index, links, etc. and enables to go
back and forth via ^o ^i.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2012-09-02 00:31:47 +02:00
Abdó Roig-Maranges
c57463a053 Added option to recolor keeping hues of original color.
If option recolor-keephue is true, the recoloring algorithm
only adjusts the lightness of the original color, keeping the
rest of the properties close to the original.

When recolor-keephue is set to false, the recoloring is performed
as it was before, interpolating linearly between recolor-lightcolor
and recolor-darkcolor except for a different weighting for the
lightness which is closer to perception.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2012-08-01 16:05:31 +02:00
Sebastian Ramacher
6d462f4732 Implement first-page-column.
Thanks to J. Commelin for the patch.
2012-06-27 22:34:16 +02:00
Moritz Lipp
365dc9a66e Improve zathura_link_t 2012-05-28 12:43:22 +02:00
sandnon
3986cbc032 Fix the bug that index can not jump to specific page 2012-05-12 17:04:25 +02:00
Moritz Lipp
800d039293 Check for numeric events 2012-05-01 19:09:33 +02:00
Moritz Lipp
c2b0f7c20f Close document in cb_destroy
Fixes: #158
2012-05-01 12:03:18 +02:00
Moritz Lipp
adc9f41264 Introduce new link types 2012-04-22 10:04:46 +02:00
Moritz Lipp
97247f41ca Unhitch zathura_t from document_t/page_t/plugin_manager_t 2012-04-03 09:02:45 +02:00
Moritz Lipp
334b4fbb95 Introduce and use zathura_document wrapper functions 2012-03-27 21:59:35 +02:00
Moritz Lipp
fa40facc71 Begin to introduce types.h 2012-03-27 11:19:39 +02:00
Moritz Lipp
efc108fbe2 Introduced page.h 2012-03-26 14:44:56 +02:00
Moritz Lipp
fd06599d57 Remove unnecessary addition 2012-03-24 17:42:31 +01:00
Sebastian Ramacher
64905f282b Remove invisible pages from the memory. 2012-03-24 16:15:34 +01:00
Sebastian Ramacher
66bc63f5a7 Rename page_widget to page-widget. 2012-03-16 14:37:54 +01:00
Moritz Lipp
9265c9473a Add 'recolor' setting 2012-03-14 17:33:35 +01:00