Skip to content
Permalink
Browse files

Add zoom reset

  • Loading branch information...
Cobinja authored and raveit65 committed Aug 30, 2017
1 parent a3ade9f commit 580e4fa77018dc57cfd88e229fb21b1d87dfd3dd
@@ -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>
@@ -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"/>
@@ -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"/>
@@ -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,
@@ -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);

@@ -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
@@ -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);
@@ -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)
@@ -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,
@@ -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);
}
@@ -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)
{
@@ -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) },
@@ -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);

0 comments on commit 580e4fa

Please sign in to comment.
You can’t perform that action at this time.