[gnome-control-center] Prepare for size_request removal in GTK3
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] Prepare for size_request removal in GTK3
- Date: Mon, 8 Nov 2010 13:08:38 +0000 (UTC)
commit f5f5aac5c065e5be0d5c080ffa1c075423c4cef7
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Nov 8 14:07:47 2010 +0100
Prepare for size_request removal in GTK3
https://bugzilla.gnome.org/show_bug.cgi?id=633321
libgnome-control-center/cc-panel.c | 41 ++++++++++++++++++-----------------
panels/datetime/cc-timezone-map.c | 24 +++++++++++++++------
panels/display/scrollarea.c | 35 ++++++++++++++++++++----------
3 files changed, 61 insertions(+), 39 deletions(-)
---
diff --git a/libgnome-control-center/cc-panel.c b/libgnome-control-center/cc-panel.c
index dd9b8cd..9cb5da5 100644
--- a/libgnome-control-center/cc-panel.c
+++ b/libgnome-control-center/cc-panel.c
@@ -124,26 +124,31 @@ cc_panel_finalize (GObject *object)
}
static void
-cc_panel_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+cc_panel_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
{
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
- guint border_width;
+
+ *minimum = *natural = 0;
if ((child = gtk_bin_get_child (bin)))
- {
- GtkRequisition child_requisition;
+ gtk_widget_get_preferred_width (child, minimum, natural);
+}
- gtk_widget_size_request (child, &child_requisition);
+static void
+cc_panel_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GtkBin *bin = GTK_BIN (widget);
+ GtkWidget *child;
- requisition->width = child_requisition.width;
- requisition->height = child_requisition.height;
- }
+ *minimum = *natural = 0;
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- requisition->width += 2 * border_width;
- requisition->height += 2 * border_width;
+ if ((child = gtk_bin_get_child (bin)))
+ gtk_widget_get_preferred_height (child, minimum, natural);
}
static void
@@ -151,18 +156,11 @@ cc_panel_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkAllocation child_allocation;
- guint border_width;
gtk_widget_set_allocation (widget, allocation);
-
child_allocation = *allocation;
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- child_allocation.width -= 2 * border_width;
- child_allocation.height -= 2 * border_width;
-
gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)),
&child_allocation);
}
@@ -178,9 +176,12 @@ cc_panel_class_init (CcPanelClass *klass)
object_class->set_property = cc_panel_set_property;
object_class->finalize = cc_panel_finalize;
- widget_class->size_request = cc_panel_size_request;
+ widget_class->get_preferred_width = cc_panel_get_preferred_width;
+ widget_class->get_preferred_height = cc_panel_get_preferred_height;
widget_class->size_allocate = cc_panel_size_allocate;
+ gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (klass));
+
g_type_class_add_private (klass, sizeof (CcPanelPrivate));
pspec = g_param_spec_object ("shell",
diff --git a/panels/datetime/cc-timezone-map.c b/panels/datetime/cc-timezone-map.c
index 487d09c..342f7c7 100644
--- a/panels/datetime/cc-timezone-map.c
+++ b/panels/datetime/cc-timezone-map.c
@@ -189,18 +189,27 @@ cc_timezone_map_finalize (GObject *object)
/* GtkWidget functions */
static void
-cc_timezone_map_size_request (GtkWidget *widget,
- GtkRequisition *req)
+cc_timezone_map_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
{
CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
- GTK_WIDGET_CLASS (cc_timezone_map_parent_class)->size_request (widget, req);
-
- req->width = gdk_pixbuf_get_width (priv->orig_background) * 0.6;
- req->height = gdk_pixbuf_get_height (priv->orig_background) * 0.6;
+ /* FIXME: should natural == full pixmap size ? */
+ *minimum = *natural = gdk_pixbuf_get_width (priv->orig_background) * 0.6;
}
static void
+cc_timezone_map_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+
+ /* FIXME: should natural == full pixmap size ? */
+ *minimum = *natural = gdk_pixbuf_get_height (priv->orig_background) * 0.6;
+}
+static void
cc_timezone_map_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
@@ -392,7 +401,8 @@ cc_timezone_map_class_init (CcTimezoneMapClass *klass)
object_class->dispose = cc_timezone_map_dispose;
object_class->finalize = cc_timezone_map_finalize;
- widget_class->size_request = cc_timezone_map_size_request;
+ widget_class->get_preferred_width = cc_timezone_map_get_preferred_width;
+ widget_class->get_preferred_height = cc_timezone_map_get_preferred_height;
widget_class->size_allocate = cc_timezone_map_size_allocate;
widget_class->realize = cc_timezone_map_realize;
widget_class->draw = cc_timezone_map_draw;
diff --git a/panels/display/scrollarea.c b/panels/display/scrollarea.c
index 9844dd4..5123511 100644
--- a/panels/display/scrollarea.c
+++ b/panels/display/scrollarea.c
@@ -117,10 +117,14 @@ enum {
static guint signals [LAST_SIGNAL] = { 0 };
-static void foo_scroll_area_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
static gboolean foo_scroll_area_draw (GtkWidget *widget,
cairo_t *cr);
+static void foo_scroll_area_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void foo_scroll_area_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
static void foo_scroll_area_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void foo_scroll_area_set_hadjustment (FooScrollArea *scroll_area,
@@ -224,7 +228,8 @@ foo_scroll_area_class_init (FooScrollAreaClass *class)
object_class->set_property = foo_scroll_area_set_property;
object_class->get_property = foo_scroll_area_get_property;
- widget_class->size_request = foo_scroll_area_size_request;
+ widget_class->get_preferred_width = foo_scroll_area_get_preferred_width;
+ widget_class->get_preferred_height = foo_scroll_area_get_preferred_height;
widget_class->draw = foo_scroll_area_draw;
widget_class->size_allocate = foo_scroll_area_size_allocate;
widget_class->realize = foo_scroll_area_realize;
@@ -944,17 +949,23 @@ foo_scroll_area_set_size (FooScrollArea *scroll_area,
}
static void
-foo_scroll_area_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+foo_scroll_area_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
{
FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
-
- requisition->width = scroll_area->priv->min_width;
- requisition->height = scroll_area->priv->min_height;
-
-#if 0
- g_print ("request %d %d\n", requisition->width, requisition->height);
-#endif
+
+ *minimum = *natural = scroll_area->priv->min_width;
+}
+
+static void
+foo_scroll_area_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
+
+ *minimum = *natural = scroll_area->priv->min_height;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]