Recognizes if input is ogg or not.
[xiph.git] / xinloe / main.py
blob8392b921297919a388042b13a17602607bf32a8d
1 '''
2 Xinloe -- A Python-Based Non-Linear Ogg Editor
3 Copyright (C) 2004 Arc Riley <arc@Xiph.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 '''
21 from general import *
22 from workbox import *
23 from sandbox import *
24 from infobox import *
26 class MainFrame(wxFrame):
27 def __init__(self):
28 wxFrame.__init__(self, None, -1, 'Xinloe', size=(620,400))
29 self.CenterOnScreen()
30 self.CreateStatusBar()
31 self.SetStatusText("Ready.")
32 self.ToolLabels = 0
33 self.mainWin = MainWindow(self)
34 self.winCount = 0
36 menuBar = wxMenuBar()
37 toolBar = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER|wxTB_FLAT|wxTB_TEXT)
39 items=(('&File',(('&New', 'Create a new project', self.OnNewWindow, 'filenew'),
40 ('&Open', 'Open a saved project', self.OnToolClick, 'fileopen'),
41 ('&Close', 'Close Project', self.CloseWindow))),
42 ('&Edit',(('Cu&t', 'Move the selected text or item(s) to the clipboard', self.OnToolClick, 'editcut'),
43 ('&Copy', 'Copy the selected text or item(s) to the clipboard', self.OnToolClick, 'editcopy'),
44 ('&Paste', 'Paste the clipboard contents', self.OnToolClick, 'editpaste'))),
45 ('&Stream',(('Sta&rt', 'Move active cursor to head of the project',
46 self.OnToolClick, 'player_start'),
47 ('&Rewind', 'Move active cursor to start of the chain',
48 self.OnToolClick, 'player_rew'),
49 ('&Play', 'Stream from active cursor',
50 self.OnToolClick, 'player_play'),
51 ('&Stop', 'Stop streaming from active cursor',
52 self.OnToolClick, 'player_stop'),
53 ('&Forward', 'Move active cursor to the end of the chain',
54 self.OnToolClick, 'player_fwd'),
55 ('&End', 'Move active cursor to tail of the project',
56 self.OnToolClick, 'player_end'))))
59 i = 0
60 for m in items :
61 menu = wxMenu()
62 for t in m[1] :
63 if t :
64 menu.Append(i, t[0], t[1])
65 EVT_MENU(self, i, t[2])
66 if len(t) > 3 :
67 if self.ToolLabels :
68 toolBar.AddLabelTool(i, t[0].replace('&',''), geticon(t[3]), longHelp=t[1])
69 else :
70 toolBar.AddSimpleTool(i, geticon(t[3]), t[0].replace('&',''), t[1])
71 EVT_TOOL(self, i, t[2])
72 EVT_TOOL_RCLICKED(self, i, self.OnToolRClick)
73 else :
74 menu.AppendSeparator()
75 i = i + 1
76 menuBar.Append(menu, m[0])
77 toolBar.AddSeparator()
79 self.SetMenuBar(menuBar)
81 EVT_MENU_HIGHLIGHT_ALL(self, self.OnMenuHighlight)
83 def OnMenuHighlight(self, event):
84 # Show how to get menu item imfo from this event handler
85 id = event.GetMenuId()
86 item = self.GetMenuBar().FindItemById(id)
87 text = item.GetText()
88 help = item.GetHelp()
89 #print text, help
90 event.Skip() # but in this case just call Skip so the default is done
92 def CloseWindow(self, event):
93 self.Close()
95 def OnToolClick(self, event):
96 tb = self.GetToolBar()
97 #tb.EnableTool(10, not tb.GetToolEnabled(10))
99 def OnToolRClick(self, event):
100 return
102 def OnNewWindow(self, evt):
103 self.mainWin.workWin.NewProject()
105 def OnExit(self, evt):
106 self.Close(True)
108 class MyCanvas(wxScrolledWindow):
109 def __init__(self, win):
110 wxScrolledWindow.__init__(self, win)
111 self.SetBackgroundColour('White')
113 class MainWindow(wxSplitterWindow):
114 def __init__(self, parent):
115 wxSplitterWindow.__init__(self, parent, -1)
117 # Work Window
118 self.workWin = WorkPanel(self)
120 # Bottom Window
121 self.bottomWin = BottomWindow(self)
123 self.SetMinimumPaneSize(5)
124 self.SplitHorizontally(self.workWin, self.bottomWin, 200)
127 class BottomWindow(wxSplitterWindow):
128 def __init__(self, parent):
129 wxSplitterWindow.__init__(self, parent, -1)
131 # Sandbox Window
132 self.sandboxWin = SandboxPanel(self)
134 # Infobox Window
135 self.infoboxWin = InfoboxPanel(self)
137 self.SetMinimumPaneSize(5)
138 self.SplitVertically(self.sandboxWin, self.infoboxWin, 250)
143 import wx # This module uses the new wx namespace
144 #print "wx.VERSION_STRING = ", wx.VERSION_STRING
146 import sys, os
148 #----------------------------------------------------------------------------
151 class RunApp(wx.App):
152 def __init__(self):
153 wx.App.__init__(self, 0)
155 def OnInit(self):
156 wx.InitAllImageHandlers()
157 wx.Log_SetActiveTarget(wx.LogStderr())
159 win = MainFrame()
160 win.Show(True)
162 self.SetTopWindow(win)
163 self.frame = win
164 return True
166 def OnCloseFrame(self, evt):
167 if hasattr(self, "window") and hasattr(self.window, "ShutdownDemo"):
168 self.window.ShutdownDemo()
169 evt.Skip()
172 app = RunApp()
173 app.MainLoop()