Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorJames Bowes <bowes@cs.dal.ca>2005-05-02 16:19:48 (GMT)
committer James Bowes <jbowes@src.gnome.org>2005-05-02 16:19:48 (GMT)
commit606f66cbbca54996a165121743cda6a993762c47 (patch)
treeaf9aeaf3c5f8b737c603576072e45503901ad434 /shell
parent8ccbb218873ff3f7d5e6b924b9ff7d44f1f6d62e (diff)
Output zoom-control Makefile. build zoom-control subdir.
2005-05-02 James Bowes <bowes@cs.dal.ca> * configure.ac: Output zoom-control Makefile. * cut-n-paste/Makefile.am: build zoom-control subdir. * cut-n-paste/zoom-control/ephy-zoom-action.c: * cut-n-paste/zoom-control/ephy-zoom-action.h: * cut-n-paste/zoom-control/ephy-zoom-control.c: * cut-n-paste/zoom-control/ephy-zoom-control.h: * cut-n-paste/zoom-control/ephy-zoom.c: * cut-n-paste/zoom-control/ephy-zoom.h: New files imported from epiphany, and modified to add a separator into the menu. * cut-n-paste/zoom-control/Makefile.am: Build zoom-control. * data/evince-ui.xml: Replace old zoom toolbar actions with new zoom-control action. * shell/Makefile.am: Include zoom-control flags. * shell/ev-view.c: (ev_view_set_zoom), (ev_view_get_zoom), (ev_view_get_sizing_mode), (ev_view_zoom_in), (ev_view_zoom_out), (ev_view_zoom_for_size_presentation), (ev_view_zoom_for_size_continuous_and_dual_page), (ev_view_zoom_for_size_continuous), (ev_view_zoom_for_size_dual_page), (ev_view_zoom_for_size_single_page), (ev_view_zoom_normal): s/ev_view_zoom/ev_view_set_zoom/ and make public, add ev_view_get_zoom and ev_view_get_sizing_mode. * shell/ev-view.h: * shell/ev-window.c: (update_action_sensitivity), (update_sizing_buttons), (zoom_control_changed_cb), (register_custom_actions): Initialize and use the zoom-control widget.
Diffstat (limited to 'shell')
-rw-r--r--shell/Makefile.am13
-rw-r--r--shell/ev-view.c36
-rw-r--r--shell/ev-view.h31
-rw-r--r--shell/ev-window.c62
4 files changed, 112 insertions, 30 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am
index f9ef2f4..498be8a 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -5,6 +5,7 @@ INCLUDES= \
-DGNOMEDATADIR=\"$(datadir)\" \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/cut-n-paste/recent-files/ \
+ -I$(top_srcdir)/cut-n-paste/zoom-control/ \
-I$(top_srcdir)/backend \
-I$(top_srcdir)/pdf \
-I$(top_srcdir)/pixbuf \
@@ -80,11 +81,13 @@ evince_SOURCES= \
main.c \
$(NULL)
-evince_LDADD= \
- $(SHELL_LIBS) \
- $(top_builddir)/cut-n-paste/recent-files/librecent.la \
- $(top_builddir)/lib/libev.la \
- libevbackendfactory.la \
+evince_LDADD= \
+ $(SHELL_LIBS) \
+ $(top_builddir)/cut-n-paste/recent-files/librecent.la \
+ $(top_builddir)/cut-n-paste/zoom-control/libephymisc.la \
+ $(top_builddir)/cut-n-paste/zoom-control/libephywidgets.la \
+ $(top_builddir)/lib/libev.la \
+ libevbackendfactory.la \
$(NULL)
BUILT_SOURCES = ev-marshal.h ev-marshal.c
diff --git a/shell/ev-view.c b/shell/ev-view.c
index 2469dca..dba309b 100644
--- a/shell/ev-view.c
+++ b/shell/ev-view.c
@@ -2006,10 +2006,10 @@ ev_view_set_document (EvView *view,
}
#define EPSILON 0.0000001
-static void
-ev_view_zoom (EvView *view,
- double factor,
- gboolean relative)
+void
+ev_view_set_zoom (EvView *view,
+ double factor,
+ gboolean relative)
{
double scale;
@@ -2026,6 +2026,11 @@ ev_view_zoom (EvView *view,
gtk_widget_queue_resize (GTK_WIDGET (view));
}
+double
+ev_view_get_zoom (EvView *view)
+{
+ return view->scale;
+}
void
ev_view_set_continuous (EvView *view,
@@ -2136,6 +2141,13 @@ ev_view_set_sizing_mode (EvView *view,
g_object_notify (G_OBJECT (view), "sizing-mode");
}
+EvSizingMode
+ev_view_get_sizing_mode (EvView *view)
+{
+ g_return_val_if_fail (EV_IS_VIEW (view), EV_SIZING_FREE);
+
+ return view->sizing_mode;
+}
gboolean
ev_view_can_zoom_in (EvView *view)
@@ -2154,7 +2166,7 @@ ev_view_zoom_in (EvView *view)
{
g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
- ev_view_zoom (view, ZOOM_IN_FACTOR, TRUE);
+ ev_view_set_zoom (view, ZOOM_IN_FACTOR, TRUE);
}
void
@@ -2162,7 +2174,7 @@ ev_view_zoom_out (EvView *view)
{
g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
- ev_view_zoom (view, ZOOM_OUT_FACTOR, TRUE);
+ ev_view_set_zoom (view, ZOOM_OUT_FACTOR, TRUE);
}
@@ -2221,7 +2233,7 @@ ev_view_zoom_for_size_presentation (EvView *view,
&doc_width,
&doc_height);
scale = zoom_for_size_best_fit (doc_width, doc_height, width, height, 0, 0);
- ev_view_zoom (view, scale, FALSE);
+ ev_view_set_zoom (view, scale, FALSE);
}
static void
@@ -2257,7 +2269,7 @@ ev_view_zoom_for_size_continuous_and_dual_page (EvView *view,
else
g_assert_not_reached ();
- ev_view_zoom (view, scale, FALSE);
+ ev_view_set_zoom (view, scale, FALSE);
}
static void
@@ -2292,7 +2304,7 @@ ev_view_zoom_for_size_continuous (EvView *view,
else
g_assert_not_reached ();
- ev_view_zoom (view, scale, FALSE);
+ ev_view_set_zoom (view, scale, FALSE);
}
static void
@@ -2339,7 +2351,7 @@ ev_view_zoom_for_size_dual_page (EvView *view,
else
g_assert_not_reached ();
- ev_view_zoom (view, scale, FALSE);
+ ev_view_set_zoom (view, scale, FALSE);
}
static void
@@ -2371,14 +2383,14 @@ ev_view_zoom_for_size_single_page (EvView *view,
else
g_assert_not_reached ();
- ev_view_zoom (view, scale, FALSE);
+ ev_view_set_zoom (view, scale, FALSE);
}
void
ev_view_zoom_normal (EvView *view)
{
- ev_view_zoom (view, 1.0, FALSE);
+ ev_view_set_zoom (view, 1.0, FALSE);
}
void
diff --git a/shell/ev-view.h b/shell/ev-view.h
index a96397f..c0108c5 100644
--- a/shell/ev-view.h
+++ b/shell/ev-view.h
@@ -57,19 +57,19 @@ void ev_view_select_all (EvView *view);
/* These are all orthoganal to each other, except 'presentation' trumps all
* other behaviors
*/
-void ev_view_set_continuous (EvView *view,
- gboolean continuous);
-void ev_view_set_dual_page (EvView *view,
- gboolean dual_page);
-void ev_view_set_fullscreen (EvView *view,
- gboolean fullscreen);
-gboolean ev_view_get_fullscreen (EvView *view);
-void ev_view_set_presentation (EvView *view,
- gboolean presentation);
-gboolean ev_view_get_presentation (EvView *view);
-void ev_view_set_sizing_mode (EvView *view,
- EvSizingMode mode);
-
+void ev_view_set_continuous (EvView *view,
+ gboolean continuous);
+void ev_view_set_dual_page (EvView *view,
+ gboolean dual_page);
+void ev_view_set_fullscreen (EvView *view,
+ gboolean fullscreen);
+gboolean ev_view_get_fullscreen (EvView *view);
+void ev_view_set_presentation (EvView *view,
+ gboolean presentation);
+gboolean ev_view_get_presentation (EvView *view);
+void ev_view_set_sizing_mode (EvView *view,
+ EvSizingMode mode);
+EvSizingMode ev_view_get_sizing_mode (EvView *view);
/* Page size */
@@ -77,6 +77,11 @@ 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_set_zoom (EvView *view,
+ double factor,
+ gboolean relative);
+double ev_view_get_zoom (EvView *view);
+
void ev_view_set_zoom_for_size (EvView *view,
int width,
int height,
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 475cb5d..58d30a4 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -47,6 +47,8 @@
#include "egg-recent-view-gtk.h"
#include "egg-recent-view.h"
#include "egg-recent-model.h"
+#include "ephy-zoom.h"
+#include "ephy-zoom-action.h"
#include <glib/gi18n.h>
#include <gtk/gtk.h>
@@ -126,6 +128,7 @@ static const GtkTargetEntry ev_drop_types[] = {
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
#define PAGE_SELECTOR_ACTION "PageSelector"
+#define ZOOM_CONTROL_ACTION "ViewZoom"
#define GCONF_CHROME_TOOLBAR "/apps/evince/show_toolbar"
#define GCONF_CHROME_SIDEBAR "/apps/evince/show_sidebar"
@@ -245,6 +248,21 @@ update_action_sensitivity (EvWindow *ev_window)
/* Toolbar-specific actions: */
set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
+ set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
+
+ if (has_pages && ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ GtkAction *action;
+ float zoom;
+ float real_zoom;
+
+ action = gtk_action_group_get_action (ev_window->priv->action_group,
+ ZOOM_CONTROL_ACTION);
+
+ real_zoom = ev_view_get_zoom (EV_VIEW (ev_window->priv->view));
+ zoom = ephy_zoom_get_nearest_zoom_level (real_zoom);
+
+ ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action), zoom);
+ }
}
static void
@@ -405,6 +423,16 @@ update_sizing_buttons (EvWindow *window)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), page_width);
g_signal_handlers_unblock_by_func
(action, G_CALLBACK (ev_window_cmd_view_page_width), window);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ ZOOM_CONTROL_ACTION);
+ if (best_fit) {
+ ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
+ EPHY_ZOOM_BEST_FIT);
+ } else if (page_width) {
+ ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
+ EPHY_ZOOM_FIT_WIDTH);
+ }
}
void
@@ -2068,6 +2096,28 @@ find_bar_search_changed_cb (EggFindBar *find_bar,
}
static void
+zoom_control_changed_cb (EphyZoomAction *action,
+ float zoom,
+ EvWindow *ev_window)
+{
+ EvSizingMode mode;
+
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ if (zoom == EPHY_ZOOM_BEST_FIT) {
+ mode = EV_SIZING_BEST_FIT;
+ } else if (zoom == EPHY_ZOOM_FIT_WIDTH) {
+ mode = EV_SIZING_FIT_WIDTH;
+ } else {
+ mode = EV_SIZING_FREE;
+ ev_view_set_zoom (EV_VIEW (ev_window->priv->view), zoom, FALSE);
+ }
+
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode);
+ update_action_sensitivity (ev_window);
+}
+
+static void
ev_window_dispose (GObject *object)
{
EvWindow *window = EV_WINDOW (object);
@@ -2294,6 +2344,18 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group)
NULL);
gtk_action_group_add_action (group, action);
g_object_unref (action);
+
+ action = g_object_new (EPHY_TYPE_ZOOM_ACTION,
+ "name", ZOOM_CONTROL_ACTION,
+ "label", _("Zoom"),
+ "stock_id", GTK_STOCK_ZOOM_IN,
+ "tooltip", _("Adjust the zoom level"),
+ "zoom", 1.0,
+ NULL);
+ g_signal_connect (action, "zoom_to_level",
+ G_CALLBACK (zoom_control_changed_cb), window);
+ gtk_action_group_add_action (group, action);
+ g_object_unref (action);
}
static void