aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-find.c18
-rw-r--r--embed/ephy-embed-find.h27
-rw-r--r--embed/mozilla/EphyFind.cpp20
-rw-r--r--embed/mozilla/EphyFind.h7
-rw-r--r--embed/mozilla/mozilla-embed-find.cpp4
5 files changed, 48 insertions, 28 deletions
diff --git a/embed/ephy-embed-find.c b/embed/ephy-embed-find.c
index f5ddb664e..80ef28b18 100644
--- a/embed/ephy-embed-find.c
+++ b/embed/ephy-embed-find.c
@@ -46,7 +46,15 @@ ephy_embed_find_set_properties (EphyEmbedFind *find,
iface->set_properties (find, search_string, case_sensitive);
}
-gboolean
+/**
+ * ephy_embed_find_find:
+ * @embed: an #EphyEmbedFind
+ * @search_string: the text to search for
+ * @links_only: whether to only search the text in links
+ *
+ * Return value: whether a match was found
+ **/
+EphyEmbedFindResult
ephy_embed_find_find (EphyEmbedFind *find,
const char *search_string,
gboolean links_only)
@@ -56,13 +64,13 @@ ephy_embed_find_find (EphyEmbedFind *find,
}
/**
- * ephy_embed_find_search_again:
+ * ephy_embed_find_find_again:
* @embed: an #EphyEmbedFind
* @forward %TRUE to search forwards in the document
*
- * Return value: %TRUE if a match was found
+ * Return value: whether a match was found
**/
-gboolean
+EphyEmbedFindResult
ephy_embed_find_find_again (EphyEmbedFind *find,
gboolean forward)
{
@@ -76,6 +84,8 @@ ephy_embed_find_find_again (EphyEmbedFind *find,
* @mask:
*
* Activates the currently focused link, if there is any.
+ *
+ * Return value: %TRUE if a link was activated
**/
gboolean
ephy_embed_find_activate_link (EphyEmbedFind *find,
diff --git a/embed/ephy-embed-find.h b/embed/ephy-embed-find.h
index a601c9a4e..0370e8c6c 100644
--- a/embed/ephy-embed-find.h
+++ b/embed/ephy-embed-find.h
@@ -39,6 +39,13 @@ G_BEGIN_DECLS
typedef struct _EphyEmbedFind EphyEmbedFind;
typedef struct _EphyEmbedFindIface EphyEmbedFindIface;
+/* Keep these the same as in nsITypeAheadFind */
+typedef enum
+{
+ EPHY_EMBED_FIND_FOUND = 0,
+ EPHY_EMBED_FIND_NOTFOUND = 1,
+ EPHY_EMBED_FIND_FOUNDWRAPPED = 2
+} EphyEmbedFindResult;
struct _EphyEmbedFindIface
{
@@ -50,11 +57,11 @@ struct _EphyEmbedFindIface
void (* set_properties) (EphyEmbedFind *find,
const char *search_string,
gboolean case_sensitive);
- gboolean (* find) (EphyEmbedFind *find,
- const char *search_string,
- gboolean links_only);
- gboolean (* find_again) (EphyEmbedFind *find,
- gboolean forward);
+ EphyEmbedFindResult (* find) (EphyEmbedFind *find,
+ const char *search_string,
+ gboolean links_only);
+ EphyEmbedFindResult (* find_again) (EphyEmbedFind *find,
+ gboolean forward);
gboolean (* activate_link) (EphyEmbedFind *find,
GdkModifierType mask);
};
@@ -68,12 +75,12 @@ void ephy_embed_find_set_properties (EphyEmbedFind *find,
const char *search_string,
gboolean case_sensitive);
-gboolean ephy_embed_find_find (EphyEmbedFind *find,
- const char *search_string,
- gboolean links_only);
+EphyEmbedFindResult ephy_embed_find_find (EphyEmbedFind *find,
+ const char *search_string,
+ gboolean links_only);
-gboolean ephy_embed_find_find_again (EphyEmbedFind *find,
- gboolean forward);
+EphyEmbedFindResult ephy_embed_find_find_again (EphyEmbedFind *find,
+ gboolean forward);
gboolean ephy_embed_find_activate_link (EphyEmbedFind *find,
GdkModifierType mask);
diff --git a/embed/mozilla/EphyFind.cpp b/embed/mozilla/EphyFind.cpp
index 5221be417..c6b9b7c9b 100644
--- a/embed/mozilla/EphyFind.cpp
+++ b/embed/mozilla/EphyFind.cpp
@@ -147,11 +147,11 @@ EphyFind::SetFindProperties (const char *aSearchString,
#endif /* TYPEAHEADFIND */
}
-PRBool
+EphyEmbedFindResult
EphyFind::Find (const char *aSearchString,
PRBool aLinksOnly)
{
- if (!mFinder) return PR_FALSE;
+ if (!mFinder) return EPHY_EMBED_FIND_NOTFOUND;
nsEmbedString uSearchString;
NS_CStringToUTF16 (nsEmbedCString (aSearchString ? aSearchString : ""),
@@ -162,7 +162,7 @@ EphyFind::Find (const char *aSearchString,
PRUint16 found = nsITypeAheadFind::FIND_NOTFOUND;
rv = mFinder->Find (uSearchString, aLinksOnly, &found);
- return NS_SUCCEEDED (rv) && found != nsITypeAheadFind::FIND_NOTFOUND;
+ return (EphyEmbedFindResult) found;
#else
mFinder->SetSearchString (uSearchString.get ());
mFinder->SetFindBackwards (PR_FALSE);
@@ -171,14 +171,15 @@ EphyFind::Find (const char *aSearchString,
PRBool didFind = PR_FALSE;
rv = mFinder->FindNext (&didFind);
- return NS_SUCCEEDED (rv) && didFind;
+ return NS_SUCCEEDED (rv) && didFind ? EPHY_EMBED_FIND_FOUND :
+ EPHY_EMBED_FIND_NOTFOUND;
#endif /* HAVE_TYPEAHEADFIND */
}
-PRBool
+EphyEmbedFindResult
EphyFind::FindAgain (PRBool aForward)
{
- if (!mFinder) return PR_FALSE;
+ if (!mFinder) return EPHY_EMBED_FIND_NOTFOUND;
#ifdef HAVE_TYPEAHEADFIND
nsresult rv;
@@ -189,15 +190,16 @@ EphyFind::FindAgain (PRBool aForward)
rv = mFinder->FindPrevious (&found);
}
- return NS_SUCCEEDED (rv) && found != nsITypeAheadFind::FIND_NOTFOUND;
+ return (EphyEmbedFindResult) found;
#else
mFinder->SetFindBackwards (!aForward);
nsresult rv;
PRBool didFind = PR_FALSE;
rv = mFinder->FindNext (&didFind);
-
- return NS_SUCCEEDED (rv) && didFind;
+
+ return NS_SUCCEEDED (rv) && didFind ? EPHY_EMBED_FIND_FOUND :
+ EPHY_EMBED_FIND_NOTFOUND;
#endif /* HAVE_TYPEAHEADFIND */
}
diff --git a/embed/mozilla/EphyFind.h b/embed/mozilla/EphyFind.h
index 8e85356cb..d5dd8e239 100644
--- a/embed/mozilla/EphyFind.h
+++ b/embed/mozilla/EphyFind.h
@@ -22,6 +22,7 @@
#define TYPEAHEADFIND_H
#include "ephy-embed.h"
+#include "ephy-embed-find.h"
#include <nsCOMPtr.h>
#include <gdk/gdktypes.h>
@@ -40,9 +41,9 @@ class EphyFind
void SetFindProperties (const char *aSearchString,
PRBool aCaseSensitive);
- PRBool Find (const char *aSearchString,
- PRBool aLinksOnly);
- PRBool FindAgain (PRBool aForward);
+ EphyEmbedFindResult Find (const char *aSearchString,
+ PRBool aLinksOnly);
+ EphyEmbedFindResult FindAgain (PRBool aForward);
PRBool ActivateLink (GdkModifierType aMask);
private:
diff --git a/embed/mozilla/mozilla-embed-find.cpp b/embed/mozilla/mozilla-embed-find.cpp
index f8f4e6c60..3026a3934 100644
--- a/embed/mozilla/mozilla-embed-find.cpp
+++ b/embed/mozilla/mozilla-embed-find.cpp
@@ -62,7 +62,7 @@ impl_set_properties (EphyEmbedFind *efind,
priv->find->SetFindProperties (find_string, case_sensitive);
}
-static gboolean
+static EphyEmbedFindResult
impl_find (EphyEmbedFind *efind,
const char *find_string,
gboolean links_only)
@@ -73,7 +73,7 @@ impl_find (EphyEmbedFind *efind,
return priv->find->Find (find_string, links_only);
}
-static gboolean
+static EphyEmbedFindResult
impl_find_again (EphyEmbedFind *efind,
gboolean forward)
{