~ubuntu-branches/ubuntu/gutsy/audacity/gutsy

« back to all changes in this revision

Viewing changes to src/Help.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2007-05-18 12:11:05 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070518121105-onhr7ojai3n5khzt
Tags: 1.3.3-1
* New upstream release
* Added watch file
* debian/patches:
   - updated libmp3lame patch
* debian/control:
   - as suggested upstream, depend on libgtk2.0-dev, otherwise 
     the code fails to build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**********************************************************************
2
 
 
3
 
  Audacity: A Digital Audio Editor
4
 
 
5
 
  Help.cpp
6
 
 
7
 
  Dominic Mazzoni
8
 
 
9
 
*******************************************************************//*!
10
 
 
11
 
\file Help.cpp
12
 
\brief Glue code to connect to html help controller.
13
 
 
14
 
  Audacity uses the wxWindows HTML help controller and gets the
15
 
  HTML files from a zip archive with a "htb" extension, which
16
 
  is supposed to stand for "HTML Book".  It expects the help
17
 
  file to be called "audacity-1.2-help.htb".
18
 
 
19
 
  If you want to edit the help file, unzip audacity-1.2-help.htb
20
 
  (rename it to audacity-1.2-help.zip first if you have to), edit
21
 
  the files, and then zip them again.  Audacity asks the user
22
 
  for the location of the help file the first time (if necessary)
23
 
  and then remembers it from then on.
24
 
 
25
 
*//*******************************************************************/
26
 
 
27
 
#include "Audacity.h"
28
 
 
29
 
#include <wx/defs.h>
30
 
#include <wx/filedlg.h>
31
 
#include <wx/msgdlg.h>
32
 
#include <wx/textdlg.h>
33
 
#include <wx/html/helpctrl.h>
34
 
#include <wx/intl.h>
35
 
 
36
 
#include "AudacityApp.h"
37
 
#include "Help.h"
38
 
#include "Internat.h"
39
 
#include "Prefs.h"
40
 
 
41
 
wxHtmlHelpController *gHelp = NULL;
42
 
 
43
 
void InitHelp(wxWindow * parent)
44
 
{
45
 
   if (!gHelp) {
46
 
      wxString defaultLoc;
47
 
      wxArrayString helpFiles;
48
 
 
49
 
      wxGetApp().FindFilesInPathList(wxT("audacity-1.2-help.htb"),
50
 
                                     wxGetApp().audacityPathList,
51
 
                                     wxFILE,
52
 
                                     helpFiles);
53
 
 
54
 
      if (helpFiles.GetCount() > 0)
55
 
         defaultLoc = helpFiles[0];
56
 
          else {
57
 
         defaultLoc = wxT(INSTALL_PREFIX);
58
 
         defaultLoc += wxT("/share/audacity/audacity-1.2-help.htb");
59
 
          }
60
 
 
61
 
      wxString helpFilePath =
62
 
          gPrefs->Read(wxT("/Help/HelpFilePath1.2"), defaultLoc);
63
 
 
64
 
      if (!::wxFileExists(helpFilePath)) {
65
 
         helpFilePath = defaultLoc;
66
 
      }
67
 
      if (!::wxFileExists(helpFilePath)) {
68
 
         helpFilePath = wxFileSelector(_("Where is audacity-1.2-help.htb?"), NULL,
69
 
                                       wxT("audacity-1.2-help.htb"),    // Name
70
 
                                       wxT(""),                     // Extension
71
 
                                       _("HTML Help Books (*.htb)|*.htb"),
72
 
                                       wxOPEN, parent);
73
 
         if (helpFilePath == wxT(""))
74
 
            return;
75
 
      }
76
 
 
77
 
      gHelp = new wxHtmlHelpController();
78
 
      if (!gHelp->AddBook(helpFilePath)) {
79
 
         wxMessageBox(_("Couldn't open the Audacity Help file."));
80
 
         delete gHelp;
81
 
         gHelp = NULL;
82
 
      }
83
 
 
84
 
      gPrefs->Write(wxT("/Help/HelpFilePath1.2"), helpFilePath);
85
 
   }
86
 
}
87
 
 
88
 
void ShowHelp(wxWindow * parent)
89
 
{
90
 
   InitHelp(parent);
91
 
 
92
 
   if (gHelp)
93
 
      gHelp->Display(wxT("contents.htm"));
94
 
}
95
 
 
96
 
void ShowHelpIndex(wxWindow * parent)
97
 
{
98
 
   InitHelp(parent);
99
 
 
100
 
   if (gHelp)
101
 
      gHelp->DisplayIndex();
102
 
}
103
 
 
104
 
void ShowHelp(wxWindow * parent, wxString topic)
105
 
{
106
 
   InitHelp(parent);
107
 
 
108
 
   if (gHelp)
109
 
      gHelp->KeywordSearch(topic);
110
 
}
111
 
 
112
 
void SearchHelp(wxWindow * parent)
113
 
{
114
 
   InitHelp(parent);
115
 
 
116
 
   if (gHelp) {
117
 
      wxString key = wxGetTextFromUser(_("Search for?"),
118
 
                                       _("Search help for keyword"),
119
 
                                       wxT(""),
120
 
                                       parent);
121
 
 
122
 
      if (!key.IsEmpty())
123
 
         gHelp->KeywordSearch(key);
124
 
   }
125
 
}
126
 
 
127
 
void QuitHelp()
128
 
{
129
 
   if (gHelp) {
130
 
      delete gHelp;
131
 
      gHelp = NULL;
132
 
   }
133
 
}
134
 
 
135
 
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
136
 
// version control system. Please do not modify past this point.
137
 
//
138
 
// Local Variables:
139
 
// c-basic-offset: 3
140
 
// indent-tabs-mode: nil
141
 
// End:
142
 
//
143
 
// vim: et sts=3 sw=3
144
 
// arch-tag: 6165cbc3-295a-4e52-b76c-825123aa7935
145