示例#1
0
 def __init__(self):
   gui.console.Controller.Controller.__init__(self)
   self.statistics = {}
   #we can't just print stuff out to the screen, so this is called instead until I figure out something less stupidlike
   Logger.PRINT_FUNCTION = self.log_msg
   self.stdscr = None
   #theses objects are usd by the credit display
   for item in ('Wallet', 'Bank Balance', 'Earned', 'Spent'):
     self.statistics[item] = (Money(item, 0))
   self.status = {"Relay": 'Unknown', "UPNP": 'Unknown', "Published": 'Unknown', "Port": 'Unknown', "Client": 'Unknown'}
   self.rows          = {}
   self.lastData      = None
   self.curDownload   = None
   self.socksDisplay  = PsuedoGobject()
   self.statusDisplay = PsuedoGobject()
   self.torrents      = {'torrents':[], 'maxLength': 0}
   self.torStatus     = None
   #Keystrokes go into a threadsafe queue and are popped out in the main thread 
   self.q = Queue.Queue()
   self.shouldListen = True
   #this is used to store the previous N calls to log_msg
   self.msgBuffer = []
   #stores infos about external socks apps
   self.apps = {}
   self.moniesDisplay = [9, None]
   self.statusDisplay = (9, 60)
   self._start_curses()
   Globals.reactor.callInThread(self._listener)
   self.catch_event("shutdown")
   ClientUtil.add_updater(self)
 def __init__(self, controller):
   GeneratorMixin.GeneratorMixin.__init__(self)
   self.controller = controller
   self.testUpdateEvent = None
   self.torApp = Tor.get()
   self.lastTestResult = None
   ClientUtil.add_updater(self)
   self._add_events("failure", "success", "size_changed")
   
   #make the components for this GUI
   instructionBox = self._make_instruction_box()
   requiredPortsBox = self._make_required_ports_box()
   optionalPortsBox = self._make_optional_ports_box()
   buttonBox = self._make_button_box()
   
   #pack them into our window:
   box = gtk.VBox(spacing=PADDING)
   box.pack_start(instructionBox, False, False, 0)
   box.pack_start(requiredPortsBox, False, False, 0)
   box.pack_start(optionalPortsBox, False, False, 0)
   box.pack_end(buttonBox, False, False, 0)
   box.show()
   
   paddedBox = GTKUtils.add_padding(box, PADDING)
   paddedBox.show()
   frame = GTKUtils.add_frame(paddedBox)
   frame.show()
   
   self.container = frame
   self.label = gtk.Label("Relay Setup")
   
   #make pretty:
   _unify_widget_widths([self.relayBox.label, self.dhtBox.label, self.dirBox.label, self.upnpBox.label])
   _unify_widget_widths([self.relayBox.entry.entry, self.dhtBox.entry.entry, self.dirBox.entry.entry, self.upnpBox.entry.entry])
   self.container.set_focus_child(self.doneButton)
示例#3
0
  def __init__(self, torApp):
    self.torApp = torApp
    ClientUtil.add_updater(self)
    self.catch_event("tor_ready")
    self.textview = gtk.TextView(buffer=None)
    self.buffer = self.textview.get_buffer()
    self.textview.set_editable(False)  
    self.textview.set_cursor_visible(False)
    self.textview.set_wrap_mode(gtk.WRAP_WORD)
    
    self.textEventList = self.textview
    self.textEventList.show()
    # create a new scrolled window.
    scrolled_window = gtk.ScrolledWindow()
    scrolled_window.set_border_width(10)
    scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    #scrolled_window.set_size_request(300, 350)
    scrolled_window.add_with_viewport(self.textEventList)
    scrolled_window.show()
    
    self.entry = gtk.Entry(100)
    self.entry.connect("activate", self.enter_callback, self.entry)
    self.entry.show()

    vbox = gtk.VBox()
    vbox.pack_start(scrolled_window, True, True, 10)
    vbox.pack_end(self.entry, False, False)
    
    self.label = gtk.Label("Console")
    self.container = vbox
示例#4
0
 def __init__(self):    
   ClientUtil.add_updater(self)
   #Statistics
   stat_vbox = gtk.VBox()
   self.statistics = {}
   for stat in ("Local Balance", "Bank Balance", "Credits Earned"):
     gtkObj = gtk.Label(stat+": ")
     gtkObj.stat_value = ""
     align = gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
     align.add(gtkObj)
     align.set_padding(0, 0, 5, 0)
     stat_vbox.pack_end(align, False, False, 5)
     align.show()
     gtkObj.show()
     self.statistics[stat] = gtkObj
   stat_align = gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
   stat_align.add(stat_vbox)
   stat_vbox.show()
   stat_align.show()
   
   self.payments = 0
   self.failures = 0
   self.withdrawals = 0
   self.deposits = 0
   self.TEST_DONE = True
   
   self.buttonRow = gtk.HBox()
   
   b = gtk.Button("Request ACoins")
   self.buttonRow.pack_start(b)
   b.connect('clicked', self.request_cb)
   
   b = gtk.Button("Deposit ACoins")
   self.buttonRow.pack_start(b)
   b.connect('clicked', self.deposit_cb)
   
   b = gtk.Button("ACoin Payment")
   self.buttonRow.pack_start(b)
   b.connect('clicked', self.payment_cb)
   
   self.buttonRow.show_all()
   
   self.entry = gtk.Entry(0)
   self.entry.connect('activate', self.entry_cb)
   balanceEntryBox = gtk.HBox()
   balanceEntryBox.pack_start(gtk.Label("Pretend bank balance is:  "), False, False, 0)
   balanceEntryBox.pack_start(self.entry, True, True, 0)
   
   #Glue:
   self.vbox = gtk.VBox()
   self.vbox.pack_start(stat_align, False, False, 10)
   self.vbox.pack_end(self.buttonRow, False, False, 10)
   self.vbox.pack_end(balanceEntryBox, False, False, 10)
   self.vbox.show()
   
   self.container = self.vbox
   self.label = gtk.Label("Bank")
   return
示例#5
0
 def __init__(self, name, settingsClass, description):
   """Create an application.  All subclasses must call this function.
   @param name:           name of the application
   @type name:            str
   @param settingsClass:  used for storing application settings
   @type settingsClass:   Settings
   @param description:    short description of the application
   @type description:     str
   """
   GeneratorMixin.GeneratorMixin.__init__(self)
   BWHistory.BWHistory.__init__(self)
   self._add_events("launched", "started", "stopped", "finished")
   #: applications are stored in a single folder, by default under this folder:
   self.appBasePath = "apps"
   #: the name of the application
   self.name = name
   #: a short description of the application
   self.desc = description
   #load the settings file:
   if not hasattr(settingsClass, "defaultFile"):
     fileName = "%sSettings.ini" % (name)
   else:
     fileName = settingsClass.defaultFile
   fileName = os.path.join(Globals.USER_DATA_DIR, fileName)
   #: the Settings class instance
   self.settings = settingsClass()
   if not self.settings.load(fileName):
     self.isFirstRun = True
   else:
     self.isFirstRun = False
   #store for later loading the file
   self.settings.fileName = fileName
   #: list of process that are this application:
   self.processes = []
   #: this indicates that the program is in the process of shutting down:
   self.shutdownDeferred = None
   #: set when the process is starting up and we're waiting for it to finish
   self.startupDeferred = None
   #: set when starting or stopping and we need to restart:
   self.restartDeferred = None
   #: flag set when restarting:
   self.isRestarting = None
   #: dictionary mapping from id -> obj for all Circuits
   self.circuits = set()
   #: as above, but closed/failed circuits are never in this dictionary
   self.liveCircuits = set()
   #: dictionary mapping from id -> obj for all Streams
   self.streams = {}
   #: the 2-letter country code of the country to exit from, or None if this setting should be ignored
   self.exitCountry = None
   #: how many coins this application has spent so far
   self.coinsSpent = 0
   #: amount of time in seconds after which we stop trying to shutdown cleanly and give up
   self.shutdownTimeoutLength = 10
   #listen for a bunch of events:
   self.catch_event("shutdown")
   self.catch_event("tor_done")
   ClientUtil.add_updater(self)
