Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv20946/src/gui

Modified Files:
        wxFolderTree.cpp wxMFolderDialogs.cpp wxMainFrame.cpp 
        wxWizards.cpp 
Log Message:
1. allow the user to change the parent in the folder create dialog whatever
   way it was invoked (popup or main menu); use the current selection in the
   tree as default parent when using the main menu
2. fixed folder name <-> path auto update in the folder create dialog once
   again (argh...)
3. API change: ShowFolderCreateDialog() doesn't take ownership of the parent
   folder pointer any more


Index: wxFolderTree.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxFolderTree.cpp,v
retrieving revision 1.194
retrieving revision 1.195
diff -b -u -2 -r1.194 -r1.195
--- wxFolderTree.cpp    14 Jul 2002 23:41:22 -0000      1.194
+++ wxFolderTree.cpp    27 Aug 2002 18:57:19 -0000      1.195
@@ -968,9 +968,7 @@
       newfolder = ShowFolderCreateDialog(winTop, FolderCreatePage_Default, parent);
    }
-   else
-   {
-      // RunCreateFolderWizard() doesn't dec ref it
+
+   if ( parent )
       parent->DecRef();
-   }
 
    return newfolder;

Index: wxMFolderDialogs.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMFolderDialogs.cpp,v
retrieving revision 1.168
retrieving revision 1.169
diff -b -u -2 -r1.168 -r1.169
--- wxMFolderDialogs.cpp        25 Jul 2002 22:40:25 -0000      1.168
+++ wxMFolderDialogs.cpp        27 Aug 2002 18:57:22 -0000      1.169
@@ -127,7 +127,7 @@
 // ============================================================================
 
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // dialog classes
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
 // base class for folder creation and properties dialog
@@ -146,9 +146,16 @@
    // set folder we're working with
    void SetFolder(MFolder *folder)
-      { m_newFolder = folder; SafeIncRef(m_newFolder); }
-   // set the parent folder: if it's !NULL, it can't be changed by user
+      { SafeIncRef(m_newFolder = folder); }
+      // set the parent folder
    void SetParentFolder(MFolder *parentFolder)
-      { m_parentFolder = parentFolder; }
+      { SafeIncRef(m_parentFolder = parentFolder); }
 
+   // accessors
+      // get the parent folder (may return NULL)
+   MFolder *GetParentFolder() const
+   {
+      m_parentFolder->IncRef();
+      return m_parentFolder;
+   }
    // get the parent folder name
    wxString GetParentFolderName() const { return m_parentName->GetValue(); }
@@ -341,4 +348,10 @@
    void OnEvent();
 
+   // hack: this method tells whether we're in process of creating the folder
+   // or just showing the properties for it. Ultimately, it shouldn't be
+   // necessary, but for now we use it to adjust our behaviour depending on
+   // what we're doing
+   bool IsCreating() const { return m_dlgCreate != NULL; }
+
    // the radiobox indices
    enum RadioIndex
@@ -426,10 +439,4 @@
    void EnableControlsForFileFolder(MFolderType folderType);
 
-   // hack: this flag tells whether we're in process of creating the folder or
-   // just showing the properties for it. Ultimately, it shouldn't be
-   // necessary, but for now we use it to adjust our behaviour depending on
-   // what we're doing
-   bool m_isCreating;
-
    /// the parent notebook control
    wxNotebook *m_notebook;
@@ -567,7 +574,7 @@
 // ============================================================================
 
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // event tables
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
 IMPLEMENT_DYNAMIC_CLASS(wxFolderBaseDialog, wxOptionsEditDialog)
@@ -667,15 +674,8 @@
    pLabel->SetConstraints(c);
 
-   // don't allow changing it if parent folder is fixed
+   m_parentName = new wxTextCtrl(panel, -1, "");
    if ( m_parentFolder )
    {
-      m_parentName = new wxTextCtrl(panel, -1,
-                                    m_parentFolder->GetFullName(),
-                                    wxDefaultPosition, wxDefaultSize,
-                                    wxTE_READONLY);
-   }
-   else
-   {
-      m_parentName = new wxTextCtrl(panel, -1, "");
+      m_parentName->SetValue(m_parentFolder->GetFullName());
    }
 
