summaryrefslogtreecommitdiffstats
path: root/src/view
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-04-22 12:16:02 +0200
committerHans de Goede <hdegoede@redhat.com>2013-04-23 13:49:24 +0200
commitd78dd5bd99f17452f7285915cfd2cd491e41f23d (patch)
tree52da3fd5f48a52fdc35aae9b5ef4d551d0183174 /src/view
parent24182b5be84232fcfcc9e85f773ab0efedcf9748 (diff)
downloadvirt-viewer-d78dd5bd99f17452f7285915cfd2cd491e41f23d.tar.gz
virt-viewer-d78dd5bd99f17452f7285915cfd2cd491e41f23d.tar.xz
virt-viewer-d78dd5bd99f17452f7285915cfd2cd491e41f23d.zip
ovBox: Make get_preferred_width/height differentiate between min and natural
gtk-3's widget size negotiation code differentiates between the minimum size and the natural size of a widget, fix ovBox to pass this along from its underlying widget to its parent. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src/view')
-rw-r--r--src/view/ovBox.c61
1 files changed, 45 insertions, 16 deletions
diff --git a/src/view/ovBox.c b/src/view/ovBox.c
index a3b1130..185b0b7 100644
--- a/src/view/ovBox.c
+++ b/src/view/ovBox.c
@@ -481,9 +481,9 @@ ViewOvBoxUnrealize(GtkWidget *widget) // IN
/*
*-----------------------------------------------------------------------------
*
- * ViewOvBoxSizeRequest --
+ * ViewOvBoxRealSizeRequest --
*
- * "size_request" method of a ViewOvBox.
+ * "size_request" method, generalized to work with both gtk-2 and 3.
*
* Results:
* None
@@ -494,12 +494,12 @@ ViewOvBoxUnrealize(GtkWidget *widget) // IN
*-----------------------------------------------------------------------------
*/
static void
-ViewOvBoxSizeRequest(GtkWidget *widget, // IN
- GtkRequisition *requisition) // OUT
+ViewOvBoxRealSizeRequest(GtkWidget *widget, // IN
+ GtkRequisition *min_in, GtkRequisition *nat_in, // IN
+ GtkRequisition *min_out, GtkRequisition *nat_out) // OUT
{
ViewOvBox *that;
ViewOvBoxPrivate *priv;
- GtkRequisition underR;
gboolean expand;
gboolean fill;
guint padding;
@@ -509,10 +509,8 @@ ViewOvBoxSizeRequest(GtkWidget *widget, // IN
priv = that->priv;
#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_get_preferred_size(priv->under, NULL, &underR);
gtk_widget_get_preferred_size(priv->over, NULL, &priv->overR);
#else
- gtk_widget_size_request(priv->under, &underR);
gtk_widget_size_request(priv->over, &priv->overR);
#endif
@@ -521,10 +519,19 @@ ViewOvBoxSizeRequest(GtkWidget *widget, // IN
"fill", &fill,
"padding", &padding,
NULL);
- requisition->width = MAX(underR.width,
- priv->overR.width + ((expand || fill) ? 0 : padding));
+
min = ViewOvBoxGetActualMin(that);
- requisition->height = MAX(underR.height + min, priv->overR.height);
+
+ if (min_out) {
+ min_out->width = MAX(min_in->width, priv->overR.width +
+ ((expand || fill) ? 0 : padding));
+ min_out->height = MAX(min_in->height + min, priv->overR.height);
+ }
+ if (nat_out) {
+ nat_out->width = MAX(nat_in->width, priv->overR.width +
+ ((expand || fill) ? 0 : padding));
+ nat_out->height = MAX(nat_in->height + min, priv->overR.height);
+ }
}
#if GTK_CHECK_VERSION(3, 0, 0)
@@ -533,11 +540,15 @@ ViewOvBox_get_preferred_width (GtkWidget *widget,
gint *minimal_width,
gint *natural_width)
{
- GtkRequisition requisition;
+ ViewOvBoxPrivate *priv = VIEW_OV_BOX(widget)->priv;
+ GtkRequisition min_in, nat_in, min_out, nat_out;
+
+ gtk_widget_get_preferred_size(priv->under, &min_in, &nat_in);
- ViewOvBoxSizeRequest (widget, &requisition);
+ ViewOvBoxRealSizeRequest(widget, &min_in, &nat_in, &min_out, &nat_out);
- *minimal_width = *natural_width = requisition.width;
+ *minimal_width = min_out.width;
+ *natural_width = nat_out.width;
}
static void
@@ -545,11 +556,29 @@ ViewOvBox_get_preferred_height (GtkWidget *widget,
gint *minimal_height,
gint *natural_height)
{
- GtkRequisition requisition;
+ ViewOvBoxPrivate *priv = VIEW_OV_BOX(widget)->priv;
+ GtkRequisition min_in, nat_in, min_out, nat_out;
+
+ gtk_widget_get_preferred_size(priv->under, &min_in, &nat_in);
+
+ ViewOvBoxRealSizeRequest(widget, &min_in, &nat_in, &min_out, &nat_out);
+
+ *minimal_height = min_out.height;
+ *natural_height = nat_out.height;
+}
+
+#else
+
+static void
+ViewOvBoxSizeRequest(GtkWidget *widget, // IN
+ GtkRequisition *requisition) // OUT
+{
+ ViewOvBoxPrivate *priv = VIEW_OV_BOX(widget)->priv;
+ GtkRequisition min;
- ViewOvBoxSizeRequest (widget, &requisition);
+ gtk_widget_size_request(priv->under, &min);
- *minimal_height = *natural_height = requisition.height;
+ ViewOvBoxRealSizeRequest(widget, &min, NULL, requisition, NULL);
}
#endif