Beispiel #1
0
 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()
Beispiel #2
0
 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()
Beispiel #3
0
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