]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
* localdir.cc: new, local package directory selection dialog; cd
authorDJ Delorie <dj@redhat.com>
Thu, 7 Sep 2000 03:09:30 +0000 (03:09 +0000)
committerDJ Delorie <dj@redhat.com>
Thu, 7 Sep 2000 03:09:30 +0000 (03:09 +0000)
into selected directory
* Makefile.in (OBJS): add localdir.o
* dialog.h: add prototype for do_local_dir
* main.cc (WinMain): initialize local_dir to cwd; add call to
do_local_dir
* net.cc (dialog_cmd): make DO_LOCAL_DIR next dialog
* source.cc (dialog_cmd): ditto
* res.rc: add DO_LOCAL_DIR dialog; remove "current directory" from
presented choices in IDD_SOURCE; add IDS_ERR_CHDIR error string
* resource.h: defines for DO_LOCAL_DIR dialog; define IDS_ERR_CHDIR
* root.cc (dialog_cmd): make DO_LOCAL_DIR previous dialog
* state.h: add local_dir variable

ChangeLog
Makefile.in
dialog.h
localdir.cc [new file with mode: 0644]
main.cc
net.cc
res.rc
resource.h
root.cc
source.cc
state.h

index 14b10f2f10d3bcedd877d205b0411a98043eb03a..8d442e8cd5038e8982b896ba3089672e104f3bb8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,20 @@
-2000-09-05  Brian Keener  <bkeener@thesoftwaresource.com>
+2000-09-06  Andrej Borsenkow  <Andrej.Borsenkow@mow.siemens.ru>
+
+       * localdir.cc: new, local package directory selection dialog; cd
+       into selected directory
+       * Makefile.in (OBJS): add localdir.o
+       * dialog.h: add prototype for do_local_dir
+       * main.cc (WinMain): initialize local_dir to cwd; add call to
+       do_local_dir
+       * net.cc (dialog_cmd): make DO_LOCAL_DIR next dialog
+       * source.cc (dialog_cmd): ditto
+       * res.rc: add DO_LOCAL_DIR dialog; remove "current directory" from
+       presented choices in IDD_SOURCE; add IDS_ERR_CHDIR error string
+       * resource.h: defines for DO_LOCAL_DIR dialog; define IDS_ERR_CHDIR
+       * root.cc (dialog_cmd): make DO_LOCAL_DIR previous dialog
+       * state.h: add local_dir variable
+
+2000-09-06  Brian Keener  <bkeener@thesoftwaresource.com>
 
        * desktop.cc: added logic to handle to the new dialog and to
        default the setting for the new checkboxes based on whether the
index 3b151d2eceec21c4b3a669bcb1a2d6799987afde..4025e81abc008b17eb362551863a248f912cbb94 100644 (file)
@@ -85,6 +85,7 @@ OBJS = \
        inilex.o \
        iniparse.o \
        install.o \
+       localdir.o \
        log.o \
        main.o \
        mkdir.o \
index 04eb3cda677fe790fa178145c92efb5034896a08..2de4cf55bdf6d48fc1f00aa7ad96b96cc1d1ef7c 100644 (file)
--- a/dialog.h
+++ b/dialog.h
@@ -32,6 +32,7 @@ D(do_download);
 D(do_fromcwd);
 D(do_ini);
 D(do_install);
+D(do_local_dir);
 D(do_net);
 D(do_other);
 D(do_postinstall);
