[gtk+/treeview-refactor] Remove size_request from GtkCheckButton
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor] Remove size_request from GtkCheckButton
- Date: Sat, 30 Oct 2010 08:31:35 +0000 (UTC)
commit 2e4e7264e6d4c0b7876a5773159d3c570cdf87bb
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Oct 26 21:29:58 2010 -0400
Remove size_request from GtkCheckButton
gtk/gtkcheckbutton.c | 103 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 77 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index fa99380..9a9b344 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -38,8 +38,12 @@
#define INDICATOR_SPACING 2
-static void gtk_check_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+static void gtk_check_button_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void gtk_check_button_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
static void gtk_check_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gboolean gtk_check_button_draw (GtkWidget *widget,
@@ -57,10 +61,11 @@ static void
gtk_check_button_class_init (GtkCheckButtonClass *class)
{
GtkWidgetClass *widget_class;
-
+
widget_class = (GtkWidgetClass*) class;
-
- widget_class->size_request = gtk_check_button_size_request;
+
+ widget_class->get_preferred_width = gtk_check_button_get_preferred_width;
+ widget_class->get_preferred_height = gtk_check_button_get_preferred_height;
widget_class->size_allocate = gtk_check_button_size_allocate;
widget_class->draw = gtk_check_button_draw;
@@ -195,14 +200,61 @@ _gtk_check_button_get_props (GtkCheckButton *check_button,
}
static void
-gtk_check_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+gtk_check_button_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget);
if (gtk_toggle_button_get_mode (toggle_button))
{
GtkWidget *child;
+ gint indicator_size;
+ gint indicator_spacing;
+ gint focus_width;
+ gint focus_pad;
+ guint border_width;
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ gtk_widget_style_get (GTK_WIDGET (widget),
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
+ *minimum = 2 * border_width;
+ *natural = 2 * border_width;
+
+ _gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
+ &indicator_size, &indicator_spacing);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child && gtk_widget_get_visible (child))
+ {
+ gint child_min, child_nat;
+
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
+
+ *minimum += child_min + indicator_spacing;
+ *natural += child_nat + indicator_spacing;
+ }
+
+ *minimum += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
+ *natural += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
+ }
+ else
+ GTK_WIDGET_CLASS (gtk_check_button_parent_class)->get_preferred_width (widget, minimum, natural);
+}
+
+static void
+gtk_check_button_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget);
+
+ if (gtk_toggle_button_get_mode (toggle_button))
+ {
+ GtkWidget *child;
gint temp;
gint indicator_size;
gint indicator_spacing;
@@ -213,34 +265,33 @@ gtk_check_button_size_request (GtkWidget *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_style_get (GTK_WIDGET (widget),
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
-
- requisition->width = border_width * 2;
- requisition->height = border_width * 2;
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
+
+ *minimum = border_width * 2;
+ *natural = border_width * 2;
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
- &indicator_size, &indicator_spacing);
-
+ &indicator_size, &indicator_spacing);
+
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
- {
- GtkRequisition child_requisition;
+ {
+ gint child_min, child_nat;
- gtk_widget_get_preferred_size (child, &child_requisition, NULL);
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
+
+ *minimum += child_min;
+ *natural += child_nat;
+ }
- requisition->width += child_requisition.width + indicator_spacing;
- requisition->height += child_requisition.height;
- }
-
- requisition->width += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
-
temp = indicator_size + indicator_spacing * 2;
- requisition->height = MAX (requisition->height, temp) + 2 * (focus_width + focus_pad);
+ *minimum = MAX (*minimum, temp) + 2 * (focus_width + focus_pad);
+ *natural = MAX (*natural, temp) + 2 * (focus_width + focus_pad);
}
else
- GTK_WIDGET_CLASS (gtk_check_button_parent_class)->size_request (widget, requisition);
+ GTK_WIDGET_CLASS (gtk_check_button_parent_class)->get_preferred_height (widget, minimum, natural);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]