Example #1
0
 def add_variable(self, varName, settingsObj, app, category, box=None, ignoreHBar=None):
   if not box:
     box = self.vbox
   if len(self.variables) > 0 and not ignoreHBar:
     box.pack_start(gtk.HSeparator(), False, False, 0)
   entry = SettingsDisplay.make_entry(settingsObj.ranges[varName], getattr(settingsObj, varName))
   box.pack_start(entry.make_wrapper(settingsObj.displayNames[varName], settingsObj.helpStrings[varName], HELP_TEXT_SIZE), False, False, 5)
   self.variables.append([varName, settingsObj, entry, app, category])
   return entry
Example #2
0
 def make_exit_row(labelText):
     #make the widgets
     label = gtk.Label()
     label.set_markup("<span size='large'>%s</span>" % (labelText))
     entry = SettingsDisplay.make_entry("bool", True)
     #and pack them together
     box = gtk.HBox()
     box.pack_start(label, False, False, 0)
     box.pack_end(entry.entry, False, False, 0)
     return (entry, box)
 def make_exit_row(labelText):
   #make the widgets
   label = gtk.Label()
   label.set_markup("<span size='large'>%s</span>" % (labelText))
   entry = SettingsDisplay.make_entry("bool", True)
   #and pack them together
   box = gtk.HBox()
   box.pack_start(label, False, False, 0)
   box.pack_end(entry.entry, False, False, 0)
   return (entry, box)
Example #4
0
 def _make_entry(self):
     self.entry = SettingsDisplay.make_entry(Globals.PORT_RANGE, 0)
     self.entry.entry.connect("changed", self._entry_changed)
Example #5
0
 def _make_entry(self):
     self.entry = SettingsDisplay.make_entry("bool", True)
     self.entry.entry.connect("toggled", self._entry_changed)
 def _make_entry(self):
   self.entry = SettingsDisplay.make_entry(Globals.PORT_RANGE, 0)
   self.entry.entry.connect("changed", self._entry_changed)
 def _make_entry(self):
   self.entry = SettingsDisplay.make_entry("bool", True)
   self.entry.entry.connect("toggled", self._entry_changed)
Example #8
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()
Example #9
0
 def __init__(self, applications, root):
   """Responsible for user interface to settings.
   @param applications: BitBlinder applications to show settings for
   @type applications: list
   @param showGlobalSettings: Bool to show the global settings- ie, username and pw
   """
   #: settings name to application instance
   self.applications = applications
   #create the dialog:
   self.dia = gtk.Dialog("Settings", root, gtk.DIALOG_DESTROY_WITH_PARENT, None)
   #: the collection of displays, organized as [appName][categoryName]
   self.settingsDisplays = {}
   
   #: the Application that corresponds to the currently selected row on the left
   self.selectedApp = None
   #: the SettingsDisplay that corresponds to the currently selected row on the left
   self.selectedDisplay = None
   #: the settings category that corresponds to the currently selected row on the left
   self.selectedCategory = None
   
   self.mdl = gtk.TreeStore(gobject.TYPE_STRING)
   self.view = gtk.TreeView(self.mdl)
   #make column
   column = gtk.TreeViewColumn("Category")
   #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)
   column.set_attributes(column.cell, text=0)
   self.view.connect("cursor-changed", self.row_changed)
   
   #Make the apply/ok/cancel buttons:
   i = 1
   #for name in ("Ok", "Apply", "Defaults", "Cancel"):
   for name in ("Ok", "Apply", "Cancel"):
     self.prevButton = self.dia.add_button(name, i)
     i += 1
   
   #glue:
   self.hbox = gtk.HBox()
   vbox = gtk.VBox()
   vbox.pack_start(self.hbox, True, True, 0)
   self.hbox.show()
   
   hbox = gtk.HBox()
   align = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0)
   align.add(GTKUtils.add_frame(self.view))
   align.set_padding(0, 0, 10, 0)
   align.show_all()
   hbox.pack_start(align, False, False, 0)
   hbox.pack_end(vbox, True, True, 0)
   hbox.show()
   vbox.show()
   
   for name, app in self.applications.iteritems():
     #create the application row:
     self.settingsDisplays[app.get_settings_name()] = {}
     rowIter = self.mdl.append(None, [app.get_settings_name()])
     #make permanent reference for the row:
     app.settingsTreeRow = gtk.TreeRowReference(self.mdl, self.mdl.get_string_from_iter(rowIter))
     #make each subcategory:
     for category in app.settings.categories.keys():
       self.settingsDisplays[app.get_settings_name()][category] = SettingsDisplay.SettingsDisplay(app.settings, category)
       if category == "":
         continue
       if category == "DEV" and not ProgramState.DEBUG:
         continue
       self.mdl.append(rowIter, [category])
   
   self.dia.vbox.pack_start(hbox, True, True, 10)
   #connect the handler:
   self.dia.connect("response", self.on_response)
   #self.dia.connect("destroy", self.destroy_cb)
   self.dia.connect('delete-event', self.hide)
   #start the dialog
   self.dia.vbox.set_size_request(700, 500)
   self.dia.show()