Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTommi Komulainen <tko@litl.com>2009-08-25 15:05:32 (GMT)
committer Marco Pesenti Gritti <marcopg@litl.com>2010-07-27 22:04:22 (GMT)
commitaded6eb5272ccb4f9b90ee529bdb014ffaa59031 (patch)
treedde7bd63762ca9fbcf17805809ebbd7c13284ea1
parent60cc60c16e52601993c77076dab3eeb9d1f0ab1a (diff)
browser-plugin: add zoom property
Example: plugin.zoom = plugin.zoom * 1.5;
-rw-r--r--browser-plugin/plugin.cpp13
-rw-r--r--browser-plugin/plugin.h2
-rw-r--r--browser-plugin/scriptable.cpp18
-rw-r--r--browser-plugin/scriptable.h1
4 files changed, 34 insertions, 0 deletions
diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp
index 8398db3..7d79100 100644
--- a/browser-plugin/plugin.cpp
+++ b/browser-plugin/plugin.cpp
@@ -80,6 +80,19 @@ Plugin::ZoomOut ()
}
void
+Plugin::SetZoom (double zoom)
+{
+ ev_view_set_sizing_mode (EV_VIEW (mView), EV_SIZING_FREE);
+ ev_view_set_zoom (EV_VIEW (mView), zoom, FALSE);
+}
+
+double
+Plugin::GetZoom (void) const
+{
+ return ev_view_get_zoom (EV_VIEW (mView));
+}
+
+void
Plugin::FindNext (const char *text)
{
}
diff --git a/browser-plugin/plugin.h b/browser-plugin/plugin.h
index 95c53ef..7ea940e 100644
--- a/browser-plugin/plugin.h
+++ b/browser-plugin/plugin.h
@@ -35,6 +35,8 @@ class Plugin {
void Load (const char *fname);
void ZoomIn ();
void ZoomOut ();
+ double GetZoom () const;
+ void SetZoom (double);
void FindNext (const char *text);
void FindPrevious (const char *text);
void ShowLoadingError ();
diff --git a/browser-plugin/scriptable.cpp b/browser-plugin/scriptable.cpp
index 6272c7d..e8fbcb2 100644
--- a/browser-plugin/scriptable.cpp
+++ b/browser-plugin/scriptable.cpp
@@ -197,6 +197,7 @@ ScriptablePluginObject::ScriptablePluginObject (NPP npp) :
mMagicWrapper(0)
{
mTitleID = NPN_GetStringIdentifier ("title");
+ mZoomID = NPN_GetStringIdentifier ("zoom");
mMagicWrapperID = NPN_GetStringIdentifier ("magicWrapper");
mZoomInID = NPN_GetStringIdentifier ("zoomIn");
@@ -229,6 +230,7 @@ ScriptablePluginObject::HasProperty (NPIdentifier name)
{
NPIdentifier properties[] = {
mTitleID,
+ mZoomID,
mMagicWrapperID
};
@@ -256,6 +258,9 @@ ScriptablePluginObject::GetProperty (NPIdentifier name, NPVariant *result)
}
return true;
+ } else if (name == mZoomID) {
+ DOUBLE_TO_NPVARIANT (plugin->GetZoom(), *result);
+ return true;
}
return false;
@@ -292,6 +297,19 @@ ScriptablePluginObject::SetProperty (NPIdentifier name, const NPVariant *value)
}
return true;
+ } else if (name == mZoomID) {
+ double zoom;
+ if (NPVARIANT_IS_DOUBLE (*value)) {
+ zoom = NPVARIANT_TO_DOUBLE (*value);
+ } else if (NPVARIANT_IS_INT32 (*value)) {
+ zoom = NPVARIANT_TO_INT32 (*value);
+ } else {
+ NPN_SetException (this, "Invalid type for zoom, expected a number");
+ return false;
+ }
+
+ plugin->SetZoom (zoom);
+ return true;
}
return false;
diff --git a/browser-plugin/scriptable.h b/browser-plugin/scriptable.h
index 79a9519..cc6ac1c 100644
--- a/browser-plugin/scriptable.h
+++ b/browser-plugin/scriptable.h
@@ -93,6 +93,7 @@ class ScriptablePluginObject : public ScriptablePluginObjectBase
private:
NPIdentifier mTitleID;
+ NPIdentifier mZoomID;
NPIdentifier mMagicWrapperID;
NPIdentifier mZoomInID;