示例#6
0
 def __init__(self, name, settingsClass, description):
     """Create an application.  All subclasses must call this function.
 @param name:           name of the application
 @type name:            str
 @param settingsClass:  used for storing application settings
 @type settingsClass:   Settings
 @param description:    short description of the application
 @type description:     str
 """
     GeneratorMixin.GeneratorMixin.__init__(self)
     BWHistory.BWHistory.__init__(self)
     self._add_events("launched", "started", "stopped", "finished")
     #: applications are stored in a single folder, by default under this folder:
     self.appBasePath = "apps"
     #: the name of the application
     self.name = name
     #: a short description of the application
     self.desc = description
     #load the settings file:
     if not hasattr(settingsClass, "defaultFile"):
         fileName = "%sSettings.ini" % (name)
     else:
         fileName = settingsClass.defaultFile
     fileName = os.path.join(Globals.USER_DATA_DIR, fileName)
     #: the Settings class instance
     self.settings = settingsClass()
     if not self.settings.load(fileName):
         self.isFirstRun = True
     else:
         self.isFirstRun = False
     #store for later loading the file
     self.settings.fileName = fileName
     #: list of process that are this application:
     self.processes = []
     #: this indicates that the program is in the process of shutting down:
     self.shutdownDeferred = None
     #: set when the process is starting up and we're waiting for it to finish
     self.startupDeferred = None
     #: set when starting or stopping and we need to restart:
     self.restartDeferred = None
     #: flag set when restarting:
     self.isRestarting = None
     #: dictionary mapping from id -> obj for all Circuits
     self.circuits = set()
     #: as above, but closed/failed circuits are never in this dictionary
     self.liveCircuits = set()
     #: dictionary mapping from id -> obj for all Streams
     self.streams = {}
     #: the 2-letter country code of the country to exit from, or None if this setting should be ignored
     self.exitCountry = None
     #: how many coins this application has spent so far
     self.coinsSpent = 0
     #: amount of time in seconds after which we stop trying to shutdown cleanly and give up
     self.shutdownTimeoutLength = 10
     #listen for a bunch of events:
     self.catch_event("shutdown")
     self.catch_event("tor_done")
     ClientUtil.add_updater(self)
示例#7
0
    def __init__(self, controller):
        GeneratorMixin.GeneratorMixin.__init__(self)
        self.controller = controller
        self.testUpdateEvent = None
        self.torApp = Tor.get()
        self.lastTestResult = None
        ClientUtil.add_updater(self)
        self._add_events("failure", "success", "size_changed")

        #make the components for this GUI
        instructionBox = self._make_instruction_box()
        requiredPortsBox = self._make_required_ports_box()
        optionalPortsBox = self._make_optional_ports_box()
        buttonBox = self._make_button_box()

        #pack them into our window:
        box = gtk.VBox(spacing=PADDING)
        box.pack_start(instructionBox, False, False, 0)
        box.pack_start(requiredPortsBox, False, False, 0)
        box.pack_start(optionalPortsBox, False, False, 0)
        box.pack_end(buttonBox, False, False, 0)
        box.show()

        paddedBox = GTKUtils.add_padding(box, PADDING)
        paddedBox.show()
        frame = GTKUtils.add_frame(paddedBox)
        frame.show()

        self.container = frame
        self.label = gtk.Label("Relay Setup")

        #make pretty:
        _unify_widget_widths([
            self.relayBox.label, self.dhtBox.label, self.dirBox.label,
            self.upnpBox.label
        ])
        _unify_widget_widths([
            self.relayBox.entry.entry, self.dhtBox.entry.entry,
            self.dirBox.entry.entry, self.upnpBox.entry.entry
        ])
        self.container.set_focus_child(self.doneButton)
示例#8
0
 def __init__(self):
     gui.console.Controller.Controller.__init__(self)
     self.statistics = {}
     #we can't just print stuff out to the screen, so this is called instead until I figure out something less stupidlike
     Logger.PRINT_FUNCTION = self.log_msg
     self.stdscr = None
     #theses objects are usd by the credit display
     for item in ('Wallet', 'Bank Balance', 'Earned', 'Spent'):
         self.statistics[item] = (Money(item, 0))
     self.status = {
         "Relay": 'Unknown',
         "UPNP": 'Unknown',
         "Published": 'Unknown',
         "Port": 'Unknown',
         "Client": 'Unknown'
     }
     self.rows = {}
     self.lastData = None
     self.curDownload = None
     self.socksDisplay = PsuedoGobject()
     self.statusDisplay = PsuedoGobject()
     self.torrents = {'torrents': [], 'maxLength': 0}
     self.torStatus = None
     #Keystrokes go into a threadsafe queue and are popped out in the main thread
     self.q = Queue.Queue()
     self.shouldListen = True
     #this is used to store the previous N calls to log_msg
     self.msgBuffer = []
     #stores infos about external socks apps
     self.apps = {}
     self.moniesDisplay = [9, None]
     self.statusDisplay = (9, 60)
     self._start_curses()
     Globals.reactor.callInThread(self._listener)
     self.catch_event("shutdown")
     ClientUtil.add_updater(self)
