Hmm, strange that the gtk_widget_hide(menuBar) doesn't seem to have any effect. But we could of course prevent it from becoming part of the main window to start with. The examples are all based on the idea that you could not alter anything in the original creation of the window by GTK, so that you had to undo part of it later by hiding the stuff you did not want. But in XBoard the creation is not hidden inside the interpretation of some .xml file by some library routine, and we have direct access to the routine that does the creation.
So for the menu bar, we can comment out the gtk_table_attach in the BarEnd case just above the new code, by prefixing it with // . You might also add an extra 'top--;' there. ('top' is a counter that counts the number of rows in the table. By default it is incremented for every Option encountered in the description table (mainOptions in dialogs.c in our case). So for options that go onto the same row as a previous one it has to be decremented again, and DropDown and BarEnd belong to the same row as BarBegin. But if even BarBegin does not require a row, because we want to suppress the menu bar completely, we have to undo the increment of 'top' for that one too. 'top--;' subtracts 1 from top. Not sure this is important, however; GTK might be smart enough to collapse a table row with nothing on it to zero height anyway.)
To remove the Quit item from the file menu, you could simply delete (or comment out) the corresponding line from the 'fileMenu' description table in menus.c:
Code: Select all
MenuItem fileMenu[] = {
{N_("New Game"), "<Ctrl>n", "NewGame", ResetGameEvent},
{N_("New Shuffle Game ..."), NULL, "NewShuffleGame", ShuffleMenuProc},
{N_("New Variant ..."), "<Alt><Shift>v", "NewVariant", NewVariantProc},// [HGM] variant: not functional yet
{"----", NULL, NULL, NothingProc},
{N_("Load Game"), "<Ctrl>o", "LoadGame", LoadGameProc, CHECK},
{N_("Load Position"), "<Ctrl><Shift>o", "LoadPosition", LoadPositionProc},
{N_("Next Position"), "<Shift>Page_Down", "LoadNextPosition", LoadNextPositionProc},
{N_("Prev Position"), "<Shift>Page_Up", "LoadPreviousPosition", LoadPrevPositionProc},
{"----", NULL, NULL, NothingProc},
{N_("Save Game"), "<Ctrl>s", "SaveGame", SaveGameProc},
{N_("Save Position"), "<Ctrl><Shift>s", "SavePosition", SavePositionProc},
{N_("Save Games as Book"), NULL, "CreateBook", CreateBookDelayed},
{"----", NULL, NULL, NothingProc},
{N_("Mail Move"), NULL, "MailMove", MailMoveEvent},
{N_("Reload CMail Message"), NULL, "ReloadCMailMessage", ReloadCmailMsgProc},
{"----", NULL, NULL, NothingProc},
{N_("Quit "), "<Ctrl>q", "Quit", QuitProc},
{NULL, NULL, NULL, NULL}
};
And also the line above it, to get rid of the separator.
This is a bit of a dubious solution, however, as menu.c is supposed to be shared between all front-ends (while xoptions.c in principle could be completely different, and resides in subdirectories .../xaw/, .../gtk/ and possibly .../osx/). Alternatives would be to use the strategy of the example, let GTK create the item as usual, and then hide it afterwards (when it gets to the BarEnd). For the menu bar the hide did not seem to work, however. Yet another way would be to intercept the item in the routine that creates menus, and suppress its creation there. This makes it more difficult to suppress the menu separator above it as well, though.
Let's try this last method
Code: Select all
static GtkWidget *
CreateMenuPopup (Option *opt, int n, int def)
{ // fromList determines if the item texts are taken from a list of strings, or from a menu table
int i;
GtkWidget *menu, *entry;
MenuItem *mb = (MenuItem *) opt->choice;
menu = gtk_menu_new();
// menu = XtCreatePopupShell(opt->name, simpleMenuWidgetClass, parent, NULL, 0);
for (i=0; 1; i++)
{
char *msg = mb[i].string;
if(!msg) break;
if(!strcmp(msg, "Quit")) continue; // ADDED
if(!strcmp(msg, "----") && !strcmp(mb[i+1].string, "Quit")) continue; // ADDED
if(strcmp(msg, "----")) { //
if(!(opt->min & NO_GETTEXT)) msg = _(msg);
The two lines with the trailing comment '// ADDED' have been added to make it ignore any item named 'Quit' (first line) and any separator followed by an item named 'Quit' (second line). More such lines could be added to suppress the creation of other items.