def __init__(self): # create GUI glade = gtk.glade.XML(GLADE_XML) # autoconnect GUI signal handlers glade.signal_autoconnect(self)
def __init__(self): APP_NAME= 'color-grab-py' glade = gtk.glade.XML('gui/color-selection-window.glade', None, APP_NAME) glade.signal_autoconnect(self) self.main_window = glade.get_widget("main_window") self.about_dialog = glade.get_widget("about_dialog")
def init(self): settings = self.settings config = self.config gtkrc = self.datadir + "/interface/table/gtkrc" if exists(gtkrc): gtk.rc_parse(gtkrc) glade_file = self.datadir + "/interface/table/mockup.glade" glade = gtk.glade.XML(glade_file) glade.signal_autoconnect(self) from gamewindow import GameWindowGlade self.glade = GameWindowGlade(glade) self.glade.signal_autoconnect(self) self.actions = { "call": self.glade.get_widget("call"), "raise": self.glade.get_widget("raise"), "raise_range": self.glade.get_widget("raise_range"), "raise_increase": self.glade.get_widget("raise_increase"), "raise_decrease": self.glade.get_widget("raise_decrease"), "raise_increase_bb": self.glade.get_widget("raise_increase_bb"), "raise_decrease_bb": self.glade.get_widget("raise_decrease_bb"), "raise_pot": self.glade.get_widget("raise_pot"), "raise_half_pot": self.glade.get_widget("raise_half_pot"), "check": self.glade.get_widget("check"), "fold": self.glade.get_widget("fold"), } self.switch = self.glade.get_widget("switch") # self.actions['check'].add_accelerator("clicked", gtk.AccelGroup(), gtk.gdk.keyval_from_name("p"), gtk.gdk.MOD1_MASK, gtk.ACCEL_VISIBLE) self.animations = pokeranimation2d.create(self.glade, config, settings)
def connect_ui( self ): self.username = '' self.password = '' glade = gtk.glade.XML( Resources.get_plugin_asset( "./GmailCheckUI.glade" ) ) self.txtUsername = glade.get_widget( "txtUsername" ) self.txtPassword = glade.get_widget( "txtPassword" ) self.txtUsername.set_text( self.username ) self.txtPassword.set_text( self.password ) self.window = glade.get_widget( "mainWindow" ) glade.signal_autoconnect( self )
def codec_btn(widget): def dialogdestroy(widget): dialog.destroy() def bsaveok(widget): path = dialog.get_filename() Tree.get_widget(button[:-3]).set_text(path) set('widget', path) dialog.destroy() button = widget.get_name() glade = gtk.glade.XML(pathglade, 'filechooserdialog1', 'gCue2tracks') dic = {'bsave_cancel' : dialogdestroy, 'bsave_ok' : bsaveok} glade.signal_autoconnect(dic) dialog = glade.get_widget('filechooserdialog1') dialog.set_current_folder(os.path.expanduser('~')) dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN) dialog.set_title('Open') response = dialog.run()
def connect_ui( self ): self.username = '' self.password = '' self.update = '5 Minutes' glade = gtk.glade.XML( Resources.get_plugin_asset( "./TwitterCheckUI.glade" ) ) self.txtUsername = glade.get_widget( "txtUsername" ) self.txtPassword = glade.get_widget( "txtPassword" ) self.txtUpdate = glade.get_widget("txtTimeLimit") self.txtUsername.set_text( self.username ) self.txtPassword.set_text( self.password ) self.txtUpdate.set_active( 1 ) self.window = glade.get_widget( "mainWindow" ) glade.signal_autoconnect( self )
def __init__(self, fileList): # Pull widgets from Glade glade = gtk.glade.XML(os.path.abspath(sys.path[0]) + '/glade/mainWindow.glade') self.btnOkay = glade.get_widget('btnOkay') self.txtFileList = glade.get_widget('txtFileList') self.window = glade.get_widget('fileListWindow') # Populate text box self.textBuffer = gtk.TextBuffer() self.textBuffer.set_text(fileList) self.txtFileList.set_buffer(self.textBuffer) # Setup callbacks self.window.connect('delete_event', self.deleteEvent) glade.signal_autoconnect(self) # Display the window self.window.show_all()
def __init__(self): glade = gtk.glade.XML("png-browser.glade") glade.signal_autoconnect(self) self.window = glade.get_widget("window") self.pane = glade.get_widget("pane") self.statusbar = glade.get_widget("statusbar") self.status_context_chunk = self.statusbar.get_context_id("Chunk Details") self.chunkview = glade.get_widget("chunkview") self.chunkview.append_column(gtk.TreeViewColumn("Chunk", gtk.CellRendererText(), text=0)) self.store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) self.chunkview.set_model(self.store) self.chunkview.get_selection().connect('changed', self.chunkview_selection_cb) self.current_iter = None self.current_view = None png = Png.open(file(sys.argv[1], "rb")) for c in png.chunks: i = self.store.append() self.store.set(i, 0, c.type, 1, c) self.show_chunk_page(None) self.window.show_all()
def __init__(self, operationName, operation, param=None): # Pull widgets from Glade glade = gtk.glade.XML(os.path.abspath(sys.path[0]) + "/glade/mainWindow.glade") self.btnOkay = glade.get_widget("btnOkay") self.prgOperationProgress = glade.get_widget("prgOperationProgress") self.lblTitle = glade.get_widget("lblTitle") self.window = glade.get_widget("wndOperationDialog") self.window.connect("show", self.onWindowShow) self.lblTitle.set_text("<b>%s</b>" % operationName) self.lblTitle.set_use_markup(True) glade.signal_autoconnect(self) self.operation = operation self.param = param # Display the window self.window.show_all()
def __init__(self, operationName, operation, param = None): # Pull widgets from Glade glade = gtk.glade.XML(os.path.abspath(sys.path[0]) + '/glade/mainWindow.glade') self.btnOkay = glade.get_widget('btnOkay') self.prgOperationProgress = glade.get_widget('prgOperationProgress') self.lblTitle = glade.get_widget('lblTitle') self.window = glade.get_widget('wndProgressDialog') self.window.connect('show', self.onWindowShow) self.lblTitle.set_text('<b>%s</b>' % operationName) self.lblTitle.set_use_markup(True) glade.signal_autoconnect(self) self.operation = operation self.param = param # Display the window self.window.show_all()
def bsavep(widget): def dialogdestroy(widget): dialog.destroy() def bsaveok(widget): path = dialog.get_filename() if button == 'savefolder_preference_btn': Tree.get_widget('open_folder').set_text(path) set('open_folder', path) else: Tree.get_widget('tmp_dir').set_text(path) set('tmp_dir', path) dialog.destroy() button = widget.get_name() glade = gtk.glade.XML(pathglade, 'filechooserdialog1', 'gCue2tracks') dic = {'bsave_cancel' : dialogdestroy, 'bsave_ok' : bsaveok} glade.signal_autoconnect(dic) dialog = glade.get_widget('filechooserdialog1') dialog.set_current_folder(os.path.expanduser('~')) response = dialog.run()
def connect_ui(self): glade = gtk.glade.XML(Resources.get_ui_asset("MainUI.glade")) menu = gtk.Menu() menuItem = gtk.ImageMenuItem(gtk.STOCK_CONNECT) menuItem.connect('activate', self.check) menu.append(menuItem) menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT) menuItem.connect('activate', self.destroy) menu.append(menuItem) self.statusicon = gtk.status_icon_new_from_file("ui/Pew_Checker_Icon.svg") self.statusicon.connect("activate", self.toggle_window) self.statusicon.connect("popup-menu", self.popup_menu_cb, menu) self.statusicon.set_visible(True) self.cmdConfigure = glade.get_widget("cmdConfigure") self.cmdCheck = glade.get_widget("cmdCheck") self.listVbox = glade.get_widget("listVbox") self.window = glade.get_widget("mainWindow") self.store = self.make_model(self.plugin_db.fetch_available_plugins()) self.mdl = self.get_model() self.view = self.make_view(self.mdl) self.tree_select = self.view.get_selection() self.tree_select.set_mode(gtk.SELECTION_SINGLE) self.tree_select.connect("changed", self.on_plugin_select) self.listVbox.pack_start(self.view) self.window.connect("delete_event", self.delete_event) glade.signal_autoconnect(self) external.init() self.window.show_all()
def __init__(self): self.username = None self.password = None glade = gtk.glade.XML('waveCheck.glade') self.txtUsername = glade.get_widget('txtUsername') self.txtPassword = glade.get_widget('txtPassword') self.btnLogin = glade.get_widget('btnLogin') self.window = glade.get_widget('mainWindow') menu = gtk.Menu() menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT) menuItem.connect('activate', lambda q: gtk.main_quit()) menu.append(menuItem) self.statusIcon = gtk.status_icon_new_from_file('wave.png') self.statusIcon.set_visible(True) self.statusIcon.connect('activate', self.onIconClick) self.statusIcon.connect('popup-menu', self.showPopupMenu, menu) self.window.connect('delete_event', lambda q: gtk.main_quit()) glade.signal_autoconnect(self)
class LibraryWindow: def __init__(self, glade, doc=None): self.widget = glade.get_widget('window') self.about = glade.get_widget('about') self.about.set_property('name', NAME) self.about.set_property('version', VERSION) self.libraryList = LibraryList(glade) if doc: try: self.libraryList.loadFromFile(doc) except InvalidLibraryException, e: print "Invalid library: %s" % e.filename # autoconnect signal methods to handlers dict = {} for name, member in inspect.getmembers(self): dict[name] = member glade.signal_autoconnect(dict)
sWtbK5s5PnTgruFNxmWOdpoayg43yHEsnPAXwVq2FOIiUvbBUwrRJTFtzIlKgprg+Spldcp/HF5dOZTfPE0/UcO7EoHtIc5tY9jKgVICdKpl03Hkt5SRNJJR UTWWitNrGjCBCBGSEwQEyiIuQkQwM/S6mWF61oPI7E2kr3ZhyMSzy5A6DxKex37DkmGpaUnLZJYUgx00C1jqwWSbuYoIIMcTMhDd0hlloKXgpuKb+Stz5PHq aLDhimWSvmEPIrS7gmVhXKCvkFUm4FMAwPTP1oWQfTXM+gt24h56OJV4T5a3ESzQDqE6OSpj0Dt5BchqKVv8iqWOf2ddIxPCzgIYsDXMRMZK5FUy724u2KGK z0ANkheHf4ivRq+msGo8Y3OHsVPXZ0zOGeeO5q3LjN4XAbUACFU9ePRp3CUKiSJKHtM107k0FODqJmXOwiaZBYBPHmNKMbOQcC8qIdpBsnSaAFw0wxCKD1ZY +kuXxXLG5hI4goPHsaQtY9xppjHJNMzHKxQlOghShGpDmQoESzkCg1AMNiUaBhEmKUOd7VRXbkGOylLQTJKMbkpukIfZsz1KHqPgO3rROB4EC5+Yz9UqbF6H eUZpPlMBzEEHaeWG83e7v2nrlxxOo/Q0x9DhH4rY3+Jl28yEY87FIdTonwD4BAIBGPsD8Kx4B2GBCLKK+lLPxyhbQQQZi3CZoIOaCDuqRuTZAkhSh3VNwm+l Td7zq4us8kJTI0qrqESh2w7+cHECBYrrUYkoIPxiJH+e70W8PEngNUgYDqlNU4NjZ4nY8X3+3u5ZqDmkiXLDwVN/Z9O/h5muRiJeiZ3MBSRpWt9BqfCWwy8a il86WNnAtXfFwFK234efRhQru1NI7xNTL1JevdjfChNpgu/gUcJupQb8XlbOCsBf1n1Cl3hMrHvBvJFSdwlfZ4HedenJBB2RBB5amDn1wETf92zkd2ifFOnX 5+SUHeJ9w195HrJakQM4ms9OuA+op7xSjWhLvxIeiiEkOlw9U1srBDURB7E3kkEGt6hpCzYMU/8XckU4UJAhwdsP ==== """)) if __name__ == "__main__": # Load main window gladeXML = getGladeWindow() glade = gtk.glade.xml_new_from_buffer(gladeXML, len(gladeXML)) glade.signal_autoconnect(globals()) glade.get_widget("btnStop").set_sensitive(False) for interface in re.findall("^\s+([0-9a-z]+):", open("/proc/net/dev").read(), re.M): glade.get_widget("interface").append_text(interface) for widget in ("interface", "time"): glade.get_widget(widget).set_active(0) gtk.gdk.threads_init() gtk.threads_init() gtk.threads_enter() gtk.main() gtk.threads_leave()
def __init__(self, *args): # Pull widgets from Glade glade = gtk.glade.XML(os.path.abspath(sys.path[0]) + '/glade/mainWindow.glade') self.btnAdd = glade.get_widget('btnAdd') self.btnDisplayList = glade.get_widget('btnDisplayList') self.txtCommitEntry = glade.get_widget('txtCommitEntry') self.txtDiffView = glade.get_widget('txtDiffView') self.wndScrolledWindow = glade.get_widget('wndScrolledWindow') self.graphWindow = glade.get_widget('graphWindow') self.hbxBranchBox = glade.get_widget('hbxBranchBox') self.commitContext = glade.get_widget('commitContext') self.window = glade.get_widget('mainWindow') # Initialize the treestore self._makeListModel() self.model = self._getListModel() self.treeView = self._makeListView(self.model) # Initialize tree view selector self.selectedCommit = self.treeView.get_selection() self.selectedCommit.set_mode(gtk.SELECTION_SINGLE) # Setup branch selection list self._buildRefsList() # Setup context menu for commit list menuItem = gtk.MenuItem('Cherry-pick this commit') menuItem.connect('activate', self.onCherryPick) self.commitContext.append(menuItem) menuItem.show() menuItem = gtk.MenuItem('Revert this commit') self.commitContext.append(menuItem) menuItem.show() # Add it to the scrollable window self.wndScrolledWindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.wndScrolledWindow.add_with_viewport(self.treeView) # self.graphWindow.add_with_viewport(graph.Graph(graph.readGitLog())) # Attach event handlers self.cmbSelectBranch.connect('changed', self.onBranchChanged) self.selectedCommit.connect('changed', self.onCommitSelected) self.treeView.connect('button_press_event', self.onCommitClicked) self.window.connect('delete_event', lambda w, q: gtk.main_quit()) glade.signal_autoconnect(self) # Display the window self.window.show_all() # Parse command line arguments if args: if args[0][0] == 'tag': pass for commit in gitHandler.getCommitsSinceTag(args[0][1]): self._addCommit(commit) self._checkCommitStatus() elif args[0][0] == 'commit': self._addCommit(args[0][1], True) self._checkCommitStatus() elif args[0][0] == 'branch': for commit in gitHandler.getBranch(args[0][1]): self._addCommit(commit) self._checkCommitStatus()
def __init__(self): Tab.__init__(self) glade = component.get("MainWindow").get_glade() self._name = "Peers" self._child_widget = glade.get_widget("peers_tab") self._tab_label = glade.get_widget("peers_tab_label") self.peer_menu = glade.get_widget("menu_peer_tab") glade.signal_autoconnect({ "on_menuitem_add_peer_activate": self._on_menuitem_add_peer_activate, }) self.listview = glade.get_widget("peers_listview") self.listview.props.has_tooltip = True self.listview.connect("button-press-event", self._on_button_press_event) self.listview.connect("query-tooltip", self._on_query_tooltip) # country pixbuf, ip, client, downspeed, upspeed, country code, int_ip, seed/peer icon, progress self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, int, int, str, float, gtk.gdk.Pixbuf, float) self.cached_flag_pixbufs = {} self.seed_pixbuf = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("seeding16.png")) self.peer_pixbuf = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("downloading16.png")) # key is ip address, item is row iter self.peers = {} # Country column column = gtk.TreeViewColumn() render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "pixbuf", 0) column.set_sort_column_id(5) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(20) column.set_reorderable(True) self.listview.append_column(column) # Address column column = gtk.TreeViewColumn(_("Address")) render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "pixbuf", 7) render = gtk.CellRendererText() column.pack_start(render, False) column.add_attribute(render, "text", 1) column.set_sort_column_id(6) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Client column column = gtk.TreeViewColumn(_("Client")) render = gtk.CellRendererText() column.pack_start(render, False) column.add_attribute(render, "text", 2) column.set_sort_column_id(2) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Progress column column = gtk.TreeViewColumn(_("Progress")) render = gtk.CellRendererProgress() column.pack_start(render, True) column.set_cell_data_func(render, cell_data_progress, 8) column.set_sort_column_id(8) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Down Speed column column = gtk.TreeViewColumn(_("Down Speed")) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_data_speed, 3) column.set_sort_column_id(3) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) column.set_reorderable(True) self.listview.append_column(column) # Up Speed column column = gtk.TreeViewColumn(_("Up Speed")) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_data_speed, 4) column.set_sort_column_id(4) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) # Bugfix: Last column needs max_width set to stop scrollbar appearing column.set_max_width(150) column.set_reorderable(True) self.listview.append_column(column) self.listview.set_model(self.liststore) self.load_state() self.torrent_id = None
def connect(self, glade, objects): dict = {} for object in [self] + objects: for name, member in inspect.getmembers(object): dict[name] = member glade.signal_autoconnect(dict)
def __init__(self): def insert_one_tag_into_buffer(buffer, name, *params): tag = gtk.TextTag(name) while(params): tag.set_property(params[0], params[1]) params = params[2:] table = buffer.get_tag_table() table.add(tag) self.bloc = True GuiPart.version = self.getver() dic = {'on_mainWindow_destroy' : self.endApplication ,'onf' : self.onf, 'start_recomp' : self.start_recomp ,'bsave' : self.bsave,'stop' : self.stop ,'on_about1_activate' : self.on_about_activate ,'test' : self.test,'codec_changed' : self.codec_changed ,'changeg' : changeg,'sync' : self.sync ,'show_log' : show_log,'note-book' : notebook ,'on_preference_activate' : on_preference_activate ,'add_task' : self.add_task, 'del_task' : self.del_task ,'job_down' : job_down, 'job_up' : job_up, 'find_cue' : self.find_cue, 'find_cue_dialog' : self.find_cue_dialog } glade.signal_autoconnect(dic) del dic bitrait = glade.get_widget('bitrate') '''read config''' bitrait.set_value(get('bitrait')) glade.get_widget('quality').set_text(get('quality')) glade.get_widget('savefolder').set_text(get('savepath')) glade.get_widget('find_cue_folder').set_text(get('find_cue_folder')) widget = [ 'same_folder', 'show_log', 'level', 'qualitybtn', 'VBR'] map(lambda x:set(x,glade.get_widget(x).set_active(get(x))), widget) codecs_list(glade) if glade.get_widget('codec').get_active_text() == 'ogg': bitrait.set_range(32, 500) Conversation.task_number = 0 Conversation.task_list = [] Conversation.task_parametrs = {} GuiPart.textview = glade.get_widget('textview1') buffer=GuiPart.textview.get_buffer() insert_one_tag_into_buffer(buffer, 'bold', 'weight', pango.WEIGHT_BOLD) glade.get_widget('log').set_property('visible',get('show_log')) glade.get_widget('mainWindow').reshow_with_initial_size() '''first build''' self.treeview = glade.get_widget('job queue') self.treeview.set_rules_hint(True) self.tree_store = self.treeview.get_model() self.tree_store = gtk.TreeStore( str, str, str, 'gboolean', str, str) TARGETS = [ ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0), ('text/plain', 0, 1), ('TEXT', 0, 2), ('STRING', 0, 3), ] self.treeview.set_model(self.tree_store) treeview_setup_dnd(self.treeview) renderer0 = gtk.CellRendererText() column = gtk.TreeViewColumn('', renderer0, text=0) self.renderer = gtk.CellRendererText() self.renderer.set_properties( xalign=0, editable=not get('cue2tracks')) self.renderer.connect('edited', col0_edited_cb, self.tree_store ) self.renderer1 = gtk.CellRendererToggle() self.renderer1.set_properties( xalign=1.0, activatable=not get('cue2tracks')) self.renderer1.connect('toggled', col1_toggled_cb, self.tree_store ) column1 = gtk.TreeViewColumn('', self.renderer1 ) column1.add_attribute(self.renderer1, 'active', 3) column1.set_clickable(True) column2 = gtk.TreeViewColumn(_('Track light'), renderer0, text=2) column0 = gtk.TreeViewColumn(_('Track name'), self.renderer, text=1) column0.add_attribute(self.renderer, 'foreground', 5) column.add_attribute(renderer0, 'foreground', 5) column0.set_resizable(True) column1.set_resizable(False) self.treeview.append_column(column) self.treeview.append_column(column0) self.treeview.append_column(column2) self.treeview.append_column(column1) self.treeview.set_cursor(0) if ARGS: filename = ARGS[-1] if not os.path.isfile(filename): print _('Wrong filename'),filename sys.exit() path = os.path.split(filename)[0] glade.get_widget('filename').set_text(filename) glade.get_widget('start').set_sensitive(get('cue2tracks')) glade.get_widget('test').set_sensitive(get('cue2tracks')) self.bloc = True gtk.gdk.threads_enter() self.getcuetag(filename) gtk.gdk.threads_leave() self.add_task(self) self.bloc = False
def __init__(self): Tab.__init__(self) glade = component.get("MainWindow").get_glade() self._name = "Files" self._child_widget = glade.get_widget("files_tab") self._tab_label = glade.get_widget("files_tab_label") self.listview = glade.get_widget("files_listview") # filename, size, progress string, progress value, priority, file index, icon id self.treestore = gtk.TreeStore(str, gobject.TYPE_UINT64, str, float, int, int, str) # We need to store the row that's being edited to prevent updating it until # it's been done editing self._editing_index = None # Filename column self.filename_column_name = _("Filename") column = gtk.TreeViewColumn(self.filename_column_name) render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "stock-id", 6) render = gtk.CellRendererText() render.set_property("editable", True) render.connect("edited", self._on_filename_edited) render.connect("editing-started", self._on_filename_editing_start) render.connect("editing-canceled", self._on_filename_editing_canceled) column.pack_start(render, True) column.add_attribute(render, "text", 0) column.set_sort_column_id(0) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(200) column.set_reorderable(True) self.listview.append_column(column) # Size column column = gtk.TreeViewColumn(_("Size")) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, deluge.ui.gtkui.listview.cell_data_size, 1) column.set_sort_column_id(1) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) column.set_reorderable(True) self.listview.append_column(column) # Progress column column = gtk.TreeViewColumn(_("Progress")) render = gtk.CellRendererProgress() column.pack_start(render) column.set_cell_data_func(render, cell_progress, (2, 3)) column.set_sort_column_id(3) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Priority column column = gtk.TreeViewColumn(_("Priority")) render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.set_cell_data_func(render, cell_priority_icon, 4) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_priority, 4) column.set_sort_column_id(4) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) # Bugfix: Last column needs max_width set to stop scrollbar appearing column.set_max_width(200) column.set_reorderable(True) self.listview.append_column(column) self.listview.set_model(self.treestore) self.listview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.file_menu = glade.get_widget("menu_file_tab") self.file_menu_priority_items = [ glade.get_widget("menuitem_donotdownload"), glade.get_widget("menuitem_normal"), glade.get_widget("menuitem_high"), glade.get_widget("menuitem_highest"), glade.get_widget("menuitem_priority_sep") ] self.localhost_widgets = [ glade.get_widget("menuitem_open_file"), glade.get_widget("menuitem3") ] self.listview.connect("row-activated", self._on_row_activated) self.listview.connect("key-press-event", self._on_key_press_event) self.listview.connect("button-press-event", self._on_button_press_event) self.listview.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, [('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.listview.enable_model_drag_dest([('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT) self.listview.connect("drag_data_get", self._on_drag_data_get_data) self.listview.connect("drag_data_received", self._on_drag_data_received_data) glade.signal_autoconnect({ "on_menuitem_open_file_activate": self._on_menuitem_open_file_activate, "on_menuitem_donotdownload_activate": self._on_menuitem_donotdownload_activate, "on_menuitem_normal_activate": self._on_menuitem_normal_activate, "on_menuitem_high_activate": self._on_menuitem_high_activate, "on_menuitem_highest_activate": self._on_menuitem_highest_activate, "on_menuitem_expand_all_activate": self._on_menuitem_expand_all_activate }) # Connect to various events from the daemon client.register_event_handler("TorrentFileRenamedEvent", self._on_torrentfilerenamed_event) client.register_event_handler("TorrentFolderRenamedEvent", self._on_torrentfolderrenamed_event) client.register_event_handler("TorrentRemovedEvent", self._on_torrentremoved_event) # Attempt to load state self.load_state() # torrent_id: (filepath, size) self.files_list = {} self.torrent_id = None
def __init__(self): Tab.__init__(self) glade = component.get("MainWindow").get_glade() self._name = "Peers" self._child_widget = glade.get_widget("peers_tab") self._tab_label = glade.get_widget("peers_tab_label") self.peer_menu = glade.get_widget("menu_peer_tab") glade.signal_autoconnect({ "on_menuitem_add_peer_activate": self._on_menuitem_add_peer_activate, }) self.listview = glade.get_widget("peers_listview") self.listview.props.has_tooltip = True self.listview.connect("button-press-event", self._on_button_press_event) self.listview.connect("query-tooltip", self._on_query_tooltip) # country pixbuf, ip, client, downspeed, upspeed, country code, int_ip, seed/peer icon, progress self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, int, int, str, float, gtk.gdk.Pixbuf, float) self.cached_flag_pixbufs = {} self.seed_pixbuf = gtk.gdk.pixbuf_new_from_file( deluge.common.get_pixmap("seeding16.png")) self.peer_pixbuf = gtk.gdk.pixbuf_new_from_file( deluge.common.get_pixmap("downloading16.png")) # key is ip address, item is row iter self.peers = {} # Country column column = gtk.TreeViewColumn() render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "pixbuf", 0) column.set_sort_column_id(5) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(20) column.set_reorderable(True) self.listview.append_column(column) # Address column column = gtk.TreeViewColumn(_("Address")) render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "pixbuf", 7) render = gtk.CellRendererText() column.pack_start(render, False) column.add_attribute(render, "text", 1) column.set_sort_column_id(6) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Client column column = gtk.TreeViewColumn(_("Client")) render = gtk.CellRendererText() column.pack_start(render, False) column.add_attribute(render, "text", 2) column.set_sort_column_id(2) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Progress column column = gtk.TreeViewColumn(_("Progress")) render = gtk.CellRendererProgress() column.pack_start(render, True) column.set_cell_data_func(render, cell_data_progress, 8) column.set_sort_column_id(8) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Down Speed column column = gtk.TreeViewColumn(_("Down Speed")) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_data_speed, 3) column.set_sort_column_id(3) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) column.set_reorderable(True) self.listview.append_column(column) # Up Speed column column = gtk.TreeViewColumn(_("Up Speed")) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_data_speed, 4) column.set_sort_column_id(4) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) # Bugfix: Last column needs max_width set to stop scrollbar appearing column.set_max_width(150) column.set_reorderable(True) self.listview.append_column(column) self.listview.set_model(self.liststore) self.load_state() self.torrent_id = None