示例#9
0
  def __init__(self):
    bbApp = BitBlinder.get()
    self.bbApp = bbApp
    self.torApp = bbApp.torApp
    self.catch_event("tor_ready")
    self.catch_event("tor_done")
    self.catch_event("new_relay")
    ClientUtil.add_updater(self)
    #create the view and store for all the data columns:
    #TODO:  make display text prettier (transition to MB as appropriate, etc)
    self.mdl = gtk.TreeStore( gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, int, str, str, "gboolean" )
    modelfilter = self.mdl.filter_new()
    self.visColumn = 10
    modelfilter.set_visible_column(self.visColumn)
    self.view = gtk.TreeView( modelfilter )
    self.columnLabels = ["ID", "Status", "Path", "BW (down)", "Reason", "Age", "Total (Down)"]

    #add each of the columns
    for i in range(0,len(self.columnLabels)):
      name = self.columnLabels[i]
      colId = i
      #make column
      column = gtk.TreeViewColumn(name)
      #basic string renderer for the data in the column
      column.cell = gtk.CellRendererText()
      #add the renderer to the column...  idk if you can add more than one
      column.pack_start(column.cell, True)
      #add the column to the treeview
      self.view.append_column(column)
      ##TODO:  this gave an exception last time for some reason
      ##this acts as a macro to set a bunch of properties that make this column sortable
      #column.set_sort_column_id(colId)
      #tell the column where to get it's string data, and the data for colors
      column.set_attributes(column.cell, text=colId, background=len(self.columnLabels)+1, foreground=len(self.columnLabels)+2)
      #set properties to make the column interact intuitively.
      column.set_properties(reorderable=True, expand=True, clickable=True, resizable=True)
      
    hbox = gtk.HBox()
    self.showCircuits = False
    self.showStreams = False
    button = gtk.CheckButton("Show closed Streams:")
    button.connect("toggled", self.toggle_cb, "streams")
    hbox.pack_start(button)
    button = gtk.CheckButton("Show closed Circuits:")
    button.connect("toggled", self.toggle_cb, "circuits")
    hbox.pack_start(button)
      
    self.vbox = gtk.VBox()
    #make scrollwindow because the circuit list gets really long
    self.scrolled_window = gtk.ScrolledWindow()
    self.scrolled_window.set_border_width(10)
    self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    #self.scrolled_window.set_size_request(500, 500)
    self.scrolled_window.add_with_viewport(self.view)
    self.scrolled_window.show()
    self.comboRow = gtk.HButtonBox()
    self.buttonRow = gtk.HButtonBox()
#    self.testRow = gtk.HBox()
    self.vbox.pack_start(hbox, False)
    self.vbox.pack_start(self.scrolled_window)
    self.vbox.pack_start(self.comboRow, False)
    self.vbox.pack_start(self.buttonRow, False)
#    self.vbox.pack_start(self.testRow, False)
    
    self.testStreams = []
    self.objects = set()
    
    self.routerCombos = []
    for i in range(0,3):
      combo = gtk.combo_box_new_text() 
      self.routerCombos.append(combo)
      combo.set_size_request(100, -1)
      self.comboRow.pack_start(combo)
      
    self.countryCombo = gtk.combo_box_new_text()
    self.countryCombo.append_text("")
    self.countryCombo.set_size_request(150, -1)
    self.comboRow.pack_start(self.countryCombo)
    self.countryCombo.connect("changed", self.country_changed_cb)
      
    b = gtk.Button("Launch Circuit")
    self.buttonRow.pack_start(b)
    b.connect('clicked', self.launch_circuit)
    
    b = gtk.Button("Download")
    self.buttonRow.pack_start(b)
    b.connect('clicked', self.launch_test_download)
    
    b = gtk.Button("Upload")
    self.buttonRow.pack_start(b)
    b.connect('clicked', self.launch_test_upload)
    
    b = gtk.Button("PAR Test")
    self.buttonRow.pack_start(b)
    b.connect('clicked', self.launch_par_test)
    
    b = gtk.Button("DHT")
    self.buttonRow.pack_start(b)
    b.connect('clicked', self.dht_cb)
    
    b = gtk.Button("Inspect")
    self.buttonRow.pack_start(b)
    b.connect('clicked', self.inspect_cb)
    
    b = gtk.Button("Kill Selected")
    self.buttonRow.pack_start(b)
    b.connect('clicked', self.kill_selected)
    
    self.vbox.show()
    self.comboRow.show()
    self.buttonRow.show()
    
    #these are used by GTK Controller to easily add the component to the main window
    self.label = gtk.Label("Circuit List")
    self.container = self.vbox
示例#10
0
  def create(self):
    self.connect("destroy", self.destroy_cb)
    
    ClientUtil.add_updater(self)
    self.catch_event("no_credits")
    
    def on_launched(button):
      self.start()
    self._start_listening_for_event("launched", self.app, on_launched)
    
    self.popupMenu = TorrentPopupMenu(self)
      
    #everything changes in relation to this magic number
    maggicPadding = 2
    
    self.statusRow = BTUtilityStatusRow(self.app, maggicPadding)
    self.buttonRow = BTUtilityButtonRow(self.app, maggicPadding)
    self._start_listening_for_event("add_file", self.buttonRow, self._add_file_cb)
    self._start_listening_for_event("remove_file", self.buttonRow, self._remove_file_cb) 
    self._start_listening_for_event("pause_torrent", self.buttonRow, self._pause_cb) 
    self._start_listening_for_event("toggle_anonymity", self.buttonRow, self._toggle_anon_cb)
    
    self.rows = {}
    self.curDownload = None
    self.exitDialog = None
    self.trackerEditDialog = None
    
    #create a liststore with one string column to use as the model
                #COLUMNS:
                #0:  File name
    typeList = [gobject.TYPE_STRING,
                #1:  Amount done
                gobject.TYPE_FLOAT,
                #2:  Status
                gobject.TYPE_STRING,
                #3:  ETA
                gobject.TYPE_STRING,
                #4:  Peers
                gobject.TYPE_STRING,
                #5:  Seeds
                gobject.TYPE_STRING,
                #6:  Download Rate
                gobject.TYPE_STRING,
                #7:  Upload Rate
                gobject.TYPE_STRING,
                #8:  Download Amount
                gobject.TYPE_STRING,
                #9:  Upload Amount
                gobject.TYPE_STRING,
                #10:  Upload Amount
                gobject.TYPE_STRING,
                #11:  the hash for the download.  Stored hex-encoded, because nulls mess up gtk
                gobject.TYPE_STRING,
                #12:  is the row visible?
                gobject.TYPE_BOOLEAN
                ]
    self.attrIdx = {}
    self.attrIdx["name"]         = 0
    self.attrIdx["progress"]     = 1
    self.attrIdx["progressMsg"]  = 2
    self.attrIdx["status"]       = 3
    self.attrIdx["peers"]        = 4
    self.attrIdx["seeds"]        = 5
    self.attrIdx["rateUp"]       = 6
    self.attrIdx["rateDown"]     = 7
    self.attrIdx["amountUp"]     = 8
    self.attrIdx["amountDown"]   = 9
    self.attrIdx["copies"]       = 10
    self.attrIdx["hash"]         = 11
    self.attrIdx["visibility"]   = 12
    self.liststore = gtk.ListStore(*typeList)
    COLUMN_NAMES = ["Name", "Progress", "Time Left", "Peers", "Seeds", "Down Rate", "Up Rate", "Down Amt", "Up Amt", "Copies"]
    
    modelfilter, treeview = GTKUtils.make_listview(self.liststore, COLUMN_NAMES)
    GTKUtils.make_text_cell(treeview.columns[0], 0)
    GTKUtils.make_progress_cell(treeview.columns[1], 1, 2)
    for i in range (2, len(COLUMN_NAMES)):
      GTKUtils.make_text_cell(treeview.columns[i], i+1)
    
    #make treeview searchable
    treeview.set_search_column(0)
    #attach the filtermodel and treeview
    treeview.set_model(gtk.TreeModelSort(modelfilter))
    treeview.connect("cursor-changed", self.row_change_cb)
    treeview.connect("button-press-event", self.button_press_cb)
    treeview.connect("button-press-event", self.button_press_cb)
