Skip to content

Commit

Permalink
previewer: Enable/disable page navigation based on current page
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Roth authored and Carlos Garcia Campos committed Mar 16, 2015
1 parent c9225a9 commit a671eb0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions previewer/ev-previewer-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,22 @@ view_focus_changed (GtkWidget *widget,
return FALSE;
}

static void
model_page_changed (EvDocumentModel* model,
gint old_page,
gint new_page,
EvPreviewerWindow *window)
{
GtkAction *action;
gint n_pages = ev_document_get_n_pages (ev_document_model_get_document (window->model));

action = gtk_action_group_get_action (window->action_group, "GoPreviousPage");
gtk_action_set_sensitive (GTK_ACTION (action), new_page > 0 );

action = gtk_action_group_get_action (window->action_group, "GoNextPage");
gtk_action_set_sensitive (GTK_ACTION (action), new_page < n_pages - 1);
}

static void
view_sizing_mode_changed (EvDocumentModel *model,
GParamSpec *pspec,
Expand Down Expand Up @@ -599,6 +615,10 @@ ev_previewer_window_constructor (GType type,
ev_view_set_model (window->view, window->model);
ev_document_model_set_continuous (window->model, FALSE);

g_signal_connect_object (window->model, "page-changed",
G_CALLBACK (model_page_changed),
window, 0);

gtk_container_add (GTK_CONTAINER (window->swindow), GTK_WIDGET (window->view));
gtk_widget_show (GTK_WIDGET (window->view));

Expand Down

0 comments on commit a671eb0

Please sign in to comment.