From: Philip Chimento Date: Sat, 25 Aug 2012 19:00:42 +0000 (+0200) Subject: Replace size-request by minimal height-for-width X-Git-Tag: v0.9~26 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=02c13aec1755ce0397011d502a92a80d1f69ea43;p=projects%2Fchimara%2Fchimara.git Replace size-request by minimal height-for-width The size-request method is now gone, in favor of height-for-width allocation. The height-for-width implementation is currently minimal, as described at http://developer.gnome.org/gtk3/stable/ch24s02.html#id1328275 This could be made much nicer. --- diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 6a4c0d3..bb2758a 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -409,7 +409,9 @@ request_recurse(winid_t win, GtkRequisition *requisition, guint spacing) gtk_widget_size_request(win->frame, requisition); } -/* Overrides gtk_widget_size_request */ +/* Old GTK 2 functionality overriding gtk_widget_size_request(); +get_preferred_width() and get_preferred_height() are implemented in terms of +this function. */ static void chimara_glk_size_request(GtkWidget *widget, GtkRequisition *requisition) { @@ -434,6 +436,36 @@ chimara_glk_size_request(GtkWidget *widget, GtkRequisition *requisition) } } +/* Minimal implementation of width-for-height request, in terms of the old +GTK 2 mechanism. FIXME: make this more efficient. */ +static void +chimara_glk_get_preferred_width(GtkWidget *widget, int *minimal, int *natural) +{ + g_return_if_fail(widget || CHIMARA_IS_GLK(widget)); + g_return_if_fail(minimal); + g_return_if_fail(natural); + + GtkRequisition requisition; + + chimara_glk_size_request(widget, &requisition); + *minimal = *natural = requisition.width; +} + +/* Minimal implementation of height-for-width request, in terms of the old +GTK 2 mechanism. FIXME: make this more efficient. */ +static void +chimara_glk_get_preferred_height(GtkWidget *widget, int *minimal, int *natural) +{ + g_return_if_fail(widget || CHIMARA_IS_GLK(widget)); + g_return_if_fail(minimal); + g_return_if_fail(natural); + + GtkRequisition requisition; + + chimara_glk_size_request(widget, &requisition); + *minimal = *natural = requisition.height; +} + /* Recursively give the Glk windows their allocated space. Returns a window containing all children of this window that must be redrawn, or NULL if there are no children that require redrawing. */ @@ -757,7 +789,8 @@ chimara_glk_class_init(ChimaraGlkClass *klass) object_class->finalize = chimara_glk_finalize; GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - widget_class->size_request = chimara_glk_size_request; + widget_class->get_preferred_width = chimara_glk_get_preferred_width; + widget_class->get_preferred_height = chimara_glk_get_preferred_height; widget_class->size_allocate = chimara_glk_size_allocate; GtkContainerClass *container_class = GTK_CONTAINER_CLASS(klass);