File: UCvsFrame.cpp

package info (click to toggle)
gcvs 1.0final-5sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 12,244 kB
  • ctags: 10,630
  • sloc: ansic: 71,709; cpp: 39,780; sh: 18,434; makefile: 1,912; yacc: 1,299; tcl: 1,283; perl: 910; lex: 249; csh: 185; lisp: 7
file content (324 lines) | stat: -rwxr-xr-x 9,500 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 1, or (at your option)
** any later version.

** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.

** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
 * Author : Alexandre Parenteau <aubonbeurre@hotmail.com> --- February 2000
 */

/*
 * 
 */

#include "stdafx.h"

#if qGTK
#	include <gtk/gtk.h>
#endif

#include "UCvsFrame.h"
#include "UCvsApp.h"
#include "UCvsCommands.h"
#include "UCvsFolders.h"
#include "CvsAlert.h"
#include "PromptFiles.h"
#include "CvsPrefs.h"
#include "AppConsole.h"
#include "CvsCommands.h"
#include "TclGlue.h"
#include "MacrosSetup.h"
#include "GetPrefs.h"
#include "UCvsDialogs.h"
#include "AboutDlg.h"

UIMPLEMENT_DYNAMIC(UCvsFrame, UWidget)

UBEGIN_MESSAGE_MAP(UCvsFrame, UWidget)
	ON_UUPDATECMD_RANGE(cmdABOUT, cmdABOUT, UCvsFrame::OnCmdUIAnytime)
	ON_UUPDATECMD_RANGE(cmdCREDITS, cmdCOPYRIGHTS, UCvsFrame::OnCmdUIAnytime)
	ON_UUPDATECMD_RANGE(UCvsFrame::kDirCombo, UCvsFrame::kBrowserPopup, UCvsFrame::OnCmdUIAnytime)
	ON_UUPDATECMD(cmdEXIT, UCvsFrame::OnCmdUIQuit)
	ON_UUPDATECMD_RANGE(cmdPREFERENCES, cmdPREFERENCES, UCvsFrame::OnCmdUIAnytime)
	ON_UUPDATECMD(cmdSTOPCVS, UCvsFrame::OnCmdUIStopcvs)
	ON_UUPDATECMD(cmdRTAGCREATE, UCvsFrame::OnCmdUICvsCmd)
	ON_UUPDATECMD(cmdSAVESETTINGS, UCvsFrame::OnCmdUICvsCmd)
	ON_UUPDATECMD(cmdINIT, UCvsFrame::OnCmdUICvsCmd)
	ON_UUPDATECMD(cmdRTAGDELETE, UCvsFrame::OnCmdUICvsCmd)
	ON_UUPDATECMD(cmdRTAGBRANCH, UCvsFrame::OnCmdUICvsCmd)
	ON_UUPDATECMD(cmdCMDLINE, UCvsFrame::OnCmdUICvsCmd)
	ON_UUPDATECMD(cmdLOGIN, UCvsFrame::OnCmdUICvsCmd)
	ON_UUPDATECMD(cmdLOGOUT, UCvsFrame::OnCmdUICvsCmd)
	ON_UUPDATECMD_RANGE(cmdMACROADMIN, cmdMACROADMINEND, UCvsFrame::OnCmdUIMacroAdmin)
	ON_COMBO_SEL(UCvsFrame::kDirCombo, UCvsFrame::OnComboSelDir)
	ON_UCOMMAND(UCvsFrame::kBrowserPopup, UCvsFrame::OnBrowserPopup)
	ON_UCOMMAND(cmdCOPYRIGHTS, UCvsFrame::OnCopyrights)
	ON_UCOMMAND(cmdCREDITS, UCvsFrame::OnCredits)
	ON_UCOMMAND(cmdABOUT, UCvsFrame::OnAbout)
	ON_UCOMMAND(cmdEXIT, UCvsFrame::OnQuit)
	ON_UCOMMAND(cmdPREFERENCES, UCvsFrame::OnCmdPreferences)
	ON_UCOMMAND(cmdSAVESETTINGS, UCvsFrame::OnCmdSaveSettings)
	ON_UCOMMAND(cmdRTAGCREATE, UCvsFrame::OnCmdRtagNew)
	ON_UCOMMAND(cmdRTAGDELETE, UCvsFrame::OnCmdRtagDelete)
	ON_UCOMMAND(cmdRTAGBRANCH, UCvsFrame::OnCmdRtagBranch)
	ON_UCOMMAND(cmdCMDLINE, UCvsFrame::OnCmdCmdline)
	ON_UCOMMAND(cmdLOGIN, UCvsFrame::OnCmdLogin)
	ON_UCOMMAND(cmdLOGOUT, UCvsFrame::OnCmdLogout)
	ON_UCOMMAND(cmdSTOPCVS, UCvsFrame::OnCmdStopcvs)
	ON_UCOMMAND(cmdINIT, UCvsFrame::OnCmdInit)
	ON_UCOMMAND_RANGE(cmdMACROADMIN, cmdMACROADMINEND, UCvsFrame::OnCmdMacroAdmin)
	ON_UDESTROY(UCvsFrame)
