diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-find-toolbar.c | 81 | ||||
-rw-r--r-- | src/ephy-find-toolbar.h | 2 | ||||
-rw-r--r-- | src/ephy-window.c | 34 | ||||
-rw-r--r-- | src/ephy-window.h | 2 |
4 files changed, 102 insertions, 17 deletions
diff --git a/src/ephy-find-toolbar.c b/src/ephy-find-toolbar.c index 40cdeb702..75740c04c 100644 --- a/src/ephy-find-toolbar.c +++ b/src/ephy-find-toolbar.c @@ -45,6 +45,7 @@ struct _EphyFindToolbarPrivate { EphyEmbedFind *find; + EphyWindow *window; EphyEmbed *embed; GtkWidget *entry; GtkToolItem *next; @@ -52,6 +53,7 @@ struct _EphyFindToolbarPrivate gulong set_focus_handler; guint preedit_changed : 1; guint prevent_activate : 1; + guint activated : 1; guint explicit_focus : 1; guint links_only : 1; }; @@ -59,7 +61,7 @@ struct _EphyFindToolbarPrivate enum { PROP_0, - PROP_TEXT + PROP_WINDOW }; enum @@ -165,6 +167,9 @@ tab_dom_key_press_cb (EphyEmbed *embed, gboolean retval = FALSE; guint oldhash, newhash; + /* don't do anything in PPV mode */ + if (ephy_window_get_is_print_preview (priv->window)) return FALSE; + event = gtk_get_current_event (); if (event == NULL) return FALSE; /* shouldn't happen! */ @@ -196,13 +201,13 @@ tab_dom_key_press_cb (EphyEmbed *embed, } oldhash = g_str_hash (gtk_entry_get_text (entry)); - priv->preedit_changed = FALSE; event_window = event_key->window; event_key->window = priv->entry->window; /* Send the event to the window. If the preedit_changed signal is emitted * during this event, we will set priv->imcontext_changed */ + priv->preedit_changed = priv->activated = FALSE; priv->prevent_activate = TRUE; retval = gtk_widget_event (priv->entry, event); priv->prevent_activate = FALSE; @@ -214,8 +219,8 @@ tab_dom_key_press_cb (EphyEmbed *embed, newhash = g_str_hash (gtk_entry_get_text (entry)); - /* FIXME: is this right? */ - return (retval && oldhash != newhash) || priv->preedit_changed; + /* FIXME: is this correct? */ + return retval && (oldhash != newhash || priv->preedit_changed) && !priv->activated; } #endif /* HAVE_TYPEAHEADFIND */ @@ -280,6 +285,7 @@ entry_activate_cb (GtkWidget *entry, { EphyFindToolbarPrivate *priv = toolbar->priv; + priv->activated = TRUE; if (priv->prevent_activate) return; g_signal_emit (toolbar, signals[NEXT], 0); @@ -310,6 +316,30 @@ set_focus_cb (EphyWindow *window, } static void +sync_print_preview_mode (EphyWindow *window, + GParamSpec *pspec, + EphyFindToolbar *toolbar) +{ + if (ephy_window_get_is_print_preview (window) && GTK_WIDGET_VISIBLE (GTK_WIDGET (toolbar))) + { + ephy_find_toolbar_close (toolbar); + } +} + +static void +ephy_find_toolbar_set_window (EphyFindToolbar *toolbar, + EphyWindow *window) +{ + EphyFindToolbarPrivate *priv = toolbar->priv; + + priv->window = window; + + sync_print_preview_mode (window, NULL, toolbar); + g_signal_connect (window, "notify::print-preview-mode", + G_CALLBACK (sync_print_preview_mode), toolbar); +} + +static void ephy_find_toolbar_parent_set (GtkWidget *widget, GtkWidget *previous_parent) { @@ -423,6 +453,32 @@ ephy_find_toolbar_finalize (GObject *object) } static void +ephy_find_toolbar_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + /* no readable properties */ + g_assert_not_reached (); +} + +static void +ephy_find_toolbar_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + EphyFindToolbar *toolbar = EPHY_FIND_TOOLBAR (object); + + switch (prop_id) + { + case PROP_WINDOW: + ephy_find_toolbar_set_window (toolbar, (EphyWindow *) g_value_get_object (value)); + break; + } +} + +static void ephy_find_toolbar_class_init (EphyFindToolbarClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -431,6 +487,8 @@ ephy_find_toolbar_class_init (EphyFindToolbarClass *klass) parent_class = g_type_class_peek_parent (klass); object_class->finalize = ephy_find_toolbar_finalize; + object_class->get_property = ephy_find_toolbar_get_property; + object_class->set_property = ephy_find_toolbar_set_property; widget_class->parent_set = ephy_find_toolbar_parent_set; widget_class->grab_focus = ephy_find_toolbar_grab_focus; @@ -466,6 +524,15 @@ ephy_find_toolbar_class_init (EphyFindToolbarClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_object_class_install_property + (object_class, + PROP_WINDOW, + g_param_spec_object ("window", + "Window", + "Parent window", + EPHY_TYPE_WINDOW, + (GParamFlags) (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY))); + g_type_class_add_private (klass, sizeof (EphyFindToolbarPrivate)); } @@ -500,9 +567,11 @@ ephy_find_toolbar_get_type (void) } EphyFindToolbar * -ephy_find_toolbar_new (void) +ephy_find_toolbar_new (EphyWindow *window) { - return EPHY_FIND_TOOLBAR (g_object_new (EPHY_TYPE_FIND_TOOLBAR, NULL)); + return EPHY_FIND_TOOLBAR (g_object_new (EPHY_TYPE_FIND_TOOLBAR, + "window", window, + NULL)); } const char * diff --git a/src/ephy-find-toolbar.h b/src/ephy-find-toolbar.h index 6d66d03b3..6bc4bf800 100644 --- a/src/ephy-find-toolbar.h +++ b/src/ephy-find-toolbar.h @@ -59,7 +59,7 @@ struct _EphyFindToolbarClass GType ephy_find_toolbar_get_type (void) G_GNUC_CONST; -EphyFindToolbar *ephy_find_toolbar_new (void); +EphyFindToolbar *ephy_find_toolbar_new (EphyWindow *window); const char *ephy_find_toolbar_get_text (EphyFindToolbar *toolbar); diff --git a/src/ephy-window.c b/src/ephy-window.c index 871f35eca..8bf8ca2a9 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2711,7 +2711,7 @@ ephy_window_init (EphyWindow *window) TRUE, TRUE, 0); gtk_widget_show (GTK_WIDGET (window->priv->notebook)); - priv->find_toolbar = ephy_find_toolbar_new (); + priv->find_toolbar = ephy_find_toolbar_new (window); g_signal_connect (priv->find_toolbar, "close", G_CALLBACK (find_toolbar_close_cb), window); gtk_box_pack_start (GTK_BOX (window->priv->main_vbox), @@ -2898,27 +2898,25 @@ ephy_window_set_print_preview (EphyWindow *window, accel_group = gtk_ui_manager_get_accel_group (window->priv->manager); - if (window->priv->ppv_mode == enabled) return; + if (priv->ppv_mode == enabled) return; - window->priv->ppv_mode = enabled; + priv->ppv_mode = enabled; sync_chromes_visibility (window); if (enabled) { - g_return_if_fail (window->priv->ppview_toolbar == NULL); + g_return_if_fail (priv->ppview_toolbar == NULL); - window->priv->ppview_toolbar = ppview_toolbar_new (window); + priv->ppview_toolbar = ppview_toolbar_new (window); gtk_window_remove_accel_group (GTK_WINDOW (window), accel_group); - - ephy_find_toolbar_close (priv->find_toolbar); } else { - g_return_if_fail (window->priv->ppview_toolbar != NULL); + g_return_if_fail (priv->ppview_toolbar != NULL); - g_object_unref (window->priv->ppview_toolbar); - window->priv->ppview_toolbar = NULL; + g_object_unref (priv->ppview_toolbar); + priv->ppview_toolbar = NULL; gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); } @@ -3402,3 +3400,19 @@ ephy_window_get_is_popup (EphyWindow *window) return window->priv->is_popup; } + +/** + * ephy_window_get_is_print_preview: + * @window: an #EphyWindow + * + * Returns whether this window is in print preview mode. + * + * Return value: %TRUE if it is in print preview mode + **/ +gboolean +ephy_window_get_is_print_preview (EphyWindow *window) +{ + g_return_val_if_fail (EPHY_IS_WINDOW (window), FALSE); + + return window->priv->ppv_mode; +} diff --git a/src/ephy-window.h b/src/ephy-window.h index 6cd3fa9bc..ba2d49ec5 100644 --- a/src/ephy-window.h +++ b/src/ephy-window.h @@ -105,6 +105,8 @@ void ephy_window_find (EphyWindow *window); gboolean ephy_window_get_is_popup (EphyWindow *window); +gboolean ephy_window_get_is_print_preview(EphyWindow *window); + G_END_DECLS #endif |