Update of /cvsroot/audacity/audacity-src/src/toolbars
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7846

Modified Files:
        SelectionBar.cpp 
Log Message:
Fix translations of time text controls in the selection toolbar, patch by Ed 
Musgrove.
The first part of the patch is loop streamlining. Don't go through the loop if 
there is nothing to test against and terminate the loop when the target is 
found. No logic was changed.

Ensure that a current, translated, TimeTextControl is used to get translated 
strings when required.


Index: SelectionBar.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/toolbars/SelectionBar.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- SelectionBar.cpp    29 May 2009 17:07:39 -0000      1.29
+++ SelectionBar.cpp    29 Dec 2009 16:53:10 -0000      1.30
@@ -100,28 +100,30 @@
 
 void SelectionBar::Populate()
 {
-   int i;
-
    // This will be inherited by all children:
    SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL));
 
    wxFlexGridSizer *mainSizer;
    wxBoxSizer *hSizer;
 
-   wxString formatName = gPrefs->Read(wxT("/SelectionFormat"), wxT(""));
-   int formatIndex = 1;
-
+   int formatIndex;
    /* we don't actually need a control yet, but we want to use it's methods
     * to do some look-ups, so we'll have to create one. We can't make the 
     * look-ups static because they depend on translations which are done at
     * runtime */
-   /* for now we don't give this a format, we'll set that later once we've
-    * done some other format-related housekeeping */
    TimeTextCtrl *ttc = new TimeTextCtrl(this, wxID_ANY, wxT(""), 0.0, mRate);
-   for(i=0; i<ttc->GetNumBuiltins(); i++)
-      if (ttc->GetBuiltinName(i) == formatName)
-         formatIndex = i;
-   formatName = ttc->GetBuiltinName(formatIndex);
+   wxString formatName;
+   if (gPrefs->Read(wxT("/SelectionFormat"), &formatName)) {
+      for(int i = 0; i < ttc->GetNumBuiltins(); i++) {
+         if (ttc->GetBuiltinName(i) == formatName) {
+            formatIndex = i;
+            break;
+         }
+      }
+   }
+   else 
+      formatIndex = 1;
+
    wxString format = ttc->GetBuiltinFormat(formatIndex);
    delete ttc;
 
@@ -359,13 +361,14 @@
    bool audioFocus = (w == mAudioTime);
    
    evt.Skip(false);
-
-   /* we need an object to call these methods on. It actually doesn't matter
-    * which as they have no effect on the object state, so we just use the 
first
-    * one to hand */
-   wxString formatName =  mLeftTime->GetBuiltinName(index);
-
+   
+   /* we don't actually need a TimeTextCtrl, but need it's 
+    * translations which are done at runtime */
+   
+   TimeTextCtrl *ttc = new TimeTextCtrl(this, wxID_ANY, wxT(""), 0.0, mRate);
+   wxString formatName(ttc->GetBuiltinName(index));
    gPrefs->Write(wxT("/SelectionFormat"), formatName);
+   delete ttc;
 
    // ToolBar::ReCreateButtons() will get rid of our sizers and controls
    // so reset pointers first.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to