コード例 #1
0
ファイル: __init__.py プロジェクト: hsbp/burnstation2
 def ev_albuminfo_created(self, albuminfo):
     albumid = str(albuminfo.album['album_id'])
     stared = self.pyjama.settings.get_value("STAR PLUGIN", "STARED ALBUMS", "")
     if albumid in stared:
         # add remove button to albuminfo
         bControlStar = StockButton(gtk.STOCK_REMOVE, gtk.ICON_SIZE_MENU)
         bControlStar.set_tooltip_text(_("Un-star this album"))
         #~ albuminfo.vbControl.pack_start(bControlStar, False, True, 10)
         bControlStar.connect("clicked", self.on_StarAlbum, albumid)
     else:
         # Add Star to albuminfo
         bControlStar = ImageButton(os.path.join(functions.install_dir(), "images", "star.png"), 16, 16)
         bControlStar.set_tooltip_text(_("Star this album"))
         #~ albuminfo.vbControl.pack_start(bControlStar, False, True, 10)
         bControlStar.connect("clicked", self.on_StarAlbum , albumid)
     albuminfo.layout.put(bControlStar, 0,0)
     albuminfo.widgets_list.append(bControlStar)
     #~ bControlStar.show()
     albuminfo.star = bControlStar
コード例 #2
0
    def __init__(self, pyjama):
        self.pyjama = pyjama
        gtk.Layout.__init__(self)
        self.set_size(350,100)   

        # Labels for Search- Window
        self.SearchLabels={}

        #
        # Search Layout
        #
        self.SearchLabels['desc'] = gtk.Label("")
        self.SearchLabels['desc'].set_single_line_mode(False)
        self.put(self.SearchLabels['desc'], 10, 10)
        if self.pyjama.nocolor:
            self.SearchLabels['desc'].set_markup(_("<span><b>Here you can search for artist, albums and tracks.\nEnter your search term in the text field\n\nAt most 100 results will be shown.</b></span>") )
        else:
            self.SearchLabels['desc'].set_markup(_("<span foreground=\"white\"><b>Here you can search for artist, albums and tracks.\nEnter your search term in the text field\n\nAt most 100 results will be shown.</b></span>"))
        self.SearchLabels['desc'].show()
            
        # Entry
        self.hbSearch = gtk.HBox()
        self.put(self.hbSearch, 10, 80)
        self.eSearch = gtk.Entry()
        self.eSearch.connect("activate", self.prepare_search)
        self.hbSearch.pack_start(self.eSearch, True, True)
        
        # Button
        self.bSearch2 = StockButton(gtk.STOCK_FIND, gtk.ICON_SIZE_SMALL_TOOLBAR )
        self.hbSearch.pack_start(self.bSearch2, True, True)
        self.bSearch2.connect("clicked", self.prepare_search)

        self.SearchLabels['hits'] = gtk.Label("")
        self.SearchLabels['hits'].set_single_line_mode(False)
        self.put(self.SearchLabels['hits'], 250,90)
        #self.hbSearch.pack_end(self.SearchLabels['hits'], True, True)
        self.hbSearch.show_all()

        # Setting Color
        self.pyjama.window.setcolor(self)
        self.show_all()
コード例 #3
0
class SearchLayout(gtk.Layout):
    def __init__(self, pyjama):
        self.pyjama = pyjama
        gtk.Layout.__init__(self)
        self.set_size(350,100)   

        # Labels for Search- Window
        self.SearchLabels={}

        #
        # Search Layout
        #
        self.SearchLabels['desc'] = gtk.Label("")
        self.SearchLabels['desc'].set_single_line_mode(False)
        self.put(self.SearchLabels['desc'], 10, 10)
        if self.pyjama.nocolor:
            self.SearchLabels['desc'].set_markup(_("<span><b>Here you can search for artist, albums and tracks.\nEnter your search term in the text field\n\nAt most 100 results will be shown.</b></span>") )
        else:
            self.SearchLabels['desc'].set_markup(_("<span foreground=\"white\"><b>Here you can search for artist, albums and tracks.\nEnter your search term in the text field\n\nAt most 100 results will be shown.</b></span>"))
        self.SearchLabels['desc'].show()
            
        # Entry
        self.hbSearch = gtk.HBox()
        self.put(self.hbSearch, 10, 80)
        self.eSearch = gtk.Entry()
        self.eSearch.connect("activate", self.prepare_search)
        self.hbSearch.pack_start(self.eSearch, True, True)
        
        # Button
        self.bSearch2 = StockButton(gtk.STOCK_FIND, gtk.ICON_SIZE_SMALL_TOOLBAR )
        self.hbSearch.pack_start(self.bSearch2, True, True)
        self.bSearch2.connect("clicked", self.prepare_search)

        self.SearchLabels['hits'] = gtk.Label("")
        self.SearchLabels['hits'].set_single_line_mode(False)
        self.put(self.SearchLabels['hits'], 250,90)
        #self.hbSearch.pack_end(self.SearchLabels['hits'], True, True)
        self.hbSearch.show_all()

        # Setting Color
        self.pyjama.window.setcolor(self)
        self.show_all()


    def draw(self, data1, data2, data3, data4):
        if data4 == None:
