예제 #1
0
 def make_button_row(labelText, callback, imageFile, descriptionText):
     button = GTKUtils.make_image_button(labelText,
                                         callback,
                                         imageFile,
                                         iconSize=32)
     button.set_size_request(200, -1)
     label = WrapLabel.WrapLabel(descriptionText)
     label.set_size_request(200, -1)
     box = gtk.HBox(spacing=3 * PADDING)
     box.pack_start(button, False, False, 0)
     box.pack_start(label, False, False, 0)
     return (box, button)
예제 #2
0
 def __init__(self, btApp, maggicPadding):
   """a button row that controls the bit torrent client and also gives the user some anon info, etc
   buttons trigger events to get to the parent window instead of slef passing"""
   GeneratorMixin.GeneratorMixin.__init__(self)
   gtk.Alignment.__init__(self, 0, 0, 1, 1)
   self._add_events("add_file", "remove_file", "pause_torrent", "toggle_anonymity")
   self.catch_event("settings_changed")
   self.btApp = btApp
  
   self.pausePixbuf = Images.make_icon("pause.png", 16)
   self.resumePixbuf = Images.make_icon("resume.png", 16)
   self.relayOnPixbuf = Images.STOP_RELAY_PIXBUF
   self.relayOnLabel = '<span size="large">Stop Relay</span>'
   self.relayOffPixbuf = Images.START_RELAY_PIXBUF
   self.relayOffLabel = '<span size="large">Start Relay</span>'
   
   #top row of buttons
   self.searchEntry = gtk.Entry(35)
   self.searchEntry.connect("activate", self._search_cb)
   self.searchEntry.set_text("Find a torrent...")
   self.searchEntry.grab_focus()
   # row- note the padding hack
   buttonRow = gtk.HBox(spacing=0) 
   buttonRow.pack_start(self.searchEntry, False, False, 0)
   # search
   self.searchButton = GTKUtils.make_image_button("Search", self._search_cb, "search.png")
   buttonRow.pack_start(self.searchButton, False, False, 0)
   # add
   self.addButton = GTKUtils.make_image_button('Add', self._connect_to_trigger("add_file"), "add.png")
   buttonRow.pack_start(self.addButton, False, False, maggicPadding + 1)
   #remove
   self.removeButton = GTKUtils.make_image_button('Remove', self._connect_to_trigger("remove_file"), "delete.png") 
   buttonRow.pack_start(self.removeButton, False, False, 0)
   # pause/resume
   self.pauseButton = GTKUtils.make_image_button('Pause', self._connect_to_trigger("pause_torrent"), "pause.png")
   buttonRow.pack_start(self.pauseButton, False, False, maggicPadding + 1)
   # relay toggle
   self.relayToggleButton = GTKUtils.make_image_button('relay toggle', self._toggle_relay_cb, "warning.png")
   buttonRow.pack_end(self.relayToggleButton, False, False, 0)
   # anon toggle
   self.anonButton = GTKUtils.make_image_button('Anonymity', self._connect_to_trigger("toggle_anonymity"), "warning.png")
   
   #Normalize button sizes
   #add padding to anon button label
   width = self.anonButton.label.size_request()[0]
   self.anonButton.label.set_size_request(width + maggicPadding, -1)
   buttonRow.pack_end(self.anonButton, False, False, maggicPadding + 1)
   
   #normalize other button sizes
   buttonList = [self.pauseButton, self.removeButton, self.addButton, self.searchButton]
   buttonWidth = maggicPadding + max([button.size_request()[0] for button in buttonList])
   [button.set_size_request(buttonWidth, -1) for button in buttonList]
   self.set_padding(maggicPadding + 3, 0, maggicPadding + 3, maggicPadding + 3)
   self.add(buttonRow)
   
   #fix relay toggle button width
   testLabel = self.relayToggleButton.label
   widths = []
   for text in [self.relayOffLabel, self.relayOnLabel]:
     testLabel.set_markup(text)
     widths.append(self.relayToggleButton.size_request()[0])
   maxWidth = max(widths)
   self.relayToggleButton.set_size_request(maxWidth + maggicPadding, -1)
   
   #initialize the buttons/labels to the correct state (since settings change does a pull :))
   self.on_settings_changed()
