def __init__(self, root): BaseDialog.BaseDialog.__init__(self, "Welcome!", ("ok",), None) self.root = root width = 200 padding = 20 imagePath = ClientUtil.get_image_file("bb_logo.png") pixbuf = gtk.gdk.pixbuf_new_from_file(imagePath) pixbuf = pixbuf.scale_simple(width, int(width * 0.553), gtk.gdk.INTERP_TILES) image = gtk.Image() image.set_from_pixbuf(pixbuf) vBox = gtk.VBox() vBox.pack_start(image, False, False, padding-3) welcomeLabel = gtk.Label(WELCOME_TEXT) welcomeLabel.set_line_wrap(True) welcomeLabel.set_justify(gtk.JUSTIFY_FILL) welcomeLabel.set_size_request(width, -1) align = gtk.Alignment(0, 0, 1, 1) align.set_padding(0, padding, padding, padding) align.add(welcomeLabel) vBox.pack_start(align, False, False, 0) frame = gtk.Frame() frame.add(vBox) widgetHack = gtk.EventBox() widgetHack.add(frame) widgetHack.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) self.dia.vbox.pack_start(widgetHack, True, True, 0) self.dia.show_all()
def __init__(self): ListenerMixin.ListenerMixin.__init__(self) #these are all the top-level windows that will ever be used. This Controller is responsible for all of them. self.loginWindow = None self.btWindow = None self.firefoxWindow = None self.bankApp = None self.torApp = None self.bbApp = None self.btApp = None self.ffApp = None self.updateDialog = None self.lowMoneyDialog = None self.povertyDialog = None self.settingsDialog = None #listen for the events that we need to know about self.catch_event("no_credits") self.catch_event("shutdown") self.catch_event("new_args") #necessary for GTK to function properly: gobject.threads_init() #set the default image for the window defaultImage = ClientUtil.get_image_file(u"bb_logo.png") gtk.window_set_default_icon_from_file(defaultImage) #: windows which have been (de)iconified by left clickingon the status icon self.previouslyToggledWindows = [] #sytem tray icon stuffs- handle when it is left clicked... statusIcon = ClientUtil.get_image_file("bb_favicon.ico") self.statusIcon = StatusIcon.StatusIcon(statusIcon) self.statusIcon.set_visible(False) self._start_listening_for_event("activated", self.statusIcon, self.on_status_icon_activated) self._start_listening_for_event("popup", self.statusIcon, self.on_status_icon_popup)
def _create_tab_label(self, label, child): text = label.get_text() label.set_markup('<span>%s</span>' % text) image = gtk.Image() imagePath = ClientUtil.get_image_file('square_x.png') pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(imagePath, 8, 8) image.set_from_pixbuf(pixbuf) # image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU) # image.set_size_request(6, 6) closeButton = gtk.Button() closeButton.set_name("LittleButton") closeButton.connect("clicked", self._close_tab, child) closeButton.set_image(image) closeButton.set_relief(gtk.RELIEF_NONE) sizeRequest = closeButton.size_request() closeButton.show() box = gtk.HBox() box.pack_start(label, True, True) box.pack_end(closeButton, False, False) box.show() return box
def make_image_button(labelText, callback, fileName, vertical=False, makeButton=True, iconSize=16): """Make a button that consists of an image and a label (joined either vertically or horizontally)""" if makeButton: button = gtk.Button() else: button = gtk.EventBox() if labelText != None: label = gtk.Label("") label.set_markup('<span size="large">%s</span>' % (labelText)) button.label = label image = gtk.Image() #get the full path filePath = ClientUtil.get_image_file(fileName) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filePath, iconSize, iconSize) image.set_from_pixbuf(pixbuf) box = None if vertical: box = gtk.VBox() else: box = gtk.HBox() button.add(box) box.pack_start(image, False, False, 0) if labelText != None: align = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=0.0) align.add(label) align.set_padding(1, 1, 1, 1) box.pack_start(align, True, False, 0) if callback: if makeButton: button.connect('clicked', callback) else: button.set_events(gtk.gdk.BUTTON_PRESS_MASK) button.connect("button_press_event", callback) button.show_all() button.image = image return button
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()
def make_icon(fileName, iconSize=24): return gtk.gdk.pixbuf_new_from_file_at_size(ClientUtil.get_image_file(fileName), iconSize, iconSize)