#            markup = self.pyjama.window.markuplbCaption.replace("TEXT", _("Search for artists, albums and tracks"))
            txt = _("Search for artists, albums and tracks")
        else:
#            markup = self.pyjama.window.markuplbCaption.replace("TEXT", _("You searched for '%s'") % data4)
            srch = "<b>%s</b>" % data4
            txt = _("You searched for '%s'") % srch
#        self.pyjama.window.lbCaption.set_markup(markup)
        self.pyjama.window.LayoutInfo.set_text(txt)
        self.pyjama.window.LayoutInfo.set_image(gtk.STOCK_FIND)
        self.search_window(data1, data2, data3, data4)

    ######################################################################
    #                                                                    #
    #                            Functions                               #
    #                                                                    #
    ######################################################################

    # This Function was installed to pass search results
    # through "clear_layout" function, which supplies
    # history functionality!
    def prepare_search(self, ev):
        if len(self.eSearch.get_text())<3:
            self.pyjama.layouts.show_layout("search", -1)
            return None
        ret1 =  self.pyjama.db.search_artist(self.eSearch.get_text())
        ret2 =  self.pyjama.db.search_album(self.eSearch.get_text())
        ret3 =  self.pyjama.db.search_track(self.eSearch.get_text())
        self.pyjama.layouts.show_layout("search", ret1, ret2, ret3, self.eSearch.get_text(), who_called = "prepare_search")

    def search_window(self, search=None, search2=None, search3=None, keyword=None):
        if search == None and search2 == None and search3 == None:
            self.SearchLabels['hits'].hide()
        else:
            self.SearchLabels['hits'].show()
        if search == -1:
            print ("Minimum length of 3 letters")
            return None

        if keyword:
            self.eSearch.set_text(keyword)
        self.pyjama.window.set_focus(self.eSearch)

        hits_artists, hits_albums, hits_tracks = 0,0,0

        
        ### Results into Treeview
        # in order to fast that up, i should
        # disconnect listview from treeview
        # temporary

        if keyword is None:
            self.pyjama.window.TVListFrame.get_label_widget().set_markup("")
        else:
            self.pyjama.window.TVListFrame.get_label_widget().set_markup(_("Artists, Albums and Tracks containing '<b>%s</b>'" % keyword))

        self.pyjama.window.tvList.clear()
        if search != None and len(search) > 0:
            for hit in search:
                results = [search[hit]['artist_name'], "", "", "", "", search[hit]['artist_id'], -1, -1]
                self.pyjama.window.tvList.add_item(results)
            hits_artists = len(search)
                
        if search2 != None and len(search2) > 0:
            for hit in search2:
                results = [search2[hit]['artist_name'], search2[hit]['album_name'], "", "", "", search2[hit]['artist_id'], search2[hit]['album_id'], -1]
                self.pyjama.window.tvList.add_item(results)
            hits_albums = len(search2)
            
        if search3 != None and len(search3) > 0:
            for track in search3:
                results = [track.artist_name, track.album_name, track.numalbum, track.name, track.license, track.artist_id, track.album_id, track.id]
                self.pyjama.window.tvList.add_item(results)
            hits_tracks = len(search3)

        if search or search2 or search3:
            hit_message = _("<u>%i hits</u>\n\n%i artists\n%i albums\n%i tracks") % (hits_artists + hits_albums + hits_tracks, hits_artists, hits_albums, hits_tracks)

            if self.pyjama.nocolor:
                self.SearchLabels['hits'].set_markup("<span><b>%s</b></span>" % hit_message)
            else:
                self.SearchLabels['hits'].set_markup("<span foreground=\"white\"><b>%s</b></span>" % hit_message)

    class ToolBar(gtk.HBox):
        def __init__(self, pyjama):
            self.pyjama = pyjama
            gtk.HBox.__init__(self)