diff --git a/localdir.cc b/localdir.cc
new file mode 100644 (file)
index 0000000..0e2e359
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2000, Red Hat, Inc.
+ *
+ *     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 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
+ * based on work and suggestions of DJ Delorie
+ *
+ */
+
+/* The purpose of this file is to ask the user where they want the
+   root of the installation to be, and to ask whether the user prefers
+   text or binary mounts. */
+
+static char *cvsid = "\n%%% $Id$\n";
+
+#include "win32.h"
+#include <shlobj.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "dialog.h"
+#include "resource.h"
+#include "state.h"
+#include "msg.h"
+#include "mount.h"
+#include "concat.h"
+#include "log.h"
+
+static void
+check_if_enable_next (HWND h)
+{
+  EnableWindow (GetDlgItem (h, IDOK), local_dir != 0);
+}
+
+static void
+load_dialog (HWND h)
+{
+  eset (h, IDC_LOCAL_DIR, local_dir);
+  check_if_enable_next (h);
+}
+
+static void
+save_dialog (HWND h)
+{
+  local_dir = eget (h, IDC_LOCAL_DIR, local_dir);
+}
+
+
+static int CALLBACK
+browse_cb (HWND h, UINT msg, LPARAM lp, LPARAM data)
+{
+  switch (msg)
+    {
+    case BFFM_INITIALIZED:
+      if (local_dir)
+       SendMessage (h, BFFM_SETSELECTION, TRUE, (LPARAM)local_dir);
+      break;
+    }
+  return 0;
+}
+
+static void
+browse (HWND h)
+{
+  BROWSEINFO bi;
+  CHAR name[MAX_PATH];
+  LPITEMIDLIST pidl;
+  memset (&bi, 0, sizeof (bi));
+  bi.hwndOwner = h;
+  bi.pszDisplayName = name;
+  bi.lpszTitle = "Select download directory";
+  bi.ulFlags = BIF_RETURNONLYFSDIRS;
+  bi.lpfn = browse_cb;
+  pidl = SHBrowseForFolder (&bi);
+  if (pidl)
+    {
+      if (SHGetPathFromIDList (pidl, name))
+       eset (h, IDC_LOCAL_DIR, name);
+    }
+}
+
+
+static BOOL
+dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
+{
+  switch (id)
+    {
+
+    case IDC_LOCAL_DIR:
+      save_dialog (h);
+      check_if_enable_next (h);
+      break;
+
+    case IDC_LOCAL_DIR_BROWSE:
+      browse (h);
+      break;
+
+    case IDOK:
+      save_dialog (h);
+      if (SetCurrentDirectoryA (local_dir))
+       {
+         switch (source)
+           {
+           case IDC_SOURCE_DOWNLOAD:
+             NEXT (IDD_NET);
+             break;
+           case IDC_SOURCE_NETINST:
+           case IDC_SOURCE_CWD:
+             NEXT (IDD_ROOT);
+             break;
+           default:
+             NEXT (0);
+             break;
+           }
+       }
+      else
+       note (IDS_ERR_CHDIR, local_dir);
+
+      break;
+
+    case IDC_BACK:
+      save_dialog (h);
+      NEXT (IDD_SOURCE);
+      break;
+
+    case IDCANCEL:
+      NEXT (0);
+      break;
+    }
+}
+
+static BOOL CALLBACK
+dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
+{
+  switch (message)
+    {
+    case WM_INITDIALOG:
+      load_dialog (h);
+      return FALSE;
+    case WM_COMMAND:
+      return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
+    }
+  return FALSE;
+}
+
+extern char cwd[_MAX_PATH];
+
+void
+do_local_dir (HINSTANCE h)
+{
+  int rv = 0;
+  rv = DialogBox (h, MAKEINTRESOURCE (IDD_LOCAL_DIR), 0, dialog_proc);
+  if (rv == -1)
+    fatal (IDS_DIALOG_FAILED);
+
+  log (0, "Selected local directory: %s", local_dir);
+}
+
diff --git a/main.cc b/main.cc
index 4fc4a8eba930ceea100bbf67d17fa427e1630604..45dc9fb3cb3ccdee3d551447acc077b617c93cef 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -61,6 +61,7 @@ WinMain (HINSTANCE h,
 
   char cwd[_MAX_PATH];
   GetCurrentDirectory (sizeof (cwd), cwd);
+  local_dir = strdup (cwd);
   log (0, "Current Directory: %s", cwd);
 
   while (next_dialog)
@@ -69,6 +70,7 @@ WinMain (HINSTANCE h,
        {
        case IDD_SPLASH:        do_splash (h);  break;
        case IDD_SOURCE:        do_source (h);  break;
+       case IDD_LOCAL_DIR:     do_local_dir (h); break;
        case IDD_ROOT:          do_root (h);    break;
        case IDD_NET:           do_net (h);     break;
        case IDD_SITE:          do_site (h);    break;
diff --git a/net.cc b/net.cc
index 41f92b7d9ba489b0a28745798f3e2f2f330b8386..f497857675c94974131dca13be38ad21d4a03e8b 100644 (file)
--- a/net.cc
+++ b/net.cc
@@ -104,7 +104,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
       switch (source)
        {
        case IDC_SOURCE_DOWNLOAD:
-         NEXT (IDD_SOURCE);
+         NEXT (IDD_LOCAL_DIR);
          break;
        case IDC_SOURCE_NETINST:
        case IDC_SOURCE_CWD:
diff --git a/res.rc b/res.rc
index 2e155c930c50b9469649fe8993ac58055d3e285b..dcf727998c81e4315d50563c39b4239c46f1475a 100644 (file)
--- a/res.rc
+++ b/res.rc
@@ -36,15 +36,29 @@ BEGIN
     DEFPUSHBUTTON   "Next -->",IDOK,100,75,45,15,WS_DISABLED
     PUSHBUTTON      "Cancel",IDCANCEL,165,75,45,15
     ICON            IDI_CYGWIN,-1,5,5,20,20
-    CONTROL         "Download from Internet to Current Directory",
+    CONTROL         "Download from Internet",
                     IDC_SOURCE_DOWNLOAD,"Button",BS_AUTORADIOBUTTON,55,15,
                     152,10
     CONTROL         "Install from Internet",IDC_SOURCE_NETINST,"Button",
                     BS_AUTORADIOBUTTON,55,30,75,10
-    CONTROL         "Install from Current Directory",IDC_SOURCE_CWD,"Button",
+    CONTROL         "Install from Local Directory",IDC_SOURCE_CWD,"Button",
                     BS_AUTORADIOBUTTON,55,45,104,10
 END
 
+IDD_LOCAL_DIR DIALOG DISCARDABLE  0, 0, 215, 95
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Local package directory"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "Next -->",IDOK,100,75,45,15
+    PUSHBUTTON      "Cancel",IDCANCEL,165,75,45,15
+    EDITTEXT        IDC_LOCAL_DIR,55,25,127,12,ES_AUTOHSCROLL
+    LTEXT           "Local Package Directory",IDC_STATIC,55,15,85,11
+    PUSHBUTTON      "<-- Back",IDC_BACK,55,75,45,15
+    ICON            IDI_CYGWIN,IDC_STATIC,5,5,20,20
+    PUSHBUTTON      "Browse...",IDC_LOCAL_DIR_BROWSE,150,10,34,14
+END
+
 IDD_ROOT DIALOG DISCARDABLE  0, 0, 215, 95
 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Cygwin Setup"
@@ -352,6 +366,7 @@ BEGIN
     IDS_NOLOGFILE           "Cannot open log file %s for writing"
     IDS_UNINSTALL_COMPLETE  "Uninstalls complete."
     IDS_WININET             "Unable to find or load the Internet Explorer 5 DLLs"
+    IDS_ERR_CHDIR           "Could not change dir to %s"
 END
 
 #endif    // English (U.S.) resources
index 854adecc7b0f8da69352d1a2f464adba01e32466..6a661b7dd46d3ad9f4ad585a70d951f014ac72d4 100644 (file)
@@ -22,6 +22,7 @@
 #define IDS_NOLOGFILE                   20
 #define IDS_UNINSTALL_COMPLETE          21
 #define IDS_WININET                     22
+#define IDS_ERR_CHDIR                  23
 #define IDD_ROOT                        101
 #define IDD_SOURCE                      102
 #define IDD_OTHER_URL                   103
@@ -43,6 +44,7 @@
 #define IDB_RTARROW                     119
 #define IDI_SPIN                        120
 #define IDI_CYGWIN                      121
+#define IDD_LOCAL_DIR                   122
 #define IDC_SOURCE_DOWNLOAD             1000
 #define IDC_SOURCE_NETINST              1001
 #define IDC_SOURCE_CWD                  1002
@@ -82,6 +84,8 @@
 #define IDC_INS_ACTION                  1040
 #define IDC_ROOT_DESKTOP                1041
 #define IDC_ROOT_MENU                   1042
+#define IDC_LOCAL_DIR_BROWSE            1043
+#define IDC_LOCAL_DIR                   1044
 #define IDC_STATIC                      -1
 
 // Next default values for new objects
@@ -90,9 +94,9 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NO_MFC                     1
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        122
+#define _APS_NEXT_RESOURCE_VALUE        123
 #define _APS_NEXT_COMMAND_VALUE         40003
-#define _APS_NEXT_CONTROL_VALUE         1043
+#define _APS_NEXT_CONTROL_VALUE         1045
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
diff --git a/root.cc b/root.cc
index e726d7d644453c87f8b4bfa08fc11268ad92fc97..ad414b6fbe6276bf62cc936b26c40e2227c63d06 100644 (file)
--- a/root.cc
+++ b/root.cc
@@ -202,7 +202,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
 
     case IDC_BACK:
       save_dialog (h);
-      NEXT (IDD_SOURCE);
+      NEXT (IDD_LOCAL_DIR);
       break;
 
     case IDCANCEL:
index 7cae72502ebdfa0a36b3b7b729021b1d66ddcff2..e5400aeec6071672d71ae233fd62c390c6e4db94 100644 (file)
--- a/source.cc
+++ b/source.cc
@@ -65,16 +65,7 @@ dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
 
     case IDOK:
       save_dialog (h);
-      switch (source)
-       {
-       case IDC_SOURCE_DOWNLOAD:
-         NEXT (IDD_NET);
-         break;
-       case IDC_SOURCE_NETINST:
-       case IDC_SOURCE_CWD:
-         NEXT (IDD_ROOT);
-         break;
-       }
+      NEXT (IDD_LOCAL_DIR);
       break;
 
     case IDC_BACK:
diff --git a/state.h b/state.h
index 2fb647b74ba406dc88c4dc627f882818648dfd4e..65bc2a71c09e210544876f679dc705a386a18c35 100644 (file)
--- a/state.h
+++ b/state.h
@@ -20,6 +20,8 @@
 
 extern int     source;
 
+extern char *  local_dir;
+
 extern char *  root_dir;
 extern int     root_text;
 extern int     root_scope;
This page took 0.044282 seconds and 5 git commands to generate.