@@ -697,5 +697,8 @@
    m_btnParentFolder->SetConstraints(c);
 
-   m_btnParentFolder->Enable(FALSE);
+   // for the "Show folder properties" dialog it doesn't make sense to keep it
+   // enabled as the parent of an existing folder cannot be changed -- and for
+   // the "Create folder" dialog it is reenabled later
+   m_btnParentFolder->Disable();
 
    // return the last control created
@@ -757,7 +760,7 @@
 }
 
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // wxFolderCreateDialog
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
 wxFolderCreateDialog::wxFolderCreateDialog(wxWindow *parent,
@@ -864,14 +867,12 @@
    }
 
-   if ( !m_parentFolder )
-   {
-      // enable changing the parent folder to choose one
-      m_btnParentFolder->Enable(TRUE);
-   }
-   //else: the parent folder is fixed, don't let user change it
-
    if ( !wxOptionsEditDialog::TransferDataToWindow() )
       return FALSE;
 
+   // enable changing the parent folder -- this can't be done for an
+   // already existing folder so the base class ctor disables it, but we are
+   // creating a new folder and so can choose its parent to be whatever we want
+   m_btnParentFolder->Enable(TRUE);
+
    m_folderName->SetFocus();
 
@@ -940,7 +941,7 @@
 }
 
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // wxFolderPropertiesDialog
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
 wxFolderPropertiesDialog::wxFolderPropertiesDialog(wxWindow *frame,
@@ -976,7 +977,7 @@
 }
 
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // wxFolderPropertiesPage
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
 wxFolderPropertiesPage::wxFolderPropertiesPage(wxNotebook *notebook,
@@ -991,5 +992,4 @@
    // are we in "view properties" or "create" mode?
    m_dlgCreate = dlg;
-   m_isCreating = m_dlgCreate != NULL;
 
    // init members
@@ -1146,5 +1146,5 @@
    (void)CreateIconEntry(labels[Label_FolderIcon], widthMax, m_folderSubtype, 
m_browseIcon);
 
-   m_radio->Enable(m_isCreating);
+   m_radio->Enable(IsCreating());
 }
 
@@ -1184,5 +1184,5 @@
    // the rest doesn't make any sense for the "properties" dialog because the
    // text in the path field can't change anyhow
-   if ( !m_isCreating )
+   if ( !IsCreating() )
    {
       // OTOH, call SetDirty() only we're changing the properites of an already
@@ -1279,5 +1279,5 @@
       CHECK_RET( dlg, "we should be only called when creating" );
 
-      wxString parentName = dlg->GetParentFolderName();
+      MFolder_obj parent(dlg->GetParentFolder());
 
       // NB: we modify the text even if the folder name is empty because
@@ -1285,7 +1285,9 @@
       //     erasing it wouldn't restore the original "Path" value
       wxString folderName;
+      if ( parent )
+         folderName = parent->GetPath();
 
       // the control whose value we will automatically set
-      wxTextCtrl *text = NULL;
+      wxTextCtrl *textToSet = NULL;
 
       MFolderType folderType = GetCurrentFolderType();
@@ -1296,5 +1298,6 @@
             //
             // AfterFirst() removes the MH root prefix
-            folderName = parentName.AfterFirst('/');
+            folderName = folderName.AfterFirst('/');
+
             if ( !folderName.empty() )
               folderName += '/';
@@ -1304,17 +1307,16 @@
          case MF_FILE:
             // MBOX folders don't have hierarchical structure, use as is
-            text = m_path;
+            textToSet = m_path;
             break;
 
          case MF_NNTP:
          case MF_NEWS:
-            text = m_newsgroup;
+            textToSet = m_newsgroup;
             // fall through
 
          case MF_IMAP:
-            if ( !text )
-               text = m_mailboxname;
+            if ( !textToSet )
+               textToSet = m_mailboxname;
 
-            folderName = parentName;
             if ( !folderName.empty() )
             {
@@ -1365,5 +1367,5 @@
       }
 
-      CHECK_RET( text, "must have been set above" );
+      CHECK_RET( textToSet, "must have been set above" );
 
       folderName += dlg->GetFolderName();
@@ -1379,5 +1381,5 @@
       m_userModifiedPath = -1;
 
-      text->SetValue(folderName);
+      textToSet->SetValue(folderName);
    }
 }
