From aa0f8e10254824b85a93d67030a9f014e2cbf4f1 Mon Sep 17 00:00:00 2001 From: fliep Date: Sun, 3 May 2009 15:22:18 +0000 Subject: [PATCH] Now pays attention to the GtkContainer "border-width" property when allocating size --- src/chimara-glk.c | 23 +++++++++++++++++------ src/main.c | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/chimara-glk.c b/src/chimara-glk.c index fd5d065..57846cb 100644 --- a/src/chimara-glk.c +++ b/src/chimara-glk.c @@ -228,11 +228,16 @@ chimara_glk_size_request(GtkWidget *widget, GtkRequisition *requisition) ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(widget); /* For now, just pass the size request on to the root Glk window */ - if(priv->root_window) + if(priv->root_window) + { request_recurse(priv->root_window->data, requisition); - else { - requisition->width = CHIMARA_GLK_MIN_WIDTH; - requisition->height = CHIMARA_GLK_MIN_HEIGHT; + requisition->width += 2 * GTK_CONTAINER(widget)->border_width; + requisition->height += 2 * GTK_CONTAINER(widget)->border_width; + } + else + { + requisition->width = CHIMARA_GLK_MIN_WIDTH + 2 * GTK_CONTAINER(widget)->border_width; + requisition->height = CHIMARA_GLK_MIN_HEIGHT + 2 * GTK_CONTAINER(widget)->border_width; } } @@ -342,8 +347,14 @@ chimara_glk_size_allocate(GtkWidget *widget, GtkAllocation *allocation) widget->allocation = *allocation; - if(priv->root_window) - allocate_recurse(priv->root_window->data, allocation); + if(priv->root_window) { + GtkAllocation child; + child.x = allocation->x + GTK_CONTAINER(widget)->border_width; + child.y = allocation->y + GTK_CONTAINER(widget)->border_width; + child.width = allocation->width - 2 * GTK_CONTAINER(widget)->border_width; + child.height = allocation->height - 2 * GTK_CONTAINER(widget)->border_width; + allocate_recurse(priv->root_window->data, &child); + } } /* Recursively invoke callback() on the GtkWidget of each non-pair window in the tree */ diff --git a/src/main.c b/src/main.c index 13de35c..bbad7e3 100644 --- a/src/main.c +++ b/src/main.c @@ -72,6 +72,7 @@ create_window(void) gtk_builder_connect_signals(builder, NULL); glk = chimara_glk_new(); + g_object_set(glk, "border-width", 6, NULL); chimara_glk_set_default_font_string(CHIMARA_GLK(glk), "Sans 11"); chimara_glk_set_monospace_font_string(CHIMARA_GLK(glk), "Monospace 10"); g_signal_connect(glk, "started", G_CALLBACK(on_started), NULL); -- 2.30.2