[Xfce4-commits] <midori:master> Introduce midori_view_get_for_widget
Christian Dywan
noreply at xfce.org
Sun Mar 25 19:38:01 CEST 2012
Updating branch refs/heads/master
to 19f6fefe9b227df63f58da2170f4fd8b20260216 (commit)
from f7d85602f84f43e20495f7a1150a9dda5b038eea (commit)
commit 19f6fefe9b227df63f58da2170f4fd8b20260216
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Mar 25 19:35:58 2012 +0200
Introduce midori_view_get_for_widget
Analogous to midori_browser_get_for_widget.
midori/midori-browser.c | 2 +-
midori/midori-view.c | 29 ++++++++++++++++++++++++-----
midori/midori-view.h | 3 +++
3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 5501679..0692d71 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -1780,8 +1780,8 @@ midori_browser_key_press_event (GtkWidget* widget,
&& !webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (focus)))
{
/* Space at the bottom of the page: Go to next page */
+ MidoriView* view = midori_view_get_for_widget (focus);
GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (focus));
- MidoriView* view = MIDORI_VIEW (gtk_widget_get_parent (GTK_WIDGET (scrolled)));
GtkAdjustment* vadjust = gtk_scrolled_window_get_vadjustment (scrolled);
if (gtk_adjustment_get_value (vadjust)
== (gtk_adjustment_get_upper (vadjust) - gtk_adjustment_get_page_size (vadjust)))
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 4a9fb4c..e985aec 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -2793,12 +2793,8 @@ static gboolean
webkit_web_view_web_view_ready_cb (GtkWidget* web_view,
MidoriView* view)
{
- #if GTK_CHECK_VERSION(3, 2, 0)
- GtkWidget* new_view = gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (web_view)));
- #else
- GtkWidget* new_view = gtk_widget_get_parent (gtk_widget_get_parent (web_view));
- #endif
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
+ GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view));
/* FIXME: Open windows opened by scripts in tabs if they otherwise
would be replacing the page the user opened. */
@@ -5815,6 +5811,29 @@ midori_view_get_web_view (MidoriView* view)
}
/**
+ * midori_view_get_for_widget:
+ * @widget: a #GtkWidget
+ *
+ * Determines the view appropriate for the specified widget.
+ *
+ * Return value: a #MidoriView
+ *
+ * Since 0.4.5
+ **/
+MidoriView*
+midori_view_get_for_widget (GtkWidget* web_view)
+{
+ GtkWidget* scrolled = gtk_widget_get_parent (web_view);
+ #if GTK_CHECK_VERSION(3, 2, 0)
+ GtkWidget* overlay = gtk_widget_get_parent (scrolled);
+ GtkWidget* view = gtk_widget_get_parent (overlay);
+ #else
+ GtkWidget* view = gtk_widget_get_parent (scrolled);
+ #endif
+ return MIDORI_VIEW (view);
+}
+
+/**
* midori_view_get_security
* @view: a #MidoriView
*
diff --git a/midori/midori-view.h b/midori/midori-view.h
index 837f424..feba052 100644
--- a/midori/midori-view.h
+++ b/midori/midori-view.h
@@ -248,6 +248,9 @@ midori_view_get_snapshot (MidoriView* view,
GtkWidget*
midori_view_get_web_view (MidoriView* view);
+MidoriView*
+midori_view_get_for_widget (GtkWidget* web_view);
+
MidoriSecurity
midori_view_get_security (MidoriView* view);
More information about the Xfce4-commits
mailing list