X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fchimara-glk.c;h=8fd1a1e81b752a430537961253813191dd685ba4;hb=59f3bc1e4f21377c362c1f497fb225711127d7a0;hp=6a4c0d3e07a402aec0ee11ce1132ca1a3912dffa;hpb=467b4ff91ae623a5bdabfab0bda9317364bfe9dd;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 6a4c0d3..8fd1a1e 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -28,27 +28,6 @@ #define CHIMARA_GLK_MIN_WIDTH 0 #define CHIMARA_GLK_MIN_HEIGHT 0 -/* Substitute functions for compiling on iLiad */ - -#if !GTK_CHECK_VERSION(2, 18, 0) -#define gtk_widget_get_allocation(w, a) \ - G_STMT_START { \ - (a)->x = (w)->allocation.x; \ - (a)->y = (w)->allocation.y; \ - (a)->width = (w)->allocation.width; \ - (a)->height = (w)->allocation.height; \ - } G_STMT_END -#define gtk_widget_set_allocation(w, a) \ - G_STMT_START { (w)->allocation = *(a); } G_STMT_END -#define gtk_widget_set_has_window(w, f) \ - G_STMT_START { \ - if(f) \ - GTK_WIDGET_UNSET_FLAGS((w), GTK_NO_WINDOW); \ - else \ - GTK_WIDGET_SET_FLAGS((w), GTK_NO_WINDOW); \ - } G_STMT_END -#endif /* GTK 2.18 */ - /** * SECTION:chimara-glk * @short_description: Widget which executes a Glk program @@ -409,7 +388,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 +415,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. */ @@ -735,18 +746,6 @@ chimara_glk_iliad_screen_update(ChimaraGlk *self, gboolean typing) /* Default signal handler */ } -/* COMPAT: G_PARAM_STATIC_STRINGS only appeared in GTK 2.13.0 */ -#ifndef G_PARAM_STATIC_STRINGS - -/* COMPAT: G_PARAM_STATIC_NAME and friends only appeared in GTK 2.8 */ -#if GTK_CHECK_VERSION(2,8,0) -#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) -#else -#define G_PARAM_STATIC_STRINGS (0) -#endif - -#endif - static void chimara_glk_class_init(ChimaraGlkClass *klass) { @@ -757,7 +756,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);