From: Markus R. <rol...@us...> - 2007-04-29 16:13:15
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv4853 Modified Files: Tag: RSGEDIT_FILEREF mainframe.cpp mainframe.h Log Message: - handle ID_CONTEXT_EDIT_SOURCE event - lookup application registered for text/plain mime type and use it to open the rsg file associated with the context node Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -C2 -d -r1.12.2.1 -r1.12.2.2 *** mainframe.h 29 Apr 2007 15:33:59 -0000 1.12.2.1 --- mainframe.h 29 Apr 2007 16:13:10 -0000 1.12.2.2 *************** *** 102,105 **** --- 102,106 ---- void OnContextProperties(wxCommandEvent& event); + void OnContextEditSource(wxCommandEvent& event); void OnExit(wxCommandEvent& event); *************** *** 147,150 **** --- 148,153 ---- void UpdateCached(); + /** edit the given file starting at the given line */ + void EditFile(const wxString& fname, int line); protected: Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.16.2.1 retrieving revision 1.16.2.2 diff -C2 -d -r1.16.2.1 -r1.16.2.2 *** mainframe.cpp 29 Apr 2007 15:33:59 -0000 1.16.2.1 --- mainframe.cpp 29 Apr 2007 16:13:09 -0000 1.16.2.2 *************** *** 26,29 **** --- 26,30 ---- #include <wx/filename.h> + #include <wx/mimetype.h> #include <wx/filedlg.h> *************** *** 45,48 **** --- 46,50 ---- #include <oxygen/sceneserver/sceneserver.h> #include <oxygen/sceneserver/fpscontroller.h> + #include <oxygen/sceneserver/scenedict.h> #include <kerosin/inputserver/inputcontrol.h> #include "simspark.h" *************** *** 79,82 **** --- 81,85 ---- EVT_MENU(ID_CONTEXT_PROPERTIES, mainframe::OnContextProperties) + EVT_MENU(ID_CONTEXT_EDIT_SOURCE, mainframe::OnContextEditSource) EVT_TIMER(TI_LOG, mainframe::OnLogTimer) *************** *** 610,614 **** return; } ! PopupMenu(context); } --- 613,617 ---- return; } ! PopupMenu(context); } *************** *** 643,646 **** --- 646,689 ---- } + void mainframe::OnContextEditSource(wxCommandEvent& event) + { + weak_ptr<Leaf> leaf = SparkContext::GetInstance().GetContextNode(); + if (leaf.expired()) + { + assert(false); + return; + } + + + const SceneDict::FileRef* ref = SceneDict::GetInstance().Lookup(leaf); + if (ref == 0) + { + assert(false); + return; + } + + EditFile(ref->fname, ref->line); + } + + void mainframe::EditFile(const wxString& fname, int line) + { + wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromMimeType("text/plain"); + if (ft == 0) + { + return; + } + + wxFileName fn(fname); + fn.Normalize(); + + wxString cmd = ft->GetOpenCommand(fn.GetFullPath()); + if (cmd.IsEmpty()) + { + return; + } + + wxExecute(cmd); + } + void mainframe::RefreshProperties() { |