#!/usr/bin/env python import gtk import gtk.glade import gobject #import sys, os #import threading, Queue #import ConfigParser from widgets import PathBar, FileView from filereader import LocalFileReader, Path #from optparse import OptionParser, OptionGroup _DEBUG = True def custom_handler(*args, **kwargs): print args, kwargs widget = eval('%s()' % args[1]) widget.set_name(args[2]) print '> creating %s' % widget return widget gtk.glade.set_custom_handler(custom_handler) class Efteep: def __init__(self): self.wt = gtk.glade.XML("efteep.glade") self.wt.signal_autoconnect(self) self.object_autoconnect() self.main.set_default_size(700, 600) self.main.set_size_request(700, 600) self.localFileReader = LocalFileReader(Path('.')) self.localPathBar.path = self.localFileReader.path self.localFileView.fileReader = self.localFileReader #self.localView = FileView(LocalFileReader('.'), self.localTreeView) #self.remoteView = FileView(LocalFileReader('/'), self.remoteTreeView) #self.setViewWidths() #self.localView.refresh() #self.remoteView.refresh() def object_autoconnect(self): for w in self.wt.get_widget_prefix(''): n = w.get_name() if not hasattr(self, n): setattr(self, n, w) def setViewWidths(self): w = (self.main.props.width_request / 2) - 5 self.localVBox.props.width_request = w def on_window_delete(self, win, args): self.quit() return True def on_quit_activate(self, obj): self.quit() return True def on_about_activate(self, obj): print "> about..." return True def on_local_pathbar_directory_changed(self, *args): #args = [pathbar, path] pathbar, path = args self.localFileReader.chdir(path) self.localFileView.fileReader = self.localFileReader def on_local_fileview_directory_changed(self, *args): fileview, path = args self.localFileReader.chdir(path) self.localFileView.fileReader = self.localFileReader self.localPathBar.path = self.localFileReader.path def on_remote_pathbar_directory_changed(self, *args): print 'rpdc> ', args def on_remote_fileview_directory_changed(self, *args): print 'rfdc> ', args def quit(self, *args): # stop the queue reader gtk.main_quit() def error(self, string): print 'ERR>'.rjust(6) + string self.quit() def D(self, string): if _DEBUG: print 'DBG>'.rjust(6) + string def v(self, string): if self.options.verbose > 0: print 'v>'.rjust(6) + string if __name__ == "__main__": ftp = Efteep() try: gtk.main() except KeyboardInterrupt: try: ftp.quit() except RuntimeError: pass