Implemented the ShouldQuit() stuff for the Quit menu item on the GTK+ backend.
This commit is contained in:
parent
c062d2d0b5
commit
5ef355f28f
|
@ -23,8 +23,11 @@ int onClosing(uiWindow *w, void *data)
|
|||
int onShouldQuit(void *data)
|
||||
{
|
||||
printf("in onShouldQuit()\n");
|
||||
uiControlDestroy(uiControl(data));
|
||||
return uiMenuItemChecked(shouldQuitItem);
|
||||
if (uiMenuItemChecked(shouldQuitItem)) {
|
||||
uiControlDestroy(uiControl(data));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uiBox *mainBox;
|
||||
|
|
10
unix/menu.c
10
unix/menu.c
|
@ -81,6 +81,12 @@ static void defaultOnClicked(uiMenuItem *item, uiWindow *w, void *data)
|
|||
// do nothing
|
||||
}
|
||||
|
||||
static void onQuitClicked(uiMenuItem *item, uiWindow *w, void *data)
|
||||
{
|
||||
if (shouldQuit())
|
||||
uiQuit();
|
||||
}
|
||||
|
||||
static void menuItemEnableDisable(struct menuItem *item, gboolean enabled)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
|
@ -110,6 +116,8 @@ static void menuItemOnClicked(uiMenuItem *ii, void (*f)(uiMenuItem *, uiWindow *
|
|||
{
|
||||
struct menuItem *item = (struct menuItem *) ii;
|
||||
|
||||
if (item->type == typeQuit)
|
||||
complain("attempt to call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead");
|
||||
item->onClicked = f;
|
||||
item->onClickedData = data;
|
||||
}
|
||||
|
@ -162,6 +170,8 @@ static uiMenuItem *newItem(struct menu *m, int type, const char *name)
|
|||
}
|
||||
|
||||
item->onClicked = defaultOnClicked;
|
||||
if (item->type == typeQuit)
|
||||
item->onClicked = onQuitClicked;
|
||||
|
||||
switch (item->type) {
|
||||
case typeCheckbox:
|
||||
|
|
Loading…
Reference in New Issue