#    treeview.set_size_request(-1, 30)
    treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
    
    self.treeview, self.modelfilter = treeview, modelfilter
    self.modelfilter.set_visible_func(self.visible_cb)
    
    topBox = gtk.VBox()
    topBox.pack_start(self.buttonRow, False, False, 0)
    scrolledTorrentsBox = GTKUtils.make_scroll_box(treeview, hPolicy=gtk.POLICY_AUTOMATIC, vPolicy=gtk.POLICY_AUTOMATIC)
    scrolledTorrentsBoxAlign = gtk.Alignment(0, 0, 1, 1) 
    scrolledTorrentsBoxAlign.set_padding(0, maggicPadding, maggicPadding, maggicPadding)
    scrolledTorrentsBoxAlign.add(scrolledTorrentsBox)

    topBox.pack_start(scrolledTorrentsBoxAlign, True, True, 0)
    
    self.priorityBox = gtk.HBox()
    self.priorityBox.pack_start(gtk.Label("Select a torrent to set the priority for its files."), True, True, 0)
    self.priorityBox.set_border_width(0)
    
    self.peerBox = gtk.HBox()
    self.peerBox.pack_start(gtk.Label("Select a torrent to see your peers in the swarm."), True, True, 0)
    
    self.bwGraph = BWGraph.BWGraph(self.app, root=self)
    self.bwGraph.container.set_size_request(-1, 150)

    self.notebook = ClosableTabNotebook.ClosableTabNotebook()
    self.notebook.set_show_border(True)
    self.notebook.set_border_width(0)
    self.bwGraph.label = gtk.Label("BitTorrent Traffic")
    self.priorityBox.label = gtk.Label("Priorities")
    self.priorityBox.container = self.priorityBox
    self.peerBox.label = gtk.Label("Peers")
    self.peerBox.container = self.peerBox
    self.notebook.show_display(self.bwGraph)
    self.notebook.show_display(self.priorityBox)
    self.notebook.show_display(self.peerBox)
    self.notebook.show_display(self.bwGraph)
    
    alignBottom = gtk.Alignment(0, 0, 1, 1)
    alignBottom.set_padding(0, maggicPadding + 3, maggicPadding + 2, maggicPadding + 2)
    alignBottom.add(self.notebook)
    
    vBoxBottom = gtk.VBox()
    vBoxBottom.pack_start(alignBottom, True, True, 0)
    vBoxBottom.pack_end(self.statusRow, False, False, 0)
    
    vpane = gtk.VPaned()
    
    self.menuBar = BitTorrentMenuBar(self.controller, self)    
    
    frame = gtk.Frame()
    frame.set_shadow_type(gtk.SHADOW_OUT)
    frame.add(topBox)
    
    alignTop = gtk.Alignment(1, 1, 1, 1)
    alignTop.set_padding(10, 0, maggicPadding + 3, maggicPadding + 3)
    alignTop.add(frame)
    
    topContainer = gtk.VBox()
    topContainer.pack_start(self.menuBar.create_menus(), False, False, 0)
    topContainer.pack_start(alignTop, True, True, 0)
    
    vpane.pack1(topContainer, resize=True, shrink=False)
    vpane.pack2(vBoxBottom, resize=False, shrink=False)
    
    self.label = gtk.Label("")
    self.label.set_markup("<span size='x-large' weight='bold'>Bit Twister</span>")
    self.container = vpane
    vpane.set_position(400)
    self.add(self.container)
    self.container.show_all()
示例#11
0
  def __init__(self, app, torrentHash, data):
    self.app = app
    ClientUtil.add_updater(self)
    self.torrentHash = torrentHash
    self.torrentData = data
    self.download = None
    #a mapping from peer id to row
    self.peerRows = {}
    self.attrIdx = {}
    
    self.COLUMNS = [ ("ip",           "IP",        "string"),
                     ("upRate",       "uRate",     "rate"),
                     ("downRate",     "dRate",     "rate"),
                     ("upTotal",      "uTotal",    "amount"),
                     ("downTotal",    "dTotal",    "amount"),
                     ("upChoked",     "uChoked",   "string"),
                     ("downChoked",   "dChoked",   "string"),
                     ("snub",         "Snub",      "string"),
                     ("upInterest",   "uInterest", "string"),
                     ("downInterest", "dInterest", "string"),
                     ("speed",        "Speed",     "rate"),
                     ("requests",     "Requests",  "string"),
                     ("circ",         "Circ",      "string"),
                     ("amountDone",   "Done",      "percent"),
                     ("client",       "Client",    "string"),
                     ("id",           "ID",        "string")]
    COLUMN_NAMES = [columnTuple[1] for columnTuple in self.COLUMNS]
    TYPE_LIST = []
    for columnTuple in self.COLUMNS:
      columnType = columnTuple[2]
      if columnType in ("string"):
        TYPE_LIST.append(gobject.TYPE_STRING)
      elif columnType == "amount":
        TYPE_LIST.append(gobject.TYPE_INT)
      elif columnType in ("rate", "percent"):
        TYPE_LIST.append(gobject.TYPE_FLOAT)
      else:
        raise Exception("Bad type for column:  %s" % (columnType))

    self.liststore = gtk.ListStore(*TYPE_LIST)
    modelfilter, treeview = GTKUtils.make_listview(self.liststore, COLUMN_NAMES)
    for i in range(0, len(self.COLUMNS)):
      attrName = self.COLUMNS[i][0]
      attrType = self.COLUMNS[i][2]
      self.attrIdx[attrName] = i
      if attrType == "string":
        GTKUtils.make_text_cell(treeview.columns[i], i, makeSortable=True)
      else:
        cellFunc = getattr(self, "_cell_data_" + attrType)
        self._make_number_cell(treeview.columns[i], i, cellFunc)
        
    #make treeview searchable
    treeview.set_search_column(0)
    #attach the filtermodel and treeview
    self.model = gtk.TreeModelSort(modelfilter)
    treeview.set_model(self.model)
    treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
    self.modelfilter, self.treeview = modelfilter, treeview
    scrolled_window = GTKUtils.make_scroll_box(self.treeview, hPolicy=gtk.POLICY_AUTOMATIC, vPolicy=gtk.POLICY_AUTOMATIC)
    scrolled_window.set_size_request(-1, 200)
    self.container = scrolled_window
