def _make_instruction_box(self): """Create a box that tells the user what to do in order to set up a relay, with links to get help if they are confused.""" #make the instructions self.instructionLabel = gtk.Label() self.instructionImage = gtk.Image() instructionBox = gtk.HBox(spacing=PADDING) instructionBox.pack_start(self.instructionImage, False, False, 0) instructionBox.pack_start(self.instructionLabel, False, False, 0) descriptionLabel = WrapLabel.WrapLabel( "You must enable UPnP in your router or forward the port manually to be a relay. Otherwise, peers cannot send traffic through your computer.\n\nAlso remember to unblock BitBlinder.exe and Tor.exe in any firewall." ) #make help link row routerAccessLink = GTKUtils.make_html_link("Access your router", "") portForwardingLink = GTKUtils.make_html_link( "How do I forward a port?", "") linkRow = gtk.HBox() linkRow.pack_start(portForwardingLink, True, True, 0) linkRow.pack_start(routerAccessLink, True, True, 0) testingBox = self._make_test_bar() #pack everything together box = gtk.VBox(spacing=PADDING) box.pack_start(instructionBox, False, False, 0) box.pack_start(testingBox, False, False, 0) box.pack_start(descriptionLabel, False, False, 0) box.pack_start(linkRow, False, False, 0) box.show_all() return box
def create_box(self): #create each of the pages: self._mainBox = gtk.HBox() self.vbox.pack_start(self._mainBox, True, True, 0) BORDER_WIDTH = 10 def add_var(name, box, ignoreHBar=None): return self.add_variable(name, Tor.get().settings, Tor.get(), "", box, ignoreHBar) #general settings page: vbox = gtk.VBox() add_var("orPort", vbox) add_var("dirPort", vbox) add_var("dhtPort", vbox) vbox.set_border_width(BORDER_WIDTH) #windows settings, if necessary if System.IS_WINDOWS: startOnBootEntry = self.add_variable("startBitBlinderOnBoot", BitBlinder.get().settings, BitBlinder.get(), "", vbox) #NOTE: change the default to starting on bootup if we're a server now if not Tor.get().settings.wasRelay: startOnBootEntry.set_value(True) self.add_variable("halfOpenConnections", BitBlinder.get().settings, BitBlinder.get(), "", vbox) self._boxes.append(vbox) #exit traffic page: vbox = gtk.VBox() vbox.set_border_width(BORDER_WIDTH) exitTypeEntry = add_var("exitType", vbox, True) exitTypeEntry.set_value("Both") vbox.pack_start( GTKUtils.make_html_link( "Learn more about exit traffic", "%s/overview/" % (ProgramState.Conf.BASE_HTTP)), False, False, 2) self._boxes.append(vbox) #bandwidth page: vbox = gtk.VBox() vbox.set_border_width(BORDER_WIDTH) label = WrapLabel.WrapLabel("") label.set_markup( """<span size='large' weight='bold'>You should run BitBlinder in the background to accumulate credits. </span> """) vbox.pack_start(label, False, False, 0) # vbox.pack_start(gtk.HSeparator(), False, False, 0) add_var("monthlyCap", vbox) add_var("bwRate", vbox) add_var("bwSchedule", vbox) self._boxes.append(vbox) self._mainBox.set_size_request(600, -1) self.set_current_page()
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)
def _make_optional_info_box(self): """shows extra information that will scare away most users""" #make entry rows moreInfos = WrapLabel.WrapLabel(greaterInfoText) moreInfos.set_justify(gtk.JUSTIFY_FILL) #make a box for hiding self.optionalInfosBox = gtk.VBox() self.optionalInfosBox.pack_start(moreInfos, False, False, 0) self.optionalInfosBox = GTKUtils.add_padding(self.optionalInfosBox, 5) #make a frame with a built-in expander for showing and hiding these entry rows frame = GTKUtils.add_frame(self.optionalInfosBox, width=0) frameWidget = gtk.Expander("Learn More") frameWidget.connect("notify::expanded", self._toggle_optional_infos) frame.set_label_widget(frameWidget) return frame
def __init__(self, app, allowNonanonymousMode=True): BaseDialog.BaseDialog.__init__(self, "%s Anonymity Selector" % (app.name), ("ok", "cancel"), None) self.app = app self.allowNonanonymousMode = allowNonanonymousMode titleLabel = gtk.Label() titleLabel.set_markup( "<span size='x-large' weight='bold'>%s Anonymity Selector</span>" % (self.app.name)) titleLabel.set_justify(gtk.JUSTIFY_CENTER) vbox = gtk.VBox() vbox.pack_start(titleLabel, False, False, 5) infoTextLabel = WrapLabel.WrapLabel(infoText) infoTextLabel.set_justify(gtk.JUSTIFY_FILL) #keep the label from having no width infoTextLabel.set_size_request(300, -1) infoAndSlider = gtk.VBox() infoAndSlider.pack_start(infoTextLabel, False, False, 0) instructionBox = self._make_instruction_box() infoAndSlider.pack_start(instructionBox, False, False, 0) #get the appropriate path length from the app if not self.allowNonanonymousMode or self.app.useTor: pathLength = self.app.settings.pathLength else: pathLength = 0 anonymityBox = self._make_slider_box(pathLength) infoAndSlider.pack_start(anonymityBox, False, False, 0) infoAndSlider = GTKUtils.add_padding(infoAndSlider, 5) infoAndSlider = GTKUtils.add_frame(infoAndSlider, name='Choose Your Anonymity Level') vbox.pack_start(infoAndSlider, False, False, 0) optionalInfos = self._make_optional_info_box() optionalInfos = GTKUtils.add_padding(optionalInfos, 0, 5, 5, 5) vbox.pack_start(optionalInfos, False, False, 0) self.dia.vbox.pack_start(vbox, False, False, 0) self.dia.vbox.show_all() self.optionalInfosBox.hide() self.dia.window.raise_()
def _make_optional_ports_box(self): """Make a box containing the settings and status for all optional ports (DHT and Dir)""" #make entry rows instructions = WrapLabel.WrapLabel( "These ports perform minor misc functions that are helpful to other BitBlinder users. Set to 0 to disable." ) self.dhtBox = PortStatusBox("Relay Port (UDP)", "dhtPort") self.dirBox = PortStatusBox("Dir Port (TCP)", "dirPort") #make a box for hiding these entry rows optionalPortsBox = gtk.VBox(spacing=PADDING) optionalPortsBox.pack_start(instructions, False, False, 0) optionalPortsBox.pack_start(self.dhtBox, False, False, 0) optionalPortsBox.pack_start(self.dirBox, False, False, 0) optionalPortsBox = GTKUtils.add_padding(optionalPortsBox, PADDING) optionalPortsBox.show_all() #make a frame with a built-in expander for showing and hiding these entry rows frame = OptionalToggleFrame.OptionalToggleFrame( optionalPortsBox, "Optional Ports") return frame
def __init__(self, bankApp): ListenerMixin.ListenerMixin.__init__(self) self.username = None self.password = None self._start_listening_for_event("login_success", bankApp, self.on_login_success) self._start_listening_for_event("login_failure", bankApp, self.on_login_failure) dia = gtk.Dialog("Login", None, 0, None) dia.connect("destroy", self.destroy_cb) # dia.connect("expose_event", self.expose_cb) self.started = False self.succeeded = False self.loginButton = dia.add_button("Login", gtk.RESPONSE_OK) self.quitButton = dia.add_button("Quit", gtk.RESPONSE_CANCEL) #username field self.usernameLabel = gtk.Label("Username") self.nameEntry = gtk.Entry() self.nameEntry.set_max_length(50) self.nameEntry.connect("activate", self.enter_callback) #password field self.pwLabel = gtk.Label("Password") self.pwEntry = gtk.Entry() self.pwEntry.set_max_length(50) #so people cant see our password: self.pwEntry.set_visibility(False) self.pwEntry.connect("activate", self.enter_callback) resetPasswordLink = GTKUtils.make_html_link( "Forgot your password?", "%s/accounts/resetPassword/" % (ProgramState.Conf.BASE_HTTP)) makeAccountLink = GTKUtils.make_html_link( "Need an account?", "%s/accounts/register/" % (ProgramState.Conf.BASE_HTTP)) #put them in a nice little table table = gtk.Table(4, 2, True) table.attach(self.usernameLabel, 0, 1, 0, 1) table.attach(self.nameEntry, 1, 2, 0, 1) table.attach(makeAccountLink, 1, 2, 1, 2) table.attach(self.pwLabel, 0, 1, 2, 3) table.attach(self.pwEntry, 1, 2, 2, 3) table.attach(resetPasswordLink, 1, 2, 3, 4) self.savePassCheck = gtk.CheckButton("Remember Username/Password") #A text entry telling the user what to do: self.label = WrapLabel.WrapLabel() self.label.set_markup( "<span weight='bold'>Use your account name and password from the BitBlinder website!</span>" ) align = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=0.0) align.add(self.label) align.set_padding(10, 10, 5, 5) dia.vbox.pack_start(GTKUtils.add_frame(align), True, True, 10) dia.vbox.pack_start(table, True, True, 0) dia.vbox.pack_start(self.savePassCheck, True, True, 10) #load a global config that said whether to store the last user that logged in (and his password) settings = GlobalSettings.load() self.nameEntry.set_text(settings.username) self.pwEntry.set_text(settings.password) self.savePassCheck.set_active(settings.save_password) #connect the handler: dia.connect("response", self.on_response) self.dia = dia
def make_text(text): label = WrapLabel.WrapLabel("") label.set_selectable(True) label.set_markup(text) return label
def create(self): # titleLabel = gtk.Label() # titleLabel.set_markup("<span size='x-large' weight='bold'>Firefox Controls</span>") descriptionLabel = WrapLabel.WrapLabel("") descriptionLabel.set_markup( "<span size='x-large' weight='bold'>Important: Flash is NOT supported yet!</span>\n\nAlso, DO NOT leave Firefox open if you are not using it! Some website might keep sending traffic and cause you to lose credits over time\n\nThese will eventually be integrated into an extension inside of Firefox." ) #make the controls: 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) anonRow, self.anonButton = make_button_row( "Anonymity Level", self._anonymity_cb, "identity.png", "Control how fast and anonymous your Firefox traffic will be.") circuitRow, circuitButton = make_button_row( "New Circuit", self._new_circuit_cb, "network.png", "Get a new circuit (and IP address) for Firefox traffic. The new circuit might be faster or slower." ) ffRow, self.ffButton = make_button_row( "Launch", self.toggle_firefox, "grey.png", "Start or stop our anonymous version of Firefox.") visibilityRow, self.visibilityButton = make_button_row( "Hide", self._hide_cb, "hide.png", "Hide these controls. They can always be opened from the system tray icon or file menu." ) controlBox = gtk.VBox(spacing=PADDING) controlBox.pack_start(ffRow, False, False, 0) controlBox.pack_start(anonRow, False, False, 0) controlBox.pack_start(circuitRow, False, False, 0) controlBox.pack_start(visibilityRow, False, False, 0) controlBox = GTKUtils.add_padding(controlBox, PADDING) controlBox = GTKUtils.add_frame(controlBox, name="Controls") def on_launched(button): self.start() self.ffButton.label.set_text("Starting...") self.ffButton.image.set_from_pixbuf(Images.YELLOW_CIRCLE) self._start_listening_for_event("launched", self.app, on_launched) def on_started(button): self.ffButton.label.set_text("Stop") self.ffButton.image.set_from_pixbuf(Images.GREEN_CIRCLE) self._start_listening_for_event("started", self.app, on_started) def on_stopped(button): self.ffButton.label.set_text("Closing...") self.ffButton.image.set_from_pixbuf(Images.YELLOW_CIRCLE) self._start_listening_for_event("stopped", self.app, on_stopped) def on_finished(button): self.ffButton.label.set_text("Start") self.ffButton.image.set_from_pixbuf(Images.GREY_CIRCLE) self._start_listening_for_event("finished", self.app, on_finished) #pack everything into our window: box = gtk.VBox(spacing=PADDING) # box.pack_start(titleLabel, False, False, 0) box.pack_start(descriptionLabel, False, False, 0) box.pack_start(controlBox, False, False, 0) box.show() paddedBox = GTKUtils.add_padding(box, PADDING) paddedBox.show() frame = GTKUtils.add_frame(paddedBox) frame.show_all() vbox = gtk.VBox() self.menuBar = FirefoxMenuBar(self.controller) vbox.pack_start(self.menuBar.create_menus(), False, False, 0) vbox.pack_start(frame, True, True, 0) vbox.show_all() self.add(vbox)