mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 10:16:00 +01:00
adopt to changes from girara
This commit is contained in:
parent
8d2d6ec0ec
commit
083a40f447
3 changed files with 29 additions and 50 deletions
12
render.c
12
render.c
|
@ -325,14 +325,10 @@ page_expose_event(GtkWidget* UNUSED(widget), GdkEventExpose* UNUSED(event),
|
||||||
cairo_rectangle(cairo, 0, 0, page_width, page->height * page->height);
|
cairo_rectangle(cairo, 0, 0, page_width, page->height * page->height);
|
||||||
cairo_fill(cairo);
|
cairo_fill(cairo);
|
||||||
|
|
||||||
bool render_loading = false;
|
bool render_loading = true;
|
||||||
bool* tmp = (page->document != NULL && page->document->zathura != NULL &&
|
if (page->document != NULL && page->document->zathura != NULL &&
|
||||||
page->document->zathura->ui.session != NULL) ?
|
page->document->zathura->ui.session != NULL)
|
||||||
girara_setting_get(page->document->zathura->ui.session, "render-loading") : NULL;
|
girara_setting_get(page->document->zathura->ui.session, "render-loading", &render_loading);
|
||||||
if (tmp != NULL) {
|
|
||||||
render_loading = *tmp;
|
|
||||||
g_free(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write text */
|
/* write text */
|
||||||
if (render_loading == true) {
|
if (render_loading == true) {
|
||||||
|
|
48
shortcuts.c
48
shortcuts.c
|
@ -33,9 +33,10 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
|
||||||
zathura_t* zathura = session->global.data;
|
zathura_t* zathura = session->global.data;
|
||||||
g_return_val_if_fail(argument != NULL, false);
|
g_return_val_if_fail(argument != NULL, false);
|
||||||
|
|
||||||
unsigned int* pages_per_row = girara_setting_get(session, "pages-per-row");
|
unsigned int pages_per_row = 1;
|
||||||
|
girara_setting_get(session, "pages-per-row", &pages_per_row);
|
||||||
|
|
||||||
if (zathura->ui.page_view == NULL || zathura->document == NULL || pages_per_row == NULL) {
|
if (zathura->ui.page_view == NULL || zathura->document == NULL) {
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,14 +50,14 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
|
||||||
double total_width = 0;
|
double total_width = 0;
|
||||||
double max_height = 0;
|
double max_height = 0;
|
||||||
|
|
||||||
for (unsigned int page_id = 0; page_id < *pages_per_row; page_id++) {
|
for (unsigned int page_id = 0; page_id < pages_per_row; page_id++) {
|
||||||
if (page_id == zathura->document->number_of_pages) {
|
if (page_id == zathura->document->number_of_pages) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_page_t* page = zathura->document->pages[page_id];
|
zathura_page_t* page = zathura->document->pages[page_id];
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
goto error_free;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (page->height > max_height) {
|
if (page->height > max_height) {
|
||||||
|
@ -71,17 +72,12 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
|
||||||
} else if (argument->n == ADJUST_BESTFIT) {
|
} else if (argument->n == ADJUST_BESTFIT) {
|
||||||
zathura->document->scale = height / max_height;
|
zathura->document->scale = height / max_height;
|
||||||
} else {
|
} else {
|
||||||
goto error_free;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* re-render all pages */
|
/* re-render all pages */
|
||||||
render_all(zathura);
|
render_all(zathura);
|
||||||
|
|
||||||
error_free:
|
|
||||||
|
|
||||||
/* cleanup */
|
|
||||||
g_free(pages_per_row);
|
|
||||||
|
|
||||||
error_ret:
|
error_ret:
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -110,14 +106,11 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* font = girara_setting_get(session, "font");
|
char* font = NULL;
|
||||||
|
girara_setting_get(session, "font", &font);
|
||||||
|
|
||||||
float transparency = 0.5;
|
float transparency = 0.5;
|
||||||
float* tmp = girara_setting_get(session, "highlight-transparency");
|
girara_setting_get(session, "highlight-transparency", &transparency);
|
||||||
if (tmp != NULL) {
|
|
||||||
transparency = *tmp;
|
|
||||||
g_free(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int link_id = 0;
|
unsigned int link_id = 0;
|
||||||
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++) {
|
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++) {
|
||||||
|
@ -296,12 +289,8 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
|
||||||
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
|
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
|
||||||
gdouble value = gtk_adjustment_get_value(adjustment);
|
gdouble value = gtk_adjustment_get_value(adjustment);
|
||||||
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
|
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
|
||||||
gdouble scroll_step = 40;
|
float scroll_step = 40;
|
||||||
float* tmp = girara_setting_get(session, "scroll-step");
|
girara_setting_get(session, "scroll-step", &scroll_step);
|
||||||
if (tmp != NULL) {
|
|
||||||
scroll_step = *tmp;
|
|
||||||
g_free(tmp);
|
|
||||||
}
|
|
||||||
gdouble new_value;
|
gdouble new_value;
|
||||||
|
|
||||||
switch(argument->n) {
|
switch(argument->n) {
|
||||||
|
@ -566,11 +555,7 @@ sc_toggle_fullscreen(girara_session_t* session, girara_argument_t*
|
||||||
render_all(zathura);
|
render_all(zathura);
|
||||||
} else {
|
} else {
|
||||||
/* backup pages per row */
|
/* backup pages per row */
|
||||||
int* tmp = girara_setting_get(session, "pages-per-row");
|
girara_setting_get(session, "pages-per-row", &pages_per_row);
|
||||||
if (tmp != NULL) {
|
|
||||||
pages_per_row = *tmp;
|
|
||||||
g_free(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set single view */
|
/* set single view */
|
||||||
int int_value = 1;
|
int int_value = 1;
|
||||||
|
@ -621,13 +606,10 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
|
||||||
g_return_val_if_fail(zathura->document != NULL, false);
|
g_return_val_if_fail(zathura->document != NULL, false);
|
||||||
|
|
||||||
/* retreive zoom step value */
|
/* retreive zoom step value */
|
||||||
int* value = girara_setting_get(zathura->ui.session, "zoom-step");
|
int value = 1;
|
||||||
if (value == NULL) {
|
girara_setting_get(zathura->ui.session, "zoom-step", &value);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
float zoom_step = *value / 100.0f;
|
float zoom_step = value / 100.0f;
|
||||||
g_free(value);
|
|
||||||
|
|
||||||
if (argument->n == ZOOM_IN) {
|
if (argument->n == ZOOM_IN) {
|
||||||
zathura->document->scale += zoom_step;
|
zathura->document->scale += zoom_step;
|
||||||
|
|
19
zathura.c
19
zathura.c
|
@ -212,27 +212,29 @@ zathura_init(int argc, char* argv[])
|
||||||
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), NULL);
|
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), NULL);
|
||||||
|
|
||||||
/* save page padding */
|
/* save page padding */
|
||||||
int* page_padding = girara_setting_get(zathura->ui.session, "page-padding");
|
zathura->global.page_padding = 1;
|
||||||
zathura->global.page_padding = (page_padding) ? *page_padding : 1;
|
girara_setting_get(zathura->ui.session, "page-padding", &zathura->global.page_padding);
|
||||||
g_free(page_padding);
|
|
||||||
|
|
||||||
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_view), zathura->global.page_padding);
|
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_view), zathura->global.page_padding);
|
||||||
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_view), zathura->global.page_padding);
|
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_view), zathura->global.page_padding);
|
||||||
|
|
||||||
/* parse colors */
|
/* parse colors */
|
||||||
char* string_value = girara_setting_get(zathura->ui.session, "recolor-darkcolor");
|
char* string_value = NULL;
|
||||||
|
girara_setting_get(zathura->ui.session, "recolor-darkcolor", &string_value);
|
||||||
if (string_value != NULL) {
|
if (string_value != NULL) {
|
||||||
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color));
|
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color));
|
||||||
g_free(string_value);
|
g_free(string_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_value = girara_setting_get(zathura->ui.session, "recolor-lightcolor");
|
string_value = NULL;
|
||||||
|
girara_setting_get(zathura->ui.session, "recolor-lightcolor", &string_value);
|
||||||
if (string_value != NULL) {
|
if (string_value != NULL) {
|
||||||
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
|
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
|
||||||
g_free(string_value);
|
g_free(string_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_value = girara_setting_get(zathura->ui.session, "highlight-color");
|
string_value = NULL;
|
||||||
|
girara_setting_get(zathura->ui.session, "highlight-color", &string_value);
|
||||||
if (string_value != NULL) {
|
if (string_value != NULL) {
|
||||||
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color));
|
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color));
|
||||||
g_free(string_value);
|
g_free(string_value);
|
||||||
|
@ -420,9 +422,8 @@ document_open(zathura_t* zathura, const char* path, const char* password)
|
||||||
zathura->document = document;
|
zathura->document = document;
|
||||||
|
|
||||||
/* view mode */
|
/* view mode */
|
||||||
int* value = girara_setting_get(zathura->ui.session, "pages-per-row");
|
int pages_per_row = 1;
|
||||||
int pages_per_row = (value) ? *value : 1;
|
girara_setting_get(zathura->ui.session, "pages-per-row", &pages_per_row);
|
||||||
g_free(value);
|
|
||||||
page_view_set_mode(zathura, pages_per_row);
|
page_view_set_mode(zathura, pages_per_row);
|
||||||
|
|
||||||
girara_set_view(zathura->ui.session, zathura->ui.page_view_alignment);
|
girara_set_view(zathura->ui.session, zathura->ui.page_view_alignment);
|
||||||
|
|
Loading…
Reference in a new issue