[gtk+] Implement get_preferred_width/height in GtkEventBox
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Implement get_preferred_width/height in GtkEventBox
- Date: Fri, 15 Oct 2010 03:05:05 +0000 (UTC)
commit 479dc131eef8793ec8e70f0b7dd929d028f68890
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Oct 14 23:03:39 2010 -0400
Implement get_preferred_width/height in GtkEventBox
And drop size_request.
gtk/gtkeventbox.c | 51 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 35 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c
index e55fdd1..5514e11 100644
--- a/gtk/gtkeventbox.c
+++ b/gtk/gtkeventbox.c
@@ -53,8 +53,12 @@ static void gtk_event_box_realize (GtkWidget *widget);
static void gtk_event_box_unrealize (GtkWidget *widget);
static void gtk_event_box_map (GtkWidget *widget);
static void gtk_event_box_unmap (GtkWidget *widget);
-static void gtk_event_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+static void gtk_event_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void gtk_event_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
static void gtk_event_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gboolean gtk_event_box_draw (GtkWidget *widget,
@@ -84,7 +88,8 @@ gtk_event_box_class_init (GtkEventBoxClass *class)
widget_class->unrealize = gtk_event_box_unrealize;
widget_class->map = gtk_event_box_map;
widget_class->unmap = gtk_event_box_unmap;
- widget_class->size_request = gtk_event_box_size_request;
+ widget_class->get_preferred_width = gtk_event_box_get_preferred_width;
+ widget_class->get_preferred_height = gtk_event_box_get_preferred_height;
widget_class->size_allocate = gtk_event_box_size_allocate;
widget_class->draw = gtk_event_box_draw;
@@ -482,33 +487,47 @@ gtk_event_box_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_event_box_parent_class)->unmap (widget);
}
-
-
static void
-gtk_event_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+gtk_event_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
{
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
- requisition->width = 0;
- requisition->height = 0;
+ if (minimum)
+ *minimum = 0;
+
+ if (natural)
+ *natural = 0;
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
- {
- GtkRequisition child_requisition;
+ gtk_widget_get_preferred_width (child, minimum, natural);
+}
+
+static void
+gtk_event_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GtkBin *bin = GTK_BIN (widget);
+ GtkWidget *child;
- gtk_widget_get_preferred_size (child, &child_requisition, NULL);
+ if (minimum)
+ *minimum = 0;
- requisition->width += child_requisition.width;
- requisition->height += child_requisition.height;
- }
+ if (natural)
+ *natural = 0;
+
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
+ gtk_widget_get_preferred_height (child, minimum, natural);
}
static void
gtk_event_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *allocation)
{
GtkBin *bin;
GtkAllocation child_allocation;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]