JokosherApp
index
/home/david/Projects/Jokosher/trunk/Jokosher/JokosherApp.py

#       THIS FILE IS PART OF THE JOKOSHER PROJECT AND LICENSED UNDER THE GPL. SEE
#       THE 'COPYING' FILE FOR DETAILS
#
#       Jokosher's main class. It creates the majority of the main window GUI
#       and gets everything up and running.
#
#-------------------------------------------------------------------------------

 
Modules
       
AddInstrumentDialog
AlsaDevices
CompactMixView
Extension
ExtensionManager
ExtensionManagerDialog
Globals
InstrumentConnectionsDialog
NewProjectDialog
PreferencesDialog
Project
RecordingView
StatusBar
TimeView
Utils
WelcomeDialog
gettext
glob
gobject
gst
gtk
math
os
pygst
pygtk
string
sys
xml.dom.minidom

 
Classes
       
MainApp

 
class MainApp
    Jokosher's main class. It creates the majority of the main window GUI and 
gets everything up and running.
 
  Methods defined here:
About(self, widget=None)
Creates and shows the "About" dialog box.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
AboutLinkActivate(self, widget, link)
Opens the Jokosher website in the user's default web browser.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
CheckGstreamerVersions(self)
Check for CVS versions of Gstreamer and gnonlin. If requirements are not met,
a warning message is issued to the user.
ClearStatusBar(self, messageID)
Clears the status bar text in the position pointed by messageID.
 
Parameters:
        messageID -- the message identifier of the text to be cleared.
CloseProject(self)
Closes the current project. If there's changes pending, it'll ask the user for confirmation.
 
Returns:
        the status of the close operation:
        0 = there was no project open or it was closed succesfully.
        1 = cancel the operation and return to the normal program flow.
InsertRecentProject(self, path, name)
Inserts a new project with its corresponding path to the recent project list.
 
Parameters:
        path -- path to the project file.
        name -- name of the project being added.
OnChangeInstrument(self, widget=None)
Changes the type of the selected Instrument.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnChangeView(self, view, mode)
Updates the state of the recording and the compact mix buttons. It also might 
need to force a redraw of the timeline when changing views as it may have been
zoomed or scrolled while hidden.
 
Parameters:
        view -- reference to the view the main window has changed to.
        mode -- mode corresponding to the view the main window has changed to:
                        MainApp.MODE_RECORDING = recording view
                        MainApp.MODE_COMPACT_MIX = mixing view
OnClearRecentProjects(self, widget)
Clears the recent projects list. It then updates the user interface to reflect
the changes.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnCloseProject(self, widget)
Closes the current project by calling CloseProject(). 
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnCompactMixView(self, window=None)
Updates the main window after switching to the compact view mixing mode.
 
Parameters:
        window -- Window object calling this method.
OnContributingDialog(self, widget)
Creates and shows the "Contributing to Jokosher" dialog.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnContributingLinkButtonClicked(self, widget)
Opens the Jokosher contributing website in the user's default web browser.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnCopy(self, widget=None)
Copies the portion of selected audio to the clipboard.  
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnCut(self, widget=None, cut=True)
Cuts the portion of selected audio and puts it in the clipboard.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
        cut --  determines whether the operation should perform a cut or copy operation:
                        True = perform a cut operation.
                        False = perform a copy operation.
OnDelete(self, widget=None)
Deletes the currently selected instrument or event.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnDestroy(self, widget=None, event=None)
Called when the main window is destroyed.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
        event -- reserved for GTK callbacks, don't use it explicitly.
 
Returns:
        True -- the current project can't be properly closed.
                        This stops signal propagation.
OnEditMenu(self, widget)
HACK: When the edit menu opens, checks if any events or instruments are selected 
and sets the cut, copy, paste and delete menu items' sensitivity accordingly.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnExport(self, widget=None)
Creates and shows a save file dialog which allows the user to export
the project as ogg or mp3.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnExportCancel(self, widget=None)
Cancels a running export operation and destroys the export progress dialog.
 
Parameters:
        widget: reserved for GTK callbacks, don't use it explicitly.
OnExtensionManagerDialog(self, widget)
Creates and shows the "Extension Manager" dialog.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnForumsMenu(self, widget)
Opens the Jokosher forum in the user's default web browser.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnForwardPressed(self, widget=None)
Starts moving forward within the project's timeline.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnForwardReleased(self, widget=None)
Stops the current forward operation.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnHelpContentsMenu(self, widget=None)
Calls the appropiate help tool with the user manual in the correct
locale.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnImportAudio(self, widget)
Imports an audio file into the selected Instrument.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnInstrumentConnectionsDialog(self, widget)
Creates and shows the "Instrument Connections Dialog".
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnInstrumentMenu(self, widget)
HACK: When the instrument menu opens, set sensitivity depending on
whether there's a selected instrument or not.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnKeyPress(self, widget, event)
Handles the hotkeys, calling whichever function they are assigned to.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
        event -- reserved for GTK callbacks, don't use it explicitly.
OnMouseDown(self, widget, mouse)
If there's a project open, clears event and instrument selections. It also
updates the current display.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
        mouse -- reserved for GTK callbacks, don't use it explicitly.
