diff options
author | Tommi Komulainen <tko@litl.com> | 2009-08-26 11:25:19 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marcopg@litl.com> | 2010-07-27 22:04:23 (GMT) |
commit | 6a0208341897847720395a42beedbaf77836a316 (patch) | |
tree | f702879f64195c55dfc8da0c8ffa99bc8043ee22 /browser-plugin/plugin.cpp | |
parent | 5ff761c012fca4cfc925de1511afca90c08d5d74 (diff) |
browser-plugin: notify browser when find comes up empty
Example:
plugin.magicWrapper = {
onFindChanged : function() {
if (plugin.canFindOnPage) { ... }
}
}
Diffstat (limited to 'browser-plugin/plugin.cpp')
-rw-r--r-- | browser-plugin/plugin.cpp | 18 |
1 files changed, 16 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), |