mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-13 07:23:45 +01:00
Updated callbacks.c
This commit is contained in:
parent
a181c04775
commit
daa523aaf5
19
callbacks.c
19
callbacks.c
@ -21,33 +21,40 @@ void
|
|||||||
buffer_changed(girara_session_t* session)
|
buffer_changed(girara_session_t* session)
|
||||||
{
|
{
|
||||||
g_return_if_fail(session != NULL);
|
g_return_if_fail(session != NULL);
|
||||||
|
g_return_if_fail(session->global.data != NULL);
|
||||||
|
|
||||||
|
zathura_t* zathura = session->global.data;
|
||||||
|
|
||||||
char* buffer = girara_buffer_get(session);
|
char* buffer = girara_buffer_get(session);
|
||||||
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, buffer);
|
girara_statusbar_item_set_text(session, zathura->ui.statusbar.buffer, buffer);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
} else {
|
} else {
|
||||||
girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, "");
|
girara_statusbar_item_set_text(session, zathura->ui.statusbar.buffer, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
|
cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
|
||||||
{
|
{
|
||||||
if (!Zathura.document || !Zathura.document->pages || !Zathura.UI.page_view) {
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
|
zathura_t* zathura = data;
|
||||||
|
if (!zathura->document || !zathura->document->pages || !zathura->ui.page_view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
/* get current adjustment values */
|
/* get current adjustment values */
|
||||||
/*gdouble lower = gtk_adjustment_get_value(adjustment);*/
|
/*gdouble lower = gtk_adjustment_get_value(adjustment);*/
|
||||||
/*gdouble upper = lower + gtk_adjustment_get_page_size(adjustment);*/
|
/*gdouble upper = lower + gtk_adjustment_get_page_size(adjustment);*/
|
||||||
|
|
||||||
/* find page that fits */
|
/* find page that fits */
|
||||||
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++)
|
||||||
{
|
{
|
||||||
zathura_page_t* page = Zathura.document->pages[page_id];
|
zathura_page_t* page = zathura->document->pages[page_id];
|
||||||
|
|
||||||
/* check for rendered attribute */
|
/* check for rendered attribute */
|
||||||
if (page->rendered) {
|
if (page->rendered) {
|
||||||
@ -62,7 +69,7 @@ cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
|
|||||||
/*|| ( (begin >= lower) && (end >= upper) && (begin <= upper) ) [> begin of the page is in viewport <]*/
|
/*|| ( (begin >= lower) && (end >= upper) && (begin <= upper) ) [> begin of the page is in viewport <]*/
|
||||||
/*) {*/
|
/*) {*/
|
||||||
if (page_id < 1) {
|
if (page_id < 1) {
|
||||||
render_page(Zathura.Sync.render_thread, Zathura.document->pages[page_id]);
|
render_page(zathura->sync.render_thread, zathura->document->pages[page_id]);
|
||||||
}
|
}
|
||||||
/*}*/
|
/*}*/
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ zathura_init(int argc, char* argv[])
|
|||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zathura->ui.session->global.data = zathura;
|
||||||
zathura->ui.statusbar.file = NULL;
|
zathura->ui.statusbar.file = NULL;
|
||||||
zathura->ui.statusbar.buffer = NULL;
|
zathura->ui.statusbar.buffer = NULL;
|
||||||
zathura->ui.statusbar.page_number = NULL;
|
zathura->ui.statusbar.page_number = NULL;
|
||||||
@ -67,7 +68,7 @@ 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);
|
||||||
|
|
||||||
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
|
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
|
||||||
g_signal_connect(G_OBJECT(view_vadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), NULL);
|
g_signal_connect(G_OBJECT(view_vadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), zathura);
|
||||||
|
|
||||||
/* girara events */
|
/* girara events */
|
||||||
zathura->ui.session->events.buffer_changed = buffer_changed;
|
zathura->ui.session->events.buffer_changed = buffer_changed;
|
||||||
@ -76,7 +77,7 @@ zathura_init(int argc, char* argv[])
|
|||||||
zathura_document_plugins_load();
|
zathura_document_plugins_load();
|
||||||
|
|
||||||
/* configuration */
|
/* configuration */
|
||||||
config_load_default();
|
config_load_default(zathura);
|
||||||
|
|
||||||
return zathura;
|
return zathura;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user