SF.net SVN: mahogany: [7211] trunk/M

[email protected]
Newsgroups gmane.mail.mahogany.cvs
Message-ID <[email protected]>
Revision: 7211
          http://svn.sourceforge.net/mahogany/?rev=7211&view=rev
Author:   vadz
Date:     2007-01-09 17:22:12 -0800 (Tue, 09 Jan 2007)

Log Message:
-----------
show the message subject in the composer window title bar

Modified Paths:
--------------
    trunk/M/CHANGES
    trunk/M/include/gui/wxComposeView.h
    trunk/M/src/gui/wxComposeView.cpp

Modified: trunk/M/CHANGES
===================================================================
--- trunk/M/CHANGES	2007-01-08 23:32:01 UTC (rev 7210)
+++ trunk/M/CHANGES	2007-01-10 01:22:12 UTC (rev 7211)
@@ -9,6 +9,7 @@
 Release 0.68 '' September xx, 2006
 ---------------------------------------
 
+2007-01-10 VZ: Show the message subject in the composer window title bar
 2007-01-08 VZ: Added support for "subject" parameter of mailto: URLs
 2006-12-25 VZ: Added "Remove attachments" command
 2006-09-05 NB: Mahogany can now be compiled with wxWine

Modified: trunk/M/include/gui/wxComposeView.h
===================================================================
--- trunk/M/include/gui/wxComposeView.h	2007-01-08 23:32:01 UTC (rev 7210)
+++ trunk/M/include/gui/wxComposeView.h	2007-01-10 01:22:12 UTC (rev 7211)
@@ -312,6 +312,16 @@
     */
    bool ConfigureInReplyTo();
 
+
+   /**
+      Update the composer frame title.
+
+      This should be called whenever the subject (shown in the title bar) or
+      the external editor status (shown too) changes and is only used
+      internally.
+    */
+   void UpdateTitle();
+
 protected:
    /** quasi-Constructor
        @param parent parent window
@@ -396,6 +406,9 @@
    /// Launch the external editor
    bool StartExternalEditor();
 
+   /// Return true if the external editor is currently running
+   bool IsExternalEditorRunning() const { return m_procExtEdit != NULL; }
+
    /**
      Return a SendMessage object filled with all data we have. It must be
      deleted by the caller (presumably after calling its Send() or

Modified: trunk/M/src/gui/wxComposeView.cpp
===================================================================
--- trunk/M/src/gui/wxComposeView.cpp	2007-01-08 23:32:01 UTC (rev 7210)
+++ trunk/M/src/gui/wxComposeView.cpp	2007-01-10 01:22:12 UTC (rev 7211)
@@ -184,9 +184,6 @@
 #define GEOMETRY_MAXIMIZED _T("M")
 #define GEOMETRY_FORMAT _T("%dx%d-%dx%d")
 
-// the composer frame title
-#define COMPOSER_TITLE _("Message Composition")
-
 // separate multiple addresses with commas
 #define CANONIC_ADDRESS_SEPARATOR   _T(", ")
 
@@ -487,12 +484,29 @@
 class wxSubjectTextCtrl : public wxTextCtrlProcessingEnter
 {
 public:
-   wxSubjectTextCtrl(wxWindow *parent) : wxTextCtrlProcessingEnter(parent) { }
+   wxSubjectTextCtrl(wxWindow *parent, wxComposeView *composeView)
+      : wxTextCtrlProcessingEnter(parent)
+   {
+      m_composeView = composeView;
+   }
 
 private:
+   void OnChange(wxCommandEvent& WXUNUSED(event))
+   {
+      // update the subject shown in the title bar
+      m_composeView->UpdateTitle();
+   }
+
+   wxComposeView *m_composeView;
+
+   DECLARE_EVENT_TABLE()
    DECLARE_NO_COPY_CLASS(wxSubjectTextCtrl)
 };
 
+BEGIN_EVENT_TABLE(wxSubjectTextCtrl, wxTextCtrlProcessingEnter)
+   EVT_TEXT(wxID_ANY, wxSubjectTextCtrl::OnChange)
+END_EVENT_TABLE()
+
 // ----------------------------------------------------------------------------
 // IconButton: class used for small buttons in the header
 // ----------------------------------------------------------------------------
@@ -1482,7 +1496,7 @@
                            );
 
    cv->SetTemplate(params.templ);
-   cv->SetTitle(COMPOSER_TITLE);
+   cv->UpdateTitle();
    cv->Create(parent, profile);
 
    return cv;
@@ -1776,6 +1790,8 @@
 
    m_editor = NULL;
    m_encoding = wxFONTENCODING_SYSTEM;
+
+   m_txtSubject = NULL;
 }
 
 bool wxComposeView::IsReplyTo(const Message& original) const
@@ -1996,7 +2012,7 @@
                      0, wxALIGN_CENTRE_VERTICAL);
 
    wxSizer *sizerSubj = new wxBoxSizer(wxHORIZONTAL);
-   m_txtSubject = new wxSubjectTextCtrl(m_panel);
+   m_txtSubject = new wxSubjectTextCtrl(m_panel, this);
    sizerSubj->Add(m_txtSubject, 1, wxALIGN_CENTRE_VERTICAL);
    SetTextAppearance(m_txtSubject);
 
@@ -2315,6 +2331,23 @@
    ResetDirty();
 }
 
+void wxComposeView::UpdateTitle()
+{
+   String title(_("Composer"));
+   if ( m_txtSubject && !m_txtSubject->IsEmpty() )
+   {
+      title << _(" - ") << m_txtSubject->GetValue();
+   }
+
+   if ( IsExternalEditorRunning() )
+      title << _(" (frozen: external editor running)");
+
+   wxFrame *frame = GetFrame();
+   CHECK_RET( frame, _T("composer without frame?") );
+   if ( title != frame->GetTitle() )
+      frame->SetTitle(title);
+}
+
 // ----------------------------------------------------------------------------
 // wxComposeView address headers stuff
 // ----------------------------------------------------------------------------
@@ -3613,20 +3646,8 @@
             EnableEditing(false);
 
             // and reflect it in the title
-            wxFrame *frame = GetFrame();
-            if ( frame )
-            {
-               wxString title;
-               title << COMPOSER_TITLE
-                     << _(" (frozen: external editor running)");
+            UpdateTitle();
 
-               frame->SetTitle(title);
-            }
-            else
-            {
-               FAIL_MSG( _T("composer without frame?") );
-            }
-
             launchedOk = true;
          }
       }
@@ -3678,16 +3699,6 @@
    // reenable editing the text in the built-in editor
    EnableEditing(true);
 
-   wxFrame *frame = GetFrame();
-   if ( frame )
-   {
-      frame->SetTitle(COMPOSER_TITLE);
-   }
-   else
-   {
-      FAIL_MSG( _T("composer without frame?") );
-   }
-
    bool ok = false;
 
    // check the return code of the editor process
@@ -3748,6 +3759,9 @@
    delete m_procExtEdit;
    m_procExtEdit = NULL;
 
+
+   UpdateTitle();
+
    // show the frame which might had been obscured by the other windows
    Raise();
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.