aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe+gnomebugz@stud.uni-saarland.de>2003-05-20 19:46:28 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-05-20 19:46:28 +0800
commit754c3261279b58118b16cfe9018613f058b59c9b (patch)
treed23770eeefb5b947ee44a27fc3cbad04f026de86 /src
parentbc555495c56dc8836db5ac7a4f3f6b5772e315d6 (diff)
downloadgsoc2013-epiphany-754c3261279b58118b16cfe9018613f058b59c9b.tar
gsoc2013-epiphany-754c3261279b58118b16cfe9018613f058b59c9b.tar.gz
gsoc2013-epiphany-754c3261279b58118b16cfe9018613f058b59c9b.tar.bz2
gsoc2013-epiphany-754c3261279b58118b16cfe9018613f058b59c9b.tar.lz
gsoc2013-epiphany-754c3261279b58118b16cfe9018613f058b59c9b.tar.xz
gsoc2013-epiphany-754c3261279b58118b16cfe9018613f058b59c9b.tar.zst
gsoc2013-epiphany-754c3261279b58118b16cfe9018613f058b59c9b.zip
Simplified and reorganised zoom. Implement a zoom control for the toolbar.
2003-05-19 Christian Persch <chpe+gnomebugz@stud.uni-saarland.de> Simplified and reorganised zoom. Implement a zoom control for the toolbar. * lib/widgets/ephy-zoom-action.h: * lib/widgets/ephy-zoom-action.c: * lib/widgets/ephy-zoom-control.h: * lib/widgets/ephy-zoom-control.c: New. A simple zoom control and a corresponding egg action. * lib/ephy-zoom.h: * lib/ephy-zoom.c: New. Define the supported zoom levels, plus some helper functions. * data/ui/epiphany-toolbar.xml.in: * src/toolbar.h: * src/toolbar.c: (toolbar_update_zoom_control), (zoom_to_level_cb), (toolbar_setup_actions): Hook up zoom control. * src/ephy-window.c: (toolbar_update_zoom_control): New. Updates toolbar zoom control and menu item sensitivity. * embed/mozilla/mozilla-embed.c: (impl_zoom_set, impl_zoom_get): * embed/ephy-embed.[ch]: (zoom_set), (zoom_get), (ephy_embed_zoom_set), (ephy_embed_zoom_get): * lib/ephy-marshal.list: * src/ephy-nautilus-view.c: (gnv_embed_zoom_change_cb), (gnv_zoomable_set_zoom_level_cb): * src/ephy-tab.c: (ephy_tab_zoom_changed_cb): * src/ephy-window.c: (ephy_window_set_zoom): Use float zoom factor instead of int percent for zoom. * src/ephy-nautilus-view.c: (ephy_nautilus_view_instance_init), (ephy_nautilus_view_class_init), (gnv_zoomable_set_zoom_level_cb), (gnv_zoomable_zoom_in_cb), (gnv_zoomable_zoom_out_cb), (gnv_zoomable_zoom_to_default_cb), (gnv_embed_zoom_change_cb): * src/window-commands.c: (window_cmd_view_zoom_in), (window_cmd_view_zoom_out), (window_cmd_view_zoom_normal): Simplified; use ephy-zoom.h where appropriate.
Diffstat (limited to 'src')
-rw-r--r--src/ephy-nautilus-view.c98
-rw-r--r--src/ephy-tab.c2
-rw-r--r--src/ephy-window.c67
-rw-r--r--src/ephy-window.h2
-rwxr-xr-xsrc/toolbar.c27
-rw-r--r--src/toolbar.h2
-rw-r--r--src/window-commands.c24
7 files changed, 133 insertions, 89 deletions
diff --git a/src/ephy-nautilus-view.c b/src/ephy-nautilus-view.c
index 56b0edb06..f4373667b 100644
--- a/src/ephy-nautilus-view.c
+++ b/src/ephy-nautilus-view.c
@@ -29,6 +29,7 @@
#include "find-dialog.h"
#include "print-dialog.h"
#include "ephy-prefs.h"
+#include "ephy-zoom.h"
#include "eel-gconf-extensions.h"
#include "ephy-debug.h"
@@ -47,7 +48,7 @@ static gint gnv_embed_dom_mouse_down_cb (EphyEmbed *embed,
EphyEmbedEvent *event,
EphyNautilusView *view);
static void gnv_embed_zoom_change_cb (EphyNautilusView *embed,
- guint new_zoom,
+ float new_zoom,
EphyNautilusView *view);
@@ -97,34 +98,6 @@ static void gnv_popup_cmd_frame_in_new_window (BonoboUIComponent *uic,
EphyEmbedPopup *popup,
const char* verbname);
-
-static float preferred_zoom_levels[] = {
- 0.2, 0.4, 0.6, 0.8,
- 1.0, 1.2, 1.4, 1.6, 1.8,
- 2.0, 2.2, 2.4, 2.6, 2.8,
- 3.0, 3.2, 3.4, 3.6, 3.8,
- 4.0, 4.2, 4.4, 4.6, 4.8,
- 5.0, 5.2, 5.4, 5.6, 5.8,
- 6.0, 6.2, 6.4, 6.6, 6.8,
- 7.0, 7.2, 7.4, 7.6, 7.8,
- 8.0, 8.2, 8.4, 8.6, 8.8,
- 9.0, 9.2, 9.4, 9.6, 9.8,
-};
-
-static const gchar *preferred_zoom_level_names[] = {
- "20%", "40%", "60%", "80%",
- "100%", "120%", "140%", "160%", "180%",
- "200%", "220%", "240%", "260%", "280%",
- "300%", "320%", "340%", "360%", "380%",
- "400%", "420%", "440%", "460%", "480%",
- "500%", "520%", "540%", "560%", "580%",
- "600%", "620%", "640%", "660%", "680%",
- "700%", "720%", "740%", "760%", "780%",
- "800%", "820%", "840%", "860%", "880%",
- "900%", "920%", "940%", "960%", "980%",
-};
-#define NUM_ZOOM_LEVELS (sizeof (preferred_zoom_levels) / sizeof (float))
-
struct EphyNautilusViewPrivate {
EphyEmbed *embed;
char *title;
@@ -170,6 +143,9 @@ ephy_nautilus_view_instance_init (EphyNautilusView *view)
GtkWidget *w;
EphyNautilusViewPrivate *p = g_new0 (EphyNautilusViewPrivate, 1);
EphyEmbedSingle *single;
+ float *levels;
+ gchar **names;
+ guint i;
single = ephy_embed_shell_get_embed_single
(EPHY_EMBED_SHELL (ephy_shell));
@@ -250,14 +226,26 @@ ephy_nautilus_view_instance_init (EphyNautilusView *view)
bonobo_object_add_interface (BONOBO_OBJECT (view),
BONOBO_OBJECT (view->priv->zoomable));
+ /* get zoom levels */
+ levels = g_new0 (float, n_zoom_levels);
+ names = g_new0 (gchar *, n_zoom_levels);
+ for (i = 0; i < n_zoom_levels; i++)
+ {
+ levels[i] = zoom_levels[i].level;
+ names[i] = zoom_levels[i].name;
+ }
+
bonobo_zoomable_set_parameters_full (view->priv->zoomable,
1.0,
- preferred_zoom_levels [0],
- preferred_zoom_levels [NUM_ZOOM_LEVELS - 1],
+ levels [0],
+ levels [n_zoom_levels-1],
FALSE, FALSE, TRUE,
- preferred_zoom_levels,
- preferred_zoom_level_names,
- NUM_ZOOM_LEVELS);
+ levels,
+ (const gchar **) names,
+ n_zoom_levels);
+
+ g_free (levels);
+ g_free (names);
bonobo_object_add_interface (BONOBO_OBJECT (view),
BONOBO_OBJECT (view->priv->zoomable));
@@ -613,33 +601,41 @@ gnv_zoomable_set_zoom_level_cb (BonoboZoomable *zoomable,
float level,
EphyNautilusView *view)
{
- gint zoom = level * 100;
g_return_if_fail (EPHY_IS_NAUTILUS_VIEW (view));
- if (zoom < 10) return;
- if (zoom > 1000) return;
- ephy_embed_zoom_set (view->priv->embed, zoom, TRUE);
+ ephy_embed_zoom_set (view->priv->embed,
+ ephy_zoom_get_nearest_zoom_level (level), TRUE);
}
static void
gnv_zoomable_zoom_in_cb (BonoboZoomable *zoomable,
EphyNautilusView *view)
{
- gint zoom;
+ float zoom, new_zoom;
+ gresult rv;
+
g_return_if_fail (EPHY_IS_NAUTILUS_VIEW (view));
- ephy_embed_zoom_get (view->priv->embed, &zoom);
- if (zoom > 990) return;
- ephy_embed_zoom_set (view->priv->embed, zoom + 10, TRUE);
+
+ rv = ephy_embed_zoom_get (view->priv->embed, &zoom);
+ if (rv == G_FAILED) return;
+
+ new_zoom = ephy_zoom_get_changed_zoom_level (zoom, 1);
+ ephy_embed_zoom_set (view->priv->embed, new_zoom, TRUE);
}
static void
gnv_zoomable_zoom_out_cb (BonoboZoomable *zoomable,
EphyNautilusView *view)
{
- gint zoom;
+ float zoom, new_zoom;
+ gresult rv;
+
g_return_if_fail (EPHY_IS_NAUTILUS_VIEW (view));
- ephy_embed_zoom_get (view->priv->embed, &zoom);
- if (zoom < 20) return;
- ephy_embed_zoom_set (view->priv->embed, zoom - 10, TRUE);
+
+ rv = ephy_embed_zoom_get (view->priv->embed, &zoom);
+ if (rv == G_FAILED) return;
+
+ new_zoom = ephy_zoom_get_changed_zoom_level (zoom, -1);
+ ephy_embed_zoom_set (view->priv->embed, new_zoom, TRUE);
}
static void
@@ -654,22 +650,18 @@ gnv_zoomable_zoom_to_default_cb (BonoboZoomable *zoomable,
EphyNautilusView *view)
{
g_return_if_fail (EPHY_IS_NAUTILUS_VIEW (view));
- ephy_embed_zoom_set (view->priv->embed, 100, TRUE);
+ ephy_embed_zoom_set (view->priv->embed, 1.0, TRUE);
}
static void
gnv_embed_zoom_change_cb (EphyNautilusView *embed,
- guint new_zoom,
+ float new_zoom,
EphyNautilusView *view)
{
- float flevel;
g_return_if_fail (EPHY_IS_NAUTILUS_VIEW (view));
- flevel = ((float) new_zoom) / 100.0;
-
bonobo_zoomable_report_zoom_level_changed (view->priv->zoomable,
- flevel, NULL);
-
+ new_zoom, NULL);
}
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 70302a595..dd6b321ab 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -407,7 +407,7 @@ ephy_tab_location_cb (EphyEmbed *embed, EphyTab *tab)
}
static void
-ephy_tab_zoom_changed_cb (EphyEmbed *embed, gint zoom, EphyTab *tab)
+ephy_tab_zoom_changed_cb (EphyEmbed *embed, float zoom, EphyTab *tab)
{
if (tab->priv->is_active)
{
diff --git a/src/ephy-window.c b/src/ephy-window.c
index b8d3bc656..aa7d4bbcd 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -30,6 +30,7 @@
#include "ephy-shell.h"
#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
+#include "ephy-zoom.h"
#include "ephy-debug.h"
#include "ephy-file-helpers.h"
#include "statusbar.h"
@@ -469,8 +470,6 @@ setup_window (EphyWindow *window)
g_object_set (action, "short_label", _("Print"), NULL);
action = egg_action_group_get_action (action_group, "FileBookmarkPage");
g_object_set (action, "short_label", _("Bookmark"), NULL);
- action = egg_action_group_get_action (action_group, "ViewZoomNormal");
- g_object_set (action, "sensitive", FALSE, NULL);
action_group = egg_action_group_new ("PopupsActions");
egg_action_group_add_actions (action_group, ephy_popups_entries,
@@ -1094,6 +1093,40 @@ update_nav_control (EphyWindow *window)
}
static void
+update_zoom_control (EphyWindow *window)
+{
+ EphyEmbed *embed;
+ EggActionGroup *action_group;
+ EggAction *action;
+ gboolean can_zoom_in = TRUE, can_zoom_out = TRUE, can_zoom_normal = FALSE;
+ float zoom = 1.0;
+ gresult rv;
+
+ g_return_if_fail (window != NULL);
+
+ embed = ephy_window_get_active_embed (window);
+ g_return_if_fail (embed != NULL);
+
+ rv = ephy_embed_zoom_get (embed, &zoom);
+ if (rv == G_OK)
+ {
+ if (zoom >= ZOOM_MAXIMAL) can_zoom_in = FALSE;
+ if (zoom <= ZOOM_MINIMAL) can_zoom_out = FALSE;
+ if (zoom != 1.0) can_zoom_normal = TRUE;
+ }
+
+ toolbar_update_zoom (window->priv->toolbar, zoom);
+
+ action_group = window->priv->action_group;
+ action = egg_action_group_get_action (action_group, "ViewZoomIn");
+ g_object_set (action, "sensitive", can_zoom_in, NULL);
+ action = egg_action_group_get_action (action_group, "ViewZoomOut");
+ g_object_set (action, "sensitive", can_zoom_out, NULL);
+ action = egg_action_group_get_action (action_group, "ViewZoomNormal");
+ g_object_set (action, "sensitive", can_zoom_normal, NULL);
+}
+
+static void
update_title_control (EphyWindow *window)
{
EphyTab *tab;
@@ -1247,6 +1280,7 @@ ephy_window_update_control (EphyWindow *window,
/* the zoom control is updated at the same time than the navigation
controls. This keeps it synched most of the time, but not always,
because we don't get a notification when zoom changes */
+ update_zoom_control (window);
case NavControl:
update_nav_control (window);
break;
@@ -1290,6 +1324,7 @@ ephy_window_update_all_controls (EphyWindow *window)
update_security (window);
update_find_control (window);
update_spinner_control (window);
+ update_zoom_control (window);
}
}
@@ -1432,27 +1467,31 @@ ephy_window_get_find_dialog (EphyWindow *window)
void
ephy_window_set_zoom (EphyWindow *window,
- gint zoom)
+ float zoom)
{
EphyEmbed *embed;
- gboolean zoom_out, zoom_normal;
- EggActionGroup *action_group;
- EggAction *action;
+ float current_zoom = 1.0;
g_return_if_fail (IS_EPHY_WINDOW (window));
embed = ephy_window_get_active_embed (window);
g_return_if_fail (embed != NULL);
- ephy_embed_zoom_set (embed, zoom, TRUE);
+ ephy_embed_zoom_get (embed, &current_zoom);
- zoom_normal = (zoom != 100);
- zoom_out = (zoom > 0);
- action_group = window->priv->action_group;
- action = egg_action_group_get_action (action_group, "ViewZoomOut");
- g_object_set (action, "sensitive", zoom_out, NULL);
- action = egg_action_group_get_action (action_group, "ViewZoomNormal");
- g_object_set (action, "sensitive", zoom_normal, NULL);
+ if (zoom == ZOOM_IN)
+ {
+ zoom = ephy_zoom_get_changed_zoom_level (current_zoom, 1);
+ }
+ else if (zoom == ZOOM_OUT)
+ {
+ zoom = ephy_zoom_get_changed_zoom_level (current_zoom, -1);
+ }
+
+ if (zoom != current_zoom)
+ {
+ ephy_embed_zoom_set (embed, zoom, TRUE);
+ }
}
Toolbar *
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 807ee5c96..39b051f0d 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -108,7 +108,7 @@ void ephy_window_load_url (EphyWindow *window,
const char *url);
void ephy_window_set_zoom (EphyWindow *window,
- gint zoom);
+ float zoom);
void ephy_window_activate_location (EphyWindow *window);
diff --git a/src/toolbar.c b/src/toolbar.c
index 728f81daf..d211de6d5 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -35,6 +35,7 @@
#include "ephy-go-action.h"
#include "ephy-navigation-action.h"
#include "ephy-bookmark-action.h"
+#include "ephy-zoom-action.h"
#include "window-commands.h"
#include "ephy-string.h"
#include "ephy-debug.h"
@@ -126,6 +127,11 @@ go_location_cb (EggAction *action, char *location, EphyWindow *window)
ephy_embed_load_url (embed, location);
}
+static void
+zoom_to_level_cb (EggAction *action, float zoom, EphyWindow *window)
+{
+ ephy_window_set_zoom (window, zoom);
+}
static EggAction *
ensure_bookmark_action (Toolbar *t, EphyBookmarks *bookmarks, gulong id, const char *action_name)
@@ -302,6 +308,16 @@ toolbar_setup_actions (Toolbar *t)
egg_action_group_add_action (t->priv->action_group, action);
g_object_unref (action);
+ action = g_object_new (EPHY_TYPE_ZOOM_ACTION,
+ "name", "Zoom",
+ "label", _("Zoom"),
+ "zoom", 1.0,
+ NULL);
+ g_signal_connect (action, "zoom_to_level",
+ G_CALLBACK (zoom_to_level_cb), t->priv->window);
+ egg_action_group_add_action (t->priv->action_group, action);
+ g_object_unref (action);
+
action = g_object_new (EPHY_TYPE_FAVICON_ACTION,
"name", "Favicon",
"label", _("Favicon"),
@@ -754,3 +770,14 @@ toolbar_set_visibility (Toolbar *t,
}
}
}
+
+void
+toolbar_update_zoom (Toolbar *t, float zoom)
+{
+ EggActionGroup *action_group;
+ EggAction *action;
+
+ action_group = t->priv->action_group;
+ action = egg_action_group_get_action (action_group, "Zoom");
+ g_object_set (action, "zoom", zoom, NULL);
+}
diff --git a/src/toolbar.h b/src/toolbar.h
index 98d6790a4..e21d12d3c 100644
--- a/src/toolbar.h
+++ b/src/toolbar.h
@@ -73,6 +73,8 @@ void toolbar_update_navigation_actions (Toolbar *t,
gboolean back,
gboolean forward,
gboolean up);
+void toolbar_update_zoom (Toolbar *t,
+ float zoom);
void toolbar_set_visibility (Toolbar *t,
gboolean normal_toolbars,
diff --git a/src/window-commands.c b/src/window-commands.c
index fbc141ca0..652b8c23e 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -36,6 +36,7 @@
#include "toolbar.h"
#include "ephy-state.h"
#include "ephy-gui.h"
+#include "ephy-zoom.h"
#include <string.h>
#include <libgnomevfs/gnome-vfs-uri.h>
@@ -565,38 +566,21 @@ void
window_cmd_view_zoom_in (EggAction *action,
EphyWindow *window)
{
- EphyEmbed *embed;
- int zoom;
-
- embed = ephy_window_get_active_embed (window);
- g_return_if_fail (embed != NULL);
-
- ephy_embed_zoom_get (embed, &zoom);
- ephy_window_set_zoom (window, zoom + 10);
+ ephy_window_set_zoom (window, ZOOM_IN);
}
void
window_cmd_view_zoom_out (EggAction *action,
EphyWindow *window)
{
- EphyEmbed *embed;
- int zoom;
-
- embed = ephy_window_get_active_embed (window);
- g_return_if_fail (embed != NULL);
-
- ephy_embed_zoom_get (embed, &zoom);
- if (zoom >= 10)
- {
- ephy_window_set_zoom (window, zoom - 10);
- }
+ ephy_window_set_zoom (window, ZOOM_OUT);
}
void
window_cmd_view_zoom_normal (EggAction *action,
EphyWindow *window)
{
- ephy_window_set_zoom (window, 100);
+ ephy_window_set_zoom (window, 1.0);
}
void