center the pages (Closes: #85, #87)

This commit is contained in:
Sebastian Ramacher 2012-01-13 17:39:46 +01:00
parent 10b5006828
commit c75eaf4c43
4 changed files with 14 additions and 4 deletions

View file

@ -262,8 +262,7 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
int offset = 0;
zathura_db_get_fileinfo(zathura->database, document->file_path,
&document->current_page_number, &offset, &document->scale);
if (document->scale <= 0)
{
if (document->scale <= FLT_EPSILON) {
girara_warning("document info: '%s' has non positive scale", document->file_path);
document->scale = 1;
}

View file

@ -455,7 +455,7 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument),
}
if (gtk_widget_get_visible(GTK_WIDGET(zathura->ui.index))) {
girara_set_view(session, zathura->ui.page_view);
girara_set_view(session, zathura->ui.page_view_alignment);
gtk_widget_hide(GTK_WIDGET(zathura->ui.index));
girara_mode_set(zathura->ui.session, zathura->modes.normal);
} else {

View file

@ -166,6 +166,13 @@ zathura_init(int argc, char* argv[])
GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
g_signal_connect(G_OBJECT(view_hadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), zathura);
/* page view alignment */
zathura->ui.page_view_alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
if (!zathura->ui.page_view_alignment) {
goto error_free;
}
gtk_container_add(GTK_CONTAINER(zathura->ui.page_view_alignment), zathura->ui.page_view);
gtk_widget_show(zathura->ui.page_view);
/* statusbar */
@ -238,6 +245,9 @@ error_free:
g_object_unref(zathura->ui.page_view);
}
if (zathura->ui.page_view_alignment) {
g_object_unref(zathura->ui.page_view_alignment);
}
error_out:
@ -394,7 +404,7 @@ document_open(zathura_t* zathura, const char* path, const char* password)
g_free(value);
page_view_set_mode(zathura, pages_per_row);
girara_set_view(zathura->ui.session, zathura->ui.page_view);
girara_set_view(zathura->ui.session, zathura->ui.page_view_alignment);
/* threads */
zathura->sync.render_thread = render_init(zathura);

View file

@ -51,6 +51,7 @@ typedef struct zathura_s
GdkColor recolor_light_color; /**> Light color for recoloring */
} colors;
GtkWidget *page_view_alignment;
GtkWidget *page_view; /**> Widget that contains all rendered pages */
GtkWidget *index; /**> Widget to show the index of the document */
} ui;