Skip to content

Commit

Permalink
Add zoom reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Cobinja authored and raveit65 committed Mar 15, 2018
1 parent a3ade9f commit 580e4fa
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/atril-previewer-ui.xml
Expand Up @@ -9,6 +9,7 @@
<toolitem name="ViewFitPage" action="ViewFitPage"/>
<toolitem name="ViewZoomIn" action="ViewZoomIn"/>
<toolitem name="ViewZoomOut" action="ViewZoomOut"/>
<toolitem name="ViewZoomReset" action="ViewZoomReset"/>
<separator/>
<toolitem name="PreviewPrint" action="PreviewPrint"/>
</toolbar>
Expand Down
1 change: 1 addition & 0 deletions data/atril-toolbar.xml
Expand Up @@ -14,6 +14,7 @@
<toolitem name="ViewZoom"/>
<toolitem name="ViewZoomIn"/>
<toolitem name="ViewZoomOut"/>
<toolitem name="ViewZoomReset"/>
<toolitem name="ViewFitPage"/>
<toolitem name="ViewFitWidth"/>
<toolitem name="ViewFullscreen"/>
Expand Down
1 change: 1 addition & 0 deletions data/atril-ui.xml
Expand Up @@ -49,6 +49,7 @@
<separator/>
<menuitem name="ViewZoomInMenu" action="ViewZoomIn"/>
<menuitem name="ViewZoomOutMenu" action="ViewZoomOut"/>
<menuitem name="ViewZoomResetMenu" action="ViewZoomReset"/>
<menuitem name="ViewFitPageMenu" action="ViewFitPage"/>
<menuitem name="ViewFitWidthMenu" action="ViewFitWidth"/>
<menuitem name="ViewExpandWindowMenu" action="ViewExpandWindow"/>
Expand Down
7 changes: 7 additions & 0 deletions libview/ev-view.c
Expand Up @@ -7088,6 +7088,13 @@ ev_view_zoom_out (EvView *view)
ev_view_zoom (view, ZOOM_OUT_FACTOR);
}

void
ev_view_zoom_reset (EvView *view)
{
g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
ev_document_model_set_scale (view->model, 1.2);
}

static double
zoom_for_size_fit_width (gdouble doc_width,
gdouble doc_height,
Expand Down
1 change: 1 addition & 0 deletions libview/ev-view.h
Expand Up @@ -63,6 +63,7 @@ gboolean ev_view_can_zoom_in (EvView *view);
void ev_view_zoom_in (EvView *view);
gboolean ev_view_can_zoom_out (EvView *view);
void ev_view_zoom_out (EvView *view);
void ev_view_zoom_reset (EvView *view);
void ev_view_zoom (EvView *view,
gdouble factor);

Expand Down
11 changes: 11 additions & 0 deletions libview/ev-web-view.c
Expand Up @@ -687,6 +687,17 @@ ev_web_view_zoom_out(EvWebView *webview)
return TRUE;
}

gboolean
ev_web_view_zoom_reset(EvWebView *webview)
{
if (webview->zoom_level == 1)
return FALSE;

webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW(webview),
1.0);
return TRUE;
}

/**
* ev_web_view_disconnect_handlers
* @webview : #EvWebView instance
Expand Down
1 change: 1 addition & 0 deletions libview/ev-web-view.h
Expand Up @@ -83,6 +83,7 @@ void ev_web_view_copy (EvWebView *webview);
/* Zoom control */
gboolean ev_web_view_zoom_in (EvWebView *webview);
gboolean ev_web_view_zoom_out (EvWebView *webview);
gboolean ev_web_view_zoom_reset (EvWebView *webview);

/*For safe replacement by an EvView*/
void ev_web_view_disconnect_handlers (EvWebView *webview);
Expand Down
11 changes: 11 additions & 0 deletions previewer/ev-previewer-window.c
Expand Up @@ -138,6 +138,14 @@ ev_previewer_window_zoom_out (GtkAction *action,
ev_view_zoom_out (window->view);
}

static void
ev_previewer_window_zoom_reset (GtkAction *action,
EvPreviewerWindow *window)
{
ev_document_model_set_sizing_mode (window->model, EV_SIZING_FREE);
ev_view_zoom_reset (window->view);
}

static void
ev_previewer_window_zoom_fit_page (GtkToggleAction *action,
EvPreviewerWindow *window)
Expand Down Expand Up @@ -284,6 +292,9 @@ static const GtkActionEntry action_entries[] = {
{ "ViewZoomOut", "zoom-out", N_("Zoom _Out"), "<control>minus",
N_("Shrink the document"),
G_CALLBACK (ev_previewer_window_zoom_out) },
{ "ViewZoomReset", "zoom-original", NULL, "<control>0",
N_("Reset zoom to 100\%"),
G_CALLBACK (ev_previewer_window_zoom_reset) },
#if GTKUNIXPRINT_ENABLED
/* translators: Print document currently shown in the Print Preview window */
{ "PreviewPrint", "document-print", N_("Print"), NULL,
Expand Down
27 changes: 27 additions & 0 deletions shell/ev-window.c
Expand Up @@ -575,6 +575,9 @@ ev_window_update_actions (EvWindow *ev_window)
has_pages &&
ev_view_can_zoom_out (view) &&
!presentation_mode);
ev_window_set_action_sensitive (ev_window, "ViewZoomReset",
has_pages &&
!presentation_mode);
ev_window_set_action_sensitive (ev_window, "ViewDualOddLeft",
dual_mode);
}
Expand Down Expand Up @@ -4724,6 +4727,23 @@ ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window)
}
}

static void
ev_window_cmd_view_zoom_reset (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));

ev_document_model_set_sizing_mode (ev_window->priv->model, EV_SIZING_FREE);
#if ENABLE_EPUB
if ( ev_window->priv->document->iswebdocument) {
ev_web_view_zoom_reset(EV_WEB_VIEW(ev_window->priv->webview));
}
else
#endif
{
ev_view_zoom_reset (EV_VIEW (ev_window->priv->view));
}
}

static void
ev_window_cmd_go_previous_page (GtkAction *action, EvWindow *ev_window)
{
Expand Down Expand Up @@ -6300,6 +6320,9 @@ static const GtkActionEntry entries[] = {
{ "ViewZoomOut", "zoom-out", N_("Zoom _Out"), "<control>minus",
N_("Shrink the document"),
G_CALLBACK (ev_window_cmd_view_zoom_out) },
{ "ViewZoomReset", "zoom-original", N_("_Reset Zoom"), "<control>0",
N_("Reset zoom to 100\%"),
G_CALLBACK (ev_window_cmd_view_zoom_reset) },
{ "ViewReload", "view-refresh", N_("_Reload"), "<control>R",
N_("Reload the document"),
G_CALLBACK (ev_window_cmd_view_reload) },
Expand Down Expand Up @@ -6653,6 +6676,10 @@ set_action_properties (GtkActionGroup *action_group)
/*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Zoom Out"), NULL);

action = gtk_action_group_get_action (action_group, "ViewZoomReset");
/*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Reset Zoom"), NULL);

action = gtk_action_group_get_action (action_group, "ViewFitPage");
/*translators: this is the label for toolbar button*/
g_object_set (action, "short_label", _("Fit Page"), NULL);
Expand Down

0 comments on commit 580e4fa

Please sign in to comment.