diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-11-03 20:37:15 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-11-03 20:37:15 +0800 |
commit | 1c87d0af88f833fff85b468ef57a7cb660805fb7 (patch) | |
tree | d15be9bdc630e4f3a43e104f0d891554ff9ce126 /src/ephy-find-toolbar.c | |
parent | 5304b565cd6192c80bae5473d3ac2364dc0de7bb (diff) | |
download | gsoc2013-epiphany-1c87d0af88f833fff85b468ef57a7cb660805fb7.tar gsoc2013-epiphany-1c87d0af88f833fff85b468ef57a7cb660805fb7.tar.gz gsoc2013-epiphany-1c87d0af88f833fff85b468ef57a7cb660805fb7.tar.bz2 gsoc2013-epiphany-1c87d0af88f833fff85b468ef57a7cb660805fb7.tar.lz gsoc2013-epiphany-1c87d0af88f833fff85b468ef57a7cb660805fb7.tar.xz 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.
Diffstat (limited to 'src/ephy-find-toolbar.c')
-rw-r--r-- | src/ephy-find-toolbar.c | 90 |
1 files changed, 77 insertions, 13 deletions
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), ""); |