示例#12
0
    def __init__(self):
        bbApp = BitBlinder.get()
        self.bbApp = bbApp
        self.torApp = bbApp.torApp
        self.catch_event("tor_ready")
        self.catch_event("tor_done")
        self.catch_event("new_relay")
        ClientUtil.add_updater(self)
        #create the view and store for all the data columns:
        #TODO:  make display text prettier (transition to MB as appropriate, etc)
        self.mdl = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                                 gobject.TYPE_STRING, gobject.TYPE_STRING,
                                 gobject.TYPE_STRING, gobject.TYPE_STRING,
                                 gobject.TYPE_STRING, int, str, str,
                                 "gboolean")
        modelfilter = self.mdl.filter_new()
        self.visColumn = 10
        modelfilter.set_visible_column(self.visColumn)
        self.view = gtk.TreeView(modelfilter)
        self.columnLabels = [
            "ID", "Status", "Path", "BW (down)", "Reason", "Age",
            "Total (Down)"
        ]

        #add each of the columns
        for i in range(0, len(self.columnLabels)):
            name = self.columnLabels[i]
            colId = i
            #make column
            column = gtk.TreeViewColumn(name)
            #basic string renderer for the data in the column
            column.cell = gtk.CellRendererText()
            #add the renderer to the column...  idk if you can add more than one
            column.pack_start(column.cell, True)
            #add the column to the treeview
            self.view.append_column(column)
            ##TODO:  this gave an exception last time for some reason
            ##this acts as a macro to set a bunch of properties that make this column sortable
            #column.set_sort_column_id(colId)
            #tell the column where to get it's string data, and the data for colors
            column.set_attributes(column.cell,
                                  text=colId,
                                  background=len(self.columnLabels) + 1,
                                  foreground=len(self.columnLabels) + 2)
            #set properties to make the column interact intuitively.
            column.set_properties(reorderable=True,
                                  expand=True,
                                  clickable=True,
                                  resizable=True)

        hbox = gtk.HBox()
        self.showCircuits = False
        self.showStreams = False
        button = gtk.CheckButton("Show closed Streams:")
        button.connect("toggled", self.toggle_cb, "streams")
        hbox.pack_start(button)
        button = gtk.CheckButton("Show closed Circuits:")
        button.connect("toggled", self.toggle_cb, "circuits")
        hbox.pack_start(button)

        self.vbox = gtk.VBox()
        #make scrollwindow because the circuit list gets really long
        self.scrolled_window = gtk.ScrolledWindow()
        self.scrolled_window.set_border_width(10)
        self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
                                        gtk.POLICY_AUTOMATIC)
        #self.scrolled_window.set_size_request(500, 500)
        self.scrolled_window.add_with_viewport(self.view)
        self.scrolled_window.show()
        self.comboRow = gtk.HButtonBox()
        self.buttonRow = gtk.HButtonBox()
        #    self.testRow = gtk.HBox()
        self.vbox.pack_start(hbox, False)
        self.vbox.pack_start(self.scrolled_window)
        self.vbox.pack_start(self.comboRow, False)
        self.vbox.pack_start(self.buttonRow, False)
        #    self.vbox.pack_start(self.testRow, False)

        self.testStreams = []
        self.objects = set()

        self.routerCombos = []
        for i in range(0, 3):
            combo = gtk.combo_box_new_text()
            self.routerCombos.append(combo)
            combo.set_size_request(100, -1)
            self.comboRow.pack_start(combo)

        self.countryCombo = gtk.combo_box_new_text()
        self.countryCombo.append_text("")
        self.countryCombo.set_size_request(150, -1)
        self.comboRow.pack_start(self.countryCombo)
        self.countryCombo.connect("changed", self.country_changed_cb)

        b = gtk.Button("Launch Circuit")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.launch_circuit)

        b = gtk.Button("Download")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.launch_test_download)

        b = gtk.Button("Upload")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.launch_test_upload)

        b = gtk.Button("PAR Test")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.launch_par_test)

        b = gtk.Button("DHT")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.dht_cb)

        b = gtk.Button("Inspect")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.inspect_cb)

        b = gtk.Button("Kill Selected")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.kill_selected)

        self.vbox.show()
        self.comboRow.show()
        self.buttonRow.show()

        #these are used by GTK Controller to easily add the component to the main window
        self.label = gtk.Label("Circuit List")
        self.container = self.vbox
示例#13
0
    def __init__(self, controller):
        GeneratorMixin.GeneratorMixin.__init__(self)
        ListenerMixin.ListenerMixin.__init__(self)

        self.controller = controller
        self.torApp = Tor.get()

        self._add_events("show_settings", "toggle_server", "show_setup", "done")
        ClientUtil.add_updater(self)

        self.bwGraph = BWGraph.BWGraph(BWHistory.remoteBandwidth, root=controller.serverWindow)
        self.bwGraph.container.set_size_request(400, 200)
        self.bwGraph.label = gtk.Label("Relay Traffic")
        self.statusRows = []

        self.statistics = {}
        self.torStatus = None
        self.rows = []
        iconSize = 24
        tooltips = gtk.Tooltips()

        def make_row_box(name, labelText, childWidget):
            """packs a gui row with a label, childWidget, and an image.
      it then adds the row and a separator to a vbox which it returns 
      as well as the label it created as for use in homogenizing all the label widths"""

            image = gtk.Image()
            image.set_from_pixbuf(Images.GREY_CIRCLE)
            imageAlign = gtk.Alignment(0, 0, 0, 0)
            # push the widget over
            imageAlign.set_padding(0, 0, 0, 10)
            imageAlign.add(image)

            textLabel = gtk.Label()
            textLabel.set_markup("<span size='large' weight='bold'>%s</span>" % (labelText))
            # stick the align on the left
            textLabel.set_alignment(0, 0.5)

            row = StatusHBox(name, textLabel, childWidget, image)
            self.statusRows.append(row)

            row.pack_start(imageAlign, False, False, 0)
            row.pack_start(textLabel, False, False, 0)
            row.pack_start(childWidget, False, False, 0)

            # pad the whole row
            rowAlign = gtk.Alignment(0, 0, 1, 1)
            rowAlign.set_padding(0, 0, 5, 5)
            rowAlign.add(row)

            sep = gtk.HSeparator()
            vBox = gtk.VBox()
            vBox.pack_start(rowAlign, False, False, 10)
            vBox.pack_start(sep, False, False, 0)

            return (vBox, row)

        creditsValueLabel = gtk.Label("0")
        creditsBox, self.creditsRow = make_row_box("credits", "Credits: ", creditsValueLabel)

        statusValueLabel = gtk.Label("Unknown")
        statusBox, self.statusRow = make_row_box("status", "Status: ", statusValueLabel)

        def on_toggle(widget):
            self._trigger_event("toggle_server")

        self.relayToggleButton = GTKUtils.make_image_button(_("Start"), on_toggle, "exit.png")
        self.relayToggleButton.set_size_request(75, -1)
        relayBox, self.relayRow = make_row_box("relay", "Relay:", self.relayToggleButton)

        textLabel = gtk.Label("Unknown")
        relayPortBox, self.tcpRelayPortRow = make_row_box("orPort", "TCP Relay Port:", textLabel)

        textLabel = gtk.Label("Unknown")
        udpRelayPortBox, self.udpRelayPortRow = make_row_box("dhtPort", "UDP Relay Port:", textLabel)

        textLabel = gtk.Label()
        textLabel.set_markup('<span size="large">     55555 is unreachable        </span>')
        dirPortBox, self.dirPortRow = make_row_box("dirPort", "Directory Port:", textLabel)

        labels = [
            box.rowLabel
            for box in self.creditsRow,
            self.statusRow,
            self.relayRow,
            self.tcpRelayPortRow,
            self.udpRelayPortRow,
            self.dirPortRow,
        ]
        maxLabelWidth = 5 + max([label.size_request()[0] for label in labels])
        for label in labels:
            label.set_size_request(maxLabelWidth, -1)

        hideButton = gtk.Button("Hide")
        hideButton.connect("clicked", self._hide_cb)
        settingsButton = gtk.Button("Settings")

        def on_settings(widget):
            self._trigger_event("show_settings")

        settingsButton.connect("clicked", on_settings)
        buttonBox = gtk.HBox()
        buttonBox.pack_start(hideButton, False, False, 0)
        buttonBox.pack_end(settingsButton, False, False, 0)

        self.serverBox = gtk.VBox()
        for box in [relayBox, statusBox, relayPortBox, udpRelayPortBox, dirPortBox, creditsBox]:
            self.serverBox.pack_start(box, True, False, 0)
        self.serverBox.pack_start(buttonBox, True, False, 0)
        align = gtk.Alignment(0, 0, 0, 0)
        align.set_padding(0, 0, 5, 5)
        align.add(self.serverBox)

        serverFrame = GTKUtils.add_frame(align)
        makeAuroraFramesRounded = gtk.HBox()
        makeAuroraFramesRounded.set_size_request(0, 0)
        serverFrame.set_label_widget(makeAuroraFramesRounded)

        self.notebook = ClosableTabNotebook.ClosableTabNotebook()
        self.notebook.show_display(self.bwGraph)

        notebookAlign = gtk.Alignment(0, 0, 1, 1)
        notebookAlign.set_padding(5, 5, 0, 5)
        notebookAlign.add(self.notebook)

        hbox = gtk.HBox()
        hbox.pack_start(serverFrame, False, False, 0)
        hbox.pack_start(notebookAlign, True, True, 0)
        hbox.show_all()

        self.catch_event("settings_changed")

        #    self.container = hbox
        self.label = gtk.Label("Server Status %s" % (Globals.VERSION))

        vbox = gtk.VBox()
        self.menuBar = BaseMenuBar.BaseMenuBar(self.controller)
        vbox.pack_start(self.menuBar.create_menus(), False, False, 0)
        vbox.pack_start(hbox, True, True, 0)
        vbox.show_all()
        self.container = vbox
