aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-11-03 20:37:15 +0800
committerChristian Persch <chpe@src.gnome.org>2005-11-03 20:37:15 +0800
commit1c87d0af88f833fff85b468ef57a7cb660805fb7 (patch)
treed15be9bdc630e4f3a43e104f0d891554ff9ce126
parent5304b565cd6192c80bae5473d3ac2364dc0de7bb (diff)
downloadgsoc2013-epiphany-1c87d0af88f833fff85b468ef57a7cb660805fb7.tar.gz
gsoc2013-epiphany-1c87d0af88f833fff85b468ef57a7cb660805fb7.tar.zst
gsoc2013-epiphany-1c87d0af88f833fff85b468ef57a7cb660805fb7.zip
More detailed result code from find backend.
2005-11-03 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-embed-find.c: * embed/ephy-embed-find.h: * embed/mozilla/EphyFind.cpp: * embed/mozilla/EphyFind.h: * embed/mozilla/mozilla-embed-find.cpp: More detailed result code from find backend. * src/ephy-find-toolbar.c: (set_status), (clear_status), (entry_changed_cb), (ephy_find_toolbar_init), (ephy_find_toolbar_find_next), (ephy_find_toolbar_find_previous), (ephy_find_toolbar_open): Add status text to the find toolbar. Reverse Next/Previous button order.
-rw-r--r--ChangeLog18
-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
-rw-r--r--src/ephy-find-toolbar.c90
7 files changed, 143 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 86cf9a0d1..c2d995cfe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2005-11-03 Christian Persch <chpe@cvs.gnome.org>
+ * embed/ephy-embed-find.c:
+ * embed/ephy-embed-find.h:
+ * embed/mozilla/EphyFind.cpp:
+ * embed/mozilla/EphyFind.h:
+ * embed/mozilla/mozilla-embed-find.cpp:
+
+ More detailed result code from find backend.
+
+ * src/ephy-find-toolbar.c: (set_status), (clear_status),
+ (entry_changed_cb), (ephy_find_toolbar_init),
+ (ephy_find_toolbar_find_next), (ephy_find_toolbar_find_previous),
+ (ephy_find_toolbar_open):
+
+ Add status text to the find toolbar.
+ Reverse Next/Previous button order.
+
+2005-11-03 Christian Persch <chpe@cvs.gnome.org>
+
* data/art/Makefile.am:
R data/art/hand-open.png:
* lib/egg/egg-toolbar-editor.c: (drag_data_get_cb),
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)
{
diff --git a/src/ephy-find-toolbar.c b/src/ephy-find-toolbar.c
index 3e9ac57ac..4c6054f2a 100644
--- a/src/ephy-find-toolbar.c
+++ b/src/ephy-find-toolbar.c
@@ -52,6 +52,9 @@ struct _EphyFindToolbarPrivate
GtkWidget *entry;
GtkToolItem *next;
GtkToolItem *prev;
+ GtkToolItem *sep;
+ GtkToolItem *status_item;
+ GtkWidget *status_label;
gulong set_focus_handler;
guint preedit_changed : 1;
guint prevent_activate : 1;
@@ -112,6 +115,42 @@ set_controls (EphyFindToolbar *toolbar,
}
static void
+set_status (EphyFindToolbar *toolbar,
+ EphyEmbedFindResult result)
+{
+ EphyFindToolbarPrivate *priv = toolbar->priv;
+ char *text = NULL;
+
+ switch (result)
+ {
+ case EPHY_EMBED_FIND_FOUND:
+ text = NULL;
+ break;
+ case EPHY_EMBED_FIND_NOTFOUND:
+ text = _("Phrase not found");
+ break;
+ case EPHY_EMBED_FIND_FOUNDWRAPPED:
+ text = _("Find wrapped");
+ break;
+ }
+
+ gtk_label_set_text (GTK_LABEL (priv->status_label),
+ text != NULL ? text : "");
+
+ g_object_set (priv->sep, "visible", text != NULL, NULL);
+ g_object_set (priv->status_item, "visible", text != NULL, NULL);
+}
+
+static void
+clear_status (EphyFindToolbar *toolbar)
+{
+ EphyFindToolbarPrivate *priv = toolbar->priv;
+
+ gtk_widget_hide (GTK_WIDGET (priv->sep));
+ gtk_widget_hide (GTK_WIDGET (priv->status_item));
+}
+
+static void
tab_content_changed_cb (EphyEmbed *embed,
const char *uri,
EphyFindToolbar *toolbar)
@@ -268,6 +307,7 @@ entry_changed_cb (GtkEntry *entry,
EphyFindToolbarPrivate *priv = toolbar->priv;
const char *text;
char *lowercase;
+ EphyEmbedFindResult result;
gboolean found = TRUE, case_sensitive;
text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
@@ -281,7 +321,10 @@ entry_changed_cb (GtkEntry *entry,
ephy_embed_find_set_properties (get_find (toolbar), text, case_sensitive);
#ifdef HAVE_TYPEAHEADFIND
- found = ephy_embed_find_find (get_find (toolbar), text, priv->links_only);
+ result = ephy_embed_find_find (get_find (toolbar), text, priv->links_only);
+
+ found = result == EPHY_EMBED_FIND_FOUND;
+ set_status (toolbar, result);
#endif
set_controls (toolbar, found, found);
}
@@ -449,6 +492,17 @@ ephy_find_toolbar_init (EphyFindToolbar *toolbar)
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
gtk_widget_show_all (GTK_WIDGET (item));
+ /* Prev */
+ arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
+ label = gtk_label_new (_("Find Previous"));
+ priv->prev = gtk_tool_button_new (arrow, _("Find Previous"));
+ gtk_tool_item_set_is_important (priv->prev, TRUE);
+ gtk_tool_item_set_tooltip (priv->prev, gtoolbar->tooltips,
+ _("Find previous occurrence of the search string"),
+ NULL);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->prev, -1);
+ gtk_widget_show_all (GTK_WIDGET (priv->prev));
+
/* Next */
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
label = gtk_label_new (_("Find Next"));
@@ -460,16 +514,17 @@ ephy_find_toolbar_init (EphyFindToolbar *toolbar)
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->next, -1);
gtk_widget_show_all (GTK_WIDGET (priv->next));
- /* Prev */
- arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
- label = gtk_label_new (_("Find Previous"));
- priv->prev = gtk_tool_button_new (arrow, _("Find Previous"));
- gtk_tool_item_set_is_important (priv->prev, TRUE);
- gtk_tool_item_set_tooltip (priv->prev, gtoolbar->tooltips,
- _("Find previous occurrence of the search string"),
- NULL);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->prev, -1);
- gtk_widget_show_all (GTK_WIDGET (priv->prev));
+ priv->sep = gtk_separator_tool_item_new ();
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->sep, -1);
+
+ priv->status_item = gtk_tool_item_new ();
+ gtk_tool_item_set_expand (priv->status_item, TRUE);
+ priv->status_label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (priv->status_label), 0.0, 0.5);
+ gtk_label_set_ellipsize (GTK_LABEL (priv->status_label), PANGO_ELLIPSIZE_END);
+ gtk_container_add (GTK_CONTAINER (priv->status_item), priv->status_label);
+ gtk_widget_show (priv->status_label);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->status_item, -1);
/* connect signals */
g_signal_connect (priv->entry, "key-press-event",
@@ -676,19 +731,26 @@ ephy_find_toolbar_set_embed (EphyFindToolbar *toolbar,
void
ephy_find_toolbar_find_next (EphyFindToolbar *toolbar)
{
+ EphyEmbedFindResult result;
gboolean found;
- found = ephy_embed_find_find_again (get_find (toolbar), TRUE);
+ result = ephy_embed_find_find_again (get_find (toolbar), TRUE);
+
+ found = result == EPHY_EMBED_FIND_FOUND;
set_controls (toolbar, found, found);
+ set_status (toolbar, result);
}
void
ephy_find_toolbar_find_previous (EphyFindToolbar *toolbar)
{
+ EphyEmbedFindResult result;
gboolean found;
- found = ephy_embed_find_find_again (get_find (toolbar), FALSE);
+ result = ephy_embed_find_find_again (get_find (toolbar), FALSE);
+ found = result == EPHY_EMBED_FIND_FOUND;
set_controls (toolbar, found, found);
+ set_status (toolbar, result);
}
void
@@ -705,6 +767,8 @@ ephy_find_toolbar_open (EphyFindToolbar *toolbar,
priv->links_only = links_only;
priv->explicit_focus = FALSE;
+ clear_status (toolbar);
+
if (clear_search)
{
gtk_entry_set_text (GTK_ENTRY (priv->entry), "");