Update for 0.51.2-pre2
[wmaker-crm.git] / WPrefs.app / NoMenuAlert.c
blob622303955395081ec45ed5094ac14e3b79620398
1 /* NoMenuAlert.c - warn user that menu can't be edited with WPrefs
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1999 Alfredo K. Kojima
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
24 #include "WPrefs.h"
27 typedef struct NoMenuPanel {
28 WMWindow *wwin;
30 WMLabel *text;
32 WMButton *copyBtn;
33 WMButton *keepBtn;
35 int finished;
36 int copy;
37 } NoMenuPanel;
40 #define MESSAGE_TEXT \
41 " The menu that is being used now could not be opened. "\
42 "This either means that there is a syntax error in it or that "\
43 "the menu is in a format not supported by WPrefs (WPrefs only "\
44 "supports property list menus).\n"\
45 " If you want to keep using the current menu, please read "\
46 "the '%s/%s' file, press 'Keep Current Menu' and edit it with a "\
47 "text editor.\n"\
48 " If you want to use this editor, press 'Copy Default Menu'. "\
49 "It will copy the default menu and will instruct Window Maker "\
50 "to use it instead of the current one.\n"\
51 " If you want more flexibility, keep using the current one "\
52 "as it allows you to use C preprocessor (cpp) macros, while being "\
53 "easy to edit. Window Maker supports both formats."
56 static void
57 closeCallback(WMWidget *self, void *data)
59 NoMenuPanel *panel = (NoMenuPanel*)data;
61 panel->finished = True;
65 static void
66 buttonCallback(WMWidget *self, void *data)
68 NoMenuPanel *panel = (NoMenuPanel*)data;
70 panel->finished = True;
71 if (self == panel->keepBtn)
72 panel->copy = False;
73 else
74 panel->copy = True;
78 Bool
79 AskMenuCopy(WMWindow *wwin)
81 NoMenuPanel panel;
82 char buffer[2048];
84 panel.wwin = WMCreatePanelForWindow(wwin, "noMenuAlert");
85 WMResizeWidget(panel.wwin, 430, 260);
86 WMSetWindowTitle(panel.wwin, "Warning");
87 WMSetWindowCloseAction(panel.wwin, closeCallback, &panel);
89 panel.text = WMCreateLabel(panel.wwin);
90 WMResizeWidget(panel.text, 370, 200);
91 WMMoveWidget(panel.text, 30, 20);
93 sprintf(buffer, _(MESSAGE_TEXT), wusergnusteppath(),
94 "Library/WindowMaker/README");
95 WMSetLabelText(panel.text, buffer);
97 panel.copyBtn = WMCreateCommandButton(panel.wwin);
98 WMResizeWidget(panel.copyBtn, 180, 24);
99 WMMoveWidget(panel.copyBtn, 30, 225);
100 WMSetButtonText(panel.copyBtn, _("Copy Default Menu"));
101 WMSetButtonAction(panel.copyBtn, buttonCallback, &panel);
103 panel.keepBtn = WMCreateCommandButton(panel.wwin);
104 WMResizeWidget(panel.keepBtn, 180, 24);
105 WMMoveWidget(panel.keepBtn, 225, 225);
106 WMSetButtonText(panel.keepBtn, _("Keep Current Menu"));
107 WMSetButtonAction(panel.keepBtn, buttonCallback, &panel);
109 WMMapSubwidgets(panel.wwin);
110 WMRealizeWidget(panel.wwin);
111 WMMapWidget(panel.wwin);
113 panel.finished = False;
114 panel.copy = False;
116 while (!panel.finished) {
117 XEvent event;
119 WMNextEvent(WMScreenDisplay(WMWidgetScreen(panel.wwin)), &event);
120 WMHandleEvent(&event);
123 WMDestroyWidget(panel.wwin);
125 return panel.copy;