OnNewProject(self, widget, destroyCallback=None)
Creates and shows the "New Project" dialog.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
        destroyCallback -- function that'll get called when the new project
                                                dialog gets destroyed.
OnOpenProject(self, widget, destroyCallback=None)
Creates and shows a open file dialog which allows the user to open
an existing Jokosher project.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
        destroyCallback -- function that'll get called when the open file
                                                dialog gets destroyed.
OnPaste(self, widget=None)
Pastes the portion of audio in the clipboard to the selected instrument,
at the selected position in time.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnPreferences(self, widget, destroyCallback=None)
Creates and shows the "Jokosher Preferences" dialog.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
        destroyCallback -- function that'll get called when the preferences 
                                                dialog gets destroyed.
OnRecentProjectsItem(self, widget, path, name)
Opens the project selected from the "Recent Projects" drop-down menu.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
        path -- path to the project file.
        name -- name of the project being opened.
OnRecordingView(self, window=None)
Updates the main window after switching to the recording mode.
 
Parameters:
        window -- Window object calling this method.
OnRedo(self, widget)
Redoes the last undo operation and updates the displays.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnRemoveInstrument(self, widget)
Removes all selected Instruments from the Project.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnRewindPressed(self, widget=None)
Starts moving backward within the project's timeline.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnRewindReleased(self, widget=None)
Stops the current rewind operation.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnSaveAsProject(self, widget=None)
Creates and shows a save as file dialog which allows the user to save
the current project to an specific file name.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnSaveProject(self, widget=None)
Saves the current project file.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnShowAddInstrumentDialog(self, widget)
Creates and shows the "Add Instrument" dialog box.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnShowBarsBeats(self, widget)
Sets and updates the current timeline view to Bars, Beats and Ticks.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnShowHoursMins(self, widget)
Sets and updates the current timeline view to Hours, Minutes and Seconds.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OnStateChanged(self, obj=None, change=None, *extra)
Updates internal flags, views and the user interface to reflect a given
change in the project.
 
Parameters:
        obj -- object calling the method.
        change -- string indicating the change which fired this function:
                        gst-bus-error = a serious core engine error occurred.
                        play = playback started.
                        pause = playback paused.
                        record = recording started.
                        stop = playback or recording was stopped.
                        transport-mode = the transport mode display was changed.
                        undo = an undo operation was performed.
        *extra -- parameters of additional information depending on the change parameter.
OnUndo(self, widget)
Undoes the last change made to the project and updates the displays.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
OpenProjectFromPath(self, path, parent=None)
Opens the project file referred by the path parameter.
 
Parameters:
        path -- path to the project to be opened.
        parent -- parent window of the error message dialog.
 
Returns:
        the status of the loading operation:
        True = the project could be successfully opened and 
                        set as the current project.
        False = loading the project failed. A dialog will be
                        displayed to user detailing the error.
OpenRecentProjects(self)
Populate the self.recentprojectpaths with items from global settings.
Play(self, widget=None)
Toggles playback.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
PopulateRecentProjects(self)
Populates the Recent Projects menu with items from self.recentprojectitems.
Record(self, widget=None)
Toggles recording. If there's an error, a warning/error message is 
issued to the user.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
SaveRecentProjects(self)
Saves the list of the last 8 recent projects to the Jokosher config file.
SetGUIProjectLoaded(self)
Refreshes the main window and it's components when a project is opened or closed.
For example, buttons are enabled/disabled whether there's a project currently open or not.
SetProject(self, project)
Tries to establish the Project parameter as the current project.
If there are errors, an error message is issued to the user.
 
Parameters:
        project -- the Project object to set as the main project.
SetStatusBar(self, message)
Appends the message parameter to the status bar text.
 
Parameters:
        message -- string to append to the status bar text.
ShowOpenProjectErrorDialog(self, error, parent=None)
Creates and shows a dialog to inform the user about an error that has ocurred.
 
Parameters:
        error -- string with the error(s) description.
        parent -- parent window of the error message dialog.
Stop(self, widget=None)
Stops the current record/playback (whichever is happening) operation.
 
Parameters:
        widget -- reserved for GTK callbacks, don't use it explicitly.
UpdateCurrentDisplay(self)
Updates the current display, Recording or Mixing, depending on which one
is active.
UpdateDisplay(self)
Updates the current display, Recording or Mixing, depending on which one
is active. Additionally, when idle, it'll update the view hidden in the
background.
UpdateExportDialog(self)
Updates the progress bar corresponding to the current export operation.
__init__(self, openproject=None, loadExtensions=True, startuptype=None)
Creates a new instance of MainApp.
 
Parameters:
        openproject -- filename of the project to open at startup.
        loadExtensions -- whether the extensions should be loaded.
        startuptype -- determines the startup state of Jokosher:
                                        0 = Open the project referred by the openproject parameter.
                                        1 = Do not display the welcome dialog or open a the previous project.
                                        2 = Display the welcome dialog.

Data and other attributes defined here:
MODE_COMPACT_MIX = 2
MODE_RECORDING = 1

 
Functions
       
main()
Main entry point for Jokosher.