Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--browser-plugin/plugin.cpp18
-rw-r--r--browser-plugin/plugin.h2
-rw-r--r--browser-plugin/scriptable.cpp5
-rw-r--r--browser-plugin/scriptable.h1
4 files changed, 24 insertions, 2 deletions
diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp
index 541e9d9..6999733 100644
--- a/browser-plugin/plugin.cpp
+++ b/browser-plugin/plugin.cpp
@@ -30,7 +30,8 @@ Plugin::Plugin (NPP instance) : mInstance (instance),
mLoadJob (0),
mFindJob (0),
mTitle (0),
- mHasSelection (false)
+ mHasSelection (false),
+ mCanFindOnPage (false)
{
mScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
@@ -141,6 +142,7 @@ Plugin::Find (const char *text)
reinterpret_cast<void*> (this));
ev_job_scheduler_push_job (mFindJob, EV_JOB_PRIORITY_NONE);
} else {
+ UpdateActions ();
gtk_widget_queue_draw (mView);
}
}
@@ -287,6 +289,18 @@ Plugin::SizingModeCallback (EvView *view, GParamSpec *pspec, gpointer data)
}
void
+Plugin::UpdateActions ()
+{
+ bool can_find = mFindJob &&
+ ev_job_find_has_results (EV_JOB_FIND (mFindJob));
+
+ if (can_find != mCanFindOnPage) {
+ mCanFindOnPage = can_find;
+ CallBrowser ("onFindChanged");
+ }
+}
+
+void
Plugin::HasSelectionCallback (EvView *view, GParamSpec *pspec, gpointer data)
{
Plugin *plugin = reinterpret_cast<Plugin*> (data);
@@ -356,7 +370,7 @@ Plugin::FindJobUpdatedCallback (EvJobFind *job, gint page, gpointer data)
{
Plugin *plugin = reinterpret_cast<Plugin*> (data);
- // FIXME: enable/disable find next/prev actions
+ plugin->UpdateActions ();
ev_view_find_changed (EV_VIEW (plugin->mView),
ev_job_find_get_results (job),
diff --git a/browser-plugin/plugin.h b/browser-plugin/plugin.h
index 96089ba..3f4ba03 100644
--- a/browser-plugin/plugin.h
+++ b/browser-plugin/plugin.h
@@ -46,6 +46,7 @@ class Plugin {
private:
void UpdateSizingMode ();
+ void UpdateActions ();
void ClearLoadJob ();
void ClearFindJob ();
@@ -78,6 +79,7 @@ class Plugin {
public:
char *mTitle;
bool mHasSelection;
+ bool mCanFindOnPage;
};
void* NPN_MemDup (const void *aMem, uint32 aLen);
diff --git a/browser-plugin/scriptable.cpp b/browser-plugin/scriptable.cpp
index 833d24f..6c7e55c 100644
--- a/browser-plugin/scriptable.cpp
+++ b/browser-plugin/scriptable.cpp
@@ -203,6 +203,7 @@ ScriptablePluginObject::ScriptablePluginObject (NPP npp) :
mTitleID = NPN_GetStringIdentifier ("title");
mZoomID = NPN_GetStringIdentifier ("zoom");
mCanCopyID = NPN_GetStringIdentifier ("canCopy");
+ mCanFindOnPageID = NPN_GetStringIdentifier ("canFindOnPage");
mMagicWrapperID = NPN_GetStringIdentifier ("magicWrapper");
mZoomInID = NPN_GetStringIdentifier ("zoomIn");
@@ -245,6 +246,7 @@ ScriptablePluginObject::HasProperty (NPIdentifier name)
mTitleID,
mZoomID,
mCanCopyID,
+ mCanFindOnPageID,
mMagicWrapperID
};
@@ -278,6 +280,9 @@ ScriptablePluginObject::GetProperty (NPIdentifier name, NPVariant *result)
} else if (name == mCanCopyID) {
BOOLEAN_TO_NPVARIANT (plugin->mHasSelection, *result);
return true;
+ } else if (name == mCanFindOnPageID) {
+ BOOLEAN_TO_NPVARIANT (plugin->mCanFindOnPage, *result);
+ return true;
}
return false;
diff --git a/browser-plugin/scriptable.h b/browser-plugin/scriptable.h
index f534149..8ab0917 100644
--- a/browser-plugin/scriptable.h
+++ b/browser-plugin/scriptable.h
@@ -95,6 +95,7 @@ class ScriptablePluginObject : public ScriptablePluginObjectBase
NPIdentifier mTitleID;
NPIdentifier mZoomID;
NPIdentifier mCanCopyID;
+ NPIdentifier mCanFindOnPageID;
NPIdentifier mMagicWrapperID;
NPIdentifier mZoomInID;