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)
|
int onShouldQuit(void *data)
|
||||||
{
|
{
|
||||||
printf("in onShouldQuit()\n");
|
printf("in onShouldQuit()\n");
|
||||||
|
if (uiMenuItemChecked(shouldQuitItem)) {
|
||||||
uiControlDestroy(uiControl(data));
|
uiControlDestroy(uiControl(data));
|
||||||
return uiMenuItemChecked(shouldQuitItem);
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiBox *mainBox;
|
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
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void onQuitClicked(uiMenuItem *item, uiWindow *w, void *data)
|
||||||
|
{
|
||||||
|
if (shouldQuit())
|
||||||
|
uiQuit();
|
||||||
|
}
|
||||||
|
|
||||||
static void menuItemEnableDisable(struct menuItem *item, gboolean enabled)
|
static void menuItemEnableDisable(struct menuItem *item, gboolean enabled)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
|
@ -110,6 +116,8 @@ static void menuItemOnClicked(uiMenuItem *ii, void (*f)(uiMenuItem *, uiWindow *
|
||||||
{
|
{
|
||||||
struct menuItem *item = (struct menuItem *) ii;
|
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->onClicked = f;
|
||||||
item->onClickedData = data;
|
item->onClickedData = data;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +170,8 @@ static uiMenuItem *newItem(struct menu *m, int type, const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
item->onClicked = defaultOnClicked;
|
item->onClicked = defaultOnClicked;
|
||||||
|
if (item->type == typeQuit)
|
||||||
|
item->onClicked = onQuitClicked;
|
||||||
|
|
||||||
switch (item->type) {
|
switch (item->type) {
|
||||||
case typeCheckbox:
|
case typeCheckbox:
|
||||||
|
|
Loading…
Reference in New Issue