예제 #3
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
예제 #4
0
 def __init__(self, controller):
   self.window = gtk.Window()
   self.window.set_title("Out of credits!")
   self.controller = controller
   
   self.catch_event("settings_changed")
   self.window.connect("destroy", self._destroy_cb)
   
   #tell the user what happened
   headerLabel = gtk.Label()
   headerLabel.set_markup("<span size='x-large' weight='bold'>You have spent all your credits.\n</span>")
   headerImage = gtk.Image()
   headerImage.set_from_pixbuf(Images.make_icon("warning.png", 32))
   headerBox = gtk.HBox(spacing=PADDING)
   headerBox.pack_start(headerImage, False, False, 0)
   headerBox.pack_start(headerLabel, False, False, 0)
   descriptionLabel = WrapLabel.WrapLabel("You must get more credits before you can keep sending traffic through BitBlinder.  All users are given a small number of new credits each hour.\n\nYou can keep downloading with BitTorrent by disabling anonymity (upper right of the BitTorrent interface), but you will obviously not be anonymous!")
   descriptionBox = gtk.VBox(spacing=PADDING)
   descriptionBox.pack_start(headerBox, False, False, 0)
   descriptionBox.pack_start(descriptionLabel, False, False, 0)
   descriptionBox.show_all()
   
   #make some help text to explain what credits are
   creditLabel = WrapLabel.WrapLabel(CREDITS_HELP_TEXT)
   creditLabel = GTKUtils.add_padding(creditLabel, PADDING)
   creditLabel.show()
   creditExplanation = OptionalToggleFrame.OptionalToggleFrame(creditLabel, "What are credits?")
   creditExplanation = GTKUtils.add_padding(creditExplanation, PADDING)
   creditExplanation.show()
   
   #only appears if the user is still not configured as a relay
   relayButton = GTKUtils.make_image_button('<span size="large">Start Relay</span>', self._start_relay_cb, "power_off.png")
   relayLabel = WrapLabel.WrapLabel()
   relayLabel.set_markup('<span size="large" weight="bold">You should set up a relay!  </span><span size="large">You will earn credits MUCH more quickly by being a relay and sending traffic for other users.</span>')
   self.relayRow = gtk.HBox(spacing=PADDING)
   spacingBox = gtk.VBox()
   spacingBox.pack_start(relayButton, True, False, 0)
   self.relayRow.pack_start(spacingBox, False, False, 0)
   self.relayRow.pack_start(relayLabel, True, True, 0)
   self.relayRow = GTKUtils.add_frame(self.relayRow, width=PADDING, name="Relay Setup")
   self.relayRow.show_all()
   
   #if we should always check
   self.alwaysShow = gtk.CheckButton("Always tell you when your credits run out.")
   self.alwaysShow.set_active(True)
   self.alwaysShow.show()
   
   #make the bottom button row
   waitButton = GTKUtils.make_image_button('<span size="large">Wait for Credits</span>', self._wait_cb, "time.png")
   purchaseButton = GTKUtils.make_image_button('<span size="large">Purchase Credits</span>', self._purchase_cb, "money.png")
   buttonRow = gtk.HBox(spacing=PADDING)
   buttonRow.pack_end(waitButton, False, False, 0)
   buttonRow.pack_end(purchaseButton, False, False, 0)
   buttonRow = GTKUtils.add_padding(buttonRow, PADDING)
   buttonRow.show_all()
   
   #pack everything together
   topBox = gtk.VBox(spacing=PADDING)
   topBox.pack_start(descriptionBox, False, False, 0)
   topBox.pack_start(creditExplanation, False, False, 0)
   topBox.pack_start(self.relayRow, False, False, 0)
   topBox.pack_start(self.alwaysShow, False, False, 0)
   topBox.show()
   topBox = GTKUtils.add_padding(topBox, PADDING)
   topBox.show()
   vbox = gtk.VBox()
   vbox.pack_start(topBox, False, False, 0)
   sep = gtk.HSeparator()
   sep.show()
   vbox.pack_end(buttonRow, False, False, 0)
   vbox.pack_end(sep, False, False, 0)
   vbox.show()
   
   #and add it into our dialog
   self.window.add(vbox)
   self.window.show()
