[gtkhtml] Bug 615294 - Does not compile with -DGSEAL_ENABLE



commit 4784f0a6a8fe23957917981152a61b402fa30bde
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed May 19 11:37:08 2010 -0400

    Bug 615294 - Does not compile with -DGSEAL_ENABLE

 configure.ac      |    1 +
 gtkhtml/gtkhtml.c |   75 ++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 70 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 16dc7dd..018145f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,7 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
 	-DGNOME_DISABLE_DEPRECATED
 	-DG_DISABLE_SINGLE_INCLUDES
 	-DGTK_DISABLE_SINGLE_INCLUDES
+	-DGSEAL_ENABLE
 	-Wall -Wextra
 	-Wno-missing-field-initializers
 	-Wno-sign-compare
diff --git a/gtkhtml/gtkhtml.c b/gtkhtml/gtkhtml.c
index f666fc0..e9e7db4 100644
--- a/gtkhtml/gtkhtml.c
+++ b/gtkhtml/gtkhtml.c
@@ -1280,12 +1280,79 @@ child_size_allocate (HTMLObject *o, HTMLEngine *e, gpointer data)
 }
 
 static void
+set_adjustment_upper (GtkAdjustment *adjustment,
+                      gdouble upper)
+{
+	gdouble page_size;
+	gdouble value;
+	gdouble min;
+
+	/* XXX Stolen from gtklayout.c and simplified. */
+
+	value = gtk_adjustment_get_value (adjustment);
+	page_size = gtk_adjustment_get_page_size (adjustment);
+	min = MAX (0., upper - page_size);
+
+	gtk_adjustment_set_upper (adjustment, upper);
+
+	if (value > min)
+		gtk_adjustment_set_value (adjustment, min);
+}
+
+static void
+gtk_layout_faux_size_allocate (GtkWidget *widget,
+                               GtkAllocation *allocation)
+{
+	GtkLayout *layout = GTK_LAYOUT (widget);
+	GtkAdjustment *adjustment;
+	guint width, height;
+
+	/* XXX This is essentially a copy of GtkLayout's size_allocate()
+	 *     method, but with the GtkLayoutChild loop removed.  We call
+	 *     this instead of chaining up to GtkLayout. */
+
+	gtk_widget_set_allocation (widget, allocation);
+	gtk_layout_get_size (layout, &width, &height);
+
+	if (gtk_widget_get_realized (widget)) {
+		gdk_window_move_resize (
+			gtk_widget_get_window (widget),
+			allocation->x, allocation->y,
+			allocation->width, allocation->height);
+
+		gdk_window_resize (
+			gtk_layout_get_bin_window (layout),
+			MAX (width, allocation->width),
+			MAX (height, allocation->height));
+	}
+
+	/* XXX Does the previous logic alter the GtkLayout size?
+	 *     Not sure, so best refetch the size just to be safe. */
+	gtk_layout_get_size (layout, &width, &height);
+
+	adjustment = gtk_layout_get_hadjustment (layout);
+	g_object_freeze_notify (G_OBJECT (adjustment));
+	gtk_adjustment_set_page_size (adjustment, allocation->width);
+	gtk_adjustment_set_page_increment (adjustment, allocation->width * 0.9);
+	gtk_adjustment_set_lower (adjustment, 0);
+	set_adjustment_upper (adjustment, MAX (allocation->width, width));
+	g_object_thaw_notify (G_OBJECT (adjustment));
+
+	adjustment = gtk_layout_get_vadjustment (layout);
+	g_object_freeze_notify (G_OBJECT (adjustment));
+	gtk_adjustment_set_page_size (adjustment, allocation->height);
+	gtk_adjustment_set_page_increment (adjustment, allocation->height * 0.9);
+	gtk_adjustment_set_lower (adjustment, 0);
+	set_adjustment_upper (adjustment, MAX (allocation->height, height));
+	g_object_thaw_notify (G_OBJECT (adjustment));
+}
+
+static void
 size_allocate (GtkWidget *widget, GtkAllocation *allocation)
 {
 	GtkHTML *html;
 	GtkLayout *layout;
 	gboolean changed_x = FALSE, changed_y = FALSE;
-	GList *children;
 
 	g_return_if_fail (widget != NULL);
 	g_return_if_fail (GTK_IS_HTML (widget));
@@ -1296,11 +1363,7 @@ size_allocate (GtkWidget *widget, GtkAllocation *allocation)
 
 	/* isolate childs from layout - we want to set them after calc size is performed
 	   and we know the children positions */
-	children = GTK_LAYOUT (widget)->children;
-	GTK_LAYOUT (widget)->children = NULL;
-	if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
-		(*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
-	GTK_LAYOUT (widget)->children = children;
+	gtk_layout_faux_size_allocate (widget, allocation);
 
 	if (html->engine->width != allocation->width
 	    || html->engine->height != allocation->height) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]