示例#14
0
  def __init__(self, controller):
    GeneratorMixin.GeneratorMixin.__init__(self)
    ListenerMixin.ListenerMixin.__init__(self)
    
    self.controller = controller
    self.torApp = Tor.get()
    
    self._add_events("show_settings", "toggle_server", "show_setup", "done")
    ClientUtil.add_updater(self)

    self.bwGraph = BWGraph.BWGraph(BWHistory.remoteBandwidth, root=controller.serverWindow)
    self.bwGraph.container.set_size_request(400, 200)
    self.bwGraph.label = gtk.Label("Relay Traffic")
    self.statusRows = []
    
    self.statistics = {}
    self.torStatus = None
    self.rows = []  
    iconSize = 24
    tooltips = gtk.Tooltips()
    
    def make_row_box(name, labelText, childWidget):
      """packs a gui row with a label, childWidget, and an image.
      it then adds the row and a separator to a vbox which it returns 
      as well as the label it created as for use in homogenizing all the label widths"""
      
      image = gtk.Image()
      image.set_from_pixbuf(Images.GREY_CIRCLE)
      imageAlign = gtk.Alignment(0, 0, 0, 0)
      #push the widget over 
      imageAlign.set_padding(0, 0, 0, 10)
      imageAlign.add(image)
     
      textLabel = gtk.Label()
      textLabel.set_markup("<span size='large' weight='bold'>%s</span>" % (labelText))
      #stick the align on the left
      textLabel.set_alignment(0, 0.5)
      
      row = StatusHBox(name, textLabel, childWidget, image)
      self.statusRows.append(row)
      
      row.pack_start(imageAlign, False, False, 0)
      row.pack_start(textLabel, False, False, 0)
      row.pack_start(childWidget, False, False, 0)
      
      #pad the whole row
      rowAlign = gtk.Alignment(0, 0, 1, 1)
      rowAlign.set_padding(0, 0, 5, 5)
      rowAlign.add(row)
      
      sep = gtk.HSeparator()
      vBox = gtk.VBox()
      vBox.pack_start(rowAlign, False, False, 10)
      vBox.pack_start(sep, False, False, 0)
      
      return (vBox, row)
    
    creditsValueLabel = gtk.Label("0")
    creditsBox, self.creditsRow = make_row_box('credits', 'Credits: ', creditsValueLabel)
    
    statusValueLabel = gtk.Label("Unknown")
    statusBox, self.statusRow = make_row_box('status', 'Status: ', statusValueLabel)
    
    def on_toggle(widget):
      self._trigger_event("toggle_server")
    self.relayToggleButton = GTKUtils.make_image_button(_("Start"), on_toggle, "exit.png")
    self.relayToggleButton.set_size_request(75, -1)
    relayBox, self.relayRow = make_row_box('relay', "Relay:", self.relayToggleButton)
    
    textLabel = gtk.Label("Unknown")
    relayPortBox, self.tcpRelayPortRow = make_row_box('orPort', "TCP Relay Port:", textLabel)
    
    textLabel = gtk.Label("Unknown")
    udpRelayPortBox, self.udpRelayPortRow = make_row_box('dhtPort', "UDP Relay Port:", textLabel)
    
    textLabel = gtk.Label()
    textLabel.set_markup('<span size="large">     55555 is unreachable        </span>')
    dirPortBox, self.dirPortRow = make_row_box('dirPort', "Directory Port:", textLabel)
    
    labels = [box.rowLabel for box in \
              self.creditsRow, self.statusRow, self.relayRow, self.tcpRelayPortRow, self.udpRelayPortRow, self.dirPortRow]
    maxLabelWidth = 5 + max([label.size_request()[0] for label in labels])
    for label in labels:
      label.set_size_request(maxLabelWidth, -1)
      
    hideButton = gtk.Button("Hide")
    hideButton.connect("clicked", self._hide_cb)
    settingsButton = gtk.Button("Settings")
    def on_settings(widget):
      self._trigger_event("show_settings")
    settingsButton.connect("clicked", on_settings)
    buttonBox = gtk.HBox()
    buttonBox.pack_start(hideButton, False, False, 0)
    buttonBox.pack_end(settingsButton, False, False, 0)
    
    self.serverBox = gtk.VBox()
    for box in [relayBox, statusBox, relayPortBox, udpRelayPortBox, dirPortBox, creditsBox]:
      self.serverBox.pack_start(box, True, False, 0)
    self.serverBox.pack_start(buttonBox, True, False, 0)
    align = gtk.Alignment(0, 0, 0, 0)
    align.set_padding(0, 0, 5, 5)
    align.add(self.serverBox)
    
    serverFrame = GTKUtils.add_frame(align)
    makeAuroraFramesRounded = gtk.HBox()
    makeAuroraFramesRounded.set_size_request(0,0)
    serverFrame.set_label_widget(makeAuroraFramesRounded)
    
    self.notebook = ClosableTabNotebook.ClosableTabNotebook()
    self.notebook.show_display(self.bwGraph)
    
    notebookAlign = gtk.Alignment(0, 0, 1, 1)
    notebookAlign.set_padding(5, 5, 0, 5)
    notebookAlign.add(self.notebook)

    hbox = gtk.HBox()
    hbox.pack_start(serverFrame, False, False, 0)
    hbox.pack_start(notebookAlign, True, True, 0)
    hbox.show_all()
    
    self.catch_event("settings_changed")
    
