Add context menu to ICS console XB-GTK
[xboard.git] / gtk / xboard.c
index 4c66bdc..7abd7ce 100644 (file)
@@ -523,6 +523,12 @@ GetActualPlacement (GtkWidget *shell, WindowPlacement *wp)
 }
 
 void
+GetPlacement (DialogClass dlg, WindowPlacement *wp)
+{ // wrapper to shield back-end from widget type
+  if(shellUp[dlg]) GetActualPlacement(shells[dlg], wp);
+}
+
+void
 GetWindowCoords ()
 { // wrapper to shield use of window handles from back-end (make addressible by number?)
   // In XBoard this will have to wait until awareness of window parameters is implemented
@@ -533,6 +539,7 @@ GetWindowCoords ()
   if(shellUp[GameListDlg]) GetActualPlacement(shells[GameListDlg], &wpGameList);
   if(shellUp[CommentDlg]) GetActualPlacement(shells[CommentDlg], &wpComment);
   if(shellUp[TagsDlg]) GetActualPlacement(shells[TagsDlg], &wpTags);
+  GetPlacement(ChatDlg, &wpConsole); if(appData.icsActive) wpConsole.visible = shellUp[ChatDlg];
 }
 
 void
@@ -752,7 +759,7 @@ int
 main (int argc, char **argv)
 {
     int i, clockFontPxlSize, coordFontPxlSize, fontPxlSize;
-    int boardWidth, boardHeight, w, h;
+    int boardWidth, w, h; //, boardHeight;
     char *p;
     int forceMono = False;
 
@@ -967,7 +974,7 @@ main (int argc, char **argv)
 
     /* [HR] height treated separately (hacked) */
     boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
-    boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
+//    boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
 
     /*
      * Determine what fonts to use.
@@ -1121,6 +1128,11 @@ main (int argc, char **argv)
       EngineOutputPopUp();
     }
 
+    if( wpConsole.visible && appData.icsActive ) {
+      ChatProc();
+      BoardToTop();
+    }
+
     InitBackEnd2();
 
     if (errorExitStatus == -1) {
@@ -1359,7 +1371,7 @@ EnableNamedMenuItem (char *menuRef, int state)
 {
     MenuItem *item = MenuNameToItem(menuRef);
 
-    if(item) gtk_widget_set_sensitive(item->handle, state);
+    if(item && item->handle) gtk_widget_set_sensitive(item->handle, state);
 }
 
 void
@@ -1560,6 +1572,7 @@ DragProc ()
            if(shellUp[HistoryDlg]) CoDrag(shells[HistoryDlg], &wpMoveHistory);
            if(shellUp[EvalGraphDlg]) CoDrag(shells[EvalGraphDlg], &wpEvalGraph);
            if(shellUp[GameListDlg]) CoDrag(shells[GameListDlg], &wpGameList);
+           if(shellUp[ChatDlg]) CoDrag(shells[ChatDlg], &wpConsole);
         }
        wpMain = wpNew;
        DrawPosition(True, NULL);