add close buttons to gtk windows
authorArun Persaud <arun@nubati.net>
Sun, 17 Feb 2013 18:49:21 +0000 (10:49 -0800)
committerArun Persaud <arun@nubati.net>
Sun, 17 Feb 2013 18:49:21 +0000 (10:49 -0800)
use windows instead of dialogs for toplevel elements

gtk/xboard.c
gtk/xoptions.c

index b3a76bd..daf49d6 100644 (file)
@@ -976,7 +976,7 @@ main (int argc, char **argv)
 //printf("start size (%d,%d), %dx%d\n", a.x, a.y, w, h);
        gtk_widget_get_allocation(boardWidget, &a);
        marginW =  w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board
-       marginH =  h - a.height - 25; // subtract 25, because GTK seems to insert this amount of extra empty space
+       marginH =  h - a.height;
        gtk_window_resize(GTK_WINDOW(shellWidget), marginW + boardWidth, marginH + boardHeight);
 //printf("margins h=%d v=%d\n", marginW, marginH);
     }
index 5b4867c..2c48446 100644 (file)
@@ -1132,16 +1132,26 @@ printf("n=%d, h=%d, w=%d\n",n,height,width);
       XtCreatePopupShell(title, !top || !appData.topLevel ? transientShellWidgetClass : topLevelShellWidgetClass,
                                                            shells[parent], args, i);
 #endif
-    dialog = gtk_dialog_new_with_buttons( title,
-                                      GTK_WINDOW(shells[parent]),
-                                     GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR |
-                                          (modal ? GTK_DIALOG_MODAL : 0),
-                                      GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-                                      GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
-                                      NULL );
+
+    if(topLevel)
+      {
+       dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       box = gtk_vbox_new(FALSE,0);
+       gtk_container_add (GTK_CONTAINER (dialog), box);
+      }
+    else
+      {
+       dialog = gtk_dialog_new_with_buttons( title,
+                                             GTK_WINDOW(shells[parent]),
+                                             GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR |
+                                             (modal ? GTK_DIALOG_MODAL : 0),
+                                             GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+                                             GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+                                             NULL );
+       box = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) );
+      }
 
     shells[dlgNr] = dialog;
-    box = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) );
 //    gtk_box_set_spacing(GTK_BOX(box), 5);
 
     arraysize = 0;
@@ -1489,17 +1499,19 @@ printf("n=%d, h=%d, w=%d\n",n,height,width);
     option[i].handle = (void *) table; // remember last table in EndMark handle (for hiding Engine-Output pane).
 
     gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_NONE);
+
     /* Show dialog */
     gtk_widget_show_all( dialog );
 
     /* hide OK/cancel buttons */
-    if((option[i].min & NO_OK)) {
+    if(!topLevel)
+      if((option[i].min & NO_OK)) {
         actionarea = gtk_dialog_get_action_area(GTK_DIALOG(dialog));
         gtk_widget_hide(actionarea);
-    } else if((option[i].min & NO_CANCEL)) {
+      } else if((option[i].min & NO_CANCEL)) {
         button = gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_REJECT);
         gtk_widget_hide(button);
-    }
+      }
 
     g_signal_connect (dialog, "response",
                       G_CALLBACK (GenericPopDown),