#    self.container = hbox
    self.label = gtk.Label("Server Status %s" % (Globals.VERSION))
    
    vbox = gtk.VBox() 
    self.menuBar = BaseMenuBar.BaseMenuBar(self.controller)    
    vbox.pack_start(self.menuBar.create_menus(), False, False, 0)
    vbox.pack_start(hbox, True, True, 0)
    vbox.show_all()
    self.container = vbox
示例#15
0
  def create(self):
    #Stores references to the program rows
    self.rows = {}
    self.selectedApp = None
    
    ClientUtil.add_updater(self)
    
    #create a liststore with one string column to use as the model
                #COLUMNS:
                #0:  Program name
    typeList = [gobject.TYPE_STRING,
                #1:  Number of hops
                gobject.TYPE_INT,
                #2:  Download Rate
                gobject.TYPE_STRING,
                #3:  Upload Rate
                gobject.TYPE_STRING,
                #4:  Coins spent
                gobject.TYPE_INT
                ]
    self.attrIdx = {}
    self.attrIdx["name"]         = 0
    self.attrIdx["numHops"]      = 1
    self.attrIdx["rateDown"]     = 2
    self.attrIdx["rateUp"]       = 3
    self.attrIdx["numCredits"]     = 4
    self.liststore = gtk.ListStore(*typeList)
    COLUMN_NAMES = ['Name','Anonymity Level', "Down Rate", "Up Rate", "Credits Used"]
    viewName = "Anonymous Programs"

    modelfilter, treeview = GTKUtils.make_listview(self.liststore, COLUMN_NAMES)
    for i in range (0, len(COLUMN_NAMES)):
      GTKUtils.make_text_cell(treeview.columns[i], i)
    
    #make treeview searchable
    treeview.set_search_column(0)
    #attach the filtermodel and treeview
    treeview.set_model(gtk.TreeModelSort(modelfilter))
#    treeview.connect("row-activated", self.row_activate_cb)
    treeview.connect("cursor-changed", self.row_change_cb)
    treeview.connect("button-press-event", self.button_press_cb)
    treeview.set_size_request(-1, 80)
    treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)
      
    def make_button(text, cb, picFile):
      return GTKUtils.make_image_button(text, cb, picFile)
    
    bottomRow = gtk.HBox()
    self.removeButton = make_button('Stop', self.stop_cb, ClientUtil.get_image_file("stop.png"))
    bottomRow.pack_start(self.removeButton, False, False, 1)
    self.anonEntry = SettingsDisplay.make_entry("anonymity level", 1)
    self.anonEntry.connect_user_changed(self.toggle_anon_cb)
    bottomRow.pack_end(self.anonEntry.get_gtk_element(), False, False, 5)
    label = gtk.Label("")
    label.set_markup('<span size="large" weight="bold">Number of Hops: </span>')
    bottomRow.pack_end(label, False, False, 5)
    
    self.treeview, self.modelfilter = treeview, modelfilter
#    self.modelfilter.set_visible_func(self.visible_cb)

    self.bankDisplay = BankDisplay.BankDisplay()
    self.circuitList = CircuitList.CircuitList()
    self.console = Console.Console(Tor.get())

    self.bwGraph = BWGraph.BWGraph(BWHistory.localBandwidth, root=self)
    self.bwGraph.container.set_size_request(-1, 200)
    self.bwGraphLabel = gtk.Label("All Traffic")
    
    self.notebook = ClosableTabNotebook.ClosableTabNotebook()
    self.notebook.show_display(self.bwGraph)
    
    notebookAlign = gtk.Alignment(0, 0, 1, 1)
    notebookAlign.set_padding(5, 5, 0, 5)
    notebookAlign.add(self.notebook)
    
    self.topBox = gtk.VBox()
    self.topBox.pack_start(GTKUtils.make_scroll_box(treeview, hPolicy=gtk.POLICY_AUTOMATIC, vPolicy=gtk.POLICY_AUTOMATIC), True, True, 10)
    self.topBox.pack_start(bottomRow, False, True, 10)
    
    alignBottom = gtk.Alignment(1, 1, 1, 1)
    alignBottom.set_padding(10, 3, 1, 1)
    alignBottom.add(notebookAlign)
    vpane = gtk.VPaned()
     
    frame = gtk.Frame()
    frame.set_shadow_type(gtk.SHADOW_OUT)
    frame.add(self.topBox)
    
    alignTop = gtk.Alignment(1, 1, 1, 1)
    alignTop.set_padding(10, 10, 7, 7)
    alignTop.add(frame)
    
    topContainer = gtk.VBox()
    topContainer.pack_start(alignTop, True, True, 0)
    
    vpane.pack1(topContainer, resize=True, shrink=False)
    vpane.pack2(alignBottom, resize=True, shrink=False)
    vpane.set_position(400)
    
    self.label = gtk.Label("")
    self.label.set_markup("<span size='x-large' weight='bold'>Applications</span>")
    self.container = vpane
    
    self.catch_event("settings_changed")
    
    self.menuBar = SocksServerMenuBar(self.root, self)
    
    vbox = gtk.VBox() 
    vbox.pack_start(self.menuBar.create_menus(), False, False, 0)
    vbox.pack_start(self.container, True, True, 0)
    self.add(vbox)
    vbox.show_all()
示例#16
0
    def __init__(self):
        ClientUtil.add_updater(self)
        #Statistics
        stat_vbox = gtk.VBox()
        self.statistics = {}
        for stat in ("Local Balance", "Bank Balance", "Credits Earned"):
            gtkObj = gtk.Label(stat + ": ")
            gtkObj.stat_value = ""
            align = gtk.Alignment(xalign=0.0,
                                  yalign=0.5,
                                  xscale=0.0,
                                  yscale=0.0)
            align.add(gtkObj)
            align.set_padding(0, 0, 5, 0)
            stat_vbox.pack_end(align, False, False, 5)
            align.show()
            gtkObj.show()
            self.statistics[stat] = gtkObj
        stat_align = gtk.Alignment(xalign=0.0,
                                   yalign=0.5,
                                   xscale=0.0,
                                   yscale=0.0)
        stat_align.add(stat_vbox)
        stat_vbox.show()
        stat_align.show()

        self.payments = 0
        self.failures = 0
        self.withdrawals = 0
        self.deposits = 0
        self.TEST_DONE = True

        self.buttonRow = gtk.HBox()

        b = gtk.Button("Request ACoins")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.request_cb)

        b = gtk.Button("Deposit ACoins")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.deposit_cb)

        b = gtk.Button("ACoin Payment")
        self.buttonRow.pack_start(b)
        b.connect('clicked', self.payment_cb)

        self.buttonRow.show_all()

        self.entry = gtk.Entry(0)
        self.entry.connect('activate', self.entry_cb)
        balanceEntryBox = gtk.HBox()
        balanceEntryBox.pack_start(gtk.Label("Pretend bank balance is:  "),
                                   False, False, 0)
        balanceEntryBox.pack_start(self.entry, True, True, 0)

        #Glue:
        self.vbox = gtk.VBox()
        self.vbox.pack_start(stat_align, False, False, 10)
        self.vbox.pack_end(self.buttonRow, False, False, 10)
        self.vbox.pack_end(balanceEntryBox, False, False, 10)
        self.vbox.show()

        self.container = self.vbox
        self.label = gtk.Label("Bank")
        return