@@ -1422,5 +1424,5 @@
    if ( isIMAP )
    {
-      if ( m_isCreating )
+      if ( IsCreating() )
       {
          // we can't change this setting when creating an IMAP folder
@@ -1456,5 +1458,5 @@
 
    // the path can't be changed for an already existing folder
-   EnableTextWithButton(m_path, m_isCreating);
+   EnableTextWithButton(m_path, IsCreating());
 
    // file folders are always local
@@ -1648,5 +1650,5 @@
    // type can't be changed later) and if there are any subtypes
    EnableControlWithLabel(m_folderSubtype,
-                          m_isCreating &&
+                          IsCreating() &&
 #if wxCHECK_VERSION(2, 3, 2)
                              m_folderSubtype->GetCount() > 0
@@ -1822,5 +1824,5 @@
                case MF_INBOX:
                case MF_FILE:
-                  if ( m_isCreating )
+                  if ( IsCreating() )
                   {
                      subtype = READ_CONFIG(m_profile, MP_FOLDER_FILE_DRIVER);
@@ -1907,5 +1909,5 @@
          m_profile->writeEntry(profileKeys[property], value);
 
-      if ( !m_isCreating )
+      if ( !IsCreating() )
       {
          // this function has a side effect: it also sets the "modified" flag
@@ -2043,9 +2045,10 @@
    }
 
+   wxTextCtrl *textToSet;
    value = READ_CONFIG_TEXT(profile, MP_FOLDER_PATH);
    switch ( selRadio )
    {
       case Radio_File:
-         if ( m_isCreating )
+         if ( IsCreating() )
          {
             // switch the browse to the correct mode
@@ -2056,4 +2059,5 @@
 
             // don't need to set anything
+            textToSet = NULL;
             break;
          }
@@ -2074,23 +2078,29 @@
 
       case Radio_Group:
-         m_path->SetValue(value);
+         textToSet = m_path;
          break;
 
       case Radio_News:
-         m_newsgroup->SetValue(value);
+         textToSet = m_newsgroup;
          break;
 
       case Radio_Imap:
-         m_mailboxname->SetValue(value);
+         textToSet = m_mailboxname;
          break;
 
       default:
          // nothing special to do
-         ;
+         textToSet = NULL;
+   }
+
+   if ( textToSet )
+   {
+      m_userModifiedPath = -1;
+      textToSet->SetValue(value);
    }
 
    m_originalValues[Path] = value;
 
-   if ( !m_isCreating )
+   if ( !IsCreating() )
       m_comment->SetValue(READ_CONFIG(profile, MP_FOLDER_COMMENT));
 
@@ -2119,5 +2129,5 @@
 #endif // USE_LOCAL_CHECKBOX
 
-   if ( m_isCreating )
+   if ( IsCreating() )
    {
       // always create folders which can be opened by default (i.e. even if
@@ -2140,5 +2150,5 @@
    // is so rare that anonymous should really be the default
    m_originalIsAnonymous = (flags & MF_FLAGS_ANON) ||
-                           (m_isCreating && folderType == MF_NNTP);
+                           (IsCreating() && folderType == MF_NNTP);
    m_isAnonymous->SetValue(m_originalIsAnonymous);
 
@@ -2152,5 +2162,5 @@
 
    // update the folder icon
-   if ( m_isCreating )
+   if ( IsCreating() )
    {
       // use default icon for the chosen folder type
@@ -2195,9 +2205,22 @@
 wxFolderPropertiesPage::TransferDataToWindow(void)
 {
-   Profile_obj profile("");
-   if ( !m_folderPath.empty() )
-      profile->SetPath(m_folderPath);
+   Profile_obj profile(m_folderPath);
 
-   if ( m_isCreating )
+   if ( IsCreating() )
+   {
+      // if we're creating a folder under a parent with some defined
+      // hierarchical type (i.e. not root or group but IMAP or NNTP, for
+      // example), default to the parents type initially
+      MFolderType typeOfParentChildren;
+      MFolder_obj folderParent(m_dlgCreate->GetParentFolder());
+      if ( folderParent &&
+            CanHaveSubfolders(folderParent->GetType(),
+                              folderParent->GetFlags(),
+                              &typeOfParentChildren) &&
+            typeOfParentChildren != MF_ILLEGAL )
+      {
+         m_folderType = typeOfParentChildren;
+      }
+      else
    {
       // use the type of the folder last created
@@ -2205,4 +2228,5 @@
          (MFolderType)(long)READ_APPCONFIG(MP_LAST_CREATED_FOLDER_TYPE);
    }
+   }
    else
    {
@@ -2211,5 +2235,5 @@
    }
 
-   if ( (m_folderType == MF_INBOX) && m_isCreating )
+   if ( (m_folderType == MF_INBOX) && IsCreating() )
    {
       // FAIL_MSG("how did we manage to create an INBOX folder?"); --
@@ -2223,5 +2247,5 @@
    {
       // this is checked for above!
-      wxASSERT_MSG( !m_isCreating, "can't create INBOX" );
+      wxASSERT_MSG( !IsCreating(), "can't create INBOX" );
 
       // we don't have any special properties for INBOX, so just treat it as
@@ -2240,5 +2264,5 @@
    }
 
-   if ( m_isCreating && (selRadio == Radio_File) )
+   if ( IsCreating() && (selRadio == Radio_File) )
    {
       // set the default value for m_path field
@@ -2645,7 +2669,7 @@
 }
 
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // wxFolderCreateNotebook
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
 // should be in sync with the enum FolderCreatePage!
@@ -2720,7 +2744,7 @@
 }
 
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // our public interface
-// -----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
 // helper function: common part of ShowFolderCreateDialog and

Index: wxMainFrame.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMainFrame.cpp,v
retrieving revision 1.154
retrieving revision 1.155
diff -b -u -2 -r1.154 -r1.155
--- wxMainFrame.cpp     23 Jul 2002 23:57:56 -0000      1.154
+++ wxMainFrame.cpp     27 Aug 2002 18:57:23 -0000      1.155
@@ -853,6 +853,7 @@
                   newfolder = ShowFolderCreateDialog(winTop,
                                                      FolderCreatePage_Default,
-                                                     NULL);
+                                                     parent);
                }
+
                SafeDecRef(newfolder);
             }

Index: wxWizards.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxWizards.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -b -u -2 -r1.35 -r1.36
--- wxWizards.cpp       11 Mar 2002 19:41:00 -0000      1.35
+++ wxWizards.cpp       27 Aug 2002 18:57:23 -0000      1.36
@@ -541,5 +541,6 @@
 
    FolderParams *GetParams() { return &m_Params; }
-   MFolder *GetParentFolder() { m_ParentFolder->IncRef(); return m_ParentFolder; }
+   MFolder *GetParentFolder() const
+      { if ( m_ParentFolder ) m_ParentFolder->IncRef(); return m_ParentFolder; }
 
    void SetUserWantsDialog() { m_wantsDialog = true; }
@@ -1082,6 +1083,18 @@
 
    MFolder_obj f = wiz->GetParentFolder();
-   Profile_obj p(f->GetProfile());
-   CHECK(p, false, "No profile?");
+   Profile *profile;
+   if ( f )
+   {
+      profile = f->GetProfile();
+   }
+   else
+   {
+      profile = mApplication->GetProfile();
+      profile->IncRef();
+   }
+
+   CHECK(profile, false, "No profile?");
+
+   Profile_obj p(profile);
 
    // don't overwrite the settings previously entered by user
@@ -1383,5 +1396,4 @@
    }
 
-   CHECK(parent,NULL, "No parent folder?");
    CreateFolderWizard *wizard = new CreateFolderWizard(parent, parentWin);
    MFolder *newfolder = NULL;
@@ -1407,5 +1419,5 @@
 
          newfolder = CreateFolderTreeEntry(
-            NULL,    // don't use parent for the folders created with wizard
+            parent,
             params->m_Name,
             type,



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to