pidgin: b8635a41: Add page up/down for WebKit view.

qulogic at pidgin.im qulogic at pidgin.im
Thu Dec 29 03:07:10 EST 2011


----------------------------------------------------------------------
Revision: b8635a4141575e5f53c7c087d35c4e3e45c7b9be
Parent:   6ab9f5ff810acde3c06a2add7b8df2bd75cce6e3
Author:   qulogic at pidgin.im
Date:     12/27/11 17:00:00
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/b8635a4141575e5f53c7c087d35c4e3e45c7b9be

Changelog: 

Add page up/down for WebKit view.

Changes against parent 6ab9f5ff810acde3c06a2add7b8df2bd75cce6e3

  patched  pidgin/gtkconv.c
  patched  pidgin/gtkwebview.c
  patched  pidgin/gtkwebview.h

-------------- next part --------------
============================================================
--- pidgin/gtkconv.c	3a5078b89226d04945f1d922f84bafa1fc87336a
+++ pidgin/gtkconv.c	e2f6e7dbfe668ccf3dea3be13181f3201ea181f1
@@ -2186,19 +2186,13 @@ entry_key_press_cb(GtkWidget *entry, Gdk
 
 		case GDK_Page_Up:
 		case GDK_KP_Page_Up:
-/* TODO WEBKIT: Write this. */
-#if 0
-			gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml));
-#endif /* if 0 */
+			gtk_webview_page_up(GTK_WEBVIEW(gtkconv->webview));
 			return TRUE;
 			break;
 
 		case GDK_Page_Down:
 		case GDK_KP_Page_Down:
-/* TODO WEBKIT: Write this. */
-#if 0
-			gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml));
-#endif /* if 0 */
+			gtk_webview_page_down(GTK_WEBVIEW(gtkconv->webview));
 			return TRUE;
 			break;
 
============================================================
--- pidgin/gtkwebview.c	9522eec752ae34fcba7b20f13beb716927e3cdc9
+++ pidgin/gtkwebview.c	444bf94b3785997f76802fa26afdd08b8a6993c3
@@ -394,6 +394,41 @@ gtk_webview_scroll_to_end(GtkWebView *we
 	}
 }
 
+void gtk_webview_page_up(GtkWebView *webview)
+{
+	GtkAdjustment *vadj = webview->priv->vadj;
+	gdouble scroll_val;
+
+#if GTK_CHECK_VERSION(2,14,0)
+	scroll_val = gtk_adjustment_get_value(vadj) - gtk_adjustment_get_page_size(vadj);
+	scroll_val = MAX(scroll_val, gtk_adjustment_get_lower(vadj));
+#else
+	scroll_val = gtk_adjustment_get_value(vadj) - vadj->page_size;
+	scroll_val = MAX(scroll_val, vadj->lower);
+#endif
+
+	gtk_adjustment_set_value(vadj, scroll_val);
+}
+
+void gtk_webview_page_down(GtkWebView *webview)
+{
+	GtkAdjustment *vadj = webview->priv->vadj;
+	gdouble scroll_val;
+	gdouble page_size;
+
+#if GTK_CHECK_VERSION(2,14,0)
+	page_size = gtk_adjustment_get_page_size(vadj);
+	scroll_val = gtk_adjustment_get_value(vadj) + page_size;
+	scroll_val = MIN(scroll_val, gtk_adjustment_get_upper(vadj) - page_size);
+#else
+	page_size = vadj->page_size;
+	scroll_val = gtk_adjustment_get_value(vadj) + page_size;
+	scroll_val = MIN(scroll_val, vadj->upper - page_size);
+#endif
+
+	gtk_adjustment_set_value(vadj, scroll_val);
+}
+
 GType
 gtk_webview_get_type(void)
 {
============================================================
--- pidgin/gtkwebview.h	ef9237cac80e6f14bb7eb47288655f747652e9e6
+++ pidgin/gtkwebview.h	957afb32234b1185a6bf176307aa43f62baa194f
@@ -143,5 +143,19 @@ void gtk_webview_scroll_to_end(GtkWebVie
  */
 void gtk_webview_scroll_to_end(GtkWebView *webview, gboolean smooth);
 
+/**
+ * Scrolls a GtkWebView up by one page.
+ *
+ * @param webview The GtkWebView.
+ */
+void gtk_webview_page_up(GtkWebView *webview);
+
+/**
+ * Scrolls a GtkWebView down by one page.
+ *
+ * @param webview The GtkWebView.
+ */
+void gtk_webview_page_down(GtkWebView *webview);
+
 #endif /* _PIDGIN_WEBVIEW_H_ */
 


More information about the Commits mailing list