2016-02-13 17:06:36 -06:00
# -*- coding: utf-8 -*-
import wx
import application
class mainWindow ( wx . Frame ) :
def makeMenu ( self ) :
mb = wx . MenuBar ( )
2016-04-04 17:54:59 -05:00
app_ = wx . Menu ( )
2016-06-19 12:25:06 -05:00
create = wx . Menu ( )
self . audio_album = create . Append ( wx . NewId ( ) , _ ( u " Audio album " ) )
app_ . AppendMenu ( wx . NewId ( ) , _ ( u " Create " ) , create )
2016-06-28 22:32:32 -05:00
delete = wx . Menu ( )
self . delete_audio_album = delete . Append ( wx . NewId ( ) , _ ( u " Audio album " ) )
app_ . AppendMenu ( wx . NewId ( ) , _ ( u " Delete " ) , delete )
2016-04-04 17:54:59 -05:00
self . settings_dialog = app_ . Append ( wx . NewId ( ) , _ ( u " Preferences " ) )
2016-02-13 17:06:36 -06:00
buffer = wx . Menu ( )
2016-06-19 12:25:06 -05:00
search = wx . Menu ( )
self . search_audios = search . Append ( wx . NewId ( ) , _ ( u " Audio " ) )
2016-04-12 15:36:30 -05:00
self . timeline = buffer . Append ( wx . NewId ( ) , _ ( u " &New timeline " ) )
2016-06-19 12:25:06 -05:00
buffer . AppendMenu ( wx . NewId ( ) , _ ( u " Search " ) , search )
2016-02-23 17:49:55 -06:00
self . update_buffer = buffer . Append ( wx . NewId ( ) , _ ( u " Update current buffer " ) )
2016-02-13 17:06:36 -06:00
self . load_previous_items = buffer . Append ( wx . NewId ( ) , _ ( u " Load previous items " ) )
2016-03-27 00:11:52 -06:00
self . remove_buffer_ = buffer . Append ( wx . NewId ( ) , _ ( u " &Remove buffer " ) )
2016-04-04 17:54:59 -05:00
mb . Append ( app_ , _ ( u " Application " ) )
2016-02-13 17:06:36 -06:00
mb . Append ( buffer , _ ( u " Buffer " ) )
help_ = wx . Menu ( )
self . about = help_ . Append ( wx . NewId ( ) , _ ( u " About {0} " ) . format ( application . name , ) )
2016-06-29 13:16:35 -05:00
self . documentation = help_ . Append ( wx . NewId ( ) , _ ( u " Manual " ) )
2016-02-13 17:06:36 -06:00
self . check_for_updates = help_ . Append ( wx . NewId ( ) , _ ( u " Check for updates " ) )
2016-04-04 11:18:42 -05:00
self . changelog = help_ . Append ( wx . NewId ( ) , _ ( u " Chan&gelog " ) )
2016-02-13 17:06:36 -06:00
mb . Append ( help_ , _ ( u " Help " ) )
self . SetMenuBar ( mb )
def __init__ ( self ) :
super ( mainWindow , self ) . __init__ ( parent = None , id = wx . NewId ( ) , title = application . name )
2016-06-08 05:12:25 -05:00
self . Maximize ( )
2016-02-13 17:06:36 -06:00
self . makeMenu ( )
self . panel = wx . Panel ( self )
self . sizer = wx . BoxSizer ( wx . VERTICAL )
self . sb = self . CreateStatusBar ( )
self . tb = wx . Treebook ( self . panel , - 1 )
2016-06-05 08:11:25 -05:00
self . sizer . Add ( self . tb , 1 , wx . ALL | wx . EXPAND , 5 )
2016-02-13 17:06:36 -06:00
def realize ( self ) :
self . panel . SetSizer ( self . sizer )
self . SetClientSize ( self . sizer . CalcMin ( ) )
2016-06-05 08:11:25 -05:00
self . Layout ( )
self . SetSize ( self . GetBestSize ( ) )
2016-02-13 17:06:36 -06:00
def change_status ( self , status ) :
self . sb . SetStatusText ( status )
def connection_error ( self ) :
wx . MessageDialog ( self , _ ( u " There is a connection error. Check your internet connection and try again later. " ) , _ ( u " Connection error " ) , wx . ICON_ERROR ) . ShowModal ( )
def get_buffer_count ( self ) :
return self . tb . GetPageCount ( )
def add_buffer ( self , buffer , name ) :
self . tb . AddPage ( buffer , name )
def insert_buffer ( self , buffer , name , pos ) :
2016-05-25 11:33:57 -05:00
return self . tb . InsertSubPage ( pos , buffer , name )
2016-02-13 17:06:36 -06:00
def search ( self , name_ ) :
for i in xrange ( 0 , self . tb . GetPageCount ( ) ) :
if self . tb . GetPage ( i ) . name == name_ : return i
def get_current_buffer ( self ) :
return self . tb . GetCurrentPage ( )
def get_current_buffer_pos ( self ) :
return self . tb . GetSelection ( )
def get_buffer ( self , pos ) :
return self . GetPage ( pos )
def change_buffer ( self , position ) :
self . tb . ChangeSelection ( position )
def get_buffer_text ( self ) :
return self . tb . GetPageText ( self . tb . GetSelection ( ) )
def get_buffer_by_id ( self , id ) :
return self . nb . FindWindowById ( id )
def advance_selection ( self , forward ) :
self . tb . AdvanceSelection ( forward )
def about_dialog ( self , * args , * * kwargs ) :
info = wx . AboutDialogInfo ( )
info . SetName ( application . name )
info . SetVersion ( application . version )
info . SetDescription ( application . description )
info . SetCopyright ( application . copyright )
2016-04-05 08:35:25 -05:00
info . SetTranslators ( application . translators )
2016-02-13 17:06:36 -06:00
# info.SetLicence(application.licence)
info . AddDeveloper ( application . author )
2016-03-23 08:38:18 -06:00
wx . AboutBox ( info )
2016-03-27 00:11:52 -06:00
def remove_buffer ( self , pos ) :
self . tb . DeletePage ( pos )