This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH] Add chooser-only mode to setup.exe
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: cygwin-apps <cygwin-apps at cygwin dot com>
- Date: Sat, 06 Feb 2010 06:32:59 +0000
- Subject: [PATCH] Add chooser-only mode to setup.exe
Hi gang,
I think we talked about this idea before once. It's a variant of
setup.exe's unattended mode that skips through everything automatically except
for the chooser page. I decided to call it 'package manager mode', because
that's what I'm planning on using it for, but don't mind if anyone wants to
change the option name.
setup/ChangeLog:
* choose.cc (ChooserPage::PlaceDialog): Only skip resizing window
in fully-unattended mode, not chooser-only mode.
(ChooserPage::OnUnattended): Return appropriate status to run page
or not according to kind of unattended mode.
* choose.h (ChooserPage::OnUnattended): Remove inline implementation
and retain prototype only.
* main.cc (PackageManagerOption): New boolean option.
(main): Take it into account when setting unattended_mode.
* proppage.cc (PropertyPage::DialogProc): Use new enum type when
setting unattended_mode.
* state.cc (unattended_mode): Change from bool to enum attend_mode.
* state.h (enum attend_mode): Declare new enum type.
(unattended_mode): Update extern declaration to use it.
Ok?
cheers,
DaveK
Index: choose.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/choose.cc,v
retrieving revision 2.153
diff -p -u -r2.153 choose.cc
--- choose.cc 22 Dec 2009 01:26:39 -0000 2.153
+++ choose.cc 6 Feb 2010 03:25:39 -0000
@@ -176,8 +176,8 @@ ChooserPage::getParentRect (HWND parent,
void
ChooserPage::PlaceDialog (bool doit)
{
- if (unattended_mode)
- /* Don't jump up and down in unattended mode */;
+ if (unattended_mode == unattended)
+ /* Don't jump up and down in (fully) unattended mode */;
else if (doit)
{
pre_chooser_placement.length = sizeof pre_chooser_placement;
@@ -262,6 +262,16 @@ ChooserPage::OnActivate()
PlaceDialog (true);
}
+long
+ChooserPage::OnUnattended()
+{
+ if (unattended_mode == unattended)
+ return OnNext ();
+ // Magic constant -1 (FIXME) means 'display page but stay unattended', as
+ // also used for progress bars; see proppage.cc!PropertyPage::DialogProc().
+ return -1;
+}
+
void
ChooserPage::logResults()
{
Index: choose.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/choose.h,v
retrieving revision 2.39
diff -p -u -r2.39 choose.h
--- choose.h 30 Jun 2009 04:03:12 -0000 2.39
+++ choose.h 6 Feb 2010 03:25:39 -0000
@@ -37,10 +37,7 @@ public:
virtual long OnNext ();
virtual long OnBack ();
virtual void OnActivate ();
- virtual long OnUnattended ()
- {
- return OnNext ();
- };
+ virtual long OnUnattended ();
static void SetHwndDialog (HWND h)
{
Index: main.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/main.cc,v
retrieving revision 2.62
diff -p -u -r2.62 main.cc
--- main.cc 27 Dec 2009 17:46:25 -0000 2.62
+++ main.cc 6 Feb 2010 03:25:39 -0000
@@ -85,6 +85,7 @@ HINSTANCE hinstance;
bool is_legacy;
static BoolOption UnattendedOption (false, 'q', "quiet-mode", "Unattended setup mode");
+static BoolOption PackageManagerOption (false, 'M', "package-manager", "Semi-attended chooser-only mode");
static BoolOption HelpOption (false, 'h', "help", "print help");
static BOOL WINAPI (*dyn_AttachConsole) (DWORD);
static BOOL WINAPI (*dyn_GetLongPathName) (LPCTSTR, LPTSTR, DWORD);
@@ -299,7 +300,9 @@ main (int argc, char **argv)
if (!GetOption::GetInstance ().Process (argc,_argv, NULL))
exit (1);
- unattended_mode = UnattendedOption;
+ unattended_mode = PackageManagerOption ? chooseronly
+ : (UnattendedOption ? unattended : attended);
+
if (unattended_mode || HelpOption)
set_cout ();
Index: proppage.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/proppage.cc,v
retrieving revision 2.18
diff -p -u -r2.18 proppage.cc
--- proppage.cc 15 Apr 2006 21:21:25 -0000 2.18
+++ proppage.cc 6 Feb 2010 03:25:39 -0000
@@ -195,7 +195,7 @@ PropertyPage::DialogProc (UINT message,
long nextwindow = OnUnattended();
if (nextwindow == -2)
{
- unattended_mode = false;
+ unattended_mode = attended;
SetWindowLong (GetHWND (), DWL_MSGRESULT, 0);
return TRUE;
}
Index: state.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/state.cc,v
retrieving revision 2.6
diff -p -u -r2.6 state.cc
--- state.cc 7 Aug 2008 22:59:17 -0000 2.6
+++ state.cc 6 Feb 2010 03:25:39 -0000
@@ -22,7 +22,7 @@ static const char *cvsid =
#include "state.h"
-bool unattended_mode;
+enum attend_mode unattended_mode = attended;
bool rebootneeded;
int source;
Index: state.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/state.h,v
retrieving revision 2.12
diff -p -u -r2.12 state.h
--- state.h 7 Aug 2008 22:59:17 -0000 2.12
+++ state.h 6 Feb 2010 03:25:39 -0000
@@ -31,7 +31,8 @@
#include <string>
-extern bool unattended_mode;
+enum attend_mode { attended = 0, unattended, chooseronly };
+extern enum attend_mode unattended_mode;
extern bool rebootneeded;
extern int source;