示例#17
0
    def create(self):
        self.connect("destroy", self.destroy_cb)

        ClientUtil.add_updater(self)
        self.catch_event("no_credits")

        def on_launched(button):
            self.start()

        self._start_listening_for_event("launched", self.app, on_launched)

        self.popupMenu = TorrentPopupMenu(self)

        #everything changes in relation to this magic number
        maggicPadding = 2

        self.statusRow = BTUtilityStatusRow(self.app, maggicPadding)
        self.buttonRow = BTUtilityButtonRow(self.app, maggicPadding)
        self._start_listening_for_event("add_file", self.buttonRow,
                                        self._add_file_cb)
        self._start_listening_for_event("remove_file", self.buttonRow,
                                        self._remove_file_cb)
        self._start_listening_for_event("pause_torrent", self.buttonRow,
                                        self._pause_cb)
        self._start_listening_for_event("toggle_anonymity", self.buttonRow,
                                        self._toggle_anon_cb)

        self.rows = {}
        self.curDownload = None
        self.exitDialog = None
        self.trackerEditDialog = None

        #create a liststore with one string column to use as the model
        #COLUMNS:
        #0:  File name
        typeList = [
            gobject.TYPE_STRING,
            #1:  Amount done
            gobject.TYPE_FLOAT,
            #2:  Status
            gobject.TYPE_STRING,
            #3:  ETA
            gobject.TYPE_STRING,
            #4:  Peers
            gobject.TYPE_STRING,
            #5:  Seeds
            gobject.TYPE_STRING,
            #6:  Download Rate
            gobject.TYPE_STRING,
            #7:  Upload Rate
            gobject.TYPE_STRING,
            #8:  Download Amount
            gobject.TYPE_STRING,
            #9:  Upload Amount
            gobject.TYPE_STRING,
            #10:  Upload Amount
            gobject.TYPE_STRING,
            #11:  the hash for the download.  Stored hex-encoded, because nulls mess up gtk
            gobject.TYPE_STRING,
            #12:  is the row visible?
            gobject.TYPE_BOOLEAN
        ]
        self.attrIdx = {}
        self.attrIdx["name"] = 0
        self.attrIdx["progress"] = 1
        self.attrIdx["progressMsg"] = 2
        self.attrIdx["status"] = 3
        self.attrIdx["peers"] = 4
        self.attrIdx["seeds"] = 5
        self.attrIdx["rateUp"] = 6
        self.attrIdx["rateDown"] = 7
        self.attrIdx["amountUp"] = 8
        self.attrIdx["amountDown"] = 9
        self.attrIdx["copies"] = 10
        self.attrIdx["hash"] = 11
        self.attrIdx["visibility"] = 12
        self.liststore = gtk.ListStore(*typeList)
        COLUMN_NAMES = [
            "Name", "Progress", "Time Left", "Peers", "Seeds", "Down Rate",
            "Up Rate", "Down Amt", "Up Amt", "Copies"
        ]

        modelfilter, treeview = GTKUtils.make_listview(self.liststore,
                                                       COLUMN_NAMES)
        GTKUtils.make_text_cell(treeview.columns[0], 0)
        GTKUtils.make_progress_cell(treeview.columns[1], 1, 2)
        for i in range(2, len(COLUMN_NAMES)):
            GTKUtils.make_text_cell(treeview.columns[i], i + 1)

        #make treeview searchable
        treeview.set_search_column(0)
        #attach the filtermodel and treeview
        treeview.set_model(gtk.TreeModelSort(modelfilter))
        treeview.connect("cursor-changed", self.row_change_cb)
        treeview.connect("button-press-event", self.button_press_cb)
        treeview.connect("button-press-event", self.button_press_cb)
        #    treeview.set_size_request(-1, 30)
        treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

        self.treeview, self.modelfilter = treeview, modelfilter
        self.modelfilter.set_visible_func(self.visible_cb)

        topBox = gtk.VBox()
        topBox.pack_start(self.buttonRow, False, False, 0)
        scrolledTorrentsBox = GTKUtils.make_scroll_box(
            treeview,
            hPolicy=gtk.POLICY_AUTOMATIC,
            vPolicy=gtk.POLICY_AUTOMATIC)
        scrolledTorrentsBoxAlign = gtk.Alignment(0, 0, 1, 1)
        scrolledTorrentsBoxAlign.set_padding(0, maggicPadding, maggicPadding,
                                             maggicPadding)
        scrolledTorrentsBoxAlign.add(scrolledTorrentsBox)

        topBox.pack_start(scrolledTorrentsBoxAlign, True, True, 0)

        self.priorityBox = gtk.HBox()
        self.priorityBox.pack_start(
            gtk.Label("Select a torrent to set the priority for its files."),
            True, True, 0)
        self.priorityBox.set_border_width(0)

        self.peerBox = gtk.HBox()
        self.peerBox.pack_start(
            gtk.Label("Select a torrent to see your peers in the swarm."),
            True, True, 0)

        self.bwGraph = BWGraph.BWGraph(self.app, root=self)
        self.bwGraph.container.set_size_request(-1, 150)

        self.notebook = ClosableTabNotebook.ClosableTabNotebook()
        self.notebook.set_show_border(True)
        self.notebook.set_border_width(0)
        self.bwGraph.label = gtk.Label("BitTorrent Traffic")
        self.priorityBox.label = gtk.Label("Priorities")
        self.priorityBox.container = self.priorityBox
        self.peerBox.label = gtk.Label("Peers")
        self.peerBox.container = self.peerBox
        self.notebook.show_display(self.bwGraph)
        self.notebook.show_display(self.priorityBox)
        self.notebook.show_display(self.peerBox)
        self.notebook.show_display(self.bwGraph)

        alignBottom = gtk.Alignment(0, 0, 1, 1)
        alignBottom.set_padding(0, maggicPadding + 3, maggicPadding + 2,
                                maggicPadding + 2)
        alignBottom.add(self.notebook)

        vBoxBottom = gtk.VBox()
        vBoxBottom.pack_start(alignBottom, True, True, 0)
        vBoxBottom.pack_end(self.statusRow, False, False, 0)

        vpane = gtk.VPaned()

        self.menuBar = BitTorrentMenuBar(self.controller, self)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_OUT)
        frame.add(topBox)

        alignTop = gtk.Alignment(1, 1, 1, 1)
        alignTop.set_padding(10, 0, maggicPadding + 3, maggicPadding + 3)
        alignTop.add(frame)

        topContainer = gtk.VBox()
        topContainer.pack_start(self.menuBar.create_menus(), False, False, 0)
        topContainer.pack_start(alignTop, True, True, 0)

        vpane.pack1(topContainer, resize=True, shrink=False)
        vpane.pack2(vBoxBottom, resize=False, shrink=False)

        self.label = gtk.Label("")
        self.label.set_markup(
            "<span size='x-large' weight='bold'>Bit Twister</span>")
        self.container = vpane
        vpane.set_position(400)
        self.add(self.container)
        self.container.show_all()