UEND_MESSAGE_MAP()

#if 0
	//}}AFX_MSG_MAP
	// Enable default OLE container implementation
	//ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, CDocument::OnUpdatePasteMenu)
	ON_COMMAND_EX_RANGE(ID_MACRO_ADMIN, ID_MACRO_ADMIN + 99, OnMacroAdmin)
	ON_COMMAND(ID_FILE_SEND_MAIL, OnFileSendMail)
	ON_UPDATE_COMMAND_UI(ID_FILE_SEND_MAIL, OnUpdateFileSendMail)
#endif

UCvsFrame::UCvsFrame() : UWidget(kUCvsFrameID)
{
}

UCvsFrame::~UCvsFrame()
{
}

void UCvsFrame::OnDestroy(void)
{
#if qGTK
	gtk_main_quit();
#endif /* qGTK */
	delete this;
}

bool UCvsFrame::AskForQuitting(void)
{
	bool res = true;

	if(UCvsApp::gApp->IsCvsRunning())
		res = !CvsAlert("Cvs is currently running. Are-you sure you want to quit ?", "Cancel", "Quit");

	gCvsPrefs.save();

	return res;
}

void UCvsFrame::OnComboSelDir(int pos, const char *txt)
{
	UCvsApp::gApp->GetBrowserView()->ResetBrowser(txt, true);
}

int UCvsFrame::OnBrowserPopup(void)
{
	const char *newPath =
		BrowserGetDirectory("Select a folder to open with the browser");
	if(newPath == 0L)
		return 0;

	UCvsApp::gApp->GetBrowserView()->ResetBrowser(newPath, true);

	return 0;
}

int UCvsFrame::OnQuit(void)
{
	if(!AskForQuitting())
		return 0;

#if qGTK
	gtk_main_quit();
#endif /* qGTK */

	return 0;
}

void UCvsFrame::OnCmdUIQuit(UCmdUI *pCmdUI)
{
	pCmdUI->Enable(true);
}

void UCvsFrame::OnCmdUIAnytime(int cmd, UCmdUI *pCmdUI)
{
	pCmdUI->Enable(!UCvsApp::gApp->IsCvsRunning());
}

int UCvsFrame::OnAbout()
{
	AboutDialog();
	return 0;
}

int UCvsFrame::OnCopyrights()
{
	const char *appName = UCvsApp::gApp->GetAppName();

	cvs_out("\nBoth %s and CVS are distributed under the terms of\n", appName);
	cvs_out("the GNU General Public Licence (GPL).\n\n");
	cvs_out("* %s : maintained by Alexandre Parenteau (aubonbeurre@hotmail.com)\n", appName);
	cvs_out("* CVS : Copyright  1989-1998 Brian Berliner, david d `zoo' zuhn,\n");
	cvs_out("        Jeff Polk, and other authors\n");
#ifdef macintosh
	printf("* MacCVS : Mike Ladwig, Matthias Neeracher, Alexandre Parenteau\n");
	printf("* GUSI : Copyright  1992-1997 Matthias Neeracher\n");
	printf("* Waste : Copyright  1993-1998 Marco Piovanelli\n");
	printf("* CWASTEEdit : Copyright  1995-1997 Timothy Paustian\n");
	printf("* ABalloon : Freeware of James W. Walker (jwwalker@kagi.com)\n");
	printf("* Metrowerks Standard Library, PowerPlant & CodeWarrior :\n");
	printf("    Copyright  1996-1997 Metrowerks Inc.\n");
	printf("* MPW, MoreFiles : Copyright  Apple Computer Inc.\n");
#endif
#ifdef WIN32
	cvs_out("* WinCvs documentation : Copyright  1999 Don Harper <don@lamrc.com>.\n");
	cvs_out("* CJLIB : Copyright  1998-99 Kirk Stowell <kstowell@codejockeys.com>\n");
	cvs_out("* MFC : Copyright  1992-1997 Microsoft Corporation\n");
#endif
	cvs_out("* Kerberos : Copyright  1997 the Massachusetts Institute of Technology\n");
	cvs_out("* TCL : Copyright  Sun Microsystems Inc.\n");
	cvs_out("\nSome others copyrights may apply, check the source code for details.\n");
	return 0;
}

