288
288
Actions: scans for the correct record then adds it to the treemodel
290
290
def add_row(self,aid):
291
#retrieve series data from the database
291
292
results=self.database.get_records(record_type=series_rec,create_view=True)
292
293
for x in results:
294
#if we found our anime, add it to the treestore
293
295
if x.value['AID']==aid:
295
self.episode_view.get_model().append(None,[x.value['Title'],'0 Episodes','',x.value['AID']])
296
self.episode_view.get_model().append(None,[x.value['Title'],'0 Episodes','',x.value['AID']])
300
302
Actions: scans for a row, then deletes it
302
304
def remove_row(self,aid):
305
# get the nescessry information, then start looking through the treestore for the correct row
303
306
model=self.episode_view.get_model()
304
307
anime_iter=model.get_iter_root()
305
308
while anime_iter != None:
309
#if we find our record, delete it
306
310
if model.get_value(anime_iter,3)==aid:
307
311
model.remove(anime_iter)
309
313
anime_iter=model.iter_next(anime_iter)
314
#if we can't find a good entry in the treestore, just forget it
377
383
Actions: Spawns a message box that has an error with the passed text
379
385
def error_box(self,text=None):
380
silly=gtk.MessageDialog(self,0,gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE,text)
386
boxer=gtk.MessageDialog(self,0,gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE,text)
384
390
#end UI functions
393
399
Actions: Spawns dialog for user to enjoy
395
401
def about(self, widget, data=None):
396
"""about - display the about box for aniworld """
402
#spawn and run a AboutDialog
397
403
about = AboutAniworldDialog.NewAboutAniworldDialog()
398
404
response = about.run()
459
465
view_episode: Spawns a player for the current file, linked to double clicking in the episode grid, sets the watched status
466
Actions: finds the selected entry, then spawns a player window for it, then marks it as watched
462
468
def view_episode(self,widget,*params):
469
#get the selected row
463
470
selector=self.episode_grid.get_selection()
464
471
(model,rows)=selector.get_selected_rows()
467
474
iterr=model.get_iter(rows[0])
475
#get the record key, and look up the record using it
468
476
record_key=model.get_value(iterr,3)
469
477
record=self.database.get_record(record_key)
470
478
self.net_scan.set_viewed(record_key)
479
#get the file uri and mark the episode as watched
471
480
file_uri=record['uri']
472
481
self.database.update_fields(record_key,{'watched':'Watched'})
473
482
model.set(iterr,2,'Watched')
474
483
if model.iter_parent(iterr):
475
484
if os.path.isfile(file_uri):
485
#close out the old player
476
486
if self.player == None:
478
488
elif self.player.returncode == None:
479
489
self.player.terminate()
490
#load the player from the preferences and play the file
480
491
player=self.preferences['player']
481
492
self.player=subprocess.Popen([player,file_uri])
493
#this needs to be fixed
494
#it depends on what is calling this, it will call view_series if the row is an anime and not an episode
495
#it means that the user double clicked on the episode view, and when the series CouchGrid got merged in,
496
#this method ended up doing three diffferent things. It will be fixed by 0.2.0
482
497
elif params !=():
483
498
self.view_series(widget)
585
600
Actions: calls a function in the net_scan thread
587
602
def pause_queue(self,widget,data=None):
603
#tell the scanner thread to stop, which will cascade
588
604
self.net_scan.pause()
593
609
Actions: spawns a gtk.FileChooseDialog, then gets back what is nescessary to add to the queue using the __add_file function
595
611
def new_file(self,widget,data=None):
612
#make a file add dialog
596
613
dialogger=gtk.FileChooserDialog("Please Select File",None,gtk.FILE_CHOOSER_ACTION_OPEN,(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,gtk.STOCK_OK,gtk.RESPONSE_ACCEPT),None)
597
614
result=dialogger.run()
615
#get the selected file
598
616
get_file=dialogger.get_filename()
599
617
dialogger.destroy()
600
618
if (result != gtk.RESPONSE_ACCEPT):
620
#send the selected file to the __add_file funcion
602
621
self.__add_file(get_file,get_file.rsplit('/',1)[1])
622
#refresh_queue to reflect the new file
603
623
self.refresh_queue()
610
630
Actions: spawns a choose folder dialog, processes the files using the os.walk function, then refreshes the queue grid
612
632
def new_folder(self,widget,data=None):
633
#make a select folder dialog, run it then get the filename
613
634
dialogger=gtk.FileChooserDialog("Please Select Folder",None,gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,gtk.STOCK_OK,gtk.RESPONSE_ACCEPT),None)
614
635
result=dialogger.run()
615
636
get_folder=dialogger.get_filename()
616
637
dialogger.destroy()
617
638
if (result != gtk.RESPONSE_ACCEPT):
640
#iterate over the possible files, feed each one to __add_file
619
641
iterator = os.walk(get_folder)
620
642
for x,y,z in iterator:
622
644
self.__add_file(x+'/'+a,a)
645
#refresh the queue CouchGrid
623
646
self.refresh_queue()
630
653
Actions: add the passed file to the database, with the nescessary queue info
632
655
def __add_file(self,file_path,file_name):
656
#check to see if the file extension is in the file type dictionary
633
657
if(file_types.has_key(file_name.rsplit('.',1).pop(1))):
635
659
y=time.localtime()
636
#this next bit looks ugly, but most of it is making a nice timestamp
637
self.database.put_record(Record({'record_type':queue_rec,'Status':'Waiting', 'Filename':file_name, 'File Path':file_path, 'Time Added':str(y.tm_mday)+'-'+str(y.tm_mon)+'-'+str(y.tm_year)+' '+str(y.tm_hour)+':'+str(y.tm_min)+':'+str(y.tm_sec), 'File Size':str(os.stat(file_path).st_size), 'Location':os.uname()[1]}))
660
#I made a custom timestamp, and this code formats it right
661
time_stamp=str(y.tm_mday)+'-'+str(y.tm_mon)+'-'+str(y.tm_year)+' '+str(y.tm_hour)+':'+str(y.tm_min)+':'+str(y.tm_sec)
662
#put a record in that is ready to be picked up by the scanner
663
self.database.put_record(Record({'record_type':queue_rec,'Status':'Waiting', 'Filename':file_name, 'File Path':file_path, 'Time Added':time_stamp, 'File Size':str(os.stat(file_path).st_size), 'Location':os.uname()[1]}))
643
669
Actions: gets the selected file, removes it from the database, then resets the queue grid
645
671
def remove_file(self,widget,data=None):
672
#get the selected records
646
673
ids = self.queue_grid.selected_record_ids
674
#for all selected ids, delete them
647
675
for x in range(0,len(ids)):
648
676
self.database.delete_record(ids[x])
649
677
self.queue_grid.record_type=queue_rec