diff options
author | Crispin Flowerday <gnome@flowerday.cx> | 2005-12-07 04:10:17 +0800 |
---|---|---|
committer | Crispin Flowerday <crispin@src.gnome.org> | 2005-12-07 04:10:17 +0800 |
commit | 89e2f69727a24f8667b1daf2341bae55b0567d10 (patch) | |
tree | a69bf24ee33e77fb002695bce9e548a4fb18fa3c | |
parent | a02815e758437be9ed36485a6a48b09423c59282 (diff) | |
download | gsoc2013-epiphany-89e2f69727a24f8667b1daf2341bae55b0567d10.tar.gz gsoc2013-epiphany-89e2f69727a24f8667b1daf2341bae55b0567d10.tar.zst gsoc2013-epiphany-89e2f69727a24f8667b1daf2341bae55b0567d10.zip |
Forward up/down/page up/page down from the findbar entry to the embed.
2005-12-06 Crispin Flowerday <gnome@flowerday.cx>
* embed/ephy-embed.c: (ephy_embed_scroll),
(ephy_embed_page_scroll):
* embed/ephy-embed.h:
* embed/mozilla/EphyBrowser.cpp:
* embed/mozilla/EphyBrowser.h:
* embed/mozilla/mozilla-embed.cpp:
* src/ephy-find-toolbar.c: (entry_key_press_event_cb):
Forward up/down/page up/page down from the findbar entry
to the embed.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | embed/ephy-embed.c | 32 | ||||
-rw-r--r-- | embed/ephy-embed.h | 10 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 29 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.h | 3 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 18 | ||||
-rw-r--r-- | src/ephy-find-toolbar.c | 31 |
7 files changed, 133 insertions, 3 deletions
@@ -1,3 +1,16 @@ +2005-12-06 Crispin Flowerday <gnome@flowerday.cx> + + * embed/ephy-embed.c: (ephy_embed_scroll), + (ephy_embed_page_scroll): + * embed/ephy-embed.h: + * embed/mozilla/EphyBrowser.cpp: + * embed/mozilla/EphyBrowser.h: + * embed/mozilla/mozilla-embed.cpp: + * src/ephy-find-toolbar.c: (entry_key_press_event_cb): + + Forward up/down/page up/page down from the findbar entry + to the embed. + 2005-12-05 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-related-action.c: (node_destroyed_cb): diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 2c6a97b25..6eaf2b66c 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -645,6 +645,38 @@ ephy_embed_get_zoom (EphyEmbed *embed) } /** + * ephy_embed_scroll: + * @embed: an #EphyEmbed + * @num_lines: The number of lines to scroll by + * + * Scrolls the view by lines. Positive numbers scroll down, negative + * numbers scroll up + * + **/ +void +ephy_embed_scroll (EphyEmbed *embed, int num_lines) +{ + EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); + iface->scroll (embed, num_lines); +} + +/** + * ephy_embed_page_scroll: + * @embed: an #EphyEmbed + * @num_lines: The number of pages to scroll by + * + * Scrolls the view by pages. Positive numbers scroll down, negative + * numbers scroll up + * + **/ +void +ephy_embed_page_scroll (EphyEmbed *embed, int num_pages) +{ + EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); + iface->page_scroll (embed, num_pages); +} + +/** * ephy_embed_shistory_n_items: * @embed: an #EphyEmbed * diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 02d3f3cb6..6f1787222 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -192,6 +192,8 @@ struct _EphyEmbedIface void (* set_zoom) (EphyEmbed *embed, float zoom); float (* get_zoom) (EphyEmbed *embed); + void (* scroll) (EphyEmbed *embed, int num_lines); + void (* page_scroll) (EphyEmbed *embed, int num_pages); char * (* get_encoding) (EphyEmbed *embed); gboolean (* has_automatic_encoding) (EphyEmbed *embed); void (* set_encoding) (EphyEmbed *embed, @@ -205,6 +207,7 @@ struct _EphyEmbedIface int page); gboolean (* has_modified_forms) (EphyEmbed *embed); void (* close) (EphyEmbed *embed); + }; GType ephy_embed_net_state_get_type (void); @@ -283,6 +286,13 @@ void ephy_embed_set_zoom (EphyEmbed *embed, float ephy_embed_get_zoom (EphyEmbed *embed); +/* Scroll */ +void ephy_embed_scroll (EphyEmbed *embed, + int num_lines); + +void ephy_embed_page_scroll (EphyEmbed *embed, + int num_pages); + /* Encoding */ char *ephy_embed_get_encoding (EphyEmbed *embed); diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index 7bfda8bcc..b87fe9bf3 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -928,6 +928,35 @@ nsresult EphyBrowser::GetZoom (float *aZoom) return mdv->GetTextZoom (aZoom); } +nsresult EphyBrowser::ScrollLines (int aNumLines) +{ + nsresult rv; + nsCOMPtr<nsIDOMWindow> DOMWindow; + + mWebBrowserFocus->GetFocusedWindow (getter_AddRefs(DOMWindow)); + if (!DOMWindow) + { + DOMWindow = mDOMWindow; + } + + DOMWindow->ScrollByLines (aNumLines); +} + +nsresult EphyBrowser::ScrollPages (int aNumPages) +{ + nsresult rv; + nsCOMPtr<nsIDOMWindow> DOMWindow; + + mWebBrowserFocus->GetFocusedWindow (getter_AddRefs(DOMWindow)); + if (!DOMWindow) + { + DOMWindow = mDOMWindow; + } + + DOMWindow->ScrollByPages (aNumPages); +} + + nsresult EphyBrowser::GetDocument (nsIDOMDocument **aDOMDocument) { return mDOMWindow->GetDocument (aDOMDocument); diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index c21aac103..56058718b 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -147,6 +147,9 @@ public: nsresult SetZoom (float aTextZoom); nsresult GetZoom (float *aTextZoom); + nsresult ScrollLines (int aNumLines); + nsresult ScrollPages (int aNumPages); + nsresult Print (); nsresult SetPrintPreviewMode (PRBool previewMode); nsresult PrintPreviewNumPages (int *numPages); diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index daeb19eaf..17797f6e3 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -652,6 +652,22 @@ impl_get_zoom (EphyEmbed *embed) return 1.0; } +static void +impl_scroll (EphyEmbed *embed, int num_lines) +{ + MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + + mpriv->browser->ScrollLines (num_lines); +} + +static void +impl_page_scroll (EphyEmbed *embed, int num_pages) +{ + MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + + mpriv->browser->ScrollPages (num_pages); +} + static int impl_shistory_n_items (EphyEmbed *embed) { @@ -1181,6 +1197,8 @@ ephy_embed_iface_init (EphyEmbedIface *iface) iface->reload = impl_reload; iface->set_zoom = impl_set_zoom; iface->get_zoom = impl_get_zoom; + iface->scroll = impl_scroll; + iface->page_scroll = impl_page_scroll; iface->shistory_n_items = impl_shistory_n_items; iface->shistory_get_nth = impl_shistory_get_nth; iface->shistory_get_pos = impl_shistory_get_pos; diff --git a/src/ephy-find-toolbar.c b/src/ephy-find-toolbar.c index ba2a5e601..f1632bfe8 100644 --- a/src/ephy-find-toolbar.c +++ b/src/ephy-find-toolbar.c @@ -243,14 +243,39 @@ entry_key_press_event_cb (GtkEntry *entry, GdkEventKey *event, EphyFindToolbar *toolbar) { + EphyFindToolbarPrivate *priv = toolbar->priv; guint mask = gtk_accelerator_get_default_mod_mask (); gboolean handled = FALSE; - /* Hide the toolbar when ESC is pressed */ - if ((event->state & mask) == 0 && event->keyval == GDK_Escape) + if ((event->state & mask) == 0) { - ephy_find_toolbar_request_close (toolbar); handled = TRUE; + switch (event->keyval) + { + case GDK_Up: + case GDK_KP_Up: + ephy_embed_scroll (priv->embed, -1); + break; + case GDK_Down: + case GDK_KP_Down: + ephy_embed_scroll (priv->embed, 1); + break; + case GDK_Page_Up: + case GDK_KP_Page_Up: + ephy_embed_page_scroll (priv->embed, -1); + break; + case GDK_Page_Down: + case GDK_KP_Page_Down: + ephy_embed_page_scroll (priv->embed, 1); + break; + case GDK_Escape: + /* Hide the toolbar when ESC is pressed */ + ephy_find_toolbar_request_close (toolbar); + break; + default: + handled = FALSE; + break; + } } else if ((event->state & mask) == GDK_CONTROL_MASK && (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)) |