Initial mouse wheel code.
[wmaker-crm.git] / WPrefs.app / NoMenuAlert.c
blob778d6c78b83b21ebce4d3af01127e4104f443057
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,
94 _(" The menu that is being used now could not be opened. "
95 "This either means that there is a syntax error in it or that "
96 "the menu is in a format not supported by WPrefs (WPrefs only "
97 "supports property list menus).\n"
98 " If you want to keep using the current menu, please read "
99 "the '%s/%s' file, press 'Keep Current Menu' and edit it with a "
100 "text editor.\n"
101 " If you want to use this editor, press 'Copy Default Menu'. "
102 "It will copy the default menu and will instruct Window Maker "
103 "to use it instead of the current one.\n"
104 " If you want more flexibility, keep using the current one "
105 "as it allows you to use C preprocessor (cpp) macros, while being "
106 "easy to edit. Window Maker supports both formats."),
107 wusergnusteppath(), "Library/WindowMaker/README");
108 WMSetLabelText(panel.text, buffer);
110 panel.copyBtn = WMCreateCommandButton(panel.wwin);
111 WMResizeWidget(panel.copyBtn, 180, 24);
112 WMMoveWidget(panel.copyBtn, 30, 225);
113 WMSetButtonText(panel.copyBtn, _("Copy Default Menu"));
114 WMSetButtonAction(panel.copyBtn, buttonCallback, &panel);
116 panel.keepBtn = WMCreateCommandButton(panel.wwin);
117 WMResizeWidget(panel.keepBtn, 180, 24);
118 WMMoveWidget(panel.keepBtn, 225, 225);
119 WMSetButtonText(panel.keepBtn, _("Keep Current Menu"));
120 WMSetButtonAction(panel.keepBtn, buttonCallback, &panel);
122 WMMapSubwidgets(panel.wwin);
123 WMRealizeWidget(panel.wwin);
124 WMMapWidget(panel.wwin);
126 panel.finished = False;
127 panel.copy = False;
129 while (!panel.finished) {
130 XEvent event;
132 WMNextEvent(WMScreenDisplay(WMWidgetScreen(panel.wwin)), &event);
133 WMHandleEvent(&event);
136 WMDestroyWidget(panel.wwin);
138 return panel.copy;