mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 08:45:59 +01:00
Experimental implementation of sc_zoom
This commit is contained in:
parent
498a1c31e4
commit
dbb304af35
5 changed files with 53 additions and 2 deletions
4
config.c
4
config.c
|
@ -14,6 +14,10 @@ config_load_default(void)
|
|||
/* general settings */
|
||||
girara_mode_set(Zathura.UI.session, NORMAL);
|
||||
|
||||
/* zathura settings */
|
||||
int int_value = 10;
|
||||
girara_setting_add(Zathura.UI.session, "zoom-step", &int_value, INT, false, "Zoom step", NULL);
|
||||
|
||||
/* define default shortcuts */
|
||||
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);
|
||||
girara_shortcut_add(Zathura.UI.session, 0, GDK_Escape, NULL, sc_abort, 0, 0, NULL);
|
||||
|
|
|
@ -103,8 +103,7 @@ zathura_document_open(const char* path, const char* password)
|
|||
}
|
||||
|
||||
double offset = 0;
|
||||
for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++)
|
||||
{
|
||||
for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++) {
|
||||
zathura_page_t* page = zathura_page_get(document, page_id);
|
||||
if (!page) {
|
||||
goto error_free;
|
||||
|
|
17
render.c
17
render.c
|
@ -174,3 +174,20 @@ render(zathura_page_t* page)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
render_all(void)
|
||||
{
|
||||
if (Zathura.document == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* unmark all pages */
|
||||
for (unsigned int page_id = 0; page_id < Zathura.document->number_of_pages; page_id++) {
|
||||
Zathura.document->pages[page_id]->rendered = false;
|
||||
}
|
||||
|
||||
/* redraw current page */
|
||||
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.view));
|
||||
cb_view_vadjustment_value_changed(view_vadjustment, NULL);
|
||||
}
|
||||
|
|
8
render.h
8
render.h
|
@ -8,6 +8,7 @@
|
|||
#include <girara-datastructures.h>
|
||||
|
||||
#include "ft/document.h"
|
||||
#include "callbacks.h"
|
||||
|
||||
typedef struct render_thread_s
|
||||
{
|
||||
|
@ -41,4 +42,11 @@ void render_free(render_thread_t* render_thread);
|
|||
*/
|
||||
bool render_page(render_thread_t* render_thread, zathura_page_t* page);
|
||||
|
||||
/**
|
||||
* This function is used to unmark all pages as not rendered. This should
|
||||
* be used if all pages should be rendered again (e.g.: the zoom level or the
|
||||
* colors have changed)
|
||||
*/
|
||||
void render_all(void);
|
||||
|
||||
#endif // RENDER_H
|
||||
|
|
23
shortcuts.c
23
shortcuts.c
|
@ -6,6 +6,7 @@
|
|||
#include "callbacks.h"
|
||||
#include "shortcuts.h"
|
||||
#include "zathura.h"
|
||||
#include "render.h"
|
||||
|
||||
bool
|
||||
sc_abort(girara_session_t* session, girara_argument_t* argument, unsigned int t)
|
||||
|
@ -244,5 +245,27 @@ sc_quit(girara_session_t* session, girara_argument_t* argument, unsigned int t)
|
|||
bool
|
||||
sc_zoom(girara_session_t* session, girara_argument_t* argument, unsigned int t)
|
||||
{
|
||||
if (session == NULL || argument == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* retreive zoom step value */
|
||||
int* value = girara_setting_get(Zathura.UI.session, "zoom-step");
|
||||
if (value == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float zoom_step = *value / 100.0f;
|
||||
|
||||
if (argument->n == ZOOM_IN) {
|
||||
Zathura.document->scale += zoom_step;
|
||||
} else if (argument->n == ZOOM_OUT) {
|
||||
Zathura.document->scale -= zoom_step;
|
||||
} else {
|
||||
Zathura.document->scale = 1.0;
|
||||
}
|
||||
|
||||
render_all();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue