wmgen

Генератор WINGs апликација
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 527cffbc424daf0f053f825dfac4dda0551e18a2
родитељ 4077732b820f482319469f613ee2b56eb35aa71c
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Mon, 11 Dec 2023 20:54:53 +0100

Add Cancel to exit confirmation dialog; add program name output in WMLog

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Mmain.c | 21+++++++++++++++------
измењених датотека: 1, додавања: 15(+), брисања: 6(-)

diff --git a/main.c b/main.c @@ -73,9 +73,7 @@ create_main_window(struct WMNewApp* wma) MyGNUstepWMAttributes attributes; wma->mainwin = WMCreateWindow(wma->scr, "mainwin"); - WMLog(wma, "before WMRealizeWidget\n"); WMRealizeWidget(wma->mainwin); - WMLog(wma, "after WMRealizeWidget\n"); set_mainwin_title(wma); WMSetWindowMinSize(wma->mainwin, 200, 200); WMSetWindowCloseAction(wma->mainwin, exit_action, wma); @@ -94,7 +92,6 @@ create_main_window(struct WMNewApp* wma) &attributes); WMMapSubwidgets(wma->mainwin); - WMLog(wma, "WMRealizeWidget\n"); WMMapWidget(wma->mainwin); } @@ -127,10 +124,20 @@ exit_action(WMWidget* self, void* data) if (!wma->state.dirty) exit(0); - if (WMRunAlertPanel(wma->scr, NULL, "Confirm", - "Document %s is modified. Save changes?", "Yes", "No", NULL) - == 0) + switch (WMRunAlertPanel(wma->scr, NULL, "Confirm", + "Document %s is modified. Save changes?", "Yes", "No", "Cancel")) + { + case 0: + WMLog(wma, "Saving changes!\n"); + exit(0); + break; + case 1: + WMLog(wma, "NOT saving changes!\n"); exit(0); + break; + default: + WMLog(wma, "Canceled exit!\n"); + } } void @@ -275,6 +282,7 @@ WMLog(const struct WMNewApp* wma, const char* msg, ...) return; va_start(arg, msg); + fprintf(stderr, "%s: ", program_name); vfprintf(stderr, msg, arg); va_end(arg); } @@ -304,6 +312,7 @@ main(int argc, char** argv) init_state(&wma.state); wma.state.debug = dbg; + //wma.state.dirty = 1; WMInitializeApplication("WMNewApp", &argc, argv);