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 ( )
self . settings_dialog = app_ . Append ( wx . NewId ( ) , _ ( u " Preferences " ) )
2016-02-13 17:06:36 -06:00
buffer = wx . Menu ( )
2016-03-23 13:52:43 -06:00
self . new_buffer = wx . Menu ( )
self . search_audios = self . new_buffer . Append ( wx . NewId ( ) , _ ( u " Audio " ) )
2016-04-12 15:36:30 -05:00
buffer . AppendMenu ( wx . NewId ( ) , _ ( u " Search " ) , self . new_buffer )
self . timeline = buffer . Append ( wx . NewId ( ) , _ ( u " &New timeline " ) )
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 , ) )
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 )
self . makeMenu ( )
self . panel = wx . Panel ( self )
self . sizer = wx . BoxSizer ( wx . VERTICAL )
self . sb = self . CreateStatusBar ( )
self . tb = wx . Treebook ( self . panel , - 1 )
self . sizer . Add ( self . tb , 0 , wx . ALL , 5 )
def realize ( self ) :
self . panel . SetSizer ( self . sizer )
self . SetClientSize ( self . sizer . CalcMin ( ) )
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 ) :
self . tb . InsertSubPage ( pos , buffer , name )
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 )