aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog35
-rw-r--r--embed/ephy-embed.c16
-rw-r--r--embed/ephy-embed.h28
-rwxr-xr-xembed/find-dialog.c319
-rw-r--r--embed/find-dialog.h19
-rw-r--r--embed/mozilla/EphyWrapper.cpp55
-rw-r--r--embed/mozilla/EphyWrapper.h8
-rw-r--r--embed/mozilla/Makefile.am1
-rw-r--r--embed/mozilla/mozilla-embed.cpp65
-rw-r--r--lib/ephy-dialog.c42
-rw-r--r--lib/ephy-dialog.h3
-rw-r--r--src/ephy-window.c55
-rw-r--r--src/ephy-window.h2
-rw-r--r--src/window-commands.c22
14 files changed, 227 insertions, 443 deletions
diff --git a/ChangeLog b/ChangeLog
index fe9037fbe..fc9639e00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,40 @@
2003-07-20 Marco Pesenti Gritti <marco@it.gnome.org>
+ * embed/ephy-embed.c: (ephy_embed_find_set_properties),
+ (ephy_embed_find_next):
+ * embed/ephy-embed.h:
+ * embed/find-dialog.c: (update_navigation_controls), (impl_show),
+ (find_dialog_class_init), (set_properties), (sync_page_change),
+ (sync_embed), (find_dialog_init), (find_dialog_finalize),
+ (find_dialog_go_next), (find_dialog_go_prev),
+ (find_close_button_clicked_cb), (find_next_button_clicked_cb),
+ (find_prev_button_clicked_cb), (find_entry_changed_cb),
+ (find_check_toggled_cb):
+ * embed/find-dialog.h:
+ * embed/mozilla/EphyWrapper.cpp:
+ * embed/mozilla/EphyWrapper.h:
+ * embed/mozilla/Makefile.am:
+ * embed/mozilla/mozilla-embed.cpp:
+ * lib/ephy-dialog.h:
+ * src/ephy-window.c: (ephy_window_find):
+ * src/ephy-window.h:
+ * src/window-commands.c: (window_cmd_edit_find),
+ (window_cmd_edit_find_next), (window_cmd_edit_find_prev):
+
+ Rework find implementation to integrate better
+ with type ahead and to simplify the code.
+ Do not try to set menus sensitivity because
+ mozilla doesnt provide an api for it and it breaks
+ with type ahead.
+
+ * lib/ephy-dialog.c: (ephy_dialog_class_init),
+ (ephy_dialog_finalize), (dialog_destroy_cb), (impl_construct),
+ (ephy_dialog_construct):
+
+ Remove no more used destruct crap.
+
+2003-07-20 Marco Pesenti Gritti <marco@it.gnome.org>
+
* data/glade/print.glade:
Remove useless icons
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index ead39fde1..f20300bc5 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -529,11 +529,21 @@ ephy_embed_get_security_level (EphyEmbed *embed,
}
gresult
-ephy_embed_find (EphyEmbed *embed,
- EmbedFindInfo *info)
+ephy_embed_find_set_properties (EphyEmbed *embed,
+ char *search_string,
+ gboolean case_sensitive,
+ gboolean match_word)
{
EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed);
- return klass->find (embed, info);
+ return klass->find_set_properties (embed, search_string, case_sensitive, match_word);
+}
+
+gresult
+ephy_embed_find_next (EphyEmbed *embed,
+ gboolean backwards)
+{
+ EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed);
+ return klass->find_next (embed, backwards);
}
gresult
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index 376213c0e..aec3d87a9 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -94,17 +94,6 @@ typedef enum
typedef struct
{
- gchar *search_string;
- gboolean backwards;
- gboolean wrap;
- gboolean entire_word;
- gboolean match_case;
- gboolean search_frames;
- gboolean interactive;
-} EmbedFindInfo;
-
-typedef struct
-{
gboolean print_to_file;
gchar *printer;
gchar *file;
@@ -263,8 +252,12 @@ struct EphyEmbedClass
gresult (* get_security_level) (EphyEmbed *embed,
EmbedSecurityLevel *level,
char **description);
- gresult (* find) (EphyEmbed *embed,
- EmbedFindInfo *find);
+ gresult (* find_set_properties) (EphyEmbed *embed,
+ char *search_string,
+ gboolean case_sensitive,
+ gboolean wrap_around);
+ gresult (* find_next) (EphyEmbed *embed,
+ gboolean backwards);
gresult (* print) (EphyEmbed *embed,
EmbedPrintInfo *info);
gresult (* print_preview_close) (EphyEmbed *embed);
@@ -384,8 +377,13 @@ gresult ephy_embed_get_security_level (EphyEmbed *embed,
EmbedSecurityLevel *level,
char **description);
-gresult ephy_embed_find (EphyEmbed *embed,
- EmbedFindInfo *find);
+gresult ephy_embed_find_set_properties (EphyEmbed *embed,
+ char *search_string,
+ gboolean case_sensitive,
+ gboolean wrap_around);
+
+gresult ephy_embed_find_next (EphyEmbed *embed,
+ gboolean backwards);
gresult ephy_embed_set_encoding (EphyEmbed *embed,
const char *encoding);
diff --git a/embed/find-dialog.c b/embed/find-dialog.c
index 058197204..a067de8aa 100755
--- a/embed/find-dialog.c
+++ b/embed/find-dialog.c
@@ -33,18 +33,6 @@ static void find_dialog_class_init (FindDialogClass *klass);
static void find_dialog_init (FindDialog *dialog);
static void find_dialog_finalize (GObject *object);
-static void
-impl_construct (EphyDialog *dialog,
- const EphyDialogProperty *properties,
- const char *file,
- const char *name);
-static void
-impl_destruct (EphyDialog *dialog);
-static void
-impl_show (EphyDialog *dialog);
-static void
-find_get_info (EphyDialog *dialog);
-
/* Glade callbacks */
void find_close_button_clicked_cb (GtkWidget *button, EphyDialog *dialog);
void find_next_button_clicked_cb (GtkWidget *button, EphyDialog *dialog);
@@ -56,10 +44,6 @@ static GObjectClass *parent_class = NULL;
struct FindDialogPrivate
{
- EmbedFindInfo *properties;
- GtkWidget *window;
- gboolean constructed;
- FindNavigationFlags nav_flags;
EphyEmbed *old_embed;
};
@@ -85,12 +69,6 @@ EphyDialogProperty properties [] =
{ -1, NULL, NULL }
};
-enum
-{
- PROP_0,
- PROP_NAVIGATION
-};
-
GType
find_dialog_get_type (void)
{
@@ -121,48 +99,28 @@ find_dialog_get_type (void)
}
static void
-set_navigation_flags (FindDialog *dialog, FindNavigationFlags flags)
+update_navigation_controls (FindDialog *dialog, gboolean prev, gboolean next)
{
- GtkWidget *forward_button;
- GtkWidget *back_button;
- gboolean can_go_prev = FALSE, can_go_next = FALSE;
+ GtkWidget *button;
- if (!dialog->priv->constructed) return;
+ button = ephy_dialog_get_control (EPHY_DIALOG (dialog), BACK_BUTTON);
+ gtk_widget_set_sensitive (button, prev);
- dialog->priv->nav_flags = flags;
-
- if (flags & FIND_CAN_GO_PREV)
- {
- can_go_prev = TRUE;
- }
- if (flags & FIND_CAN_GO_NEXT)
- {
- can_go_next = TRUE;
- }
-
- back_button = ephy_dialog_get_control (EPHY_DIALOG (dialog), BACK_BUTTON);
- gtk_widget_set_sensitive (back_button, can_go_prev);
-
- forward_button = ephy_dialog_get_control (EPHY_DIALOG (dialog), FORWARD_BUTTON);
- gtk_widget_set_sensitive (forward_button, can_go_next);
-
- g_object_notify (G_OBJECT (dialog), "navigation");
+ button = ephy_dialog_get_control (EPHY_DIALOG (dialog), FORWARD_BUTTON);
+ gtk_widget_set_sensitive (button, next);
}
static void
-ephy_find_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+impl_show (EphyDialog *dialog)
{
- FindDialog *dialog = FIND_DIALOG (object);
- switch (prop_id)
- {
- case PROP_NAVIGATION:
- g_value_set_int (value, dialog->priv->nav_flags);
- break;
- }
+ EPHY_DIALOG_CLASS (parent_class)->show (dialog);
+
+ /* Focus the text entry. This will correctly select or leave
+ * unselected the existing text in the entry depending on the
+ * 'gtk-entry-select-on-focus = 0 / 1' setting in user's gtkrc.
+ */
+ gtk_widget_grab_focus (ephy_dialog_get_control (dialog, WORD_PROP));
}
static void
@@ -175,34 +133,47 @@ find_dialog_class_init (FindDialogClass *klass)
ephy_dialog_class = EPHY_DIALOG_CLASS (klass);
object_class->finalize = find_dialog_finalize;
- object_class->get_property = ephy_find_dialog_get_property;
- ephy_dialog_class->construct = impl_construct;
- ephy_dialog_class->destruct = impl_destruct;
ephy_dialog_class->show = impl_show;
-
- g_object_class_install_property (object_class,
- PROP_NAVIGATION,
- g_param_spec_int ("navigation",
- "Navigation flags",
- "The find dialog's navigation flags",
- 0,
- FIND_CAN_GO_PREV |
- FIND_CAN_GO_NEXT,
- 0,
- G_PARAM_READABLE));
}
static void
-ensure_constructed (FindDialog *dialog)
+set_properties (FindDialog *find_dialog)
{
- if (!dialog->priv->constructed)
- {
- ephy_dialog_construct (EPHY_DIALOG(dialog),
- properties,
- "epiphany.glade",
- "find_dialog");
- }
+ char *search_string;
+ GValue match_case = {0, };
+ GValue wrap = {0, };
+ GValue word = {0, };
+ gboolean b_match_case;
+ gboolean b_wrap;
+ EphyDialog *dialog = EPHY_DIALOG (find_dialog);
+ EphyEmbed *embed;
+
+ /* get the search string from the entry field */
+ ephy_dialog_get_value (dialog, WORD_PROP, &word);
+ search_string = g_strdup (g_value_get_string (&word));
+ g_value_unset (&word);
+
+ /* don't do null searches */
+ if (search_string == NULL || search_string[0] == '\0')
+ {
+ update_navigation_controls (find_dialog, FALSE, FALSE);
+ g_free (search_string);
+
+ return;
+ }
+
+ ephy_dialog_get_value (dialog, MATCH_CASE_PROP, &match_case);
+ b_match_case = g_value_get_boolean (&match_case);
+
+ ephy_dialog_get_value (dialog, AUTOWRAP_PROP, &wrap);
+ b_wrap = g_value_get_boolean (&wrap);
+
+ embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG(dialog));
+ g_return_if_fail (embed != NULL);
+
+ ephy_embed_find_set_properties (embed, search_string,
+ b_match_case, b_wrap);
}
static void
@@ -210,11 +181,8 @@ sync_page_change (EphyEmbed *embed, const char *address, FindDialog *dialog)
{
g_return_if_fail (IS_EPHY_EMBED (embed));
- if (dialog->priv->constructed == FALSE) return;
-
- set_navigation_flags (dialog, FIND_CAN_GO_PREV | FIND_CAN_GO_NEXT);
-
- find_get_info (EPHY_DIALOG (dialog));
+ update_navigation_controls (dialog, TRUE, TRUE);
+ set_properties (dialog);
}
static void
@@ -249,126 +217,36 @@ sync_embed (FindDialog *dialog, GParamSpec *pspec, gpointer data)
g_object_add_weak_pointer (G_OBJECT (embed),
(gpointer *)&dialog->priv->old_embed);
- if (dialog->priv->constructed)
- {
- set_navigation_flags (dialog, FIND_CAN_GO_PREV | FIND_CAN_GO_NEXT);
-
- find_get_info (EPHY_DIALOG (dialog));
- }
- else
- {
- set_navigation_flags (dialog, 0);
- }
+ update_navigation_controls (dialog, TRUE, TRUE);
+ set_properties (dialog);
}
static void
find_dialog_init (FindDialog *dialog)
{
+ GdkPixbuf *icon;
+ GtkWidget *window;
+
dialog->priv = g_new0 (FindDialogPrivate, 1);
- dialog->priv->properties = NULL;
- dialog->priv->nav_flags = 0;
- dialog->priv->constructed = FALSE;
dialog->priv->old_embed = NULL;
- g_signal_connect_object (dialog, "notify::embed",
- G_CALLBACK (sync_embed), NULL, 0);
+ ephy_dialog_construct (EPHY_DIALOG(dialog),
+ properties,
+ "epiphany.glade",
+ "find_dialog");
+ update_navigation_controls (dialog, TRUE, TRUE);
- ensure_constructed (dialog);
-}
-
-static void
-impl_construct (EphyDialog *dialog,
- const EphyDialogProperty *properties,
- const char *file,
- const char *name)
-{
- FIND_DIALOG(dialog)->priv->constructed = TRUE;
-
- EPHY_DIALOG_CLASS (parent_class)->construct (dialog, properties, file, name);
-}
-
-static void
-impl_destruct (EphyDialog *dialog)
-{
- FIND_DIALOG(dialog)->priv->constructed = FALSE;
-
- EPHY_DIALOG_CLASS (parent_class)->destruct (dialog);
-}
-
-static void
-find_get_info (EphyDialog *dialog)
-{
- EmbedFindInfo *properties;
- char *search_string;
- GValue word = {0, };
- GValue match_case = {0, };
- GValue wrap = {0, };
- FindDialog *find_dialog = FIND_DIALOG(dialog);
-
- if (find_dialog->priv->constructed == FALSE) return;
-
- /* get the search string from the entry field */
- ephy_dialog_get_value (dialog, WORD_PROP, &word);
- search_string = g_strdup (g_value_get_string (&word));
- g_value_unset (&word);
-
- /* don't do null searches */
- if (search_string == NULL || search_string[0] == '\0')
- {
- set_navigation_flags (find_dialog, 0);
- g_free (search_string);
-
- return;
- }
-
- if (find_dialog->priv->properties != NULL)
- {
- g_free (find_dialog->priv->properties->search_string);
- g_free (find_dialog->priv->properties);
- }
-
- /* build search structure */
- properties = g_new0 (EmbedFindInfo,1);
- properties->search_string = search_string;
-
- ephy_dialog_get_value (dialog, MATCH_CASE_PROP, &match_case);
- properties->match_case = g_value_get_boolean (&match_case);
-
- ephy_dialog_get_value (dialog, AUTOWRAP_PROP, &wrap);
- properties->wrap = g_value_get_boolean (&wrap);
-
- properties->entire_word = FALSE;
- properties->search_frames = TRUE;
-
- find_dialog->priv->properties = properties;
-}
-
-static void
-impl_show (EphyDialog *dialog)
-{
- GdkPixbuf *icon;
- FindDialog *find_dialog = FIND_DIALOG(dialog);
- ensure_constructed (find_dialog);
-
- set_navigation_flags (find_dialog, FIND_CAN_GO_PREV | FIND_CAN_GO_NEXT);
- find_dialog->priv->window = ephy_dialog_get_control (dialog, WINDOW_PROP);
- find_get_info (dialog);
-
- icon = gtk_widget_render_icon (find_dialog->priv->window,
- GTK_STOCK_FIND,
- GTK_ICON_SIZE_MENU,
- "find_dialog");
- gtk_window_set_icon (GTK_WINDOW(find_dialog->priv->window), icon);
+ window = ephy_dialog_get_control (EPHY_DIALOG (dialog), WINDOW_PROP);
+ icon = gtk_widget_render_icon (window,
+ GTK_STOCK_FIND,
+ GTK_ICON_SIZE_MENU,
+ "find_dialog");
+ gtk_window_set_icon (GTK_WINDOW(window), icon);
g_object_unref (icon);
- EPHY_DIALOG_CLASS (parent_class)->show (dialog);
-
- /* Focus the text entry. This will correctly select or leave
- * unselected the existing text in the entry depending on the
- * 'gtk-entry-select-on-focus = 0 / 1' setting in user's gtkrc.
- */
- gtk_widget_grab_focus (ephy_dialog_get_control (dialog, WORD_PROP));
+ g_signal_connect_object (dialog, "notify::embed",
+ G_CALLBACK (sync_embed), NULL, 0);
}
static void
@@ -385,12 +263,6 @@ find_dialog_finalize (GObject *object)
g_return_if_fail (dialog->priv != NULL);
- if (dialog->priv->properties != NULL)
- {
- g_free (dialog->priv->properties->search_string);
- g_free (dialog->priv->properties);
- }
-
unset_old_embed (dialog);
g_free (dialog->priv);
@@ -424,59 +296,49 @@ find_dialog_new_with_parent (GtkWidget *window,
return EPHY_DIALOG(dialog);
}
-void
-find_dialog_go_next (FindDialog *dialog,
- gboolean interactive)
+static void
+find_dialog_go_next (FindDialog *dialog)
{
gresult result;
EphyEmbed *embed;
g_return_if_fail (IS_FIND_DIALOG (dialog));
- if ((dialog->priv->nav_flags & FIND_CAN_GO_NEXT) == 0) return;
-
- dialog->priv->properties->backwards = FALSE;
- dialog->priv->properties->interactive = interactive;
embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG(dialog));
g_return_if_fail (embed != NULL);
- result = ephy_embed_find (embed, dialog->priv->properties);
+ result = ephy_embed_find_next (embed, FALSE);
if (result == G_OK)
{
- set_navigation_flags (dialog, FIND_CAN_GO_PREV | FIND_CAN_GO_NEXT);
+ update_navigation_controls (dialog, TRUE, TRUE);
}
else
{
- set_navigation_flags (dialog, FIND_CAN_GO_PREV);
+ update_navigation_controls (dialog, TRUE, FALSE);
}
}
-void
-find_dialog_go_prev (FindDialog *dialog,
- gboolean interactive)
+static void
+find_dialog_go_prev (FindDialog *dialog)
{
gresult result;
EphyEmbed *embed;
g_return_if_fail (IS_FIND_DIALOG (dialog));
- if ((dialog->priv->nav_flags & FIND_CAN_GO_PREV) == 0) return;
-
- dialog->priv->properties->backwards = TRUE;
- dialog->priv->properties->interactive = interactive;
embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG(dialog));
g_return_if_fail (embed != NULL);
- result = ephy_embed_find (embed, dialog->priv->properties);
+ result = ephy_embed_find_next (embed, TRUE);
if (result == G_OK)
{
- set_navigation_flags (dialog, FIND_CAN_GO_PREV | FIND_CAN_GO_NEXT);
+ update_navigation_controls (dialog, TRUE, TRUE);
}
else
{
- set_navigation_flags (dialog, FIND_CAN_GO_NEXT);
+ update_navigation_controls (dialog, FALSE, TRUE);
}
}
@@ -484,21 +346,20 @@ void
find_close_button_clicked_cb (GtkWidget *button,
EphyDialog *dialog)
{
- ephy_dialog_destruct (dialog);
g_object_unref (dialog);
}
void find_next_button_clicked_cb (GtkWidget *button,
EphyDialog *dialog)
{
- find_dialog_go_next (FIND_DIALOG(dialog), TRUE);
+ find_dialog_go_next (FIND_DIALOG(dialog));
}
void
find_prev_button_clicked_cb (GtkWidget *button,
EphyDialog *dialog)
{
- find_dialog_go_prev (FIND_DIALOG(dialog), TRUE);
+ find_dialog_go_prev (FIND_DIALOG(dialog));
}
void
@@ -507,9 +368,8 @@ find_entry_changed_cb (GtkWidget *editable,
{
FindDialog *find_dialog = FIND_DIALOG(dialog);
- set_navigation_flags (find_dialog, FIND_CAN_GO_PREV | FIND_CAN_GO_NEXT);
-
- find_get_info (dialog);
+ update_navigation_controls (find_dialog, TRUE, TRUE);
+ set_properties (find_dialog);
}
void
@@ -518,15 +378,6 @@ find_check_toggled_cb (GtkWidget *toggle,
{
FindDialog *find_dialog = FIND_DIALOG(dialog);
- set_navigation_flags (find_dialog, FIND_CAN_GO_PREV | FIND_CAN_GO_NEXT);
-
- find_get_info (dialog);
-}
-
-FindNavigationFlags
-find_dialog_get_navigation_flags (FindDialog *dialog)
-{
- g_return_val_if_fail (IS_FIND_DIALOG (dialog), 0);
-
- return dialog->priv->nav_flags;
+ update_navigation_controls (find_dialog, TRUE, TRUE);
+ set_properties (find_dialog);
}
diff --git a/embed/find-dialog.h b/embed/find-dialog.h
index c93a78303..b4c106f92 100644
--- a/embed/find-dialog.h
+++ b/embed/find-dialog.h
@@ -21,9 +21,6 @@
#include "ephy-embed-dialog.h"
-#include <glib-object.h>
-#include <glib.h>
-
G_BEGIN_DECLS
typedef struct FindDialog FindDialog;
@@ -37,12 +34,6 @@ typedef struct FindDialogClass FindDialogClass;
typedef struct FindDialogPrivate FindDialogPrivate;
-typedef enum
-{
- FIND_CAN_GO_PREV = 1 << 0,
- FIND_CAN_GO_NEXT = 1 << 1
-} FindNavigationFlags;
-
struct FindDialog
{
EphyEmbedDialog parent;
@@ -52,8 +43,6 @@ struct FindDialog
struct FindDialogClass
{
EphyEmbedDialogClass parent_class;
-
- void (* search) (FindDialog *dialog);
};
GType find_dialog_get_type (void);
@@ -63,14 +52,6 @@ EphyDialog* find_dialog_new (EphyEmbed *embed);
EphyDialog * find_dialog_new_with_parent (GtkWidget *window,
EphyEmbed *embed);
-void find_dialog_go_next (FindDialog *dialog,
- gboolean interactive);
-
-void find_dialog_go_prev (FindDialog *dialog,
- gboolean interactive);
-
-FindNavigationFlags find_dialog_get_navigation_flags (FindDialog *dialog);
-
G_END_DECLS
#endif
diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp
index 1252f7ece..fc306898b 100644
--- a/embed/mozilla/EphyWrapper.cpp
+++ b/embed/mozilla/EphyWrapper.cpp
@@ -68,8 +68,6 @@
#include "nsIDeviceContext.h"
#include "nsIPresContext.h"
#include "ContentHandler.h"
-#include "nsITypeAheadFind.h"
-#include "nsSupportsPrimitives.h"
#include "EphyEventListener.h"
EphyWrapper::EphyWrapper ()
@@ -499,50 +497,25 @@ nsresult EphyWrapper::GetSHUrlAtIndex (PRInt32 index, nsCString &url)
return NS_OK;
}
-nsresult EphyWrapper::Find (const PRUnichar *search_string,
- PRBool interactive,
- PRBool matchcase, PRBool search_backwards,
- PRBool search_wrap_around,
- PRBool search_for_entire_word,
- PRBool search_in_frames,
- PRBool *didFind)
+nsresult EphyWrapper::FindSetProperties (const PRUnichar *search_string,
+ PRBool case_sensitive,
+ PRBool wrap_around)
{
- if (!interactive)
- {
- nsresult rv;
- nsCOMPtr<nsITypeAheadFind> tAFinder
- (do_GetService(NS_TYPEAHEADFIND_CONTRACTID, &rv));
- if (NS_SUCCEEDED(rv))
- {
- nsCOMPtr<nsIDOMWindow> aFocusedWindow;
- rv = GetFocusedDOMWindow(getter_AddRefs(aFocusedWindow));
- if (NS_SUCCEEDED(rv))
- {
- nsSupportsInterfacePointerImpl windowPtr;
- windowPtr.SetData(aFocusedWindow);
-
- tAFinder->FindNext(search_backwards, &windowPtr);
-
- nsCOMPtr<nsISupports> retValue;
- rv = windowPtr.GetData(getter_AddRefs(retValue));
- if (NS_SUCCEEDED(rv) && !retValue)
- {
- *didFind = PR_TRUE;
- return NS_OK;
- }
- }
- }
+ nsCOMPtr<nsIWebBrowserFind> finder (do_GetInterface(mWebBrowser));
+
+ finder->SetSearchString (search_string);
+ finder->SetMatchCase (case_sensitive);
- }
+ return NS_OK;
+}
+nsresult EphyWrapper::Find (PRBool backwards,
+ PRBool *didFind)
+{
nsCOMPtr<nsIWebBrowserFind> finder (do_GetInterface(mWebBrowser));
- finder->SetSearchString (search_string);
- finder->SetFindBackwards (search_backwards);
- finder->SetWrapFind (search_wrap_around);
- finder->SetEntireWord (search_for_entire_word);
- finder->SetMatchCase (matchcase);
- finder->SetSearchFrames (search_in_frames);
+ finder->SetFindBackwards (backwards);
+
return finder->FindNext(didFind);
}
diff --git a/embed/mozilla/EphyWrapper.h b/embed/mozilla/EphyWrapper.h
index dd9d1c228..a210cdbfd 100644
--- a/embed/mozilla/EphyWrapper.h
+++ b/embed/mozilla/EphyWrapper.h
@@ -54,10 +54,10 @@ public:
nsresult PrintPreviewNumPages (int *numPages);
nsresult PrintPreviewNavigate(PRInt16 navType, PRInt32 pageNum);
- nsresult Find (const PRUnichar *search_string,
- PRBool matchcase, PRBool interactive,
- PRBool search_backwards, PRBool search_wrap_around,
- PRBool search_for_entire_word, PRBool search_in_frames,
+ nsresult FindSetProperties (const PRUnichar *search_string,
+ PRBool case_sensitive,
+ PRBool wrap_around);
+ nsresult Find (PRBool bacwards,
PRBool *didFind);
nsresult GetMainDocumentUrl (nsCString &url);
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index 851c1bdb5..8c462963c 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -22,7 +22,6 @@ INCLUDES = \
-I$(MOZILLA_INCLUDE_ROOT)/pref \
-I$(MOZILLA_INCLUDE_ROOT)/progressDlg \
-I$(MOZILLA_INCLUDE_ROOT)/shistory \
- -I$(MOZILLA_INCLUDE_ROOT)/typeaheadfind \
-I$(MOZILLA_INCLUDE_ROOT)/unicharutil \
-I$(MOZILLA_INCLUDE_ROOT)/uriloader \
-I$(MOZILLA_INCLUDE_ROOT)/wallet \
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index b0fbda45b..fa78a245b 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -145,10 +145,6 @@ impl_get_security_level (EphyEmbed *embed,
EmbedSecurityLevel *level,
char **description);
static gresult
-impl_find (EphyEmbed *embed,
- EmbedFindInfo *info);
-
-static gresult
impl_set_encoding (EphyEmbed *embed,
const char *encoding);
@@ -295,6 +291,42 @@ mozilla_embed_get_type (void)
return mozilla_embed_type;
}
+static gresult
+impl_find_next (EphyEmbed *embed,
+ gboolean backwards)
+{
+ nsresult result = NS_OK;
+ EphyWrapper *wrapper;
+
+ wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
+ g_return_val_if_fail (wrapper != NULL, G_FAILED);
+
+ PRBool didFind;
+
+ result = wrapper->Find (backwards, &didFind);
+
+ return didFind ? G_OK : G_FAILED;
+}
+
+static gresult
+impl_find_set_properties (EphyEmbed *embed,
+ char *search_string,
+ gboolean case_sensitive,
+ gboolean wrap_around)
+{
+ nsresult result = NS_OK;
+ EphyWrapper *wrapper;
+
+ wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
+ g_return_val_if_fail (wrapper != NULL, G_FAILED);
+
+ result = wrapper->FindSetProperties
+ ((NS_ConvertUTF8toUCS2(search_string)).get(),
+ case_sensitive, wrap_around);
+
+ return result ? G_OK : G_FAILED;
+}
+
static void
ephy_embed_init (EphyEmbedClass *embed_class)
{
@@ -330,7 +362,8 @@ ephy_embed_init (EphyEmbedClass *embed_class)
embed_class->shistory_go_nth = impl_shistory_go_nth;
embed_class->shistory_copy = impl_shistory_copy;
embed_class->get_security_level = impl_get_security_level;
- embed_class->find = impl_find;
+ embed_class->find_next = impl_find_next;
+ embed_class->find_set_properties = impl_find_set_properties;
embed_class->set_encoding = impl_set_encoding;
embed_class->select_all = impl_select_all;
embed_class->print = impl_print;
@@ -1140,28 +1173,6 @@ impl_print_preview_navigate (EphyEmbed *embed,
}
static gresult
-impl_find (EphyEmbed *embed,
- EmbedFindInfo *info)
-{
- nsresult result = NS_OK;
- EphyWrapper *wrapper;
-
- wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
-
- PRBool didFind;
-
- result = wrapper->Find ((NS_ConvertUTF8toUCS2(info->search_string)).get(),
- info->interactive,
- info->match_case,
- info->backwards, info->wrap,
- info->entire_word, info->search_frames,
- &didFind);
-
- return didFind ? G_OK : G_FAILED;
-}
-
-static gresult
impl_set_encoding (EphyEmbed *embed,
const char *encoding)
{
diff --git a/lib/ephy-dialog.c b/lib/ephy-dialog.c
index aa5ed1a16..1b182e0aa 100644
--- a/lib/ephy-dialog.c
+++ b/lib/ephy-dialog.c
@@ -51,10 +51,6 @@ impl_construct (EphyDialog *dialog,
const EphyDialogProperty *properties,
const char *file,
const char *name);
-
-static void
-impl_destruct (EphyDialog *dialog);
-
static GtkWidget *
impl_get_control (EphyDialog *dialog,
int property_id);
@@ -161,7 +157,6 @@ ephy_dialog_class_init (EphyDialogClass *klass)
klass->get_value = impl_get_value;
klass->run = impl_run;
klass->show = impl_show;
- klass->destruct = impl_destruct;
g_object_class_install_property (object_class,
PROP_PARENT_WINDOW,
@@ -939,7 +934,7 @@ ephy_dialog_finalize (GObject *object)
if (dialog->priv->dialog)
{
- ephy_dialog_destruct (dialog);
+ gtk_widget_destroy (dialog->priv->dialog);
}
free_props (dialog->priv->props);
@@ -1065,15 +1060,6 @@ init_props (const EphyDialogProperty *properties, GladeXML *gxml)
}
static void
-dialog_destruction_notify (EphyDialog *dialog,
- GObject *where_the_object_was)
-{
- dialog->priv->dialog = NULL;
- ephy_dialog_destruct (dialog);
- g_object_unref (dialog);
-}
-
-static void
dialog_destroy_cb (GtkWidget *widget, EphyDialog *dialog)
{
if (dialog->priv->props &&
@@ -1081,6 +1067,8 @@ dialog_destroy_cb (GtkWidget *widget, EphyDialog *dialog)
{
save_props (dialog->priv->props);
}
+
+ g_object_unref (dialog);
}
static void
@@ -1110,23 +1098,6 @@ impl_construct (EphyDialog *dialog,
dialog);
g_object_unref (gxml);
-
- g_object_weak_ref (G_OBJECT(dialog->priv->dialog),
- (GWeakNotify)dialog_destruction_notify,
- dialog);
-}
-
-static void
-impl_destruct (EphyDialog *dialog)
-{
- if (dialog->priv->dialog)
- {
- g_object_weak_unref (G_OBJECT(dialog->priv->dialog),
- (GWeakNotify)dialog_destruction_notify,
- dialog);
- gtk_widget_destroy (dialog->priv->dialog);
- dialog->priv->dialog = NULL;
- }
}
static GtkWidget *
@@ -1245,13 +1216,6 @@ ephy_dialog_construct (EphyDialog *dialog,
return klass->construct (dialog, properties, file, name);
}
-void
-ephy_dialog_destruct (EphyDialog *dialog)
-{
- EphyDialogClass *klass = EPHY_DIALOG_GET_CLASS (dialog);
- klass->destruct (dialog);
-}
-
gint
ephy_dialog_run (EphyDialog *dialog)
{
diff --git a/lib/ephy-dialog.h b/lib/ephy-dialog.h
index 9bc054e6b..646c146fc 100644
--- a/lib/ephy-dialog.h
+++ b/lib/ephy-dialog.h
@@ -71,7 +71,6 @@ struct EphyDialogClass
const EphyDialogProperty *properties,
const char *file,
const char *name);
- void (* destruct) (EphyDialog *dialog);
gint (* run) (EphyDialog *dialog);
void (* show) (EphyDialog *dialog);
GtkWidget * (* get_control) (EphyDialog *dialog,
@@ -92,8 +91,6 @@ void ephy_dialog_construct (EphyDialog *dialog,
const char *file,
const char *name);
-void ephy_dialog_destruct (EphyDialog *dialog);
-
void ephy_dialog_add_enum (EphyDialog *dialog,
int id,
guint n_items,
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 2fda4cf13..1f58e3bb3 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -703,32 +703,6 @@ setup_window (EphyWindow *window)
}
static void
-sync_find_dialog (FindDialog *dialog, GParamSpec *spec, EphyWindow *window)
-{
- EggActionGroup *action_group;
- EggAction *action;
- FindNavigationFlags flags;
- gboolean can_go_prev = FALSE, can_go_next = FALSE;
-
- flags = find_dialog_get_navigation_flags (dialog);
-
- if (flags & FIND_CAN_GO_PREV)
- {
- can_go_prev = TRUE;
- }
- if (flags & FIND_CAN_GO_NEXT)
- {
- can_go_next = TRUE;
- }
-
- action_group = window->priv->action_group;
- action = egg_action_group_get_action (action_group, "EditFindPrev");
- g_object_set (action, "sensitive", can_go_prev, NULL);
- action = egg_action_group_get_action (action_group, "EditFindNext");
- g_object_set (action, "sensitive", can_go_next, NULL);
-}
-
-static void
sync_tab_address (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
{
const char *address;
@@ -1855,31 +1829,26 @@ ephy_window_notebook_switch_page_cb (GtkNotebook *notebook,
update_tabs_menu_sensitivity (window);
}
-EphyDialog *
-ephy_window_get_find_dialog (EphyWindow *window)
+void
+ephy_window_find (EphyWindow *window)
{
EphyDialog *dialog;
EphyEmbed *embed;
- if (window->priv->find_dialog)
+ if (window->priv->find_dialog == NULL)
{
- return window->priv->find_dialog;
- }
-
- embed = ephy_window_get_active_embed (window);
- g_return_val_if_fail (GTK_IS_WINDOW(window), NULL);
- dialog = find_dialog_new_with_parent (GTK_WIDGET(window),
- embed);
+ embed = ephy_window_get_active_embed (window);
+ g_return_if_fail (GTK_IS_WINDOW(window));
- sync_find_dialog (FIND_DIALOG (dialog), NULL, window);
- g_signal_connect_object (dialog, "notify::embed",
- G_CALLBACK (sync_find_dialog), window, 0);
- g_signal_connect_object (dialog, "notify::navigation",
- G_CALLBACK (sync_find_dialog), window, 0);
+ dialog = find_dialog_new_with_parent (GTK_WIDGET(window),
+ embed);
+ window->priv->find_dialog = dialog;
- window->priv->find_dialog = dialog;
+ g_object_add_weak_pointer(G_OBJECT (dialog),
+ (gpointer *) &window->priv->find_dialog);
+ }
- return dialog;
+ ephy_dialog_show (window->priv->find_dialog);
}
static void
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 092c30020..d1eeb1d20 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -112,7 +112,7 @@ Toolbar *ephy_window_get_toolbar (EphyWindow *window);
/* Dialogs */
-EphyDialog *ephy_window_get_find_dialog (EphyWindow *window);
+void ephy_window_find (EphyWindow *window);
void ephy_window_print (EphyWindow *window);
diff --git a/src/window-commands.c b/src/window-commands.c
index 53b134eef..b53ebc709 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -23,7 +23,6 @@
#include "ephy-shell.h"
#include "ephy-debug.h"
#include "window-commands.h"
-#include "find-dialog.h"
#include "print-dialog.h"
#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
@@ -61,12 +60,7 @@ void
window_cmd_edit_find (EggAction *action,
EphyWindow *window)
{
- EphyDialog *dialog;
- dialog = ephy_window_get_find_dialog (window);
-
- g_object_ref (dialog);
-
- ephy_dialog_show (dialog);
+ ephy_window_find (window);
}
void
@@ -476,22 +470,24 @@ void
window_cmd_edit_find_next (EggAction *action,
EphyWindow *window)
{
- EphyDialog *dialog;
+ EphyEmbed *embed;
- dialog = ephy_window_get_find_dialog (window);
+ embed = ephy_window_get_active_embed (window);
+ g_return_if_fail (embed != NULL);
- find_dialog_go_next (FIND_DIALOG(dialog), FALSE);
+ ephy_embed_find_next (embed, FALSE);
}
void
window_cmd_edit_find_prev (EggAction *action,
EphyWindow *window)
{
- EphyDialog *dialog;
+ EphyEmbed *embed;
- dialog = ephy_window_get_find_dialog (window);
+ embed = ephy_window_get_active_embed (window);
+ g_return_if_fail (embed != NULL);
- find_dialog_go_prev (FIND_DIALOG(dialog), FALSE);
+ ephy_embed_find_next (embed, TRUE);
}
void