From 52950958d0291eb2b2167319f5863a43f2795669 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Tue, 13 Oct 2009 21:46:00 -0700 Subject: [PATCH] got resizing the window working a bit better using the GtkAspectFrame seems to be working. The whole board is displayed now and the resizing works kind of ;) --- callback.c | 5 +++-- gtk-interface.xml | 1 + interface.c | 17 ----------------- interface.h | 2 +- xboard.c | 3 +++ 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/callback.c b/callback.c index 9abeca0..c8a97bf 100644 --- a/callback.c +++ b/callback.c @@ -60,12 +60,13 @@ ExposeProc(object, user_data) gtk_widget_size_request(GTK_WIDGET(GUI_Buttonbar), &w); totalh += w.height; - ratio = (totalh+boardHeight)/(boardWidth) ; + ratio = ((float)totalh+boardHeight)/((float)boardWidth) ; gtk_widget_set_size_request(GTK_WIDGET(GUI_Board), boardWidth,boardHeight); - GUI_SetAspectRatio(ratio); + gtk_aspect_frame_set (GTK_ASPECT_FRAME(GUI_Aspect),0,0,ratio,TRUE); + /* recreate pieces with new size... TODO: keep svg in memory and just recreate pixmap instead of reloading files */ CreatePieces(); } diff --git a/gtk-interface.xml b/gtk-interface.xml index 4a67cf6..f060108 100644 --- a/gtk-interface.xml +++ b/gtk-interface.xml @@ -1056,6 +1056,7 @@ + False 3 diff --git a/interface.c b/interface.c index b5381c9..ef59a5f 100644 --- a/interface.c +++ b/interface.c @@ -49,20 +49,3 @@ GdkPixbuf *load_pixbuf(char *filename,int size) } return image; } - -void GUI_SetAspectRatio(ratio) - int ratio; -{ - /* sets the aspect ration of the main window */ - GdkGeometry hints; - extern GtkWidget *GUI_Window; - - hints.min_aspect = ratio; - hints.max_aspect = ratio; - - gtk_window_set_geometry_hints (GTK_WINDOW (GUI_Window), - GTK_WIDGET (GUI_Window), - &hints, - GDK_HINT_ASPECT); - return; -} diff --git a/interface.h b/interface.h index b3a457a..10f975b 100644 --- a/interface.h +++ b/interface.h @@ -2,6 +2,7 @@ GtkBuilder *builder=NULL; GtkWidget *GUI_Window=NULL; +GtkWidget *GUI_Aspect=NULL; GtkWidget *GUI_History=NULL; GtkWidget *GUI_Board=NULL; GtkWidget *GUI_Whiteclock=NULL; @@ -30,4 +31,3 @@ GdkCursor *BoardCursor=NULL; GdkPixbuf *load_pixbuf(char *filename,int size); -void GUI_SetAspectRatio(int ratio); diff --git a/xboard.c b/xboard.c index 03261ad..d0345f1 100644 --- a/xboard.c +++ b/xboard.c @@ -2198,6 +2198,9 @@ main(argc, argv) GUI_Window = GTK_WIDGET (gtk_builder_get_object (builder, "MainWindow")); if(!GUI_Window) printf("Error: gtk_builder didn't work!\n"); + GUI_Aspect = GTK_WIDGET (gtk_builder_get_object (builder, "Aspectframe")); + if(!GUI_Aspect) printf("Error: gtk_builder didn't work!\n"); + GUI_History = GTK_WIDGET (gtk_builder_get_object (builder, "MoveHistory")); if(!GUI_History) printf("Error: gtk_builder didn't work!\n"); -- 1.7.0.4