[evolution/webkit: 131/182] Automatically resize webviews to prevent individual horizontal scrolling
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 131/182] Automatically resize webviews to prevent individual horizontal scrolling
- Date: Tue, 6 Mar 2012 16:19:44 +0000 (UTC)
commit 0eeb70d4b536d6abcecbbb58aca91b1dc2339899
Author: Dan VrÃtil <dvratil redhat com>
Date: Wed Jan 25 14:44:10 2012 +0100
Automatically resize webviews to prevent individual horizontal scrolling
The horizontal scrollbar should appear only in EMailDisplay, not in individual
webviews.
This is a partial fix of bug #668585 - the webviews are not automatically
scaled down when zoomed out.
mail/e-mail-display.c | 45 +++++++++++++++++++++++++++++++++++++--------
mail/e-mail-paned-view.c | 2 --
2 files changed, 37 insertions(+), 10 deletions(-)
---
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 6166827..5492274 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -710,13 +710,37 @@ mail_display_setup_webview (EMailDisplay *display,
}
static void
+mail_display_on_web_view_sw_hadjustment_changed (GtkAdjustment* adjustment,
+ gpointer user_data)
+{
+ GtkWidget *scrolled_window = user_data;
+ GtkWidget *vscrollbar;
+ GtkWidget *web_view;
+ gint new_width, height;
+
+ web_view = gtk_bin_get_child (GTK_BIN (scrolled_window));
+ gtk_widget_get_preferred_width (web_view, NULL, &new_width);
+
+ vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (scrolled_window));
+ if (vscrollbar && gtk_widget_get_visible (vscrollbar)) {
+ gint scrollbar_width;
+ gtk_widget_get_preferred_width (vscrollbar, &scrollbar_width, NULL);
+ new_width += scrollbar_width;
+ }
+
+ gtk_widget_get_size_request (scrolled_window, NULL, &height);
+ gtk_widget_set_size_request (scrolled_window, new_width, height);
+}
+
+
+static void
mail_display_on_web_view_sw_vadjustment_changed (GtkAdjustment* adjustment,
gpointer user_data)
{
GtkWidget *scrolled_window = user_data;
GtkWidget *hscrollbar;
GtkWidget *web_view;
- gint new_height;
+ gint new_height, width;
web_view = gtk_bin_get_child (GTK_BIN (scrolled_window));
gtk_widget_get_preferred_height (web_view, &new_height, NULL);
@@ -730,7 +754,8 @@ mail_display_on_web_view_sw_vadjustment_changed (GtkAdjustment* adjustment,
new_height += scrollbar_height;
}
- gtk_widget_set_size_request (scrolled_window, -1, new_height);
+ gtk_widget_get_size_request (scrolled_window, &width, NULL);
+ gtk_widget_set_size_request (scrolled_window, width, new_height);
}
static GtkWidget*
@@ -738,7 +763,7 @@ mail_display_insert_web_view (EMailDisplay *display,
EWebView *web_view)
{
GtkWidget *scrolled_window;
- GtkAdjustment *vadjustment;
+ GtkAdjustment *adjustment;
GdkWindow *window;
display->priv->webviews = g_list_append (display->priv->webviews, web_view);
@@ -746,14 +771,18 @@ mail_display_insert_web_view (EMailDisplay *display,
g_object_set (G_OBJECT (scrolled_window),
"vexpand", FALSE,
"vexpand-set", TRUE,
- "shadow-type", GTK_SHADOW_NONE,
+ "hexpand", FALSE,
+ "hexpand-set", TRUE,
+ "shadow-type", GTK_SHADOW_NONE,
NULL);
- vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window));
- g_signal_connect (G_OBJECT (vadjustment), "changed",
- G_CALLBACK (mail_display_on_web_view_sw_vadjustment_changed), scrolled_window);
- g_signal_connect (G_OBJECT (vadjustment), "value-changed",
+ adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window));
+ g_signal_connect (G_OBJECT (adjustment), "changed",
G_CALLBACK (mail_display_on_web_view_sw_vadjustment_changed), scrolled_window);
+
+ adjustment = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (scrolled_window));
+ g_signal_connect (G_OBJECT (adjustment), "changed",
+ G_CALLBACK (mail_display_on_web_view_sw_hadjustment_changed), scrolled_window);
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view));
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index 6c2cedd..941545c 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -634,8 +634,6 @@ mail_paned_view_constructed (GObject *object)
"headers-collapsable", TRUE, NULL);
widget = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
- GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_scrolled_window_set_shadow_type (
GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (priv->display));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]