def __init__(self, parenttab): """ Constructor """ ServerList.__init__(self, parenttab) self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, str,\ str, int, str, str, str, object, int, str) self.serverlistview.set_model(self.liststore) self.column_connections = gtk.TreeViewColumn('Connections') self.column_lastconnection = gtk.TreeViewColumn('Last Connection') self.column_connections.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.column_connections.set_expand(True) self.column_connections.set_fixed_width(30) self.column_lastconnection.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.column_lastconnection.set_expand(True) self.column_lastconnection.set_fixed_width(75) self.serverlistview.append_column(self.column_connections) self.serverlistview.append_column(self.column_lastconnection) cell8 = gtk.CellRendererText() cell9 = gtk.CellRendererText() self.column_connections.pack_start(cell8, expand=False) self.column_lastconnection.pack_start(cell9, expand=False) self.column_connections.add_attribute(cell8, 'text', 9) self.column_lastconnection.add_attribute(cell9, 'text', 10) self.column_connections.set_reorderable(True) self.column_lastconnection.set_reorderable(True) self.column_connections.set_clickable(True) self.column_lastconnection.set_clickable(True) self.column_connections.connect('clicked', self.on_table_column_clicked, 9) self.column_lastconnection.connect('clicked', self.on_table_column_clicked, 10) # set intial values for sorting order and column self.sortorder = gtk.SORT_DESCENDING self.sortcolumn = 10 # and apply sorting self.liststore.set_sort_column_id(self.sortcolumn, self.sortorder) self.column_lastconnection.set_sort_order(self.sortorder) self.column_lastconnection.set_sort_indicator(True) self.show_all()
def __init__(self, parenttab): """ Constructor """ ServerList.__init__(self, parenttab) self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, str,\ str, int, str, str, str, object, int, str) self.serverlistview.set_model(self.liststore) self.column_connections = gtk.TreeViewColumn('Connections') self.column_lastconnection = gtk.TreeViewColumn('Last Connection') self.column_connections.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.column_connections.set_expand(True) self.column_connections.set_fixed_width(30) self.column_lastconnection.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.column_lastconnection.set_expand(True) self.column_lastconnection.set_fixed_width(75) self.serverlistview.append_column(self.column_connections) self.serverlistview.append_column(self.column_lastconnection) cell8=gtk.CellRendererText() cell9=gtk.CellRendererText() self.column_connections.pack_start(cell8, expand=False) self.column_lastconnection.pack_start(cell9, expand=False) self.column_connections.add_attribute(cell8, 'text', 9) self.column_lastconnection.add_attribute(cell9, 'text',10) self.column_connections.set_reorderable(True) self.column_lastconnection.set_reorderable(True) self.column_connections.set_clickable(True) self.column_lastconnection.set_clickable(True) self.column_connections.connect('clicked', self.on_table_column_clicked, 9) self.column_lastconnection.connect('clicked', self.on_table_column_clicked,10) # set intial values for sorting order and column self.sortorder = gtk.SORT_DESCENDING self.sortcolumn = 10 # and apply sorting self.liststore.set_sort_column_id(self.sortcolumn, self.sortorder) self.column_lastconnection.set_sort_order(self.sortorder) self.column_lastconnection.set_sort_indicator(True) self.show_all()
def __init__(self): """ Constructor """ gtk.VBox.__init__(self) fm = FileManager() config = fm.getConfiguration() if cfgvalues.BASIC_FILTER == config[cfgkey.OPT_FILTER]: self.filter = ServerListFilter(self) else: self.filter = AdvancedFilter(self) self.filter.show() self.pack_start(self.filter, False, False) # top pane area paned = gtk.VPaned() paned.show() self.pack_start(paned) # bottom add a statusbar self.statusbar = StatusBar(self) self.pack_start(self.statusbar, False, False) # serverlist window self.serverlist = ServerList(self) paned.pack1(self.serverlist, True, False) #paned.add1(self.serverlist) # bottom panearea bottompane = gtk.HPaned() paned.pack2(bottompane, True, False) #paned.add2(bottompane) #left box self.playerlist = PlayerList() bottompane.pack1(self.playerlist, False, False) #right box self.detailsbox = ServerDetailBox() vbox = gtk.VBox() bottompane.pack2(vbox, True, False) buttonbox = gtk.HBox() #self.detailsbox.pack_start(buttonbox, False, False) vbox.pack_start(buttonbox, False, False) vbox.pack_start(self.detailsbox) refresh_button = gtk.Button('Refresh') refreshimage = gtk.Image() refreshimage.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON) refresh_button.set_image(refreshimage) connect_button = gtk.Button('Connect') connectimage = gtk.Image() connectimage.set_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON) connect_button.set_image(connectimage) addfav_button = gtk.Button('Add to Favorites') favimage = gtk.Image() favimage.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) addfav_button.set_image(favimage) buttonbox.pack_start(refresh_button, True, True) buttonbox.pack_start(connect_button, True, True) buttonbox.pack_start(addfav_button, True, True) refresh_button.connect("clicked", self.onRefreshButtonClicked) addfav_button.connect("clicked", self.onAddFavButtonClicked) connect_button.connect("clicked", self.connect_button_clicked) self.show_all()
def __init__(self): """ Constructor """ gtk.VBox.__init__(self) #prepare images: offline_image = gtk.Image() offline_image.set_from_file(Globals.icon_dir+'/gray-icon.png') self.offline_pixbuf = offline_image.get_pixbuf() online_image = gtk.Image() online_image.set_from_file(Globals.icon_dir+'/green-icon.png') self.online_pixbuf = online_image.get_pixbuf() mainbox = gtk.HBox() self.pack_start(mainbox) buddieslistview = self.create_buddy_list_view() mainbox.pack_start(buddieslistview, False, False) serverlistbox = gtk.VBox() mainbox.pack_start(serverlistbox) self.filter = BuddiesFilter(self) self.filter.show() serverlistbox.pack_start(self.filter, False, False) # top pane area paned = gtk.VPaned() paned.show() serverlistbox.pack_start(paned) # bottom add a statusbar self.statusbar = StatusBar(self) serverlistbox.pack_start(self.statusbar, False, False) # serverlist window self.serverlist = ServerList(self) paned.pack1(self.serverlist, True, False) #paned.add1(self.serverlist) # bottom panearea bottompane = gtk.HPaned() paned.pack2(bottompane, True, False) #paned.add2(bottompane) #left box self.playerlist = PlayerList() bottompane.pack1(self.playerlist, False, False) #right box self.detailsbox = ServerDetailBox() vbox = gtk.VBox() bottompane.pack2(vbox, True, False) buttonbox = gtk.HBox() #self.detailsbox.pack_start(buttonbox, False, False) vbox.pack_start(buttonbox, False, False) vbox.pack_start(self.detailsbox) addfav_button = gtk.Button('Add to Favorites') favimage = gtk.Image() favimage.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) addfav_button.set_image(favimage) refresh_button = gtk.Button('Refresh') refreshimage = gtk.Image() refreshimage.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON) refresh_button.set_image(refreshimage) connect_button = gtk.Button('Connect') connectimage = gtk.Image() connectimage.set_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON) connect_button.set_image(connectimage) buttonbox.pack_start(refresh_button, True, True) buttonbox.pack_start(connect_button, True, True) buttonbox.pack_start(addfav_button, True, True) refresh_button.connect("clicked", self.onRefreshButtonClicked) addfav_button.connect("clicked", self.onAddFavButtonClicked) connect_button.connect("clicked", self.connect_button_clicked) self.show_all()
def __init__(self): """ Constructor """ gtk.VBox.__init__(self) self.filter = FavoritesFilter() self.filter.show() self.pack_start(self.filter, False, False) # top pane area paned = gtk.VPaned() paned.show() self.pack_start(paned) # bottom add a statusbar self.statusbar = StatusBar(self) self.pack_start(self.statusbar, False, False) # serverlist window self.serverlist = ServerList(self) paned.pack1(self.serverlist, True, False) #paned.add1(self.serverlist) # bottom panearea bottompane = gtk.HPaned() paned.pack2(bottompane, True, False) #paned.add2(bottompane) #left box self.playerlist = PlayerList() bottompane.pack1(self.playerlist, False, False) #right box self.detailsbox = ServerDetailBox() vbox = gtk.VBox() bottompane.pack2(vbox, True, False) buttonbox = gtk.HBox() #self.detailsbox.pack_start(buttonbox, False, False) vbox.pack_start(buttonbox, False, False) vbox.pack_start(self.detailsbox) refresh_button = gtk.Button('Refresh') refreshimage = gtk.Image() refreshimage.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON) refresh_button.set_image(refreshimage) connect_button = gtk.Button('Connect') connectimage = gtk.Image() connectimage.set_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON) connect_button.set_image(connectimage) removefav_button = gtk.Button('Remove from Favorites') removeimage = gtk.Image() removeimage.set_from_stock(gtk.STOCK_DELETE, gtk.ICON_SIZE_BUTTON) removefav_button.set_image(removeimage) buttonbox.pack_start(refresh_button, True, True) buttonbox.pack_start(connect_button, True, True) buttonbox.pack_start(removefav_button, False, False) refresh_button.connect("clicked", self.onRefreshButtonClicked) removefav_button.connect("clicked", self.onRemoveFavoriteClicked) connect_button.connect("clicked", self.connect_button_clicked) self.show_all()
class FavoritesTab(BaseTab): """ UI Element for the content of the favorites tab. """ def __init__(self): """ Constructor """ gtk.VBox.__init__(self) self.filter = FavoritesFilter() self.filter.show() self.pack_start(self.filter, False, False) # top pane area paned = gtk.VPaned() paned.show() self.pack_start(paned) # bottom add a statusbar self.statusbar = StatusBar(self) self.pack_start(self.statusbar, False, False) # serverlist window self.serverlist = ServerList(self) paned.pack1(self.serverlist, True, False) #paned.add1(self.serverlist) # bottom panearea bottompane = gtk.HPaned() paned.pack2(bottompane, True, False) #paned.add2(bottompane) #left box self.playerlist = PlayerList() bottompane.pack1(self.playerlist, False, False) #right box self.detailsbox = ServerDetailBox() vbox = gtk.VBox() bottompane.pack2(vbox, True, False) buttonbox = gtk.HBox() #self.detailsbox.pack_start(buttonbox, False, False) vbox.pack_start(buttonbox, False, False) vbox.pack_start(self.detailsbox) refresh_button = gtk.Button('Refresh') refreshimage = gtk.Image() refreshimage.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON) refresh_button.set_image(refreshimage) connect_button = gtk.Button('Connect') connectimage = gtk.Image() connectimage.set_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON) connect_button.set_image(connectimage) removefav_button = gtk.Button('Remove from Favorites') removeimage = gtk.Image() removeimage.set_from_stock(gtk.STOCK_DELETE, gtk.ICON_SIZE_BUTTON) removefav_button.set_image(removeimage) buttonbox.pack_start(refresh_button, True, True) buttonbox.pack_start(connect_button, True, True) buttonbox.pack_start(removefav_button, False, False) refresh_button.connect("clicked", self.onRefreshButtonClicked) removefav_button.connect("clicked", self.onRemoveFavoriteClicked) connect_button.connect("clicked", self.connect_button_clicked) self.show_all() # self.pack_start(button,False) def connect_button_clicked(self, widget): """ Callback of the the connect button """ gui = GuiController() server = self.detailsbox.current_server if server: if server.needsPassword(): passdialog = PasswordDialog(server, PassDialogType\ .SERVER_PASSWORD) passdialog.run() else: gui.connectToServer(server) def onRemoveFavoriteClicked(self, widget): """ Callback method for the remove button. Triggers the removal of the favorite entry by calling the gui controller which then removes the favorite (from list in memory and also from file) Also removes the favorite directly from the liststore. @param widget - the widget that emitted the clicked signal - the button """ #the current selected server displayed in the details server = self.detailsbox.current_server if server: #remove it from the favoriteslist gui = GuiController() gui.removeFavorite(server) #remove row from liststore selection = self.serverlist.serverlistview.get_selection() result = selection.get_selected() if result: model, iter = result model.remove(iter) def onRefreshButtonClicked(self, widget): """ Callback of the refreshbutton. """ selection = self.serverlist.serverlistview.get_selection() model, paths = selection.get_selected_rows() if paths: row = model[paths[0][0]] server = row[8] guicontroller = GuiController() guicontroller.setDetailServer(server, self) def addServer(self, server): """ Add a server to the listview/store. Called by the guicontroller. """ self.serverlist.addServer(server) def clearServerList(self): """ Clears the embeded serverlist treeview """ self.serverlist.clear() def setServerdetails(self, server): """ Updates the embedded serverdetails element """ self.playerlist.clear() for player in server.getPlayerList(): self.playerlist.addPlayer(player) self.detailsbox.setServerDetails(server) # update row in list # but only if the corresponding option is True fm = FileManager() config = fm.getConfiguration() if 'True' == config[cfgkey.OPT_UPDATE_SL_ROW]: self.serverlist.update_selected_row(server) def serverlist_loading_finished(self): """ Callback method executed when the search has finished """ #reactivate the search button self.filter.refresh_button.set_sensitive(True) self.statusbar.lock() self.qm = None