got resizing the window working a bit better
authorArun Persaud <arun@nubati.net>
Wed, 14 Oct 2009 04:46:00 +0000 (21:46 -0700)
committerArun Persaud <arun@nubati.net>
Wed, 14 Oct 2009 04:46:00 +0000 (21:46 -0700)
using the GtkAspectFrame seems to be working. The whole board is displayed now and the resizing works kind of ;)

callback.c
gtk-interface.xml
interface.c
interface.h
xboard.c

index 9abeca0..c8a97bf 100644 (file)
@@ -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();
     } 
index 4a67cf6..f060108 100644 (file)
                 <signal name="button_release_event" handler="UserMoveProc"/>
               </object>
               <packing>
+                <property name="fill">False</property>
                 <property name="position">3</property>
               </packing>
             </child>
index b5381c9..ef59a5f 100644 (file)
@@ -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;
-}
index b3a457a..10f975b 100644 (file)
@@ -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);
index 03261ad..d0345f1 100644 (file)
--- 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");