[gtkhtml/gtk3] Bug #635571 - Adapt size_request to gtk-3.0 change
- From: Vibha Yadav <yvibha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkhtml/gtk3] Bug #635571 - Adapt size_request to gtk-3.0 change
- Date: Thu, 2 Dec 2010 12:14:00 +0000 (UTC)
commit d5f996e934d9d18ad8572d0c8e5f63dc4645d1b6
Author: Vibha Yadav <yvibha novell com>
Date: Thu Dec 2 17:40:44 2010 +0530
Bug #635571 - Adapt size_request to gtk-3.0 change
Build is failing as size_request is deprecated from GtkWidgetClass
Using get_preferred_width and get_preferred_height instead of
size_request.
components/editor/gtkhtml-color-combo.c | 22 +++++++++++++++---
components/editor/gtkhtml-color-swatch.c | 22 +++++++++++++++---
gtkhtml/gtkhtml-embedded.c | 33 +++++++++++++++++++++-----
gtkhtml/gtkhtml.c | 36 ++++++++++++++++++++---------
4 files changed, 87 insertions(+), 26 deletions(-)
---
diff --git a/components/editor/gtkhtml-color-combo.c b/components/editor/gtkhtml-color-combo.c
index 18cc6ac..56c9db9 100644
--- a/components/editor/gtkhtml-color-combo.c
+++ b/components/editor/gtkhtml-color-combo.c
@@ -603,14 +603,27 @@ color_combo_dispose (GObject *object)
}
static void
-color_combo_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+color_combo_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
GtkhtmlColorComboPrivate *priv;
priv = GTKHTML_COLOR_COMBO_GET_PRIVATE (widget);
- gtk_widget_get_preferred_size (priv->toggle_button, requisition, NULL);
+ gtk_widget_get_preferred_width (priv->toggle_button, minimum_width, natural_width);
+}
+
+static void
+color_combo_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GtkhtmlColorComboPrivate *priv;
+
+ priv = GTKHTML_COLOR_COMBO_GET_PRIVATE (widget);
+
+ gtk_widget_get_preferred_height (priv->toggle_button, minimum_height, natural_height);
}
static void
@@ -711,7 +724,8 @@ color_combo_class_init (GtkhtmlColorComboClass *class)
object_class->dispose = color_combo_dispose;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->size_request = color_combo_size_request;
+ widget_class->get_preferred_width = color_combo_get_preferred_width;
+ widget_class->get_preferred_height = color_combo_get_preferred_height;
widget_class->size_allocate = color_combo_size_allocate;
class->popup = color_combo_popup;
diff --git a/components/editor/gtkhtml-color-swatch.c b/components/editor/gtkhtml-color-swatch.c
index 523e229..7100ebb 100644
--- a/components/editor/gtkhtml-color-swatch.c
+++ b/components/editor/gtkhtml-color-swatch.c
@@ -137,14 +137,27 @@ color_swatch_dispose (GObject *object)
}
static void
-color_swatch_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+color_swatch_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
GtkhtmlColorSwatchPrivate *priv;
priv = GTKHTML_COLOR_SWATCH_GET_PRIVATE (widget);
- gtk_widget_get_preferred_size (priv->frame, requisition, NULL);
+ gtk_widget_get_preferred_width (priv->frame, minimum_width, natural_width);
+}
+
+static void
+color_swatch_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GtkhtmlColorSwatchPrivate *priv;
+
+ priv = GTKHTML_COLOR_SWATCH_GET_PRIVATE (widget);
+
+ gtk_widget_get_preferred_height (priv->frame, minimum_height, natural_height);
}
static void
@@ -174,7 +187,8 @@ color_swatch_class_init (GtkhtmlColorSwatchClass *class)
object_class->dispose = color_swatch_dispose;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->size_request = color_swatch_size_request;
+ widget_class->get_preferred_width = color_swatch_get_preferred_width;
+ widget_class->get_preferred_height = color_swatch_get_preferred_height;
widget_class->size_allocate = color_swatch_size_allocate;
g_object_class_install_property (
diff --git a/gtkhtml/gtkhtml-embedded.c b/gtkhtml/gtkhtml-embedded.c
index 31719e0..6482633 100644
--- a/gtkhtml/gtkhtml-embedded.c
+++ b/gtkhtml/gtkhtml-embedded.c
@@ -32,7 +32,8 @@
static void gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class);
static void gtk_html_embedded_init (GtkHTMLEmbedded *gspaper);
-static void gtk_html_embedded_size_request (GtkWidget *widget, GtkRequisition *requisition);
+static void gtk_html_embedded_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width);
+static void gtk_html_embedded_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height);
static void gtk_html_embedded_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
/* saved parent calls */
@@ -201,7 +202,8 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
object_class->finalize = gtk_html_embedded_finalize;
- widget_class->size_request = gtk_html_embedded_size_request;
+ widget_class->get_preferred_width = gtk_html_embedded_get_preferred_width;
+ widget_class->get_preferred_height = gtk_html_embedded_get_preferred_height;
widget_class->size_allocate = gtk_html_embedded_size_allocate;
old_add = container_class->add;
@@ -211,23 +213,40 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
}
static void
-gtk_html_embedded_size_request (GtkWidget *widget, GtkRequisition *requisition)
+gtk_html_embedded_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height)
{
GtkWidget *child;
g_return_if_fail (widget != NULL);
- g_return_if_fail (requisition != NULL);
child = gtk_bin_get_child (GTK_BIN (widget));
if (child) {
- gtk_widget_get_preferred_size (child, requisition, NULL);
+ gtk_widget_get_preferred_height (child, minimum_height, natural_height);
} else {
GtkRequisition self_requisition;
gtk_widget_get_requisition (widget, &self_requisition);
- requisition->width = self_requisition.width;
- requisition->height = self_requisition.height;
+ *minimum_height = *natural_height = self_requisition.height;
+ }
+}
+
+static void
+gtk_html_embedded_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width)
+{
+ GtkWidget *child;
+
+ g_return_if_fail (widget != NULL);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
+ if (child) {
+ gtk_widget_get_preferred_width (child, minimum_width, natural_width);
+ } else {
+ GtkRequisition self_requisition;
+
+ gtk_widget_get_requisition (widget, &self_requisition);
+ *minimum_width = *natural_width = self_requisition.width;
}
}
diff --git a/gtkhtml/gtkhtml.c b/gtkhtml/gtkhtml.c
index 4ff98f7..cb59516 100644
--- a/gtkhtml/gtkhtml.c
+++ b/gtkhtml/gtkhtml.c
@@ -1275,25 +1275,38 @@ expose (GtkWidget *widget, GdkEventExpose *event)
#endif
static void
-gtk_html_size_request (GtkWidget *widget, GtkRequisition *requisition)
+gtk_html_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height)
{
HTMLEngine *e = GTK_HTML (widget)->engine;
if (!e->writing) {
- gint old_width, old_height;
+ gint old_height;
- old_width = e->width;
old_height = e->height;
- e->width = requisition->width;
- e->height = requisition->height;
+ e->height = *minimum_height;
html_engine_calc_size (e, NULL);
- requisition->width = html_engine_get_doc_width (e);
- requisition->height = html_engine_get_doc_height (e);
- e->width = old_width;
+ *minimum_height = *natural_height = html_engine_get_doc_height (e);
e->height = old_height;
html_engine_calc_size (e, NULL);
} else {
- requisition->width = html_engine_get_doc_width (e);
- requisition->height = html_engine_get_doc_height (e);
+ *minimum_height = *natural_height = html_engine_get_doc_height (e);
+ }
+}
+
+static void
+gtk_html_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width)
+{
+ HTMLEngine *e = GTK_HTML (widget)->engine;
+ if (!e->writing) {
+ gint old_width;
+
+ old_width = e->width;
+ e->width = *minimum_width;
+ html_engine_calc_size (e, NULL);
+ *minimum_width = *natural_width = html_engine_get_doc_width (e);
+ e->width = old_width;
+ html_engine_calc_size (e, NULL);
+ } else {
+ *minimum_width = *natural_width = html_engine_get_doc_width (e);
}
}
@@ -3218,7 +3231,8 @@ gtk_html_class_init (GtkHTMLClass *klass)
#else
widget_class->expose_event = expose;
#endif
- widget_class->size_request = gtk_html_size_request;
+ widget_class->get_preferred_width = gtk_html_get_preferred_width;
+ widget_class->get_preferred_height = gtk_html_get_preferred_height;
widget_class->size_allocate = size_allocate;
widget_class->motion_notify_event = motion_notify_event;
widget_class->visibility_notify_event = visibility_notify_event;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]