Develop and Download Open Source Software

Browse CVS Repository

Contents of /malonnote/main.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.9 - (show annotations) (download) (as text)
Fri Feb 10 05:58:54 2006 UTC (18 years, 1 month ago) by maloninc
Branch: MAIN
CVS Tags: rel_1_7_1
Changes since 1.8: +2 -3 lines
File MIME type: text/x-c++src
fixed fatal bug for first users.

1 // -*- C++ -*- generated by wxGlade 0.3.5.1 on Wed Jun 29 12:57:38 2005
2
3 #include <wx/wx.h>
4 #include <wx/image.h>
5 #include <wx/snglinst.h>
6 #include <wx/xrc/xmlres.h>
7 #include "mnDef.h"
8 #include "mnFrame.h"
9 #include "mnFrameController.h"
10
11 extern void InitXmlResource(); // defined in mnResource.cpp generated by wxrc
12
13 class mnApp: public wxApp {
14 public:
15 bool OnInit();
16 int OnExit();
17
18 private:
19 mnFrame* mainFrame;
20 wxSingleInstanceChecker* m_checker;
21 };
22
23 IMPLEMENT_APP(mnApp)
24
25 //static wxLocale locale(wxLANGUAGE_DEFAULT);
26
27 bool mnApp::OnInit()
28 {
29 wxString* dirName = new wxString();
30 wxString gotDirName;
31 wxDirDialog* dlg;
32 wxString confKey;
33
34 const wxString appName = wxString::Format(wxT(MN_APP_NAME) wxT("-%s"), wxGetUserId().c_str());
35
36 m_checker = new wxSingleInstanceChecker(appName);
37 if ( m_checker->IsAnotherRunning() ){
38 wxMessageBox(wxT("Another program instance is already running, aborting."));
39 delete m_checker;
40 exit(0);
41 }
42
43 wxInitAllImageHandlers();
44 wxXmlResource::Get()->InitAllHandlers();
45 InitXmlResource();
46
47 mainFrame = new mnFrame(0);
48
49 /* set controller object as event handler */
50 mnFrameController* controller = new mnFrameController(mainFrame);
51 mainFrame->PushEventHandler(controller);
52
53 SetTopWindow(mainFrame);
54 mainFrame->Show();
55
56 /* add note panel */
57 wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));
58 if(config->Read(wxT(CONF_WIKI_DIR), dirName) == FALSE) {
59 delete dirName;
60 dlg = new wxDirDialog(mainFrame);
61 if(dlg->ShowModal() == wxID_OK) {
62 gotDirName = dlg->GetPath();
63 config->Write(wxT(CONF_WIKI_DIR), gotDirName.c_str());
64 mainFrame->addNotePanel(&gotDirName);
65 }
66 else {
67 mainFrame->Close();
68 }
69 }
70 else {
71 mainFrame->addNotePanel(dirName);
72
73 for(int i = 1; ;i++) {
74 confKey.sprintf(wxT(CONF_WIKI_DIR) "%d", i);
75 if(config->Read(confKey.c_str(), dirName) == FALSE) break;
76 mainFrame->addNotePanel(dirName);
77 }
78 mainFrame->getNotebook()->SetSelection(0);
79 }
80
81 delete config;
82
83 mainFrame->setFocusToSearchTextCtrl();
84 return true;
85 }
86
87 int mnApp::OnExit()
88 {
89 delete m_checker;
90 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26