From 28620a5398a51fe9e4105958b1c61164e852d67f Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Tue, 21 Oct 2014 11:35:21 +0200 Subject: [PATCH] Let GTK dialogs open with actual-size Graph widgets The Graph Option size values are now uses as size_request, to give proper dialog sizing at popup. But the size_request is then reset so that free sizing by the user becomes possible. --- gtk/xboard.c | 2 ++ gtk/xoptions.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/gtk/xboard.c b/gtk/xboard.c index 88550f7..f02762e 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -650,9 +650,11 @@ ResizeBoardWindow (int w, int h, int inhibit) gtk_widget_get_allocation(shellWidget, &a); marginW = a.width - bw; gtk_widget_get_allocation(optList[W_WHITE].handle, &a); + gtk_widget_set_size_request(optList[W_BOARD].handle, w, h); // protect board widget w += marginW + 1; // [HGM] not sure why the +1 is (sometimes) needed... h += marginH + a.height + 1; gtk_window_resize(GTK_WINDOW(shellWidget), w, h); + gtk_widget_set_size_request(optList[W_BOARD].handle, -1, -1); // liberate board again } int diff --git a/gtk/xoptions.c b/gtk/xoptions.c index 0d36830..29be641 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -1529,7 +1529,7 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); break; case Graph: option[i].handle = (void*) (graph = gtk_drawing_area_new()); -// gtk_widget_set_size_request(graph, option[i].max, option[i].value); + gtk_widget_set_size_request(graph, option[i].max, option[i].value); if(0){ GtkAllocation a; a.x = 0; a.y = 0; a.width = option[i].max, a.height = option[i].value; gtk_widget_set_allocation(graph, &a); @@ -1666,6 +1666,9 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); gtk_window_resize(GTK_WINDOW(dialog), wp[dlgNr]->width, wp[dlgNr]->height); } + for(i=0; option[i].type != EndMark; i++) if(option[i].type == Graph) + gtk_widget_set_size_request(option[i].handle, -1, -1); // remove size requests after realization, so user can shrink + return 1; // tells caller he must do initialization (e.g. add specific event handlers) } -- 1.7.0.4