예제 #5
0
 def make_button(text, cb, picFile):
   return GTKUtils.make_image_button(text, cb, picFile)
예제 #6
0
    def __init__(self, btApp, maggicPadding):
        """a button row that controls the bit torrent client and also gives the user some anon info, etc
    buttons trigger events to get to the parent window instead of slef passing"""
        GeneratorMixin.GeneratorMixin.__init__(self)
        gtk.Alignment.__init__(self, 0, 0, 1, 1)
        self._add_events("add_file", "remove_file", "pause_torrent",
                         "toggle_anonymity")
        self.catch_event("settings_changed")
        self.btApp = btApp

        self.pausePixbuf = Images.make_icon("pause.png", 16)
        self.resumePixbuf = Images.make_icon("resume.png", 16)
        self.relayOnPixbuf = Images.STOP_RELAY_PIXBUF
        self.relayOnLabel = '<span size="large">Stop Relay</span>'
        self.relayOffPixbuf = Images.START_RELAY_PIXBUF
        self.relayOffLabel = '<span size="large">Start Relay</span>'

        #top row of buttons
        self.searchEntry = gtk.Entry(35)
        self.searchEntry.connect("activate", self._search_cb)
        self.searchEntry.set_text("Find a torrent...")
        self.searchEntry.grab_focus()
        # row- note the padding hack
        buttonRow = gtk.HBox(spacing=0)
        buttonRow.pack_start(self.searchEntry, False, False, 0)
        # search
        self.searchButton = GTKUtils.make_image_button("Search",
                                                       self._search_cb,
                                                       "search.png")
        buttonRow.pack_start(self.searchButton, False, False, 0)
        # add
        self.addButton = GTKUtils.make_image_button(
            'Add', self._connect_to_trigger("add_file"), "add.png")
        buttonRow.pack_start(self.addButton, False, False, maggicPadding + 1)
        #remove
        self.removeButton = GTKUtils.make_image_button(
            'Remove', self._connect_to_trigger("remove_file"), "delete.png")
        buttonRow.pack_start(self.removeButton, False, False, 0)
        # pause/resume
        self.pauseButton = GTKUtils.make_image_button(
            'Pause', self._connect_to_trigger("pause_torrent"), "pause.png")
        buttonRow.pack_start(self.pauseButton, False, False, maggicPadding + 1)
        # relay toggle
        self.relayToggleButton = GTKUtils.make_image_button(
            'relay toggle', self._toggle_relay_cb, "warning.png")
        buttonRow.pack_end(self.relayToggleButton, False, False, 0)
        # anon toggle
        self.anonButton = GTKUtils.make_image_button(
            'Anonymity', self._connect_to_trigger("toggle_anonymity"),
            "warning.png")

        #Normalize button sizes
        #add padding to anon button label
        width = self.anonButton.label.size_request()[0]
        self.anonButton.label.set_size_request(width + maggicPadding, -1)
        buttonRow.pack_end(self.anonButton, False, False, maggicPadding + 1)

        #normalize other button sizes
        buttonList = [
            self.pauseButton, self.removeButton, self.addButton,
            self.searchButton
        ]
        buttonWidth = maggicPadding + max(
            [button.size_request()[0] for button in buttonList])
        [button.set_size_request(buttonWidth, -1) for button in buttonList]
        self.set_padding(maggicPadding + 3, 0, maggicPadding + 3,
                         maggicPadding + 3)
        self.add(buttonRow)

        #fix relay toggle button width
        testLabel = self.relayToggleButton.label
        widths = []
        for text in [self.relayOffLabel, self.relayOnLabel]:
            testLabel.set_markup(text)
            widths.append(self.relayToggleButton.size_request()[0])
        maxWidth = max(widths)
        self.relayToggleButton.set_size_request(maxWidth + maggicPadding, -1)

        #initialize the buttons/labels to the correct state (since settings change does a pull :))
        self.on_settings_changed()
예제 #7
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