def metadata_thread_gui_callback(self, data, mimetype, bmpdata): """ Called by GUI thread """ if DEBUG: print "subip: ThumbnailViewer: GUI callback" metadata = {} if 'persistent' in data: metadata['ThumbnailBitmap'] = self.iconsManager.get_default( 'subscriptionsMode', 'BUDDYCAST_THUMB') else: if mimetype is not None: metadata['ThumbnailBitmap'] = data2wxBitmap(mimetype, bmpdata, dim=16) else: metadata['ThumbnailBitmap'] = None data['metadata'] = metadata # This item may be displaying another subscription right now, only show the icon # when it's still the same person if data['url'] == self.data['url']: if 'ThumbnailBitmap' in metadata and metadata[ 'ThumbnailBitmap'] is not None: self.setBitmap(metadata['ThumbnailBitmap']) self.Refresh()
def getNameMugshot(self): self.myname = self.utility.session.get_nickname() mime, data = self.utility.session.get_mugshot() if data is None: im = IconsManager.getInstance() self.mugshot = im.get_default('personsMode','DEFAULT_THUMB') else: self.mugshot = data2wxBitmap(mime, data)
def getNameMugshot(self): self.myname = self.utility.session.get_nickname() mime, data = self.utility.session.get_mugshot() if data is None: im = IconsManager.getInstance() self.mugshot = im.get_default('personsMode', 'DEFAULT_THUMB') else: self.mugshot = data2wxBitmap(mime, data)
def __init__(self, parent, type): WizardPageSimple.__init__(self, parent) self.utility = parent.utility # 0. mainbox mainbox = wx.BoxSizer(wx.VERTICAL) # 1. topbox topbox = wx.BoxSizer(wx.VERTICAL) # Ask public name name = self.utility.session.get_nickname() name_box = wx.BoxSizer(wx.HORIZONTAL) self.myname = wx.TextCtrl(self, -1, name) name_box.Add(wx.StaticText(self, -1, self.utility.lang.get('myname')), 0, wx.ALIGN_CENTER_VERTICAL) name_box.Add(self.myname, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 5) topbox.Add(name_box, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 5) # Ask public user icon / avatar icon_box = wx.BoxSizer(wx.HORIZONTAL) icon_box.Add(wx.StaticText(self, -1, self.utility.lang.get('myicon')), 0, wx.ALIGN_CENTER_VERTICAL) ## TODO: integrate this code with makefriends.py, especially checking code self.iconbtn = None self.iconmime, self.icondata = self.utility.session.get_mugshot() if self.icondata: bm = data2wxBitmap(self.iconmime, self.icondata) else: im = IconsManager.getInstance() bm = im.get_default('PEER_THUMB') if sys.platform == 'darwin': path = get_home_dir() self.iconbtn = wx.FilePickerCtrl(self, -1, path) self.Bind(wx.EVT_FILEPICKER_CHANGED, self.OnIconSelected, id=self.iconbtn.GetId()) icon_box.Add(self.iconbtn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 5) else: self.iconbtn = wx.BitmapButton(self, -1, bm) icon_box.Add(self.iconbtn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 5) #label = wx.StaticText(self, -1, self.utility.lang.get('obligiconformat')) #icon_box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) self.Bind(wx.EVT_BUTTON, self.OnIconButton, self.iconbtn) topbox.Add(icon_box, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 5) mainbox.Add(topbox, 0, wx.EXPAND) self.SetSizerAndFit(mainbox)
def metadata_thread_gui_callback(self,data,mimetype,bmpdata,type=''): """ Called by GUI thread """ if DEBUG: print >>sys.stderr,"pip: ThumbnailViewer: GUI callback" metadata = {} metadata['tried_time'] = time()+(random.random()*100) if mimetype is not None: metadata['ThumbnailBitmap'] = data2wxBitmap(mimetype,bmpdata) else: superpeers = self.superpeer_db.getSuperPeers() """ if data['name'].lower().startswith("superpeer"): print >>sys.stderr,"pip: Name is superpeer",data['name'],"permid",show_permid_short(data['permid']) for speer in superpeers: print >>sys.stderr,"pip: Comparing to superpeer",show_permid_short(speer) """ if data['permid'] in superpeers: bm = self.iconsManager.get_default('personsMode','SUPERPEER_BITMAP') metadata['ThumbnailBitmap'] = bm else: metadata['ThumbnailBitmap'] = None if type and metadata['ThumbnailBitmap'] is not None: iw, ih = metadata['ThumbnailBitmap'].GetSize() w, h = self.GetSize() if (iw/float(ih)) > (w/float(h)): nw = w nh = int(ih * w/float(iw)) else: nh = h nw = int(iw * h/float(ih)) if nw != iw or nh != ih: #print 'Rescale from (%d, %d) to (%d, %d)' % (iw, ih, nw, nh) img = wx.ImageFromBitmap(metadata['ThumbnailBitmap']) img.Rescale(nw, nh) metadata['ThumbnailBitmap'+type] = wx.BitmapFromImage(img) #print >>sys.stderr,"pip: Netresult is",metadata['ThumbnailBitmap'] if DEBUG: print >>sys.stderr,"pip: ThumbnailViewer: Setting metadata" data['metadata'] = metadata # This item may be displaying another person right now, only show the icon # when it's still the same person if data['permid'] == self.data['permid']: thumb_type = 'ThumbnailBitmap' if type: thumb_type = thumb_type+type if thumb_type in metadata and metadata[thumb_type] is not None: self.setBitmap(metadata[thumb_type]) self.Refresh()
def avantar(self): im = IconsManager.getInstance() if self.peer_id == None: mime, data = self.get_mugshot() if data: data = data2wxBitmap(mime, data, SMALL_ICON_MAX_DIM) else: data = im.load_wxBitmapByPeerId(self.peer_id, SMALL_ICON_MAX_DIM) if data is None: data = im.get_default('PEER_THUMB',SMALL_ICON_MAX_DIM) return data
def avantar(self): im = IconsManager.getInstance() if self.peer_id == None: mime, data = self.get_mugshot() if data: data = data2wxBitmap(mime, data, SMALL_ICON_MAX_DIM) else: data = im.load_wxBitmapByPeerId(self.peer_id, SMALL_ICON_MAX_DIM) if data is None: data = im.get_default('PEER_THUMB', SMALL_ICON_MAX_DIM) return data
def __init__(self,parent,type): WizardPageSimple.__init__(self,parent) self.utility = parent.utility # 0. mainbox mainbox = wx.BoxSizer(wx.VERTICAL) # 1. topbox topbox = wx.BoxSizer(wx.VERTICAL) # Ask public name name = self.utility.session.get_nickname() name_box = wx.BoxSizer(wx.HORIZONTAL) self.myname = wx.TextCtrl(self, -1, name) name_box.Add(wx.StaticText(self, -1, self.utility.lang.get('myname')), 0, wx.ALIGN_CENTER_VERTICAL) name_box.Add(self.myname, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5) topbox.Add(name_box, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5) # Ask public user icon / avatar icon_box = wx.BoxSizer(wx.HORIZONTAL) icon_box.Add(wx.StaticText(self, -1, self.utility.lang.get('myicon')), 0, wx.ALIGN_CENTER_VERTICAL) ## TODO: integrate this code with makefriends.py, especially checking code self.iconbtn = None self.iconmime, self.icondata = self.utility.session.get_mugshot() if self.icondata: bm = data2wxBitmap(self.iconmime, self.icondata) else: im = IconsManager.getInstance() bm = im.get_default('personsMode','DEFAULT_THUMB') if sys.platform == 'darwin': path = get_home_dir() self.iconbtn = wx.FilePickerCtrl(self, -1, path) self.Bind(wx.EVT_FILEPICKER_CHANGED,self.OnIconSelected,id=self.iconbtn.GetId()) icon_box.Add(self.iconbtn, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5) else: self.iconbtn = wx.BitmapButton(self, -1, bm) icon_box.Add(self.iconbtn, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5) #label = wx.StaticText(self, -1, self.utility.lang.get('obligiconformat')) #icon_box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) self.Bind(wx.EVT_BUTTON, self.OnIconButton, self.iconbtn) topbox.Add(icon_box, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5) mainbox.Add(topbox, 0, wx.EXPAND) self.SetSizerAndFit(mainbox)
def metadata_thread_gui_callback(self,data,mimetype,bmpdata): """ Called by GUI thread """ if DEBUG: print "subip: ThumbnailViewer: GUI callback" metadata = {} if 'persistent' in data: metadata['ThumbnailBitmap'] = self.iconsManager.get_default('subscriptionsMode','BUDDYCAST_THUMB') else: if mimetype is not None: metadata['ThumbnailBitmap'] = data2wxBitmap(mimetype,bmpdata,dim=16) else: metadata['ThumbnailBitmap'] = None data['metadata'] = metadata # This item may be displaying another subscription right now, only show the icon # when it's still the same person if data['url'] == self.data['url']: if 'ThumbnailBitmap' in metadata and metadata['ThumbnailBitmap'] is not None: self.setBitmap(metadata['ThumbnailBitmap']) self.Refresh()
def _PostInit(self): self.guiUtility = GUIUtility.getInstance() self.utility = self.guiUtility.utility self.defaultDLConfig = DefaultDownloadStartupConfig.getInstance() dialog = xrc.XRCCTRL(self, "settingsDialog") for element in self.elementsName: xrcElement = xrc.XRCCTRL(dialog, element) if not xrcElement: print "settingsOverviewPanel: Error: Could not identify xrc element:", element self.elements[element] = xrcElement # Building tree self.tree = xrc.XRCCTRL(self, "settings_tree") root = self.tree.AddRoot("Root") self.tree.SelectItem( self.tree.AppendItem(root, "General", data=wx.TreeItemData(xrc.XRCCTRL(self, "general_panel"))), True ) self.tree.AppendItem(root, "Connection", data=wx.TreeItemData(xrc.XRCCTRL(self, "connection_panel"))) self.tree.AppendItem(root, "Limits", data=wx.TreeItemData(xrc.XRCCTRL(self, "bandwidth_panel"))) self.tree.AppendItem(root, "Seeding", data=wx.TreeItemData(xrc.XRCCTRL(self, "seeding_panel"))) self.tree.AppendItem(root, "Experimental", data=wx.TreeItemData(xrc.XRCCTRL(self, "exp_panel"))) self.tree.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnSelectionChanging) # Bind event listeners self.elements["zeroUp"].Bind(wx.EVT_BUTTON, lambda event: self.setUp(0, event)) self.elements["fiftyUp"].Bind(wx.EVT_BUTTON, lambda event: self.setUp(50, event)) self.elements["hundredUp"].Bind(wx.EVT_BUTTON, lambda event: self.setUp(100, event)) self.elements["unlimitedUp"].Bind(wx.EVT_BUTTON, lambda event: self.setUp("unlimited", event)) self.elements["seventyfiveDown"].Bind(wx.EVT_BUTTON, lambda event: self.setDown(75, event)) self.elements["threehundredDown"].Bind(wx.EVT_BUTTON, lambda event: self.setDown(300, event)) self.elements["sixhundreddDown"].Bind(wx.EVT_BUTTON, lambda event: self.setDown(600, event)) self.elements["unlimitedDown"].Bind(wx.EVT_BUTTON, lambda event: self.setDown("unlimited", event)) self.elements["uploadCtrl"].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements["downloadCtrl"].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements["edit"].Bind(wx.EVT_BUTTON, self.EditClicked) self.elements["browse"].Bind(wx.EVT_BUTTON, self.BrowseClicked) self.Bind(wx.EVT_BUTTON, self.saveAll, id=xrc.XRCID("wxID_OK")) self.Bind(wx.EVT_BUTTON, self.cancelAll, id=xrc.XRCID("wxID_CANCEL")) # Loading settings self.myname = self.utility.session.get_nickname() mime, data = self.utility.session.get_mugshot() if data is None: im = IconsManager.getInstance() self.mugshot = im.get_default("PEER_THUMB") else: self.mugshot = data2wxBitmap(mime, data) self.elements["myNameField"].SetValue(self.myname) self.elements["thumb"].SetBitmap(self.mugshot) if self.guiUtility.frame.SRstatusbar.IsReachable(): self.elements["firewallStatusText"].SetLabel("Your network connection is working properly.") else: self.elements["firewallStatusText"].SetLabel( "Tribler has not yet received any incoming connections. \nThis could indicate a problem with your network connection." ) self.currentPortValue = str(self.utility.session.get_listen_port()) self.elements["firewallValue"].SetValue(self.currentPortValue) self.elements["downloadCtrl"].SetValue(self.utility.getMaxDown()) self.elements["uploadCtrl"].SetValue(self.utility.getMaxUp()) self.currentDestDir = self.defaultDLConfig.get_dest_dir() self.elements["diskLocationCtrl"].SetValue(self.currentDestDir) self.elements["diskLocationChoice"].SetValue(self.defaultDLConfig.get_show_saveas()) if sys.platform != "darwin": min_to_tray = self.utility.config.Read("mintray", "int") == 1 self.elements["minimize_to_tray"].SetValue(min_to_tray) else: self.elements["minimize_to_tray"].Enable(False) self.elements["t4t0"].SetLabel(self.utility.lang.get("no_leeching")) self.elements["t4t0"].Refresh() self.elements["t4t1"].SetLabel(self.utility.lang.get("unlimited_seeding")) self.elements["t4t2"].SetLabel(self.utility.lang.get("seed_sometime")) self.elements["t4t3"].SetLabel(self.utility.lang.get("no_seeding")) self.elements["g2g0"].SetLabel(self.utility.lang.get("seed_for_large_ratio")) self.elements["g2g1"].SetLabel(self.utility.lang.get("boost__reputation")) self.elements["g2g2"].SetLabel(self.utility.lang.get("seed_sometime")) self.elements["g2g3"].SetLabel(self.utility.lang.get("no_seeding")) t4t_option = self.utility.config.Read("t4t_option", "int") self.elements["t4t%d" % t4t_option].SetValue(True) t4t_ratio = self.utility.config.Read("t4t_ratio", "int") / 100.0 index = self.elements["t4t0choice"].FindString(str(t4t_ratio)) if index != wx.NOT_FOUND: self.elements["t4t0choice"].Select(index) t4t_hours = self.utility.config.Read("t4t_hours", "int") t4t_minutes = self.utility.config.Read("t4t_mins", "int") self.elements["t4t2text"].SetLabel("%d:%d" % (t4t_hours, t4t_minutes)) g2g_option = self.utility.config.Read("g2g_option", "int") self.elements["g2g%d" % g2g_option].SetValue(True) g2g_ratio = self.utility.config.Read("g2g_ratio", "int") / 100.0 index = self.elements["g2g0choice"].FindString(str(g2g_ratio)) if index != wx.NOT_FOUND: self.elements["g2g0choice"].Select(index) g2g_hours = self.utility.config.Read("g2g_hours", "int") g2g_mins = self.utility.config.Read("g2g_mins", "int") self.elements["g2g2text"].SetLabel("%d:%d" % (g2g_hours, g2g_mins)) self.elements["use_webui"].SetValue(self.utility.config.Read("use_webui", "boolean")) self.elements["webui_port"].SetValue(str(self.utility.config.Read("webui_port", "int"))) wx.CallAfter(self.Refresh)
def _PostInit(self): self.guiUtility = GUIUtility.getInstance() self.utility = self.guiUtility.utility self.defaultDLConfig = DefaultDownloadStartupConfig.getInstance() dialog = xrc.XRCCTRL(self, "settingsDialog") for element in self.elementsName: xrcElement = xrc.XRCCTRL(dialog, element) if not xrcElement: print 'settingsOverviewPanel: Error: Could not identify xrc element:',element self.elements[element] = xrcElement #Building tree self.tree = xrc.XRCCTRL(self,"settings_tree") root = self.tree.AddRoot('Root') self.tree.SelectItem(self.tree.AppendItem(root,'General',data=wx.TreeItemData(xrc.XRCCTRL(self,"general_panel"))),True) self.tree.AppendItem(root,'Connection',data=wx.TreeItemData(xrc.XRCCTRL(self,"connection_panel"))) self.tree.AppendItem(root,'Bandwidth',data=wx.TreeItemData(xrc.XRCCTRL(self,"bandwidth_panel"))) self.tree.AppendItem(root,'Misc',data=wx.TreeItemData(xrc.XRCCTRL(self,"misc_panel"))) self.tree.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnSelectionChanging) #Bind event listeners self.elements['diskLocationChoice'].Bind(wx.EVT_CHECKBOX, self.OnDownloadChoice) self.elements['zeroUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(0, event)) self.elements['fiftyUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(50, event)) self.elements['hundredUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(100, event)) self.elements['unlimitedUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp('unlimited', event)) self.elements['seventyfiveDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(75, event)) self.elements['threehundredDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(300, event)) self.elements['sixhundreddDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(600, event)) self.elements['unlimitedDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown('unlimited', event)) self.elements['uploadCtrl'].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements['downloadCtrl'].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements['edit'].Bind(wx.EVT_BUTTON, self.EditClicked) self.elements['browse'].Bind(wx.EVT_BUTTON, self.BrowseClicked) self.elements['batchstart'].Bind(wx.EVT_BUTTON, lambda event: self.OnMultiple(True)) self.elements['batchstop'].Bind(wx.EVT_BUTTON, lambda event: self.OnMultiple(False)) self.Bind(wx.EVT_BUTTON, self.saveAll, id = xrc.XRCID("wxID_OK")) self.Bind(wx.EVT_BUTTON, self.cancelAll, id = xrc.XRCID("wxID_CANCEL")) #Loading settings self.myname = self.utility.session.get_nickname() mime, data = self.utility.session.get_mugshot() if data is None: im = IconsManager.getInstance() self.mugshot = im.get_default('personsMode','DEFAULT_THUMB') else: self.mugshot = data2wxBitmap(mime, data) self.elements['myNameField'].SetValue(self.myname) self.elements['thumb'].setBitmap(self.mugshot) if self.guiUtility.frame.SRstatusbar.IsReachable(): self.elements['firewallStatus'].setSelected(2) self.elements['firewallStatusText'].SetLabel('Port is working') if self.utility.config.Read('family_filter', "boolean"): self.elements['familyFilter'].SetSelection(0) else: self.elements['familyFilter'].SetSelection(1) self.currentPopup = self.utility.config.Read('popup_player', "boolean") if self.currentPopup: self.elements['externalplayer'].SetSelection(1) else: self.elements['externalplayer'].SetSelection(0) self.currentPortValue = str(self.guiUtility.get_port_number()) self.elements['firewallValue'].SetValue(self.currentPortValue) maxdownloadrate = self.utility.config.Read('maxdownloadrate', 'int') if maxdownloadrate == 0: self.elements['downloadCtrl'].SetValue('unlimited') else: self.elements['downloadCtrl'].SetValue(str(maxdownloadrate)) maxuploadrate = self.utility.config.Read('maxuploadrate', 'int') if maxuploadrate == -1: self.elements['uploadCtrl'].SetValue('0') elif maxuploadrate == 0: self.elements['uploadCtrl'].SetValue('unlimited') else: self.elements['uploadCtrl'].SetValue(str(maxuploadrate)) self.currentDestDir = self.defaultDLConfig.get_dest_dir() self.elements['diskLocationCtrl'].SetValue(self.currentDestDir) self.elements['diskLocationCtrl'].Enable(not self.defaultDLConfig.get_show_saveas()) self.elements['diskLocationChoice'].SetValue(self.defaultDLConfig.get_show_saveas()) self.elements['use_bundle_magic'].SetValue(self.utility.config.Read('use_bundle_magic', "boolean")) wx.CallAfter(self.Refresh)
def _PostInit(self): self.guiUtility = GUIUtility.getInstance() self.utility = self.guiUtility.utility self.defaultDLConfig = DefaultDownloadStartupConfig.getInstance() dialog = xrc.XRCCTRL(self, "settingsDialog") for element in self.elementsName: xrcElement = xrc.XRCCTRL(dialog, element) if not xrcElement: print 'settingsOverviewPanel: Error: Could not identify xrc element:', element self.elements[element] = xrcElement #Building tree self.tree = xrc.XRCCTRL(self, "settings_tree") root = self.tree.AddRoot('Root') self.tree.SelectItem( self.tree.AppendItem(root, 'General', data=wx.TreeItemData( xrc.XRCCTRL(self, "general_panel"))), True) self.tree.AppendItem(root, 'Connection', data=wx.TreeItemData( xrc.XRCCTRL(self, "connection_panel"))) self.tree.AppendItem(root, 'Limits', data=wx.TreeItemData( xrc.XRCCTRL(self, "bandwidth_panel"))) self.tree.AppendItem(root, 'Seeding', data=wx.TreeItemData( xrc.XRCCTRL(self, "seeding_panel"))) self.tree.AppendItem(root, 'Experimental', data=wx.TreeItemData( xrc.XRCCTRL(self, "exp_panel"))) self.tree.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnSelectionChanging) #Bind event listeners self.elements['zeroUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(0, event)) self.elements['fiftyUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(50, event)) self.elements['hundredUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(100, event)) self.elements['unlimitedUp'].Bind( wx.EVT_BUTTON, lambda event: self.setUp('unlimited', event)) self.elements['seventyfiveDown'].Bind( wx.EVT_BUTTON, lambda event: self.setDown(75, event)) self.elements['threehundredDown'].Bind( wx.EVT_BUTTON, lambda event: self.setDown(300, event)) self.elements['sixhundreddDown'].Bind( wx.EVT_BUTTON, lambda event: self.setDown(600, event)) self.elements['unlimitedDown'].Bind( wx.EVT_BUTTON, lambda event: self.setDown('unlimited', event)) self.elements['uploadCtrl'].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements['downloadCtrl'].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements['edit'].Bind(wx.EVT_BUTTON, self.EditClicked) self.elements['browse'].Bind(wx.EVT_BUTTON, self.BrowseClicked) self.Bind(wx.EVT_BUTTON, self.saveAll, id=xrc.XRCID("wxID_OK")) self.Bind(wx.EVT_BUTTON, self.cancelAll, id=xrc.XRCID("wxID_CANCEL")) #Loading settings self.myname = self.utility.session.get_nickname() mime, data = self.utility.session.get_mugshot() if data is None: im = IconsManager.getInstance() self.mugshot = im.get_default('PEER_THUMB') else: self.mugshot = data2wxBitmap(mime, data) self.elements['myNameField'].SetValue(self.myname) self.elements['thumb'].setBitmap(self.mugshot) if self.guiUtility.frame.SRstatusbar.IsReachable(): self.elements['firewallStatus'].setSelected(2) self.elements['firewallStatusText'].SetLabel('Port is working') self.currentPortValue = str(self.guiUtility.get_port_number()) self.elements['firewallValue'].SetValue(self.currentPortValue) self.elements['downloadCtrl'].SetValue(self.utility.getMaxDown()) self.elements['uploadCtrl'].SetValue(self.utility.getMaxUp()) self.currentDestDir = self.defaultDLConfig.get_dest_dir() self.elements['diskLocationCtrl'].SetValue(self.currentDestDir) self.elements['diskLocationChoice'].SetValue( self.defaultDLConfig.get_show_saveas()) if sys.platform != "darwin": min_to_tray = self.utility.config.Read('mintray', "int") == 1 self.elements['minimize_to_tray'].SetValue(min_to_tray) else: self.elements['minimize_to_tray'].Enable(False) self.elements['t4t0'].SetLabel(self.utility.lang.get('no_leeching')) self.elements['t4t0'].Refresh() self.elements['t4t1'].SetLabel( self.utility.lang.get('unlimited_seeding')) self.elements['t4t2'].SetLabel(self.utility.lang.get('seed_sometime')) self.elements['t4t3'].SetLabel(self.utility.lang.get('no_seeding')) self.elements['g2g0'].SetLabel( self.utility.lang.get('seed_for_large_ratio')) self.elements['g2g1'].SetLabel( self.utility.lang.get('boost__reputation')) self.elements['g2g2'].SetLabel(self.utility.lang.get('seed_sometime')) self.elements['g2g3'].SetLabel(self.utility.lang.get('no_seeding')) t4t_option = self.utility.config.Read('t4t_option', 'int') self.elements['t4t%d' % t4t_option].SetValue(True) t4t_ratio = self.utility.config.Read('t4t_ratio', 'int') / 100.0 index = self.elements['t4t0choice'].FindString(str(t4t_ratio)) if index != wx.NOT_FOUND: self.elements['t4t0choice'].Select(index) t4t_hours = self.utility.config.Read('t4t_hours', 'int') t4t_minutes = self.utility.config.Read('t4t_mins', 'int') self.elements['t4t2text'].SetLabel("%d:%d" % (t4t_hours, t4t_minutes)) g2g_option = self.utility.config.Read('g2g_option', 'int') self.elements['g2g%d' % g2g_option].SetValue(True) g2g_ratio = self.utility.config.Read('g2g_ratio', 'int') / 100.0 index = self.elements['g2g0choice'].FindString(str(g2g_ratio)) if index != wx.NOT_FOUND: self.elements['g2g0choice'].Select(index) g2g_hours = self.utility.config.Read('g2g_hours', 'int') g2g_mins = self.utility.config.Read('g2g_mins', 'int') self.elements['g2g2text'].SetLabel("%d:%d" % (g2g_hours, g2g_mins)) self.elements['use_webui'].SetValue( self.utility.config.Read('use_webui', "boolean")) self.elements['webui_port'].SetValue( str(self.utility.config.Read('webui_port', "int"))) wx.CallAfter(self.Refresh)
def _PostInit(self): self.guiUtility = GUIUtility.getInstance() self.utility = self.guiUtility.utility self.defaultDLConfig = DefaultDownloadStartupConfig.getInstance() dialog = xrc.XRCCTRL(self, "settingsDialog") for element in self.elementsName: xrcElement = xrc.XRCCTRL(dialog, element) if not xrcElement: print 'settingsOverviewPanel: Error: Could not identify xrc element:',element self.elements[element] = xrcElement #Building tree self.tree = xrc.XRCCTRL(self,"settings_tree") root = self.tree.AddRoot('Root') self.tree.SelectItem(self.tree.AppendItem(root,'General',data=wx.TreeItemData(xrc.XRCCTRL(self,"general_panel"))),True) self.tree.AppendItem(root,'Connection',data=wx.TreeItemData(xrc.XRCCTRL(self,"connection_panel"))) self.tree.AppendItem(root,'Limits',data=wx.TreeItemData(xrc.XRCCTRL(self,"bandwidth_panel"))) self.tree.AppendItem(root,'Seeding',data=wx.TreeItemData(xrc.XRCCTRL(self,"seeding_panel"))) self.tree.AppendItem(root,'Misc',data=wx.TreeItemData(xrc.XRCCTRL(self,"misc_panel"))) self.tree.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnSelectionChanging) #Bind event listeners self.elements['zeroUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(0, event)) self.elements['fiftyUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(50, event)) self.elements['hundredUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp(100, event)) self.elements['unlimitedUp'].Bind(wx.EVT_BUTTON, lambda event: self.setUp('unlimited', event)) self.elements['seventyfiveDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(75, event)) self.elements['threehundredDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(300, event)) self.elements['sixhundreddDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown(600, event)) self.elements['unlimitedDown'].Bind(wx.EVT_BUTTON, lambda event: self.setDown('unlimited', event)) self.elements['uploadCtrl'].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements['downloadCtrl'].Bind(wx.EVT_KEY_DOWN, self.removeUnlimited) self.elements['edit'].Bind(wx.EVT_BUTTON, self.EditClicked) self.elements['browse'].Bind(wx.EVT_BUTTON, self.BrowseClicked) self.elements['batchstart'].Bind(wx.EVT_BUTTON, lambda event: self.OnMultiple(True)) self.elements['batchstop'].Bind(wx.EVT_BUTTON, lambda event: self.OnMultiple(False)) self.elements['batchmove'].Bind(wx.EVT_BUTTON, self.OnMultipleMove) self.Bind(wx.EVT_BUTTON, self.saveAll, id = xrc.XRCID("wxID_OK")) self.Bind(wx.EVT_BUTTON, self.cancelAll, id = xrc.XRCID("wxID_CANCEL")) #Loading settings self.myname = self.utility.session.get_nickname() mime, data = self.utility.session.get_mugshot() if data is None: im = IconsManager.getInstance() self.mugshot = im.get_default('PEER_THUMB') else: self.mugshot = data2wxBitmap(mime, data) self.elements['myNameField'].SetValue(self.myname) self.elements['thumb'].setBitmap(self.mugshot) if self.guiUtility.frame.SRstatusbar.IsReachable(): self.elements['firewallStatus'].setSelected(2) self.elements['firewallStatusText'].SetLabel('Port is working') if self.utility.config.Read('family_filter', "boolean"): self.elements['familyFilter'].SetSelection(0) else: self.elements['familyFilter'].SetSelection(1) self.currentPopup = self.utility.config.Read('popup_player', "boolean") if self.currentPopup: self.elements['externalplayer'].SetSelection(1) else: self.elements['externalplayer'].SetSelection(0) self.currentPortValue = str(self.guiUtility.get_port_number()) self.elements['firewallValue'].SetValue(self.currentPortValue) maxdownloadrate = self.utility.config.Read('maxdownloadrate', 'int') if maxdownloadrate == 0: self.elements['downloadCtrl'].SetValue('unlimited') else: self.elements['downloadCtrl'].SetValue(str(maxdownloadrate)) maxuploadrate = self.utility.config.Read('maxuploadrate', 'int') if maxuploadrate == -1: self.elements['uploadCtrl'].SetValue('0') elif maxuploadrate == 0: self.elements['uploadCtrl'].SetValue('unlimited') else: self.elements['uploadCtrl'].SetValue(str(maxuploadrate)) self.currentDestDir = self.defaultDLConfig.get_dest_dir() self.elements['diskLocationCtrl'].SetValue(self.currentDestDir) self.elements['diskLocationChoice'].SetValue(self.defaultDLConfig.get_show_saveas()) self.elements['use_bundle_magic'].SetValue(self.utility.config.Read('use_bundle_magic', "boolean")) self.elements['t4t0'].SetLabel(self.utility.lang.get('no_leeching')) self.elements['t4t1'].SetLabel(self.utility.lang.get('unlimited_seeding')) self.elements['t4t2'].SetLabel(self.utility.lang.get('seed_sometime')) self.elements['t4t3'].SetLabel(self.utility.lang.get('no_seeding')) self.elements['g2g0'].SetLabel(self.utility.lang.get('seed_for_large_ratio')) self.elements['g2g1'].SetLabel(self.utility.lang.get('boost__reputation')) self.elements['g2g2'].SetLabel(self.utility.lang.get('seed_sometime')) self.elements['g2g3'].SetLabel(self.utility.lang.get('no_seeding')) t4t_option = self.utility.config.Read('t4t_option', 'int') self.elements['t4t%d'%t4t_option].SetValue(True) t4t_ratio = self.utility.config.Read('t4t_ratio', 'int')/100.0 index = self.elements['t4t0choice'].FindString(str(t4t_ratio)) if index != wx.NOT_FOUND: self.elements['t4t0choice'].Select(index) t4t_hours = self.utility.config.Read('t4t_hours', 'int') t4t_minutes = self.utility.config.Read('t4t_mins', 'int') self.elements['t4t2text'].SetLabel("%d:%d"%(t4t_hours, t4t_minutes)) g2g_option = self.utility.config.Read('g2g_option', 'int') self.elements['g2g%d'%g2g_option].SetValue(True) g2g_ratio = self.utility.config.Read('g2g_ratio', 'int')/100.0 index = self.elements['g2g0choice'].FindString(str(g2g_ratio)) if index != wx.NOT_FOUND: self.elements['g2g0choice'].Select(index) g2g_hours = self.utility.config.Read('g2g_hours', 'int') g2g_mins = self.utility.config.Read('g2g_mins', 'int') self.elements['g2g2text'].SetLabel("%d:%d"%(g2g_hours, g2g_mins)) wx.CallAfter(self.Refresh)