int UCvsFrame::OnCredits()
{
	const char *appName = UCvsApp::gApp->GetAppName();
	const char *appVers = UCvsApp::gApp->GetAppVersion();

#ifndef macintosh
	cvs_out("\n%s %s - Client/Local\n", appName, appVers);
#else
	cvs_out("\n%s %s - Client\n", appName, appVers);
#endif
	cvs_out("%s is maintained by Alexandre Parenteau\n", appName);
        cvs_out("- WinCvs/MacCvs/gcvs page : http://www.wincvs.org or http://cvsgui.sourceforge.net/\n");
	cvs_out("- cvs page : http://www.cvshome.org\n");
#ifdef WIN32
	cvs_out("- WinCvs documentation : Don Harper <don@lamrc.com>.\n");
	cvs_out("- WinHelp cvs documentation : Norbert Klamann.\n");
#endif
#ifdef macintosh
	printf("- Mac port :\n");
	printf("\t* Mike Ladwig <mike@twinpeaks.prc.com>\n");
	printf("\t* Matthias Neeracher <neeri@iis.ee.ethz.ch>\n");
	printf("\t* Alexandre Parenteau <aubonbeurre@hotmail.com>\n");
	printf("- With contributions of :\n");
	printf("\t* Miro Jurisic <meeroh@mit.edu> (Kerberos)\n");
	printf("\t* Aleks Totic <atotic@netscape.com> (AppleSingle)\n");
	printf("\t* Jocelyn Houle <houlejo@IRO.UMontreal.CA> (Help balloons)\n");
#endif
	cvs_out("- Special thanks to :\n");
	cvs_out("\t* Gary Bringhurst from C3D Digital who gives me time, resources,\n");
	cvs_out("\t  help and ideas for doing this project (http://www.3d.com)\n");
	cvs_out("\t* The Freeware community for providing cvs, Linux, Perl, GTK, gcc\n");
	cvs_out("\t  and so many others valuables tools\n");
	cvs_out("\t* The users of the CvsGui project (WinCvs, MacCvs, gcvs) who have\n");
	cvs_out("\t  defined all the functionnalities and help every day to enhance it\n");
	cvs_out("- Cvs contributors :\n");
	cvs_out("\t* Too many to be listed here, see the 'ChangeLog' instead !\n");
	return 0;
}

int UCvsFrame::OnCmdPreferences(void)
{
	CompatGetPrefs();
	return 0;
}

int UCvsFrame::OnCmdSaveSettings(void)
{
	UCvsFolders *browser = UCvsApp::gApp->GetBrowserView();
	if(browser != 0L && browser->GetRoot() != 0L)
		AskCreatePersistentSettings(browser->GetRoot());
	return 0;
}

int UCvsFrame::OnCmdRtagNew(void)
{
	CvsCmdRtagCreate();
	return 0;
}

int UCvsFrame::OnCmdRtagDelete(void)
{
	CvsCmdRtagDelete();
	return 0;
}

int UCvsFrame::OnCmdRtagBranch(void)
{
	CvsCmdRtagBranch();
	return 0;
}

int UCvsFrame::OnCmdCmdline(void)
{
	CvsCmdLine();
	return 0;
}

int UCvsFrame::OnCmdLogin(void)
{
	CvsCmdLogin();
	return 0;
}

int UCvsFrame::OnCmdLogout(void)
{
	CvsCmdLogout();
	return 0;
}

int UCvsFrame::OnCmdStopcvs(void)
{
	UCvsApp::gApp->SetCvsStopping(true);
	if(UCvsApp::gApp->GetCvsProcess() != 0L && cvs_process_is_active(UCvsApp::gApp->GetCvsProcess()))
	{
		cvs_process_kill(UCvsApp::gApp->GetCvsProcess());
		cvs_out("*****CVS stopped on user request !!! *****\n\n");
	}
	
	return 0;
}

int UCvsFrame::OnCmdInit(void)
{
	CvsCmdInit();
	return 0;
}

int UCvsFrame::OnCmdMacroAdmin(int cmd)
{
	CMacroEntry & entry = gMacrosAdmin.entries[cmd - cmdMACROADMIN];
	CvsCmdMacrosAdmin(entry.path);
	return 0;
}

void UCvsFrame::OnCmdUIStopcvs(UCmdUI *pCmdUI)
{
	UCvsApp *app = UCvsApp::gApp;
	pCmdUI->Enable(app->IsCvsRunning() && !app->IsCvsStopping());
}

void UCvsFrame::OnCmdUICvsCmd(UCmdUI *pCmdUI)
{
	pCmdUI->Enable(!UCvsApp::gApp->IsCvsRunning() && !gCvsPrefs.empty());
}

void UCvsFrame::OnCmdUIMacroAdmin(int cmd, UCmdUI *pCmdUI)
{
	pCmdUI->Enable(!UCvsApp::gApp->IsCvsRunning() && !gCvsPrefs.empty() && CTcl_Interp::IsAvail());
}