Ejemplo n.º 1
0
 def display(self, screen):
     super(saveGameScreen,self).display(screen)
     screen.fill(ui.COLOR_BACKGROUND)
     screen.blit(bg3,(0,0))
     self.show_music_controls(screen)
     pygame.draw.rect(screen, ui.COLOR_PURPLE, (0, 0, screen.get_width(), screen.get_height()*0.1))
     ui.centered_text('SaveGame',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width(), screen.get_height()*0.1), True)
     ui.centered_text('Name: ' + str(ReadExcel.loadname(1))+' Score: '+str('{0:2.0f}'.format(ReadExcel.loadscore(1)))+' Round: '+str('{0:2.0f}'.format(ReadExcel.loadround(1))),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.2, screen.get_width(), screen.get_height()*0.2), True)
     ui.centered_text('Name: ' + str(ReadExcel.loadname(2))+' Score: '+str('{0:2.0f}'.format(ReadExcel.loadscore(2)))+' Round: '+str('{0:2.0f}'.format(ReadExcel.loadround(2))),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.3, screen.get_width(), screen.get_height()*0.3), True)
     ui.centered_text('Name: ' + str(ReadExcel.loadname(3))+' Score: '+str('{0:2.0f}'.format(ReadExcel.loadscore(3)))+' Round: '+str('{0:2.0f}'.format(ReadExcel.loadround(3))),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.4, screen.get_width(), screen.get_height()*0.4), True)
     ui.centered_text('Name: ' + str(ReadExcel.loadname(4))+' Score: '+str('{0:2.0f}'.format(ReadExcel.loadscore(4)))+' Round: '+str('{0:2.0f}'.format(ReadExcel.loadround(4))),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.5, screen.get_width(), screen.get_height()*0.5), True)
     if ui.show_save_button(screen, screen.get_width()*0.1, screen.get_height()*0.25):
         ReadExcel.savename(1,g._player)
         ReadExcel.savescore(1,g._total_score)
         ReadExcel.saveround(1,g._round)
     if ui.show_save_button(screen, screen.get_width()*0.1, screen.get_height()*0.4):
         ReadExcel.savename(2,g._player)
         ReadExcel.savescore(2,g._total_score)
         ReadExcel.saveround(2,g._round)
     if ui.show_save_button(screen, screen.get_width()*0.1, screen.get_height()*0.55):
         ReadExcel.savename(3,g._player)
         ReadExcel.savescore(3,g._total_score)
         ReadExcel.saveround(3,g._round)
     if ui.show_save_button(screen, screen.get_width()*0.1, screen.get_height()*0.70):
         ReadExcel.savename(4,g._player)
         ReadExcel.savescore(4,g._total_score)
         ReadExcel.saveround(4,g._round)
     if ui.button(screen,'Back',screen.get_width()*0.3-ui.BUTTON_WIDTH/2,screen.get_height()*0.75+ui.BUTTON_HEIGHT,(238,232,170,240)):
         change_screen(RoundEndScreen())
     if ui.button(screen,'Quit',screen.get_width()*0.7-ui.BUTTON_WIDTH/2,screen.get_height()*0.75+ui.BUTTON_HEIGHT,(255,0,0)):
         pygame.quit()
         quit()
     if ui.show_home_button(screen, 0, -2):
         change_screen(SplashScreen())
Ejemplo n.º 2
0
def MainMenu():
    container = generic.render_listings('/')

    container.add(
        button('heading.favorites',
               favorites.MainMenu,
               icon='icon-favorites.png'))
    container.add(
        input_button('heading.search',
                     'search.prompt',
                     SearchResultsMenu,
                     icon='icon-search.png',
                     foo=1))
    container.add(
        button('search.heading.saved',
               search.MainMenu,
               icon='icon-saved-search.png'))
    container.add(
        button('heading.download',
               downloads.MainMenu,
               refresh=0,
               icon='icon-downloads.png'))
    container.add(
        button('heading.system', system.MainMenu, icon='icon-system.png'))
    container.add(PrefsObject(title=L('system.heading.preferences')))
    updater.add_button_to(container, PerformUpdate)
    return container
Ejemplo n.º 3
0
 def display(self, screen):
     super(choseRoundScreen,self).display(screen)
     screen.fill(ui.COLOR_BACKGROUND)
     screen.blit(bg3,(0,0))
     self.show_music_controls(screen)
     pygame.draw.rect(screen, ui.COLOR_PURPLE, (0, 0, screen.get_width(), screen.get_height()*0.1))
     ui.centered_text('LoadGame',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width(), screen.get_height()*0.1), True)
     ui.centered_text('Name: ' + str(ReadExcel.loadname(1))+' Score: '+str('{0:2.0f}'.format(ReadExcel.loadscore(1)))+' Round: '+str('{0:2.0f}'.format(ReadExcel.loadround(1))),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.2, screen.get_width(), screen.get_height()*0.2), True)
     ui.centered_text('Name: ' + str(ReadExcel.loadname(2))+' Score: '+str('{0:2.0f}'.format(ReadExcel.loadscore(2)))+' Round: '+str('{0:2.0f}'.format(ReadExcel.loadround(2))),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.3, screen.get_width(), screen.get_height()*0.3), True)
     ui.centered_text('Name: ' + str(ReadExcel.loadname(3))+' Score: '+str('{0:2.0f}'.format(ReadExcel.loadscore(3)))+' Round: '+str('{0:2.0f}'.format(ReadExcel.loadround(3))),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.4, screen.get_width(), screen.get_height()*0.4), True)
     ui.centered_text('Name: ' + str(ReadExcel.loadname(4))+' Score: '+str('{0:2.0f}'.format(ReadExcel.loadscore(4)))+' Round: '+str('{0:2.0f}'.format(ReadExcel.loadround(4))),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.5, screen.get_width(), screen.get_height()*0.5), True)
     if ui.show_choose_button(screen, screen.get_width()*0.1, screen.get_height()*0.25):
         g._total_score = ReadExcel.loadscore(1)
         g._last_round_score = ReadExcel.loadscore(1)
         g._round = ReadExcel.loadround(1) 
         g._words = g.load_words_for_round(-1,True,g._round)
         g._player = ReadExcel.loadname(1)
         ui.played_round = True
         g_word, g._definition = g.choose_random_definition()
         checkPerson(ReadExcel.loadname(1))
         change_screen(RoundEndScreen())
     if ui.show_choose_button(screen, screen.get_width()*0.1, screen.get_height()*0.4):
         g._total_score = ReadExcel.loadscore(2)
         g._last_round_score = ReadExcel.loadscore(2)
         g._round = ReadExcel.loadround(2) 
         ui.played_round = True
         g._words = g.load_words_for_round(-1,True,g._round)
         g._player = ReadExcel.loadname(2)
         g_word, g._definition = g.choose_random_definition()
         checkPerson(ReadExcel.loadname(2))
         change_screen(RoundEndScreen())
     if ui.show_choose_button(screen, screen.get_width()*0.1, screen.get_height()*0.55):
         g._total_score = ReadExcel.loadscore(3)
         g._last_round_score = ReadExcel.loadscore(3)
         g._round = ReadExcel.loadround(3)
         ui.played_round = True
         g._words = g.load_words_for_round(-1,True,g._round)
         g._player = ReadExcel.loadname(3)
         g_word, g._definition = g.choose_random_definition()
         checkPerson(ReadExcel.loadname(3))
         change_screen(RoundEndScreen())
     if ui.show_choose_button(screen, screen.get_width()*0.1, screen.get_height()*0.70):
         g._total_score = ReadExcel.loadscore(4)
         g._last_round_score = ReadExcel.loadscore(4)
         g._round = ReadExcel.loadround(4)
         ui.played_round = True
         g._player = ReadExcel.loadname(4)
         g._words = g.load_words_for_round(-1,True,g._round+1)
         g_word, g._definition = g.choose_random_definition()
         checkPerson(ReadExcel.loadname(4))
         change_screen(RoundEndScreen())
     if ui.button(screen,'Back',screen.get_width()*0.3-ui.BUTTON_WIDTH/2,screen.get_height()*0.75+ui.BUTTON_HEIGHT,(238,232,170,240)):
         change_screen(SplashScreen())
     if ui.button(screen,'Quit',screen.get_width()*0.7-ui.BUTTON_WIDTH/2,screen.get_height()*0.75+ui.BUTTON_HEIGHT,(255,0,0)):
         pygame.quit()
         quit()
     if ui.show_home_button(screen, 0, -2):
         change_screen(SplashScreen())
Ejemplo n.º 4
0
def MainMenu():
    container = generic.render_listings('/')

    container.add(button('heading.favorites',    favorites.MainMenu, icon = 'icon-favorites.png'))
    container.add(input_button('heading.search', 'search.prompt', SearchResultsMenu, icon = 'icon-search.png', foo = 1))
    container.add(button('search.heading.saved', search.MainMenu, icon = 'icon-saved-search.png'))
    container.add(button('heading.download',     downloads.MainMenu, refresh = 0, icon = 'icon-downloads.png'))
    container.add(button('heading.system',       system.MainMenu, icon = 'icon-system.png'))
    container.add(PrefsObject(title = L('system.heading.preferences')))
    updater.add_button_to(container, PerformUpdate)
    return container
Ejemplo n.º 5
0
Archivo: menu.py Proyecto: SteinW1/OOP
    def __init__(self, gameDisplay, window, gameClock):
        state.State.__init__(self, gameDisplay, window, gameClock)
        self.Title = None
        self.StartButton = ui.button(150, 450, 100, 50, colors['bright_green'], colors['green'], colors['black'], "comicsansms", 20, "Start")
        self.ExitButton = ui.button(550, 450, 100, 50, colors['bright_red'], colors['red'], colors['black'], "comicsansms", 20, "Exit")

        self.titleBackground = pygame.image.load('images/TitleBackground.png')
        self.titleBackground_width = 500
        self.titleBackground_height = 300

        #set the next states 'next' variables
        self.targetState = 'game'
Ejemplo n.º 6
0
	def about_load(self, stats):
		self.about_dialog = gtk.AboutDialog()
		try:
			self.about_dialog.set_transient_for(self.parent_window)
			self.about_dialog.set_modal(True)
		except:
			pass
		self.about_dialog.set_name('Sonata')
		self.about_dialog.set_role('about')
		self.about_dialog.set_version(self.version)
		commentlabel = _('An elegant music client for MPD.')
		self.about_dialog.set_comments(commentlabel)
		if stats:
			self.about_dialog.set_copyright(self.statstext(stats))
		self.about_dialog.set_license(self.license)
		self.about_dialog.set_authors(['Scott Horowitz <*****@*****.**>', 'Tuukka Hastrup <*****@*****.**>'])
		self.about_dialog.set_artists(['Adrian Chromenko <*****@*****.**>\nhttp://oss.rest0re.org/'])
		self.about_dialog.set_translator_credits(translators)
		gtk.about_dialog_set_url_hook(self.show_website)
		self.about_dialog.set_website("http://sonata.berlios.de/")
		large_icon = gtk.gdk.pixbuf_new_from_file(self.icon_file)
		self.about_dialog.set_logo(large_icon)
		# Add button to show keybindings:
		shortcut_button = ui.button(text=_("_Shortcuts"))
		self.about_dialog.action_area.pack_start(shortcut_button)
		self.about_dialog.action_area.reorder_child(self.about_dialog.action_area.get_children()[-1], -2)
		# Connect to callbacks
		self.about_dialog.connect('response', self.about_close)
		self.about_dialog.connect('delete_event', self.about_close)
		shortcut_button.connect('clicked', self.about_shortcuts)
		self.about_dialog.show_all()
Ejemplo n.º 7
0
	def about_load(self, stats):
		self.about_dialog = gtk.AboutDialog()
		try:
			self.about_dialog.set_transient_for(self.parent_window)
			self.about_dialog.set_modal(True)
		except:
			pass
		self.about_dialog.set_name('Sonata')
		self.about_dialog.set_role('about')
		self.about_dialog.set_version(self.version)
		commentlabel = _('An elegant music client for MPD.')
		self.about_dialog.set_comments(commentlabel)
		if stats:
			self.about_dialog.set_copyright(self.statstext(stats))
		self.about_dialog.set_license(self.license)
		self.about_dialog.set_authors(['Scott Horowitz <*****@*****.**>', 'Tuukka Hastrup <*****@*****.**>', 'Stephen Boyd <*****@*****.**>'])
		self.about_dialog.set_artists(['Adrian Chromenko <*****@*****.**>\nhttp://oss.rest0re.org/'])
		self.about_dialog.set_translator_credits(translators)
		gtk.about_dialog_set_url_hook(self.show_website)
		self.about_dialog.set_website("http://sonata.berlios.de/")
		large_icon = gtk.gdk.pixbuf_new_from_file(self.icon_file)
		self.about_dialog.set_logo(large_icon)
		# Add button to show keybindings:
		shortcut_button = ui.button(text=_("_Shortcuts"))
		self.about_dialog.action_area.pack_start(shortcut_button)
		self.about_dialog.action_area.reorder_child(self.about_dialog.action_area.get_children()[-1], -2)
		# Connect to callbacks
		self.about_dialog.connect('response', self.about_close)
		self.about_dialog.connect('delete_event', self.about_close)
		shortcut_button.connect('clicked', self.about_shortcuts)
		self.about_dialog.show_all()
Ejemplo n.º 8
0
def drawStart(screen, titlefont, state, events, title):
    global special
    global complete

    if title == "Platformer":
        pygame.draw.rect(screen, (153, 0, 0), (0, 0, 250, 85))
        pygame.draw.rect(screen, (41, 41, 41), (0, 0, 220, 70))
    else:
        pygame.draw.rect(screen, (153, 0, 0), (0, 0, 350, 85))
        pygame.draw.rect(screen, (41, 41, 41), (0, 0, 320, 70))

    char1 = titlefont.render(title, 1, (255, 255, 255))
    screen.blit(char1, (10, 10))
    startbutton3 = ui.button("Done", 370, 485, 300, 75)
    startbutton3.render(screen)

    ip = special[0].render(screen, events)
    port = special[1].render(screen, events)
    name = special[2].render(screen, events)

    if ip is not None:
        complete[0] = ip
    if port is not None:
        complete[1] = port

    if name is not None:
        complete[2] = name

    if startbutton3.pressed(events):
        return (complete)
Ejemplo n.º 9
0
    def display(self, screen):
        super(GameOverScreen, self).display(screen)
        screen.fill(ui.COLOR_BACKGROUND)
        screen.blit(bg1,(0,0))
        self.show_music_controls(screen)

        pygame.draw.rect(screen, ui.COLOR_PURPLE, (0, 0, screen.get_width(), screen.get_height()*0.1))
        ui.centered_text('Game Over!',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width(), screen.get_height()*0.1), True)
        pygame.draw.rect(screen, ui.COLOR_PURPLE, (254, screen.get_height()*0.2, screen.get_width()*0.6, screen.get_height()*0.25))
        ui.centered_text('Your score was ' + str(g.get_total_score()) + '/' + str(g.get_max_total_score()),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.2, screen.get_width(), screen.get_height()*0.25), True)
        
        if ui.button(screen,'Play Again',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5,(255,215,0)) or pygame.key.get_pressed()[pygame.K_RETURN]:
            change_screen(SplashScreen())

        if ui.button(screen,'Quit',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5+ui.BUTTON_HEIGHT,(255,0,0)):
            quit()
        if ui.show_home_button(screen, 0, -2):
            change_screen(SplashScreen())
Ejemplo n.º 10
0
    def display(self, screen):
        super(SplashScreen, self).display(screen)
        screen.fill(ui.COLOR_BACKGROUND)
        screen.blit(bg1,(0,0))
        self.show_music_controls(screen)

        self.ticker += self.delta_time * 0.001
        if self.ticker > 2 * math.pi: self.ticker = 0

        pygame.draw.rect(screen, ui.COLOR_PURPLE, (0, 0, screen.get_width(), screen.get_height()*0.1))
        ui.centered_text('Definition Game',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0 + math.sin(self.ticker) * 10, screen.get_width(), screen.get_height()*0.1), True)
        if ui.button(screen,'New Game',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5-ui.BUTTON_HEIGHT-10,(255,215,0)) or pygame.key.get_pressed()[pygame.K_RETURN]:
            change_screen(choosePersonScreen())
        if ui.button(screen,'Load Game',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5-10,(255,127,80,230)):
            change_screen(choseRoundScreen())
        if ui.button(screen,'How to play',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5+ui.BUTTON_HEIGHT-10,(255,99,71,230)):
            change_screen(howToPlayScreen())
        if ui.button(screen,'Quit',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5+ui.BUTTON_HEIGHT*2-10,(255,0,0)):
            quit()
Ejemplo n.º 11
0
 def display(self, screen):
     super(RoundEndScreen, self).display(screen)
     screen.fill(ui.COLOR_BACKGROUND)
     screen.blit(bg1,(0,0))
     self.show_music_controls(screen)
     g._pass = True
     pygame.draw.rect(screen, ui.COLOR_PURPLE, (0, 0, screen.get_width(), screen.get_height()*0.1))
     ui.centered_text('The round is finished.',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width(), screen.get_height()*0.1), True)
     ui.centered_text('Your score was ' + str(g.get_last_round_score()),  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.1, screen.get_width(), screen.get_height()*0.1), True)
     if ui.button(screen,'Next Round',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5-ui.BUTTON_HEIGHT,(0,191,255,250)) or pygame.key.get_pressed()[pygame.K_RETURN]:
         if ui.played_round:
             g._round+=1
             ui.played_round = False
         change_screen(GameScreen())
     if ui.button(screen,'Save Game',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5,(100,149,237,240)) or pygame.key.get_pressed()[pygame.K_RETURN]:
         change_screen(saveGameScreen())
     if ui.button(screen,'Quit',screen.get_width()*0.5-ui.BUTTON_WIDTH/2,screen.get_height()*0.5+ui.BUTTON_HEIGHT,(255,0,0)):
         quit()
     if ui.show_home_button(screen, 0, -2):
         change_screen(SplashScreen())
Ejemplo n.º 12
0
    def display(self, screen):
        super(HowToPlayScreen2, self).display(screen)
        screen.fill(ui.COLOR_BACKGROUND)
        screen.blit(bg1,(0,0))
        self.show_music_controls(screen)

        pygame.draw.rect(screen, ui.COLOR_PURPLE, (0, 0, screen.get_width(), screen.get_height()*0.1))
        ui.centered_text('Game Rules',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width(), screen.get_height()*0.1), True)
        ui.centered_text('1. Before a round starts you have to choose a person as your player.',  ui.FONT_INSTRUCTION, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.16, screen.get_width()*0.75+75, screen.get_height()*0.1),True)
        ui.centered_text('2. You would be given a definition and a set of 12 words each round to choose from.',  ui.FONT_INSTRUCTION, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.24, screen.get_width()*0.91+100, screen.get_height()*0.1),True)
        ui.centered_text('3. If a word you choose is wrong it is disabled and you score no marks. ',  ui.FONT_INSTRUCTION, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.32, screen.get_width()*0.785+80, screen.get_height()*0.1),True)
        ui.centered_text('4. If you score a word right, you are awarded marks.',  ui.FONT_INSTRUCTION, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.40, screen.get_width()*0.6+50, screen.get_height()*0.1),True)
        ui.centered_text('5. You can save a game  when you finish the round. QUIT with no mark.',  ui.FONT_INSTRUCTION, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.48, screen.get_width()*0.84+13, screen.get_height()*0.1),True)
        ui.centered_text('6. For now, when you past 4 rounds, the game is over.',  ui.FONT_INSTRUCTION, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.56, screen.get_width()*0.62+55, screen.get_height()*0.1),True)
        ui.centered_text('7. You would see your total score when finish the game.',  ui.FONT_INSTRUCTION, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.64, screen.get_width()*0.64+57, screen.get_height()*0.1),True)
        ui.centered_text('8. You can click the profile of your player to get one free help for each round.',  ui.FONT_INSTRUCTION, ui.COLOR_DEFINITION, Rect(0, screen.get_height()*0.72, screen.get_width()*0.84+93, screen.get_height()*0.1),True)

        if ui.show_home_button(screen, 0, -2):
            change_screen(SplashScreen())
        if ui.button(screen,'Back',screen.get_width()*0.3-ui.BUTTON_WIDTH/2,screen.get_height()*0.75+ui.BUTTON_HEIGHT,(238,232,170,240)):
            change_screen(howToPlayScreen())
        if ui.button(screen,'New Game',screen.get_width()*0.7-ui.BUTTON_WIDTH/2,screen.get_height()*0.75+ui.BUTTON_HEIGHT,(255,215,0)):
            change_screen(choosePersonScreen())
Ejemplo n.º 13
0
    def display(self, screen):
        super(howToPlayScreen,self).display(screen)
        screen.fill(ui.COLOR_BACKGROUND)
        screen.blit(bg1,(0,0))
        self.show_music_controls(screen)
        #screen.blit(pythonlogo,(900,30))
        
        pygame.draw.rect(screen, ui.COLOR_PURPLE, (0, 0, screen.get_width(), screen.get_height()*0.1))
        screen.blit(pygamelogo,(1050,3))
        ui.centered_text('How to play.',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width(), screen.get_height()*0.1), True)
        ui.show_mute_button(screen, 150, 130)
        ui.centered_text('Mute the sound',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*0.65, screen.get_height()*0.46), True)
        ui.show_next_button(screen, 150, 210)
        ui.centered_text('Next song',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*0.56, screen.get_height()*0.7), True)
        ui.show_pause_button(screen, 150, 290)
        ui.centered_text('Pause',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*0.49, screen.get_height()*0.93), True)
        ui.show_choose_button(screen, 150, 370)
        ui.centered_text('Load Game',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*0.58, screen.get_height()*1.15), True)
        ui.show_save_button(screen, 142, 450)
        ui.centered_text('Save Game',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*0.58, screen.get_height()*1.39), True)
        ui.show_home_button(screen, 700, 130)
        ui.centered_text('Home',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*1.35, screen.get_height()*0.46), True)
        ui.show_profile_button(screen, 700, 210,0,0,True)
        ui.centered_text('Amy',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*1.35, screen.get_height()*0.7), True)
        ui.show_profile_button(screen, 700, 290,1,0,True)
        ui.centered_text('Aaron',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*1.35, screen.get_height()*0.93), True)
        ui.show_profile_button(screen, 700, 370,2,0,True)
        ui.centered_text('James',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*1.35, screen.get_height()*1.15), True)
        ui.show_profile_button(screen, 700, 450,3,0,True)
        ui.centered_text('Lina',  ui.FONT_TITLE, ui.COLOR_DEFINITION, Rect(0, 0, screen.get_width()*1.35, screen.get_height()*1.39), True)

        if ui.button(screen,'Back',screen.get_width()*0.3-ui.BUTTON_WIDTH/2,screen.get_height()*0.75+ui.BUTTON_HEIGHT,(238,232,170,240)):
            change_screen(SplashScreen())
        if ui.button(screen,'Next',screen.get_width()*0.7-ui.BUTTON_WIDTH/2,screen.get_height()*0.75+ui.BUTTON_HEIGHT,(0,206,209,240)):
            change_screen(HowToPlayScreen2())
        if ui.show_home_button(screen, 0, -2):
            change_screen(SplashScreen())
Ejemplo n.º 14
0
    def _create_label_entry_button_hbox(self, label_name, track=False):
        """Creates a label, entry, apply all button, packing them into an hbox.

        This is usually one row in the tagedit dialog, for example the title.
        """
        entry = ui.entry()
        button = ui.button()
        buttonvbox = self.tags_win_create_apply_all_button(button, entry, track)

        label = ui.label(text=label_name, x=1)
        hbox = gtk.HBox()
        hbox.pack_start(label, False, False, 2)
        hbox.pack_start(entry, True, True, 2)
        hbox.pack_start(buttonvbox, False, False, 2)

        return (label, entry, button, hbox)
Ejemplo n.º 15
0
 def display(self, screen):
     """Main method for screen which draws everything"""
     super(GameScreen, self).display(screen)
     screen.fill(ui.COLOR_BACKGROUND)
     #bg9=bg2.convert_alpha().set_alpha(200)
     screen.blit(bg2,(0,0))
     self.show_definition(screen)
     self.show_words(screen)
     self.show_score_and_round(screen)
     self.show_bottom_panel(screen)
     self.show_timer(screen)
     self.show_typed_words(screen)
     self.show_pause_control(screen)
     self.show_music_controls(screen)
     if ui.show_profile_button(screen, -5, -15, personIndex,g._total_score+g._score,g._pass) and g._pass:
         self.correct(g.get_word())
         g._pass = False
     # Quit button
     if ui.button(screen, 'Quit', screen.get_width() - ui.BUTTON_WIDTH - 16, screen.get_height() - 16 - 64, ui.COLOR_PURPLE, font=ui.FONT_UI_BOLD):
         change_screen(GameOverScreen())
def Initialise(create, pw, pa):
    global pixel_amount, pixel_width, size, window, input_field, create_training_data, buttons

    buttons.clear()
    create_training_data = create
    pixel_width = pw
    pixel_amount = pa

    width = (
        (pixel_width + round(pixel_width / 8)) * pixel_amount) + pixel_width
    height = width + 50
    size = width, height
    window = py.display.set_mode(size)
    window.fill((65, 85, 105))

    i = 0
    while i < pixel_amount:
        j = 0
        while j < pixel_amount:
            row_pos = (pixel_width + round(pixel_width / 8)) * j + round(
                pixel_width / 2)
            col_pos = (pixel_width + round(pixel_width / 8)) * i + round(
                pixel_width / 2)
            buttons.append(
                ui.button(col_pos, row_pos, pixel_width, pixel_width, window))
            py.display.update()
            j += 1
        i += 1

    if_pos_x = buttons[0].pos_x
    if_pos_y = size[1] - 50
    if_width = (buttons[len(buttons) - 1].pos_x -
                buttons[0].pos_x) + pixel_width
    if_height = 40
    input_field = ui.input_field(if_pos_x, if_pos_y, if_width, if_height,
                                 window)
Ejemplo n.º 17
0
    def show_words(self, screen):
        """Draws word buttons"""
        button_offset_y = screen.get_height() * 0.35 + 64
        button_offset_x = (screen.get_width() - ui.BUTTON_WIDTH * 4) / 2
        button_row = 0
        button_col = 0
        # big mess for organizing buttons in grid
        for w in self.keyset:
            if button_col == 4:
                button_row += 1
                button_col = 0
            if w in self.disabled_words:
                ui.disabled_button(screen, w, button_offset_x + ui.BUTTON_WIDTH * button_col, button_offset_y + 64 * button_row)
            elif w in self.correct_words:
                ui.correct_button(screen, w, button_offset_x + ui.BUTTON_WIDTH*button_col, button_offset_y + 64 * button_row)
            elif ui.button(screen, w, button_offset_x + ui.BUTTON_WIDTH * button_col, button_offset_y + 64 * button_row):
                if g.check_word(w): # game logic stuff like this shouldn't be here
                    self.correct(w)
                else: # and this
                    self.incorrect(w)
                pass
            button_col += 1

        return w
Ejemplo n.º 18
0
	def __init__(self, config, client, artwork, TAB_LIBRARY, album_filename, settings_save, filtering_entry_make_red, filtering_entry_revert_color, filter_key_pressed, on_add_item, parse_formatting, connected, on_library_button_press, on_library_search_text_click):
		self.artwork = artwork
		self.config = config
		self.client = client
		self.librarymenu = None # cyclic dependency, set later
		self.TAB_LIBRARY = TAB_LIBRARY
		self.album_filename = album_filename
		self.settings_save = settings_save
		self.filtering_entry_make_red = filtering_entry_make_red
		self.filtering_entry_revert_color = filtering_entry_revert_color
		self.filter_key_pressed = filter_key_pressed
		self.on_add_item = on_add_item
		self.parse_formatting = parse_formatting
		self.connected = connected
		self.on_library_button_press = on_library_button_press
		self.on_library_search_text_click = on_library_search_text_click

		self.NOTAG = _("Untagged")
		self.VAstr = _("Various Artists")
		self.search_terms = [_('Artist'), _('Title'), _('Album'), _('Genre'), _('Filename'), _('Everything')]
		self.search_terms_mpd = ['artist', 'title', 'album', 'genre', 'file', 'any']

		self.libfilterbox_cmd_buf = None
		self.libfilterbox_cond = None
		self.libfilterbox_source = None

		self.prevlibtodo_base = None
		self.prevlibtodo_base_results = None
		self.prevlibtodo = None

		self.save_timeout = None
		self.libsearch_last_tooltip = None

		self.lib_view_filesystem_cache = None
		self.lib_view_artist_cache = None
		self.lib_view_genre_cache = None
		self.lib_view_album_cache = None
		self.lib_list_genres = None
		self.lib_list_artists = None
		self.lib_list_albums = None
		self.lib_list_years = None
		self.view_caches_reset()

		self.libraryvbox = gtk.VBox()
		self.library = ui.treeview()
		self.library_selection = self.library.get_selection()
		expanderwindow2 = ui.scrollwindow(add=self.library)
		self.searchbox = gtk.HBox()
		self.searchcombo = ui.combo(items=self.search_terms)
		self.searchtext = ui.entry()
		self.searchbutton = ui.button(text=_('_End Search'), img=ui.image(stock=gtk.STOCK_CLOSE), h=self.searchcombo.size_request()[1])
		self.searchbutton.set_no_show_all(True)
		self.searchbutton.hide()
		self.libraryview = ui.button(relief=gtk.RELIEF_NONE)
		self.libraryview.set_tooltip_text(_("Library browsing view"))
		self.library_view_assign_image()
		self.searchbox.pack_start(self.libraryview, False, False, 1)
		self.searchbox.pack_start(gtk.VSeparator(), False, False, 0)
		self.searchbox.pack_start(self.searchcombo, False, False, 2)
		self.searchbox.pack_start(self.searchtext, True, True, 2)
		self.searchbox.pack_start(self.searchbutton, False, False, 2)
		self.libraryvbox.pack_start(expanderwindow2, True, True, 2)
		self.libraryvbox.pack_start(self.searchbox, False, False, 2)
		libraryhbox = gtk.HBox()
		libraryhbox.pack_start(ui.image(stock=gtk.STOCK_HARDDISK), False, False, 2)
		libraryhbox.pack_start(ui.label(text=self.TAB_LIBRARY), False, False, 2)
		self.libraryevbox = ui.eventbox(add=libraryhbox)
		self.libraryevbox.show_all()

		# Assign some pixbufs for use in self.library
		self.openpb = self.library.render_icon(gtk.STOCK_OPEN, gtk.ICON_SIZE_LARGE_TOOLBAR)
		self.harddiskpb = self.library.render_icon(gtk.STOCK_HARDDISK, gtk.ICON_SIZE_LARGE_TOOLBAR)
		self.albumpb = gtk.gdk.pixbuf_new_from_file_at_size(album_filename, consts.LIB_COVER_SIZE, consts.LIB_COVER_SIZE)
		self.genrepb = self.library.render_icon('gtk-orientation-portrait', gtk.ICON_SIZE_LARGE_TOOLBAR)
		self.artistpb = self.library.render_icon('artist', gtk.ICON_SIZE_LARGE_TOOLBAR)
		self.sonatapb = self.library.render_icon('sonata', gtk.ICON_SIZE_MENU)

		self.library.connect('row_activated', self.on_library_row_activated)
		self.library.connect('button_press_event', self.on_library_button_press)
		self.library.connect('key-press-event', self.on_library_key_press)
		self.library.connect('query-tooltip', self.on_library_query_tooltip)
		expanderwindow2.connect('scroll-event', self.on_library_scrolled)
		self.libraryview.connect('clicked', self.library_view_popup)
		self.searchtext.connect('button_press_event', self.on_library_search_text_click)
		self.searchtext.connect('key-press-event', self.libsearchfilter_key_pressed)
		self.searchtext.connect('activate', self.libsearchfilter_on_enter)
		self.searchbutton.connect('clicked', self.on_search_end)

		self.libfilter_changed_handler = self.searchtext.connect('changed', self.libsearchfilter_feed_loop)
		searchcombo_changed_handler = self.searchcombo.connect('changed', self.on_library_search_combo_change)

		# Initialize library data and widget
		self.libraryposition = {}
		self.libraryselectedpath = {}
		self.searchcombo.handler_block(searchcombo_changed_handler)
		self.searchcombo.set_active(self.config.last_search_num)
		self.searchcombo.handler_unblock(searchcombo_changed_handler)
		self.librarydata = gtk.ListStore(gtk.gdk.Pixbuf, str, str)
		self.library.set_model(self.librarydata)
		self.library.set_search_column(2)
		self.librarycell = gtk.CellRendererText()
		self.librarycell.set_property("ellipsize", pango.ELLIPSIZE_END)
		self.libraryimg = gtk.CellRendererPixbuf()
		self.librarycolumn = gtk.TreeViewColumn()
		self.librarycolumn.pack_start(self.libraryimg, False)
		self.librarycolumn.pack_start(self.librarycell, True)
		self.librarycolumn.set_attributes(self.libraryimg, pixbuf=0)
		self.librarycolumn.set_attributes(self.librarycell, markup=2)
		self.librarycolumn.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
		self.library.append_column(self.librarycolumn)
		self.library_selection.set_mode(gtk.SELECTION_MULTIPLE)
Ejemplo n.º 19
0
    term.goto(23, 9)
    term.echo("*** **  *** *** **  *   * *  * **  *   *    * *   *".replace(
        "*", term.colour(" ", bg="white")))
    term.goto(23, 10)
    term.echo("*** **  *   *   *   *   * *  * *   *   *    * *   *".replace(
        "*", term.colour(" ", bg="white")))
    term.goto(23, 11)
    term.echo("*   * * *** *** *   *    *  *   **  **  *    *  **".replace(
        "*", term.colour(" ", bg="white")))


while action == 0:
    while button == -1:
        loginBack()

        ui.button("Login", x=36, y=15, big=True)
        ui.button("Power ^",
                  x=68,
                  y=28,
                  big=False,
                  bg=ui.proscxb,
                  fg=ui.proscfg)
        button = ui.sense(screen=False)

    if button == 0:
        loginBack()

        ui.text("For a hint, leave the password field blank.",
                x=2,
                y=29,
                bg=ui.prolibg,
Ejemplo n.º 20
0
	def on_prefs_real(self, parent_window, popuptimes, scrobbler, trayicon_available, trayicon_in_use, reconnect, renotify, reinfofile, prefs_notif_toggled, prefs_stylized_toggled, prefs_art_toggled, prefs_playback_toggled, prefs_progress_toggled, prefs_statusbar_toggled, prefs_lyrics_toggled, prefs_trayicon_toggled, prefs_crossfade_toggled, prefs_crossfade_changed, prefs_window_response, prefs_last_tab):
		"""Display the preferences dialog"""
		self.window = parent_window
		self.scrobbler = scrobbler
		self.reconnect = reconnect
		self.renotify = renotify
		self.reinfofile = reinfofile
		self.last_tab = prefs_last_tab

		self.prefswindow = ui.dialog(title=_("Preferences"), parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, role='preferences', resizable=False, separator=False)
		hbox = gtk.HBox()
		prefsnotebook = gtk.Notebook()
		# MPD tab
		mpdlabel = ui.label(markup='<b>' + _('MPD Connection') + '</b>', y=1)
		mpd_frame = gtk.Frame()
		mpd_frame.set_label_widget(mpdlabel)
		mpd_frame.set_shadow_type(gtk.SHADOW_NONE)
		controlbox = gtk.HBox()
		profiles = ui.combo()
		add_profile = ui.button(img=ui.image(stock=gtk.STOCK_ADD))
		remove_profile = ui.button(img=ui.image(stock=gtk.STOCK_REMOVE))
		self.prefs_populate_profile_combo(profiles, self.config.profile_num, remove_profile)
		controlbox.pack_start(profiles, False, False, 2)
		controlbox.pack_start(remove_profile, False, False, 2) 
		controlbox.pack_start(add_profile, False, False, 2)
		namelabel = ui.label(textmn=_("_Name") + ":")
		nameentry = ui.entry()
		namelabel.set_mnemonic_widget(nameentry)
		hostlabel = ui.label(textmn=_("_Host") + ":")
		hostentry = ui.entry()
		hostlabel.set_mnemonic_widget(hostentry)
		portlabel = ui.label(textmn=_("_Port") + ":")
		portentry = gtk.SpinButton(gtk.Adjustment(0 ,0 ,65535, 1),1)
		portentry.set_numeric(True)
		portlabel.set_mnemonic_widget(portentry)
		dirlabel = ui.label(textmn=_("_Music dir") + ":")
		direntry = gtk.FileChooserButton(_('Select a Music Directory'))
		direntry.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
		direntry.connect('selection-changed', self.prefs_direntry_changed, profiles)
		dirlabel.set_mnemonic_widget(direntry)
		passwordlabel = ui.label(textmn=_("Pa_ssword") + ":")
		passwordentry = ui.entry(password=True)
		passwordlabel.set_mnemonic_widget(passwordentry)
		passwordentry.set_tooltip_text(_("Leave blank if no password is required."))
		autoconnect = gtk.CheckButton(_("_Autoconnect on start"))
		autoconnect.set_active(self.config.autoconnect)
		autoconnect.connect('toggled', self.prefs_config_widget_active, 'autoconnect')
		# Fill in entries with current profile:
		self.prefs_profile_chosen(profiles, nameentry, hostentry, portentry, passwordentry, direntry)
		# Update display if $MPD_HOST or $MPD_PORT is set:
		host, port, password = misc.mpd_env_vars()
		if host or port:
			using_mpd_env_vars = True
			if not host:
				host = ""
			if not port:
				port = 0
			if not password:
				password = ""
			hostentry.set_text(str(host))
			portentry.set_value(port)
			passwordentry.set_text(str(password))
			nameentry.set_text(_("Using MPD_HOST/PORT"))
			for widget in [hostentry, portentry, passwordentry, nameentry, profiles, add_profile, remove_profile]:
				widget.set_sensitive(False)
		else:
			using_mpd_env_vars = False
			nameentry.connect('changed', self.prefs_nameentry_changed, profiles, remove_profile)
			hostentry.connect('changed', self.prefs_hostentry_changed, profiles)
			portentry.connect('value-changed', self.prefs_portentry_changed, profiles)
			passwordentry.connect('changed', self.prefs_passwordentry_changed, profiles)
			profiles.connect('changed', self.prefs_profile_chosen, nameentry, hostentry, portentry, passwordentry, direntry)
			add_profile.connect('clicked', self.prefs_add_profile, nameentry, profiles, remove_profile)
			remove_profile.connect('clicked', self.prefs_remove_profile, profiles, remove_profile)

		rows = [(namelabel, nameentry),
			(hostlabel, hostentry),
			(portlabel, portentry),
			(passwordlabel, passwordentry),
			(dirlabel, direntry)]

		connection_table = gtk.Table(len(rows), 2)
		connection_table.set_col_spacings(12)
		for i, (label, entry) in enumerate(rows):
			connection_table.attach(label, 0, 1, i, i+1, gtk.FILL,
				gtk.FILL)
			connection_table.attach(entry, 1, 2, i, i+1,
				gtk.FILL|gtk.EXPAND, gtk.FILL)

		connection_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		connection_alignment.set_padding(12, 12, 12, 12)
		connection_alignment.add(connection_table)
		connection_frame = gtk.Frame()
		connection_frame.set_label_widget(controlbox)
		connection_frame.add(connection_alignment)
		mpd_table = gtk.Table(2, 1)
		mpd_table.set_row_spacings(12)
		mpd_table.attach(connection_frame, 0, 1, 0, 1,
			gtk.FILL|gtk.EXPAND, gtk.FILL)
		mpd_table.attach(autoconnect, 0, 1, 1, 2, gtk.FILL|gtk.EXPAND,
			gtk.FILL)
		mpd_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		mpd_alignment.set_padding(12, 0, 12, 0)
		mpd_alignment.add(mpd_table)
		mpd_frame.add(mpd_alignment)
		mpd_tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		mpd_tab.set_padding(12, 12, 12, 12)
		mpd_tab.add(mpd_frame)

		# Extras tab
		if not self.scrobbler.imported():
			self.config.as_enabled = False
		as_label = ui.label(markup='<b>' + _('Extras') + '</b>')
		extras_frame = gtk.Frame()
		extras_frame.set_label_widget(as_label)
		extras_frame.set_shadow_type(gtk.SHADOW_NONE)

		as_checkbox = gtk.CheckButton(_("_Audioscrobbling (Last.fm)"))
		as_checkbox.set_active(self.config.as_enabled)
		as_user_label = ui.label(textmn=_("_Username:"******"_Password:"******"Popup _notification on song changes"))
		display_notification.set_active(self.config.show_notification)

		time_names = ["%s %s" %
			(i , gettext.ngettext('second', 'seconds', int(i)))
			for i in popuptimes if i != _('Entire song')]
		time_names.append(_('Entire song'))
		notification_options = ui.combo(items=time_names, active=self.config.popup_option, changed_cb=self.prefs_notiftime_changed)

		notification_locs = ui.combo(items=self.popuplocations, active=self.config.traytips_notifications_location, changed_cb=self.prefs_notiflocation_changed)
		notifhbox = gtk.HBox(spacing=6)
		notifhbox.pack_end(notification_locs, False, False)
		notifhbox.pack_end(notification_options, False, False)
		display_notification.connect('toggled', prefs_notif_toggled, notifhbox)
		if not self.config.show_notification:
			notifhbox.set_sensitive(False)
		crossfadespin = gtk.SpinButton()
		crossfadespin.set_range(1, 30)
		crossfadespin.set_value(self.config.xfade)
		crossfadespin.set_numeric(True)
		crossfadespin.set_increments(1, 5)
		crossfadespin.connect('value-changed', prefs_crossfade_changed)
		crossfadelabel2 = ui.label(text=_("Fade length") + ":")
		crossfadelabel2 = ui.label(textmn=_("_Fade length") + ":")
		crossfadelabel2.set_mnemonic_widget(crossfadespin)
		crossfadelabel3 = ui.label(text=_("sec"))
		crossfadebox = gtk.HBox(spacing=12)
		crossfadebox.pack_end(crossfadelabel3, False, False)
		crossfadebox.pack_end(crossfadespin, False, False)
		crossfadebox.pack_end(crossfadelabel2, False, False)
		crossfadecheck = gtk.CheckButton(_("C_rossfade"))
		crossfadecheck.connect('toggled', self.prefs_crossfadecheck_toggled, crossfadespin, crossfadelabel2, crossfadelabel3)
		crossfadecheck.connect('toggled', prefs_crossfade_toggled, crossfadespin)
		crossfadecheck.set_active(self.config.xfade_enabled)
		crossfadecheck.toggled() # Force the toggled callback

		extras_widgets = (as_checkbox, as_entries, display_notification,
			notifhbox, crossfadecheck, crossfadebox)
		extras_table = gtk.Table(len(extras_widgets), 1)
		extras_table.set_col_spacings(12)
		extras_table.set_row_spacings(6)
		for i, widget in enumerate(extras_widgets):
			extras_table.attach(widget, 0, 1, i, i+1,
				gtk.FILL|gtk.EXPAND, gtk.FILL)
		extras_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		extras_alignment.set_padding(12, 0, 12, 0)
		extras_alignment.add(extras_table)
		extras_frame.add(extras_alignment)
		extras_tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		extras_tab.set_padding(12, 12, 12, 12)
		extras_tab.add(extras_frame)

		as_checkbox.connect('toggled', self.prefs_as_enabled_toggled, as_user_entry, as_pass_entry, as_user_label, as_pass_label)
		if not self.config.as_enabled or not self.scrobbler.imported():
			for widget in (as_user_entry, as_pass_entry,
					as_user_label, as_pass_label):
				widget.set_sensitive(False)
		# Display tab
		displaylabel = ui.label(markup='<b>' + _('Display') + '</b>')
		display_frame = gtk.Frame()
		display_frame.set_label_widget(displaylabel)
		display_frame.set_shadow_type(gtk.SHADOW_NONE)

		display_art = gtk.CheckButton(_("_Album art"))
		display_art.set_active(self.config.show_covers)
		display_stylized_combo = ui.combo(items=[_("Standard"), _("Stylized")], active=self.config.covers_type, changed_cb=prefs_stylized_toggled)
		display_stylized_hbox = gtk.HBox(spacing=12)
		display_stylized_hbox.pack_end(display_stylized_combo, False, False)
		display_stylized_hbox.pack_end(ui.label(text=_("Artwork style:")), False, False)
		display_stylized_hbox.set_sensitive(self.config.show_covers)
		display_art_combo = ui.combo(items=[_("Local only"), _("Local and remote")], active=self.config.covers_pref)
		display_art_combo.connect('changed', self.prefs_config_widget_active, 'covers_pref')
		orderart_label = ui.label(text=_("Search locations:"))
		display_art_hbox = gtk.HBox(spacing=12)
		display_art_hbox.pack_end(display_art_combo, False, False)
		display_art_hbox.pack_end(orderart_label, False, False)
		display_art_hbox.set_sensitive(self.config.show_covers)

		art_paths = ["~/.covers/"]
		art_paths += ("%s/%s" % (_("SONG_DIR"), item)
			for item in ("cover.jpg", "album.jpg", "folder.jpg",
				_("custom")))
		display_art_location = ui.combo(items=art_paths, active=self.config.art_location, changed_cb=self.prefs_art_location_changed)

		display_art_location_hbox = gtk.HBox(spacing=12)
		display_art_location_hbox.pack_end(display_art_location, False, False)
		display_art_location_hbox.pack_end(ui.label(text=_("Save art to:")), False, False)
		display_art_location_hbox.set_sensitive(self.config.show_covers)
		display_art.connect('toggled', prefs_art_toggled, display_art_hbox, display_art_location_hbox, display_stylized_hbox)
		display_playback = gtk.CheckButton(_("_Playback/volume buttons"))
		display_playback.set_active(self.config.show_playback)
		display_playback.connect('toggled', prefs_playback_toggled)
		display_progress = gtk.CheckButton(_("Pr_ogressbar"))
		display_progress.set_active(self.config.show_progress)
		display_progress.connect('toggled', prefs_progress_toggled)
		display_statusbar = gtk.CheckButton(_("_Statusbar"))
		display_statusbar.set_active(self.config.show_statusbar)
		display_statusbar.connect('toggled', prefs_statusbar_toggled)
		display_lyrics = gtk.CheckButton(_("Song Ly_rics"))
		display_lyrics.set_active(self.config.show_lyrics)
		savelyrics_label = ui.label(text=_("Save lyrics to:"), x=1)
		display_lyrics_location = ui.combo(items=["~/.lyrics/", _("SONG_DIR") + "/"], active=self.config.lyrics_location, changed_cb=self.prefs_lyrics_location_changed)
		display_lyrics_location_hbox = gtk.HBox(spacing=12)
		display_lyrics_location_hbox.pack_end(display_lyrics_location,
			False, False)
		display_lyrics_location_hbox.pack_end(savelyrics_label, False,
			False)
		display_lyrics_location_hbox.set_sensitive(self.config.show_lyrics)
		display_lyrics.connect('toggled', prefs_lyrics_toggled, display_lyrics_location_hbox)
		display_trayicon = gtk.CheckButton(_("System _tray icon"))
		display_trayicon.set_active(self.config.show_trayicon)
		display_trayicon.set_sensitive(trayicon_available)

		display_widgets = (display_playback, display_progress,
			display_statusbar, display_trayicon, display_lyrics,
			display_lyrics_location_hbox, display_art,
			display_stylized_hbox, display_art_hbox,
			display_art_location_hbox)
		display_table = gtk.Table(len(display_widgets), 1, False)
		for i, widget in enumerate(display_widgets):
			display_table.attach(widget, 0, 1, i, i+1,
				gtk.FILL|gtk.EXPAND, gtk.FILL)
		display_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		display_alignment.set_padding(12, 0, 12, 0)
		display_alignment.add(display_table)
		display_frame.add(display_alignment)
		display_tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		display_tab.set_padding(12, 12, 12, 12)
		display_tab.add(display_frame)

		# Behavior tab
		windowlabel = ui.label(markup='<b>'+_('Window Behavior')+'</b>')
		window_frame = gtk.Frame()
		window_frame.set_label_widget(windowlabel)
		window_frame.set_shadow_type(gtk.SHADOW_NONE)
		win_sticky = gtk.CheckButton(_("_Show window on all workspaces"))
		win_sticky.set_active(self.config.sticky)
		win_sticky.connect('toggled', self.prefs_config_widget_active, 'sticky')
		win_ontop = gtk.CheckButton(_("_Keep window above other windows"))
		win_ontop.set_active(self.config.ontop)
		win_ontop.connect('toggled', self.prefs_config_widget_active, 'ontop')
		win_decor = gtk.CheckButton(_("_Hide window titlebar"))
		win_decor.set_active(not self.config.decorated)
		win_decor.connect('toggled',
			lambda w: setattr(self.config, 'decorated',
				not w.get_active()))
		minimize = gtk.CheckButton(_("_Minimize to system tray on close/escape"))
		minimize.set_active(self.config.minimize_to_systray)
		minimize.set_tooltip_text(_("If enabled, closing Sonata will minimize it to the system tray. Note that it's currently impossible to detect if there actually is a system tray, so only check this if you have one."))
		minimize.connect('toggled', self.prefs_config_widget_active, 'minimize_to_systray')
		display_trayicon.connect('toggled', prefs_trayicon_toggled, minimize)
		minimize.set_sensitive(trayicon_in_use)
		widgets = (win_sticky, win_ontop, win_decor, minimize)
		window_table = gtk.Table(len(widgets), 1)
		for i, widget in enumerate(widgets):
			window_table.attach(widget, 0, 1, i, i+1,
				gtk.FILL|gtk.EXPAND, gtk.FILL)
		window_alignment = gtk.Alignment()
		window_alignment.set_padding(12, 0, 12, 0)
		window_alignment.add(window_table)
		window_frame.add(window_alignment)

		misclabel = ui.label(markup='<b>' + _('Miscellaneous') + '</b>')
		misc_frame = gtk.Frame()
		misc_frame.set_label_widget(misclabel)
		misc_frame.set_shadow_type(gtk.SHADOW_NONE)
		update_start = gtk.CheckButton(_("_Update MPD library on start"))
		update_start.set_active(self.config.update_on_start)
		update_start.set_tooltip_text(_("If enabled, Sonata will automatically update your MPD library when it starts up."))
		update_start.connect('toggled', self.prefs_config_widget_active, 'update_on_start')
		exit_stop = gtk.CheckButton(_("S_top playback on exit"))
		exit_stop.set_active(self.config.stop_on_exit)
		exit_stop.set_tooltip_text(_("MPD allows playback even when the client is not open. If enabled, Sonata will behave like a more conventional music player and, instead, stop playback upon exit."))
		exit_stop.connect('toggled', self.prefs_config_widget_active, 'stop_on_exit')
		infofile_usage = gtk.CheckButton(_("_Write status file:"))
		infofile_usage.set_active(self.config.use_infofile)
		infofile_usage.set_tooltip_text(_("If enabled, Sonata will create a xmms-infopipe like file containing information about the current song. Many applications support the xmms-info file (Instant Messengers, IRC Clients...)"))
		infopath_options = ui.entry(text=self.config.infofile_path)
		infopath_options.set_tooltip_text(_("If enabled, Sonata will create a xmms-infopipe like file containing information about the current song. Many applications support the xmms-info file (Instant Messengers, IRC Clients...)"))
		if not self.config.use_infofile:
			infopath_options.set_sensitive(False)
		infofile_usage.connect('toggled', self.prefs_infofile_toggled, infopath_options)
		infofilebox = gtk.HBox(spacing=6)
		infofilebox.pack_start(infofile_usage, False, False)
		infofilebox.pack_start(infopath_options, True, True)
		widgets = (update_start, exit_stop, infofilebox)
		misc_table = gtk.Table(len(widgets), 1)
		for i, widget in enumerate(widgets):
			misc_table.attach(widget, 0, 1, i, i+1,
				gtk.FILL|gtk.EXPAND, gtk.FILL)
		misc_alignment = gtk.Alignment()
		misc_alignment.set_padding(12, 0, 12, 0)
		misc_alignment.add(misc_table)
		misc_frame.add(misc_alignment)

		behavior_table = gtk.Table(2, 1)
		behavior_table.set_row_spacings(12)
		behavior_table.attach(window_frame, 0, 1, 0, 1, gtk.FILL|gtk.EXPAND, gtk.FILL)
		behavior_table.attach(misc_frame, 0, 1, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL)
		behavior_tab = gtk.Alignment()
		behavior_tab.set_padding(12, 12, 12, 12)
		behavior_tab.add(behavior_table)

		# Format tab
		formatlabel = ui.label(markup='<b>'+_('Song Formatting')+'</b>')
		format_frame = gtk.Frame()
		format_frame.set_label_widget(formatlabel)
		format_frame.set_shadow_type(gtk.SHADOW_NONE)

		rows = [(_("C_urrent playlist:"), self.config.currentformat),
			(_("_Library:"), self.config.libraryformat),
			(_("_Window title:"), self.config.titleformat),
			(_("Current _song line 1:"),
				self.config.currsongformat1),
			(_("Current s_ong line 2:"),
				self.config.currsongformat2)]

		format_labels = []
		format_entries = []
		for label_text, entry_text in rows:
			label = ui.label(textmn=label_text)
			entry = ui.entry(text=entry_text)

			label.set_mnemonic_widget(entry)

			format_labels.append(label)
			format_entries.append(entry)

		currentoptions = format_entries[0]
		libraryoptions = format_entries[1]
		titleoptions = format_entries[2]
		currsongoptions1 = format_entries[3]
		currsongoptions2 = format_entries[4]

		availableheading = ui.label(markup='<small>' + _('Available options') + ':</small>', y=0)
		availablevbox = gtk.VBox()
		availableformatbox = gtk.HBox()
		# XXX get these directly from the formatting function:
		formatcodes = [('A', _('Artist name')),
			       ('B', _('Album name')),
			       ('T', _('Track name')),
			       ('N', _('Track number')),
			       ('D', _('Disc number')),
			       ('Y', _('Year')),
			       ('G', _('Genre')),
			       ('P', _('File path')),
			       ('F', _('File name')),
			       ('S', _('Stream name')),
			       ('L', _('Song length')),
			       ('E', _('Elapsed time (title only)')),
			       ]
		for codes in [formatcodes[:(len(formatcodes)+1)/2], 
			      formatcodes[(len(formatcodes)+1)/2:]]:
			rows = '\n'.join('<tt>%' + code + '</tt> - ' + help 
					 for code, help in codes)
			markup = '<small>' + rows + '</small>'
			formattinghelp = ui.label(markup=markup, y=0)
			availableformatbox.pack_start(formattinghelp)

		availablevbox.pack_start(availableformatbox, False, False, 0)
		additionalinfo = ui.label(markup='<small><tt>{ }</tt> - ' + _('Info displayed only if all enclosed tags are defined') + '\n' + '<tt>|</tt> - ' + _('Creates columns in the current playlist') + '</small>', y=0)
		availablevbox.pack_start(additionalinfo, False, False, 4)

		num_rows = len(rows) + 2
		format_table = gtk.Table(num_rows, 2)
		format_table.set_col_spacings(12)
		label_entries = enumerate(zip(format_labels, format_entries))
		for i, (label, entry) in label_entries:
			format_table.attach(label, 0, 1, i, i+1, gtk.FILL)
			format_table.attach(entry, 1, 2, i, i+1)
		format_table.attach(availableheading, 0, 2, num_rows-2,
			num_rows-1, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND,
			0, 6)
		format_table.attach(availablevbox, 0, 2, num_rows-1, num_rows)
		format_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		format_alignment.set_padding(12, 0, 12, 0)
		format_alignment.add(format_table)
		format_frame.add(format_alignment)
		format_tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		format_tab.set_padding(12, 12, 12, 12)
		format_tab.add(format_frame)

		# Plugins tab

		plugin_actions = (
			('plugin_about', gtk.STOCK_ABOUT, _('_About'), None, None, self.plugin_about),
			('plugin_configure', gtk.STOCK_PREFERENCES, _('_Configure...'), None, None, self.plugin_configure),
			)
		
		uiDescription = """
			<ui>
			  <popup name="pluginmenu">
			    <menuitem action="plugin_configure"/>
			    <menuitem action="plugin_about"/>
			  </popup>
			</ui>
			"""

		self.plugin_UIManager = gtk.UIManager()
		actionGroup = gtk.ActionGroup('PluginActions')
		actionGroup.add_actions(plugin_actions)
		self.plugin_UIManager.insert_action_group(actionGroup, 0)
		self.plugin_UIManager.add_ui_from_string(uiDescription)

		self.pluginview = ui.treeview()
		self.pluginview.set_headers_visible(True)
		self.pluginselection = self.pluginview.get_selection()
		self.pluginselection.set_mode(gtk.SELECTION_SINGLE)
		self.pluginview.set_rules_hint(True)
		self.pluginview.set_property('can-focus', False)
		pluginwindow = ui.scrollwindow(add=self.pluginview)
		plugindata = gtk.ListStore(bool, gtk.gdk.Pixbuf, str)
		self.pluginview.set_model(plugindata)
		self.pluginview.connect('button-press-event', self.plugin_click)

		plugincheckcell = gtk.CellRendererToggle()
		plugincheckcell.set_property('activatable', True)
		plugincheckcell.connect('toggled', self.plugin_toggled, (plugindata, 0))
		pluginpixbufcell = gtk.CellRendererPixbuf()
		plugintextcell = gtk.CellRendererText()

		plugincol0 = gtk.TreeViewColumn()
		self.pluginview.append_column(plugincol0)
		plugincol0.pack_start(plugincheckcell, True)
		plugincol0.set_attributes(plugincheckcell, active=0)
		plugincol0.set_title("  " + _("Loaded") + "  ")
		
		plugincol1 = gtk.TreeViewColumn()
		self.pluginview.append_column(plugincol1)
		plugincol1.pack_start(pluginpixbufcell, False)
		plugincol1.pack_start(plugintextcell, True)
		plugincol1.set_attributes(pluginpixbufcell, pixbuf=1)
		plugincol1.set_attributes(plugintextcell, markup=2)
		plugincol1.set_title(_("Description"))

		plugindata.clear()
		for plugin in pluginsystem.get_info():
			pb = self.plugin_get_icon_pixbuf(plugin)
			plugin_text = "<b> " + plugin.longname + "</b>   " + plugin.version_string
			plugin_text += "\n " + plugin.description
			enabled = True
			plugindata.append((enabled, pb, plugin_text))
		
		# Set up table
		tables = [(_("MPD"), mpd_tab),
		               (_("Display"), display_tab),
		               (_("Behavior"), behavior_tab),
		               (_("Format"), format_tab),
		               (_("Extras"), extras_tab)]
					   # XXX Plugins temporarily disabled
		               #(_("Plugins"), pluginwindow)]
		for table_name, table in tables:
			tmplabel = ui.label(text=table_name)
			prefsnotebook.append_page(table, tmplabel)
		hbox.pack_start(prefsnotebook, False, False, 10)
		self.prefswindow.vbox.pack_start(hbox, False, False, 10)
		close_button = self.prefswindow.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
		self.prefswindow.show_all()
		prefsnotebook.set_current_page(self.last_tab)
		close_button.grab_focus()
		self.prefswindow.connect('response', prefs_window_response, prefsnotebook, direntry, currentoptions, libraryoptions, titleoptions, currsongoptions1, currsongoptions2, infopath_options, using_mpd_env_vars, self.prev_host, self.prev_port, self.prev_password)
		# Save previous connection properties to determine if we should try to
		# connect to MPD after prefs are closed:
		self.prev_host = self.config.host[self.config.profile_num]
		self.prev_port = self.config.port[self.config.profile_num]
		self.prev_password = self.config.password[self.config.profile_num]
Ejemplo n.º 21
0
	def mpd_tab(self, cbs=None):
		"""Construct and layout the MPD tab"""
		mpdlabel = ui.label(markup='<b>' + _('MPD Connection') + '</b>')
		frame = gtk.Frame()
		frame.set_label_widget(mpdlabel)
		frame.set_shadow_type(gtk.SHADOW_NONE)
		controlbox = gtk.HBox()
		profiles = ui.combo()
		add_profile = ui.button(img=ui.image(stock=gtk.STOCK_ADD))
		remove_profile = ui.button(img=ui.image(stock=gtk.STOCK_REMOVE))
		self._populate_profile_combo(profiles, self.config.profile_num,
			remove_profile)
		controlbox.pack_start(profiles, False, False, 2)
		controlbox.pack_start(remove_profile, False, False, 2) 
		controlbox.pack_start(add_profile, False, False, 2)
		namelabel = ui.label(textmn=_("_Name") + ":")
		nameentry = ui.entry()
		namelabel.set_mnemonic_widget(nameentry)
		hostlabel = ui.label(textmn=_("_Host") + ":")
		hostentry = ui.entry()
		hostlabel.set_mnemonic_widget(hostentry)
		portlabel = ui.label(textmn=_("_Port") + ":")
		portentry = gtk.SpinButton(gtk.Adjustment(0 ,0 ,65535, 1),1)
		portentry.set_numeric(True)
		portlabel.set_mnemonic_widget(portentry)
		dirlabel = ui.label(textmn=_("_Music dir") + ":")
		direntry = gtk.FileChooserButton(_('Select a Music Directory'))
		self.direntry = direntry
		direntry.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
		direntry.connect('selection-changed', self._direntry_changed,
			profiles)
		dirlabel.set_mnemonic_widget(direntry)
		passwordlabel = ui.label(textmn=_("Pa_ssword") + ":")
		passwordentry = ui.entry(password=True)
		passwordlabel.set_mnemonic_widget(passwordentry)
		passwordentry.set_tooltip_text(_("Leave blank if no password is required."))
		autoconnect = gtk.CheckButton(_("_Autoconnect on start"))
		autoconnect.set_active(self.config.autoconnect)
		autoconnect.connect('toggled', self._config_widget_active,
			'autoconnect')
		# Fill in entries with current profile:
		self._profile_chosen(profiles, nameentry, hostentry,
			portentry, passwordentry, direntry)
		# Update display if $MPD_HOST or $MPD_PORT is set:
		host, port, password = misc.mpd_env_vars()
		if host or port:
			self.using_mpd_env_vars = True
			if not host:
				host = ""
			if not port:
				port = 0
			if not password:
				password = ""
			hostentry.set_text(str(host))
			portentry.set_value(port)
			passwordentry.set_text(str(password))
			nameentry.set_text(_("Using MPD_HOST/PORT"))
			for widget in [hostentry, portentry, passwordentry,
				       nameentry, profiles, add_profile,
				       remove_profile]:
				widget.set_sensitive(False)
		else:
			self.using_mpd_env_vars = False
			nameentry.connect('changed', self._nameentry_changed,
				profiles, remove_profile)
			hostentry.connect('changed', self._hostentry_changed,
				profiles)
			portentry.connect('value-changed',
				self._portentry_changed, profiles)
			passwordentry.connect('changed',
				self._passwordentry_changed, profiles)
			profiles.connect('changed',
				self._profile_chosen, nameentry, hostentry,
				portentry, passwordentry, direntry)
			add_profile.connect('clicked', self._add_profile,
				nameentry, profiles, remove_profile)
			remove_profile.connect('clicked', self._remove_profile,
				profiles, remove_profile)

		rows = [(namelabel, nameentry),
			(hostlabel, hostentry),
			(portlabel, portentry),
			(passwordlabel, passwordentry),
			(dirlabel, direntry)]

		connection_table = gtk.Table(len(rows), 2)
		connection_table.set_col_spacings(12)
		for i, (label, entry) in enumerate(rows):
			connection_table.attach(label, 0, 1, i, i+1, gtk.FILL,
				gtk.FILL)
			connection_table.attach(entry, 1, 2, i, i+1,
				gtk.FILL|gtk.EXPAND, gtk.FILL)

		connection_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		connection_alignment.set_padding(12, 12, 12, 12)
		connection_alignment.add(connection_table)
		connection_frame = gtk.Frame()
		connection_frame.set_label_widget(controlbox)
		connection_frame.add(connection_alignment)
		table = gtk.Table(2, 1)
		table.set_row_spacings(12)
		table.attach(connection_frame, 0, 1, 0, 1,
			gtk.FILL|gtk.EXPAND, gtk.FILL)
		table.attach(autoconnect, 0, 1, 1, 2, gtk.FILL|gtk.EXPAND,
			gtk.FILL)
		alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		alignment.set_padding(12, 0, 12, 0)
		alignment.add(table)
		frame.add(alignment)
		tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		tab.set_padding(12, 12, 12, 12)
		tab.add(frame)

		return tab
Ejemplo n.º 22
0
	def on_prefs_real(self, parent_window, popuptimes, as_imported, as_import, as_init, as_reauth, trayicon_available, trayicon_in_use, reconnect, renotify, reinfofile, prefs_notif_toggled, prefs_stylized_toggled, prefs_art_toggled, prefs_playback_toggled, prefs_progress_toggled, prefs_statusbar_toggled, prefs_lyrics_toggled, prefs_trayicon_toggled, prefs_window_response):
		"""Display the preferences dialog"""
		self.window = parent_window
		self.as_imported = as_imported
		self.as_import = as_import
		self.as_init = as_init
		self.as_reauth = as_reauth
		self.reconnect = reconnect
		self.renotify = renotify
		self.reinfofile = reinfofile

		prefswindow = ui.dialog(title=_("Preferences"), parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, role='preferences', resizable=False, separator=False)
		hbox = gtk.HBox()
		prefsnotebook = gtk.Notebook()
		# MPD tab
		mpdlabel = ui.label(markup='<b>' + _('MPD Connection') + '</b>', y=1)
		controlbox = gtk.HBox()
		profiles = ui.combo()
		add_profile = ui.button(img=ui.image(stock=gtk.STOCK_ADD))
		remove_profile = ui.button(img=ui.image(stock=gtk.STOCK_REMOVE))
		self.prefs_populate_profile_combo(profiles, self.profile_num, remove_profile)
		controlbox.pack_start(profiles, False, False, 2)
		controlbox.pack_start(remove_profile, False, False, 2) 
		controlbox.pack_start(add_profile, False, False, 2)
		namebox = gtk.HBox()
		namelabel = ui.label(text=_("Name") + ":")
		namebox.pack_start(namelabel, False, False, 0)
		nameentry = ui.entry()
		namebox.pack_start(nameentry, True, True, 10)
		hostbox = gtk.HBox()
		hostlabel = ui.label(text=_("Host") + ":")
		hostbox.pack_start(hostlabel, False, False, 0)
		hostentry = ui.entry()
		hostbox.pack_start(hostentry, True, True, 10)
		portbox = gtk.HBox()
		portlabel = ui.label(text=_("Port") + ":")
		portbox.pack_start(portlabel, False, False, 0)
		portentry = ui.entry()
		portbox.pack_start(portentry, True, True, 10)
		dirbox = gtk.HBox()
		dirlabel = ui.label(text=_("Music dir") + ":")
		dirbox.pack_start(dirlabel, False, False, 0)
		direntry = ui.entry()
		direntry.connect('changed', self.prefs_direntry_changed, profiles)
		dirbox.pack_start(direntry, True, True, 10)
		passwordbox = gtk.HBox()
		passwordlabel = ui.label(text=_("Password") + ":")
		passwordbox.pack_start(passwordlabel, False, False, 0)
		passwordentry = ui.entry(password=True)
		passwordentry.set_tooltip_text(_("Leave blank if no password is required."))
		passwordbox.pack_start(passwordentry, True, True, 10)
		mpd_labels = [namelabel, hostlabel, portlabel, passwordlabel, dirlabel]
		ui.set_widths_equal(mpd_labels)
		autoconnect = gtk.CheckButton(_("Autoconnect on start"))
		autoconnect.set_active(self.autoconnect)
		# Fill in entries with current profile:
		self.prefs_profile_chosen(profiles, nameentry, hostentry, portentry, passwordentry, direntry)
		# Update display if $MPD_HOST or $MPD_PORT is set:
		host, port, password = misc.mpd_env_vars()
		if host or port:
			using_mpd_env_vars = True
			if not host:
				host = ""
			if not port:
				port = ""
			if not password:
				password = ""
			hostentry.set_text(str(host))
			portentry.set_text(str(port))
			passwordentry.set_text(str(password))
			nameentry.set_text(_("Using MPD_HOST/PORT"))
			for widget in [hostentry, portentry, passwordentry, nameentry, profiles, add_profile, remove_profile]:
				widget.set_sensitive(False)
		else:
			using_mpd_env_vars = False
			# remove_profile is properly set in populate_profile_combo:
			for widget in [hostentry, portentry, passwordentry, nameentry, profiles, add_profile]: 
				widget.set_sensitive(True)
			nameentry.connect('changed', self.prefs_nameentry_changed, profiles, remove_profile)
			hostentry.connect('changed', self.prefs_hostentry_changed, profiles)
			portentry.connect('changed', self.prefs_portentry_changed, profiles)
			passwordentry.connect('changed', self.prefs_passwordentry_changed, profiles)
			profiles.connect('changed', self.prefs_profile_chosen, nameentry, hostentry, portentry, passwordentry, direntry)
			add_profile.connect('clicked', self.prefs_add_profile, nameentry, profiles, remove_profile)
			remove_profile.connect('clicked', self.prefs_remove_profile, profiles, remove_profile)
		mpd_frame = gtk.Frame()
		table = gtk.Table(6, 2, False)
		table.set_col_spacings(3)
		table.attach(ui.label(), 1, 3, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		table.attach(namebox, 1, 3, 2, 3, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		table.attach(hostbox, 1, 3, 3, 4, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		table.attach(portbox, 1, 3, 4, 5, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		table.attach(passwordbox, 1, 3, 5, 6, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		table.attach(dirbox, 1, 3, 6, 7, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		table.attach(ui.label(), 1, 3, 7, 8, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		mpd_frame.add(table)
		mpd_frame.set_label_widget(controlbox)
		mpd_table = gtk.Table(9, 2, False)
		mpd_table.set_col_spacings(3)
		mpd_table.attach(ui.label(), 1, 3, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		mpd_table.attach(mpdlabel, 1, 3, 2, 3, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		mpd_table.attach(ui.label(), 1, 3, 3, 4, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 10, 0)
		mpd_table.attach(mpd_frame, 1, 3, 4, 10, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		mpd_table.attach(ui.label(), 1, 3, 10, 11, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		mpd_table.attach(autoconnect, 1, 3, 11, 12, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		mpd_table.attach(ui.label(), 1, 3, 12, 13, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		mpd_table.attach(ui.label(), 1, 3, 13, 14, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		mpd_table.attach(ui.label(), 1, 3, 14, 15, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		# Extras tab
		if not as_imported:
			self.as_enabled = False
		as_label = ui.label(markup='<b>' + _('Extras') + '</b>')
		as_frame = gtk.Frame()
		as_frame.set_label_widget(as_label)
		as_frame.set_shadow_type(gtk.SHADOW_NONE)
		as_frame.set_border_width(15)
		as_vbox = gtk.VBox()
		as_vbox.set_border_width(15)
		as_checkbox = gtk.CheckButton(_("Enable Audioscrobbler"))
		as_checkbox.set_active(self.as_enabled)
		as_vbox.pack_start(as_checkbox, False)
		as_table = gtk.Table(2, 2)
		as_table.set_col_spacings(3)
		as_user_label = ui.label(text="          " + _("Username:"******"          " + _("Password:"******"Popup notification on song changes"))
		display_notification.set_active(self.show_notification)
		notifhbox = gtk.HBox()
		notif_blank = ui.label(x=1)
		notifhbox.pack_start(notif_blank)

		time_names = []
		for i in popuptimes:
			if i != _('Entire song'):
				time_names.append(i + ' ' + gettext.ngettext('second', 'seconds', int(i)))
			else:
				time_names.append(i)
		notification_options = ui.combo(items=time_names, active=self.popup_option, changed_cb=self.prefs_notiftime_changed)

		notification_locs = ui.combo(items=self.popuplocations, active=self.traytips_notifications_location, changed_cb=self.prefs_notiflocation_changed)
		display_notification.connect('toggled', prefs_notif_toggled, notifhbox)
		notifhbox.pack_start(notification_options, False, False, 2)
		notifhbox.pack_start(notification_locs, False, False, 2)
		if not self.show_notification:
			notifhbox.set_sensitive(False)
		crossfadecheck = gtk.CheckButton(_("Enable Crossfade"))
		crossfadespin = gtk.SpinButton()
		crossfadespin.set_digits(0)
		crossfadespin.set_range(1, 30)
		crossfadespin.set_value(self.xfade)
		crossfadespin.set_numeric(True)
		crossfadespin.set_increments(1, 5)
		crossfadespin.set_size_request(70, -1)
		crossfadelabel2 = ui.label(text=_("Fade length") + ":", x=1)
		crossfadelabel3 = ui.label(text=_("sec"))
		if not self.xfade_enabled:
			crossfadespin.set_sensitive(False)
			crossfadelabel2.set_sensitive(False)
			crossfadelabel3.set_sensitive(False)
			crossfadecheck.set_active(False)
		else:
			crossfadespin.set_sensitive(True)
			crossfadelabel2.set_sensitive(True)
			crossfadelabel3.set_sensitive(True)
			crossfadecheck.set_active(True)
		crossfadebox = gtk.HBox()
		crossfadebox.pack_start(crossfadelabel2)
		crossfadebox.pack_start(crossfadespin, False, False, 5)
		crossfadebox.pack_start(crossfadelabel3, False, False, 0)
		crossfadecheck.connect('toggled', self.prefs_crossfadecheck_toggled, crossfadespin, crossfadelabel2, crossfadelabel3)
		as_table.attach(as_user_label, 0, 1, 0, 1)
		as_table.attach(as_user_entry, 1, 2, 0, 1)
		as_table.attach(as_pass_label, 0, 1, 1, 2)
		as_table.attach(as_pass_entry, 1, 2, 1, 2)
		as_table.attach(ui.label(), 0, 2, 2, 3)
		as_table.attach(display_notification, 0, 2, 3, 4)
		as_table.attach(notifhbox, 0, 2, 4, 5)
		as_table.attach(ui.label(), 0, 2, 5, 6)
		as_table.attach(crossfadecheck, 0, 2, 6, 7)
		as_table.attach(crossfadebox, 0, 2, 7, 8)
		as_table.attach(ui.label(), 0, 2, 8, 9)
		as_vbox.pack_start(as_table, False)
		as_frame.add(as_vbox)
		as_checkbox.connect('toggled', self.prefs_as_enabled_toggled, as_user_entry, as_pass_entry, as_user_label, as_pass_label)
		if not self.as_enabled or not as_imported:
			as_user_entry.set_sensitive(False)
			as_pass_entry.set_sensitive(False)
			as_user_label.set_sensitive(False)
			as_pass_label.set_sensitive(False)
		# Display tab
		table2 = gtk.Table(7, 2, False)
		displaylabel = ui.label(markup='<b>' + _('Display') + '</b>', y=1)
		display_art_hbox = gtk.HBox()
		display_art = gtk.CheckButton(_("Enable album art"))
		display_art.set_active(self.show_covers)
		display_stylized_combo = ui.combo(items=[_("Standard"), _("Stylized")], active=self.covers_type, changed_cb=prefs_stylized_toggled)
		display_stylized_hbox = gtk.HBox()
		display_stylized_hbox.pack_start(ui.label(text=_("Artwork style:"), x=1))
		display_stylized_hbox.pack_start(display_stylized_combo, False, False, 5)
		display_stylized_hbox.set_sensitive(self.show_covers)
		display_art_combo = ui.combo(items=[_("Local only"), _("Local and remote")], active=self.covers_pref)
		orderart_label = ui.label(text=_("Search locations:"), x=1)
		display_art_hbox.pack_start(orderart_label)
		display_art_hbox.pack_start(display_art_combo, False, False, 5)
		display_art_hbox.set_sensitive(self.show_covers)
		display_art_location_hbox = gtk.HBox()
		display_art_location_hbox.pack_start(ui.label(text=_("Save art to:"), x=1))

		art_paths = ["~/.covers/"]
		for item in ["/cover.jpg", "/album.jpg", "/folder.jpg", "/" + _("custom")]:
			art_paths.append("../" + _("file_path") + item)
		display_art_location = ui.combo(items=art_paths, active=self.art_location, changed_cb=self.prefs_art_location_changed)

		display_art_location_hbox.pack_start(display_art_location, False, False, 5)
		display_art_location_hbox.set_sensitive(self.show_covers)
		display_art.connect('toggled', prefs_art_toggled, display_art_hbox, display_art_location_hbox, display_stylized_hbox)
		display_playback = gtk.CheckButton(_("Enable playback/volume buttons"))
		display_playback.set_active(self.show_playback)
		display_playback.connect('toggled', prefs_playback_toggled)
		display_progress = gtk.CheckButton(_("Enable progressbar"))
		display_progress.set_active(self.show_progress)
		display_progress.connect('toggled', prefs_progress_toggled)
		display_statusbar = gtk.CheckButton(_("Enable statusbar"))
		display_statusbar.set_active(self.show_statusbar)
		display_statusbar.connect('toggled', prefs_statusbar_toggled)
		display_lyrics = gtk.CheckButton(_("Enable lyrics"))
		display_lyrics.set_active(self.show_lyrics)
		display_lyrics_location_hbox = gtk.HBox()
		savelyrics_label = ui.label(text=_("Save lyrics to:"), x=1)
		display_lyrics_location_hbox.pack_start(savelyrics_label)
		display_lyrics_location = ui.combo(items=["~/.lyrics/", "../" + _("file_path") + "/"], active=self.lyrics_location, changed_cb=self.prefs_lyrics_location_changed)
		display_lyrics_location_hbox.pack_start(display_lyrics_location, False, False, 5)
		display_lyrics_location_hbox.set_sensitive(self.show_lyrics)
		display_lyrics.connect('toggled', prefs_lyrics_toggled, display_lyrics_location_hbox)
		display_trayicon = gtk.CheckButton(_("Enable system tray icon"))
		display_trayicon.set_active(self.show_trayicon)
		display_trayicon.set_sensitive(trayicon_available)
		table2.attach(ui.label(), 1, 3, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table2.attach(displaylabel, 1, 3, 2, 3, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table2.attach(ui.label(), 1, 3, 3, 4, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table2.attach(display_playback, 1, 3, 4, 5, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_progress, 1, 3, 5, 6, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_statusbar, 1, 3, 6, 7, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_trayicon, 1, 3, 7, 8, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_lyrics, 1, 3, 8, 9, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_lyrics_location_hbox, 1, 3, 9, 10, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_art, 1, 3, 10, 11, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_stylized_hbox, 1, 3, 11, 12, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_art_hbox, 1, 3, 12, 13, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(display_art_location_hbox, 1, 3, 13, 14, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table2.attach(ui.label(), 1, 3, 14, 15, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 75, 0)
		# Behavior tab
		table3 = gtk.Table()
		behaviorlabel = ui.label(markup='<b>' + _('Window Behavior') + '</b>', y=1)
		win_sticky = gtk.CheckButton(_("Show window on all workspaces"))
		win_sticky.set_active(self.sticky)
		win_ontop = gtk.CheckButton(_("Keep window above other windows"))
		win_ontop.set_active(self.ontop)
		update_start = gtk.CheckButton(_("Update MPD library on start"))
		update_start.set_active(self.update_on_start)
		update_start.set_tooltip_text(_("If enabled, Sonata will automatically update your MPD library when it starts up."))
		exit_stop = gtk.CheckButton(_("Stop playback on exit"))
		exit_stop.set_active(self.stop_on_exit)
		exit_stop.set_tooltip_text(_("MPD allows playback even when the client is not open. If enabled, Sonata will behave like a more conventional music player and, instead, stop playback upon exit."))
		minimize = gtk.CheckButton(_("Minimize to system tray on close/escape"))
		minimize.set_active(self.minimize_to_systray)
		minimize.set_tooltip_text(_("If enabled, closing Sonata will minimize it to the system tray. Note that it's currently impossible to detect if there actually is a system tray, so only check this if you have one."))
		display_trayicon.connect('toggled', prefs_trayicon_toggled, minimize)
		minimize.set_sensitive(trayicon_in_use)
		infofilebox = gtk.HBox()
		infofile_usage = gtk.CheckButton(_("Write status file:"))
		infofile_usage.set_active(self.use_infofile)
		infofile_usage.set_tooltip_text(_("If enabled, Sonata will create a xmms-infopipe like file containing information about the current song. Many applications support the xmms-info file (Instant Messengers, IRC Clients...)"))
		infopath_options = ui.entry(text=self.infofile_path)
		infopath_options.set_tooltip_text(_("If enabled, Sonata will create a xmms-infopipe like file containing information about the current song. Many applications support the xmms-info file (Instant Messengers, IRC Clients...)"))
		if not self.use_infofile:
			infopath_options.set_sensitive(False)
		infofile_usage.connect('toggled', self.prefs_infofile_toggled, infopath_options)
		infofilebox.pack_start(infofile_usage, False, False, 0)
		infofilebox.pack_start(infopath_options, True, True, 5)
		behaviorlabel2 = ui.label(markup='<b>' + _('Miscellaneous') + '</b>', y=1)
		table3.attach(ui.label(), 1, 3, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table3.attach(behaviorlabel, 1, 3, 2, 3, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table3.attach(ui.label(), 1, 3, 3, 4, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table3.attach(win_sticky, 1, 3, 4, 5, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(win_ontop, 1, 3, 5, 6, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(minimize, 1, 3, 6, 7, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(ui.label(), 1, 3, 7, 8, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table3.attach(behaviorlabel2, 1, 3, 8, 9, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table3.attach(ui.label(), 1, 3, 9, 10, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table3.attach(update_start, 1, 3, 10, 11, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(exit_stop, 1, 3, 11, 12, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(infofilebox, 1, 3, 12, 13, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(ui.label(), 1, 3, 13, 14, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(ui.label(), 1, 3, 14, 15, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(ui.label(), 1, 3, 15, 16, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(ui.label(), 1, 3, 16, 17, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(ui.label(), 1, 3, 17, 18, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table3.attach(ui.label(), 1, 3, 18, 19, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		# Format tab
		table4 = gtk.Table(9, 2, False)
		table4.set_col_spacings(3)
		formatlabel = ui.label(markup='<b>' + _('Song Formatting') + '</b>', y=1)
		currentformatbox = gtk.HBox()
		currentlabel = ui.label(text=_("Current playlist:"))
		currentoptions = ui.entry(text=self.currentformat)
		currentformatbox.pack_start(currentlabel, False, False, 0)
		currentformatbox.pack_start(currentoptions, False, False, 10)
		libraryformatbox = gtk.HBox()
		librarylabel = ui.label(text=_("Library:"))
		libraryoptions = ui.entry(text=self.libraryformat)
		libraryformatbox.pack_start(librarylabel, False, False, 0)
		libraryformatbox.pack_start(libraryoptions, False, False, 10)
		titleformatbox = gtk.HBox()
		titlelabel = ui.label(text=_("Window title:"))
		titleoptions = ui.entry(text=self.titleformat)
		titleoptions.set_text(self.titleformat)
		titleformatbox.pack_start(titlelabel, False, False, 0)
		titleformatbox.pack_start(titleoptions, False, False, 10)
		currsongformatbox1 = gtk.HBox()
		currsonglabel1 = ui.label(text=_("Current song line 1:"))
		currsongoptions1 = ui.entry(text=self.currsongformat1)
		currsongformatbox1.pack_start(currsonglabel1, False, False, 0)
		currsongformatbox1.pack_start(currsongoptions1, False, False, 10)
		currsongformatbox2 = gtk.HBox()
		currsonglabel2 = ui.label(text=_("Current song line 2:"))
		currsongoptions2 = ui.entry(text=self.currsongformat2)
		currsongformatbox2.pack_start(currsonglabel2, False, False, 0)
		currsongformatbox2.pack_start(currsongoptions2, False, False, 10)
		formatlabels = [currentlabel, librarylabel, titlelabel, currsonglabel1, currsonglabel2]
		for label in formatlabels:
			label.set_alignment(0, 0.5)
		ui.set_widths_equal(formatlabels)
		availableheading = ui.label(markup='<small>' + _('Available options') + ':</small>', y=0)
		availablevbox = gtk.VBox()
		availableformatbox = gtk.HBox()
		availableformatting = ui.label(markup='<small><span font_family="Monospace">%A</span> - ' + _('Artist name') + '\n<span font_family="Monospace">%B</span> - ' + _('Album name') + '\n<span font_family="Monospace">%T</span> - ' + _('Track name') + '\n<span font_family="Monospace">%N</span> - ' + _('Track number') + '\n<span font_family="Monospace">%D</span> - ' + _('Disc Number') + '\n<span font_family="Monospace">%Y</span> - ' + _('Year') + '</small>', y=0)
		availableformatting2 = ui.label(markup='<small><span font_family="Monospace">%G</span> - ' + _('Genre') + '\n<span font_family="Monospace">%F</span> - ' + _('File name') + '\n<span font_family="Monospace">%S</span> - ' + _('Stream name') + '\n<span font_family="Monospace">%L</span> - ' + _('Song length') + '\n<span font_family="Monospace">%E</span> - ' + _('Elapsed time (title only)') + '</small>', y=0)
		availableformatbox.pack_start(availableformatting)
		availableformatbox.pack_start(availableformatting2)
		availablevbox.pack_start(availableformatbox, False, False, 0)
		additionalinfo = ui.label(markup='<small>{ } - ' + _('Info displayed only if all enclosed tags are defined') + '\n' + '| - ' + _('Creates columns in the current playlist') + '</small>', y=0)
		availablevbox.pack_start(additionalinfo, False, False, 4)
		table4.attach(ui.label(), 1, 3, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table4.attach(formatlabel, 1, 3, 2, 3, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table4.attach(ui.label(), 1, 3, 3, 4, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 15, 0)
		table4.attach(currentformatbox, 1, 3, 4, 5, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table4.attach(libraryformatbox, 1, 3, 5, 6, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table4.attach(titleformatbox, 1, 3, 6, 7, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table4.attach(currsongformatbox1, 1, 3, 7, 8, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table4.attach(currsongformatbox2, 1, 3, 8, 9, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table4.attach(ui.label(), 1, 3, 9, 10, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table4.attach(availableheading, 1, 3, 10, 11, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table4.attach(availablevbox, 1, 3, 11, 12, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 45, 0)
		table4.attach(ui.label(), 1, 3, 12, 13, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 30, 0)
		table_names = [[_("_MPD"), mpd_table], 
		               [_("_Display"), table2], 
		               [_("_Behavior"), table3], 
		               [_("_Format"), table4], 
		               [_("_Extras"), as_frame]]
		for table_name in table_names:
			tmplabel = ui.label(textmn=table_name[0])
			prefsnotebook.append_page(table_name[1], tmplabel)
		hbox.pack_start(prefsnotebook, False, False, 10)
		prefswindow.vbox.pack_start(hbox, False, False, 10)
		close_button = prefswindow.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
		prefswindow.show_all()
		close_button.grab_focus()
		prefswindow.connect('response', prefs_window_response, prefsnotebook, exit_stop, win_ontop, display_art_combo, win_sticky, direntry, minimize, update_start, autoconnect, currentoptions, libraryoptions, titleoptions, currsongoptions1, currsongoptions2, crossfadecheck, crossfadespin, infopath_options, using_mpd_env_vars, self.prev_host, self.prev_port, self.prev_password)
		# Save previous connection properties to determine if we should try to
		# connect to MPD after prefs are closed:
		self.prev_host = self.host[self.profile_num]
		self.prev_port = self.port[self.profile_num]
		self.prev_password = self.password[self.profile_num]
		prefswindow.show()
Ejemplo n.º 23
0
    def __init__(self, config, client, TAB_CURRENT, on_current_button_press,
                 parse_formatting_colnames, parse_formatting, connected,
                 sonata_loaded, songinfo, update_statusbar, iterate_now,
                 libsearchfilter_get_style, new_tab):
        self.config = config
        self.client = client
        self.on_current_button_press = on_current_button_press
        self.parse_formatting_colnames = parse_formatting_colnames
        self.parse_formatting = parse_formatting
        self.connected = connected
        self.sonata_loaded = sonata_loaded
        self.songinfo = songinfo
        self.update_statusbar = update_statusbar
        self.iterate_now = iterate_now
        self.libsearchfilter_get_style = libsearchfilter_get_style

        self.currentdata = None
        self.filterbox_visible = False
        self.current_update_skip = False
        self.filter_row_mapping = [
        ]  # Mapping between filter rows and self.currentdata rows
        self.columnformat = None
        self.columns = None

        self.current_songs = None
        self.filterbox_cmd_buf = None
        self.filterbox_cond = None
        self.filterbox_source = None
        self.column_sorted = (None, gtk.SORT_DESCENDING
                              )  # TreeViewColumn, order
        self.total_time = 0
        self.edit_style_orig = None
        self.resizing_columns = None
        self.prev_boldrow = -1
        self.prevtodo = None
        self.plpos = None
        self.playlist_pos_before_filter = None
        self.sel_rows = None

        # Current tab
        self.current = ui.treeview(reorder=True, search=False, headers=True)
        self.current_selection = self.current.get_selection()
        self.expanderwindow = ui.scrollwindow(shadow=gtk.SHADOW_IN,
                                              add=self.current)
        self.filterpattern = ui.entry()
        self.filterbox = gtk.HBox()
        self.filterbox.pack_start(ui.label(text=_("Filter") + ":"), False,
                                  False, 5)
        self.filterbox.pack_start(self.filterpattern, True, True, 5)
        filterclosebutton = ui.button(img=ui.image(stock=gtk.STOCK_CLOSE),
                                      relief=gtk.RELIEF_NONE)
        self.filterbox.pack_start(filterclosebutton, False, False, 0)
        self.filterbox.set_no_show_all(True)
        self.vbox_current = gtk.VBox()
        self.vbox_current.pack_start(self.expanderwindow, True, True)
        self.vbox_current.pack_start(self.filterbox, False, False, 5)

        self.tab = new_tab(self.vbox_current, gtk.STOCK_CDROM, TAB_CURRENT,
                           self.current)

        self.current.connect('drag_data_received', self.on_dnd)
        self.current.connect('row_activated', self.on_current_click)
        self.current.connect('button_press_event',
                             self.on_current_button_press)
        self.current.connect('drag-begin', self.on_current_drag_begin)
        self.current.connect_after('drag-begin',
                                   self.dnd_after_current_drag_begin)
        self.current.connect('button_release_event',
                             self.on_current_button_release)

        self.filter_changed_handler = self.filterpattern.connect(
            'changed', self.searchfilter_feed_loop)
        self.filterpattern.connect('activate', self.searchfilter_on_enter)
        self.filterpattern.connect('key-press-event',
                                   self.searchfilter_key_pressed)
        filterclosebutton.connect('clicked', self.searchfilter_toggle)

        # Set up current view
        self.initialize_columns()
        self.current_selection.set_mode(gtk.SELECTION_MULTIPLE)
        target_reorder = ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0)
        target_file_managers = ('text/uri-list', 0, 0)
        self.current.enable_model_drag_source(
            gtk.gdk.BUTTON1_MASK, [target_reorder, target_file_managers],
            gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_DEFAULT)
        self.current.enable_model_drag_dest(
            [target_reorder, target_file_managers],
            gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_DEFAULT)
        self.current.connect('drag-data-get',
                             self.dnd_get_data_for_file_managers)
Ejemplo n.º 24
0
    def on_tags_edit(self, files, temp_mpdpaths, music_dir):
        """Display the editing dialog"""
        # Try loading module
        global tagpy
        if tagpy is None:
            try:
                import tagpy
            except ImportError:
                ui.show_msg(self.window, _("Taglib and/or tagpy not found, tag editing support disabled."), _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
                ui.change_cursor(None)
                return
            # Set default tag encoding to utf8.. fixes some reported bugs.
            import tagpy.id3v2 as id3v2
            id3v2.FrameFactory.instance().setDefaultTextEncoding(tagpy.StringType.UTF8)

        # Make sure tagpy is at least 0.91
        if hasattr(tagpy.Tag.title, '__call__'):
            ui.show_msg(self.window, _("Tagpy version < 0.91. Please upgrade to a newer version, tag editing support disabled."), _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            ui.change_cursor(None)
            return

        if not os.path.isdir(misc.file_from_utf8(music_dir)):
            ui.show_msg(self.window, _("The path %s does not exist. Please specify a valid music directory in preferences.") % music_dir, _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            ui.change_cursor(None)
            return

                # XXX file list was created here

        if len(files) == 0:
            ui.change_cursor(None)
            return

        # Initialize:
        self.tagnum = -1

        tags = [{'title':'', 'artist':'', 'album':'', 'year':'', 'track':'',
             'genre':'', 'comment':'', 'title-changed':False,
             'artist-changed':False, 'album-changed':False,
             'year-changed':False, 'track-changed':False,
             'genre-changed':False, 'comment-changed':False,
             'fullpath':misc.file_from_utf8(filename),
             'mpdpath':path}
            for filename, path in zip(files, temp_mpdpaths)]

        if not os.path.exists(tags[0]['fullpath']):
            ui.change_cursor(None)
            ui.show_msg(self.window, _("File '%s' not found. Please specify a valid music directory in preferences.") % tags[0]['fullpath'], _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            return
        if not self.tags_next_tag(tags):
            ui.change_cursor(None)
            ui.show_msg(self.window, _("No music files with editable tags found."), _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            return
        editwindow = ui.dialog(parent=self.window, flags=gtk.DIALOG_MODAL, role='editTags', resizable=False, separator=False)
        editwindow.set_size_request(375, -1)
        table = gtk.Table(9, 2, False)
        table.set_row_spacings(2)
        self.filelabel = ui.label(select=True, wrap=True)
        filehbox = gtk.HBox()
        sonataicon = ui.image(stock='sonata', stocksize=gtk.ICON_SIZE_DND, x=1)
        expandbutton = ui.button(" ")
        self.set_expandbutton_state(expandbutton)
        expandvbox = gtk.VBox()
        expandvbox.pack_start(ui.label(), True, True)
        expandvbox.pack_start(expandbutton, False, False)
        expandvbox.pack_start(ui.label(), True, True)
        expandbutton.connect('clicked', self.toggle_path)
        blanklabel = ui.label(w=5, h=12)
        filehbox.pack_start(sonataicon, False, False, 2)
        filehbox.pack_start(self.filelabel, True, True, 2)
        filehbox.pack_start(expandvbox, False, False, 2)
        filehbox.pack_start(blanklabel, False, False, 2)

        titlelabel, titleentry, titlebutton, titlehbox = self._create_label_entry_button_hbox(_("Title:"))
        artistlabel, artistentry, artistbutton, artisthbox = self._create_label_entry_button_hbox(_("Artist:"))
        albumlabel, albumentry, albumbutton, albumhbox = self._create_label_entry_button_hbox(_("Album:"))
        yearlabel, yearentry, yearbutton, yearhbox = self._create_label_entry_button_hbox(_("Year:"))
        yearentry.set_size_request(50,-1)
        tracklabel, trackentry, trackbutton, trackhbox = self._create_label_entry_button_hbox("  " + _("Track:"), True)
        trackentry.set_size_request(50,-1)
        yearandtrackhbox = gtk.HBox()
        yearandtrackhbox.pack_start(yearhbox, True, True, 0)
        yearandtrackhbox.pack_start(trackhbox, True, True, 0)

        yearentry.connect("insert_text", self.tags_win_entry_constraint, True)
        trackentry.connect("insert_text", self.tags_win_entry_constraint, False)

        genrelabel = ui.label(text=_("Genre:"), x=1)
        genrecombo = ui.comboentry(items=self.tags_win_genres(), wrap=2)
        genreentry = genrecombo.get_child()
        genrehbox = gtk.HBox()
        genrebutton = ui.button()
        genrebuttonvbox = self.tags_win_create_apply_all_button(genrebutton,
                                                                genreentry)
        genrehbox.pack_start(genrelabel, False, False, 2)
        genrehbox.pack_start(genrecombo, True, True, 2)
        genrehbox.pack_start(genrebuttonvbox, False, False, 2)

        commentlabel, commententry, commentbutton, commenthbox = self._create_label_entry_button_hbox(_("Comment:"))

        ui.set_widths_equal([titlelabel, artistlabel, albumlabel, yearlabel, genrelabel, commentlabel, sonataicon])
        genrecombo.set_size_request(-1, titleentry.size_request()[1])
        tablewidgets = [ui.label(), filehbox, ui.label(), titlehbox, artisthbox, albumhbox, yearandtrackhbox, genrehbox, commenthbox, ui.label()]
        for i, widget in enumerate(tablewidgets):
            table.attach(widget, 1, 2, i+1, i+2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 2, 0)
        editwindow.vbox.pack_start(table)
        saveall_button = None
        if len(files) > 1:
            # Only show save all button if more than one song being edited.
            saveall_button = ui.button(text=_("Save _All"))
            editwindow.action_area.pack_start(saveall_button)
        editwindow.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
        editwindow.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT)
        editwindow.connect('delete_event', self.tags_win_hide, tags)
        entries = [titleentry, artistentry, albumentry, yearentry, trackentry, genreentry, commententry]
        buttons = [titlebutton, artistbutton, albumbutton, yearbutton, trackbutton, genrebutton, commentbutton]
        entries_names = ["title", "artist", "album", "year", "track", "genre", "comment"]
        editwindow.connect('response', self.tags_win_response, tags, entries, entries_names)
        if saveall_button:
            saveall_button.connect('clicked', self.tags_win_save_all, editwindow, tags, entries, entries_names)

        for button, name, entry in zip(buttons, entries_names, entries):
            entry.connect('changed', self.tags_win_entry_changed)
            button.connect('clicked', self.tags_win_apply_all, name, tags, entry)

        self.tags_win_update(editwindow, tags, entries, entries_names)
        ui.change_cursor(None)
        self.filelabel.set_size_request(editwindow.size_request()[0] - titlelabel.size_request()[0] - 70, -1)
        editwindow.show_all()
Ejemplo n.º 25
0
import pygame, time, random  #Global Dependencies
import ui, entities, objects  #Project Libraries

#Juicy Zesty Bitter Sweet - Copyright (c) 2019 Orion Williams

#VARIABLE DECLARATIONS
pygame.init()
pygame.mixer.init()
window = pygame.display.set_mode([800, 600])
pygame.display.set_caption("juicyZESTYbitterSWEET")
running = True
mouse = [0, 0]
screen = "intro"
player = entities.player([380, 280])
play = ui.button("Play Game", [349, 505])
howto = ui.button("How to Play", [344, 535])
quitbutton = ui.button("Quit Game", [350, 565])
juicy = ui.imagebutton("spells/juicy-solution.png", [110, 425])
zesty = ui.imagebutton("spells/zestful-potion.png", [270, 425])
bitter = ui.imagebutton("spells/bitter-curse.png", [430, 425])
sweet = ui.imagebutton("spells/sweet-spell.png", [590, 425])
juicys = ui.button("Buy!", [750, 275])
zestys = ui.button("Buy!", [750, 325])
bitters = ui.button("Buy!", [750, 375])
sweets = ui.button("Buy!", [750, 425])
back = ui.button("Back", [5, 5])
next = ui.bigbutton("Next Section", [285, 550])
returntogame = ui.button("Return to Game", [328, 505])
nextday = ui.button("Next Day", [356, 400])
replayday = ui.button("Replay Day", [345, 430])
resetbutton = ui.button("Reset Spells", [282, 5])
Ejemplo n.º 26
0
async def get_app_home(user_id):
    global system_active
    current_status = manager.get_student_status(user_id)
    is_ta, is_active = manager.is_ta(user_id)

    # Info
    blocks = [
        ui.welcome_title(await slack.get_user_name(user_id)),
        ui.greeting(is_ta, is_active, system_active),
    ]

    # Control Panel for TA Only
    if is_ta:
        blocks += [
            ui.DIVIDER,
            ui.text(
                f"*{manager.get_queue_length()} Students* waiting in queue"),
            ui.text(await manager.str_queue()),
            ui.actions([
                ui.button_styled("System States Reset",
                                 INTERACTION_ADMIN_RESET, "danger",
                                 ui.reset_confirm()),
                ui.button_styled("Turn on system",
                                 INTERACTION_TA_MASTER_SWITCH, "primary")
                if not system_active else ui.button_styled(
                    "Turn off system", INTERACTION_TA_MASTER_SWITCH, "danger",
                    ui.off_confirm())
            ])
        ]

    # Functional
    if system_active:
        blocks += [ui.DIVIDER, ui.active_ta(manager.get_ta_size())]
        blocks += [ui.text(manager.str_free_ta())]
        busy_tas = [
            await ta.get_status_text(ta_view=is_ta)
            for ta in manager.pairs.keys()
        ]
        blocks += [ui.list_quote_text(busy_tas)]

        if current_status == 'idle':
            blocks += [
                ui.actions([
                    ui.button_styled(":telephone_receiver: Connect to a TA",
                                     INTERACTION_STUDENT_CONNECT_TA,
                                     "primary"),
                    ui.button(manager.get_ta_login_text(user_id),
                              INTERACTION_TA_LOGIN),
                ])
            ]
        elif current_status == 'queued':
            blocks += [
                ui.text(
                    f"You are *#{manager.get_queue_position(user_id)}* in the queue."
                    f" Click *refresh* button below to refresh."),
                ui.actions(
                    [ui.button("Cancel Request", INTERACTION_STUDENT_DEQUEUE)])
            ]
        elif current_status == 'busy':
            blocks += [
                ui.text(
                    "You are connected with a TA. Look for their direct message in a moment."
                )
                # TODO: Haven't implemented notify TA so disabled for now
                # {"type": "actions",
                #  "elements": [{"type": "button",
                #                "text": {"type": "plain_text",
                #                         "text": "End Chat",
                #                         "emoji": True},
                #                "value": INTERACTION_STUDENT_END_CHAT}
                #               ]
                #  }
            ]
        else:
            raise ValueError(
                f"Unexpected current_status: {current_status} for student {await slack.get_user_name(user_id)}"
            )
    else:
        blocks += [
            ui.actions([
                ui.button(manager.get_ta_login_text(user_id),
                          INTERACTION_TA_LOGIN)
            ])
        ]
    blocks += [
        ui.actions([
            ui.button(":arrows_counterclockwise: Refresh",
                      INTERACTION_STUDENT_REFRESH)
        ])
    ]
    return {"type": "home", "blocks": blocks}
Ejemplo n.º 27
0
	def update_breadcrumbs(self):
		# remove previous buttons
		for b in self.breadcrumbs:
			self.breadcrumbs.remove(b)

		# add the views button first
		b = ui.button(text=_(" v "), can_focus=False, relief=gtk.RELIEF_NONE)
		b.connect('clicked', self.library_view_popup)
		self.breadcrumbs.pack_start(b, False, False)
		b.show()
		
		# add the ellipsis explicitly XXX make this unnecessary
		b = ui.label("...")
		self.breadcrumbs.pack_start(b, False, False)
		b.show()

		# find info for current view		
		view, _name, icon, label = [v for v in self.VIEWS 
						  if v[0] == self.config.lib_view][0]

		# the first crumb is the root of the current view
		crumbs = [(label, icon, None, self.library_set_data(path='/'))]

		# rest of the crumbs are specific to the view
		if view == consts.VIEW_FILESYSTEM:
			path = self.library_get_data(self.config.wd, 'path')
			
			if path and path != '/':
				parts = path.split('/')
			else:
				parts = [] # no crumbs for /
			# append a crumb for each part
			for i, part in enumerate(parts):
				partpath = '/'.join(parts[:i+1])
				target = self.library_set_data(path=partpath)
				crumbs.append((part, gtk.STOCK_OPEN, None, target))
		else:
			if view == consts.VIEW_ALBUM:
				# We don't want to show an artist button in album view
				keys = 'genre', 'album'
				nkeys = 2
			else:
				keys = 'genre', 'artist', 'album'
				nkeys = 3
			parts = self.library_get_data(self.config.wd, *keys)
			# append a crumb for each part
			for i, key, part in zip(range(nkeys), keys, parts):
				if part is None:
					continue
				partdata = dict(zip(keys, parts)[:i+1])
				target = self.library_set_data(**partdata)
				pb, icon = None, None
				if key == 'album':
					# Album artwork, with self.alumbpb as a backup:
					artist, album, path = self.library_get_data(self.config.wd, 'artist', 'album', 'path')
					cache_data = self.library_set_data(artist=artist, album=album, path=path)
					pb = self.artwork.get_library_artwork_cached_pb(cache_data, None)
					if pb is None:
						icon = 'album'
				elif key == 'artist':
					icon = 'artist'
				else:
					icon = gtk.STOCK_ORIENTATION_PORTRAIT
				crumbs.append((part, icon, pb, target))

		# add a button for each crumb
		for crumb in crumbs:
			text, icon, pb, target = crumb
			text = misc.escape_html(text)
			if crumb is crumbs[-1]:
				text = "<b>%s</b>" % text
			label = ui.label(markup=text)

			if icon:
				image = ui.image(stock=icon)
			elif pb:
				pb = pb.scale_simple(16, 16, gtk.gdk.INTERP_HYPER)
				image = ui.image(pb=pb)

			b = breadcrumbs.CrumbButton(image, label)

			if crumb is crumbs[-1]:
				# FIXME makes the button request minimal space:
				# label.props.ellipsize = pango.ELLIPSIZE_END
				b.props.active = True
			# FIXME why doesn't the tooltip show?
			b.set_tooltip_text(label.get_label())
			b.connect('toggled', self.library_browse, target)
			self.breadcrumbs.pack_start(b, False, False)
			b.show_all()
Ejemplo n.º 28
0
	def mpd_tab(self, cbs=None):
		"""Construct and layout the MPD tab"""
		mpdlabel = ui.label(markup='<b>' + _('MPD Connection') + '</b>')
		frame = gtk.Frame()
		frame.set_label_widget(mpdlabel)
		frame.set_shadow_type(gtk.SHADOW_NONE)
		controlbox = gtk.HBox()
		profiles = ui.combo()
		add_profile = ui.button(img=ui.image(stock=gtk.STOCK_ADD))
		remove_profile = ui.button(img=ui.image(stock=gtk.STOCK_REMOVE))
		self._populate_profile_combo(profiles, self.config.profile_num,
			remove_profile)
		controlbox.pack_start(profiles, False, False, 2)
		controlbox.pack_start(remove_profile, False, False, 2) 
		controlbox.pack_start(add_profile, False, False, 2)
		namelabel = ui.label(textmn=_("_Name:"))
		nameentry = ui.entry()
		namelabel.set_mnemonic_widget(nameentry)
		hostlabel = ui.label(textmn=_("_Host:"))
		hostentry = ui.entry()
		hostlabel.set_mnemonic_widget(hostentry)
		portlabel = ui.label(textmn=_("_Port:"))
		portentry = gtk.SpinButton(gtk.Adjustment(0 ,0 ,65535, 1),1)
		portentry.set_numeric(True)
		portlabel.set_mnemonic_widget(portentry)
		dirlabel = ui.label(textmn=_("_Music dir:"))
		direntry = gtk.FileChooserButton(_('Select a Music Directory'))
		self.direntry = direntry
		direntry.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
		direntry.connect('selection-changed', self._direntry_changed,
			profiles)
		dirlabel.set_mnemonic_widget(direntry)
		passwordlabel = ui.label(textmn=_("Pa_ssword:"))
		passwordentry = ui.entry(password=True)
		passwordlabel.set_mnemonic_widget(passwordentry)
		passwordentry.set_tooltip_text(_("Leave blank if no password is required."))
		autoconnect = gtk.CheckButton(_("_Autoconnect on start"))
		autoconnect.set_active(self.config.autoconnect)
		autoconnect.connect('toggled', self._config_widget_active,
			'autoconnect')
		# Fill in entries with current profile:
		self._profile_chosen(profiles, nameentry, hostentry,
			portentry, passwordentry, direntry)
		# Update display if $MPD_HOST or $MPD_PORT is set:
		host, port, password = misc.mpd_env_vars()
		if host or port:
			self.using_mpd_env_vars = True
			if not host:
				host = ""
			if not port:
				port = 0
			if not password:
				password = ""
			hostentry.set_text(str(host))
			portentry.set_value(port)
			passwordentry.set_text(str(password))
			nameentry.set_text(_("Using MPD_HOST/PORT"))
			for widget in [hostentry, portentry, passwordentry,
				       nameentry, profiles, add_profile,
				       remove_profile]:
				widget.set_sensitive(False)
		else:
			self.using_mpd_env_vars = False
			nameentry.connect('changed', self._nameentry_changed,
				profiles, remove_profile)
			hostentry.connect('changed', self._hostentry_changed,
				profiles)
			portentry.connect('value-changed',
				self._portentry_changed, profiles)
			passwordentry.connect('changed',
				self._passwordentry_changed, profiles)
			profiles.connect('changed',
				self._profile_chosen, nameentry, hostentry,
				portentry, passwordentry, direntry)
			add_profile.connect('clicked', self._add_profile,
				nameentry, profiles, remove_profile)
			remove_profile.connect('clicked', self._remove_profile,
				profiles, remove_profile)

		rows = [(namelabel, nameentry),
			(hostlabel, hostentry),
			(portlabel, portentry),
			(passwordlabel, passwordentry),
			(dirlabel, direntry)]

		connection_table = gtk.Table(len(rows), 2)
		connection_table.set_col_spacings(12)
		for i, (label, entry) in enumerate(rows):
			connection_table.attach(label, 0, 1, i, i+1, gtk.FILL,
				gtk.FILL)
			connection_table.attach(entry, 1, 2, i, i+1,
				gtk.FILL|gtk.EXPAND, gtk.FILL)

		connection_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		connection_alignment.set_padding(12, 12, 12, 12)
		connection_alignment.add(connection_table)
		connection_frame = gtk.Frame()
		connection_frame.set_label_widget(controlbox)
		connection_frame.add(connection_alignment)
		table = gtk.Table(2, 1)
		table.set_row_spacings(12)
		table.attach(connection_frame, 0, 1, 0, 1,
			gtk.FILL|gtk.EXPAND, gtk.FILL)
		table.attach(autoconnect, 0, 1, 1, 2, gtk.FILL|gtk.EXPAND,
			gtk.FILL)
		alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		alignment.set_padding(12, 0, 12, 0)
		alignment.add(table)
		frame.add(alignment)
		tab = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
		tab.set_padding(12, 12, 12, 12)
		tab.add(frame)

		return tab
Ejemplo n.º 29
0
    def on_prefs_real(self, parent_window, popuptimes, as_imported, as_import,
                      as_init, as_reauth, trayicon_available, trayicon_in_use,
                      reconnect, renotify, reinfofile, prefs_notif_toggled,
                      prefs_stylized_toggled, prefs_art_toggled,
                      prefs_playback_toggled, prefs_progress_toggled,
                      prefs_statusbar_toggled, prefs_lyrics_toggled,
                      prefs_trayicon_toggled, prefs_window_response):
        """Display the preferences dialog"""
        self.window = parent_window
        self.as_imported = as_imported
        self.as_import = as_import
        self.as_init = as_init
        self.as_reauth = as_reauth
        self.reconnect = reconnect
        self.renotify = renotify
        self.reinfofile = reinfofile

        prefswindow = ui.dialog(title=_("Preferences"),
                                parent=self.window,
                                flags=gtk.DIALOG_DESTROY_WITH_PARENT,
                                role='preferences',
                                resizable=False,
                                separator=False)
        hbox = gtk.HBox()
        prefsnotebook = gtk.Notebook()
        # MPD tab
        mpdlabel = ui.label(markup='<b>' + _('MPD Connection') + '</b>', y=1)
        controlbox = gtk.HBox()
        profiles = ui.combo()
        add_profile = ui.button(img=ui.image(stock=gtk.STOCK_ADD))
        remove_profile = ui.button(img=ui.image(stock=gtk.STOCK_REMOVE))
        self.prefs_populate_profile_combo(profiles, self.profile_num,
                                          remove_profile)
        controlbox.pack_start(profiles, False, False, 2)
        controlbox.pack_start(remove_profile, False, False, 2)
        controlbox.pack_start(add_profile, False, False, 2)
        namebox = gtk.HBox()
        namelabel = ui.label(text=_("Name") + ":")
        namebox.pack_start(namelabel, False, False, 0)
        nameentry = ui.entry()
        namebox.pack_start(nameentry, True, True, 10)
        hostbox = gtk.HBox()
        hostlabel = ui.label(text=_("Host") + ":")
        hostbox.pack_start(hostlabel, False, False, 0)
        hostentry = ui.entry()
        hostbox.pack_start(hostentry, True, True, 10)
        portbox = gtk.HBox()
        portlabel = ui.label(text=_("Port") + ":")
        portbox.pack_start(portlabel, False, False, 0)
        portentry = ui.entry()
        portbox.pack_start(portentry, True, True, 10)
        dirbox = gtk.HBox()
        dirlabel = ui.label(text=_("Music dir") + ":")
        dirbox.pack_start(dirlabel, False, False, 0)
        direntry = ui.entry()
        direntry.connect('changed', self.prefs_direntry_changed, profiles)
        dirbox.pack_start(direntry, True, True, 10)
        passwordbox = gtk.HBox()
        passwordlabel = ui.label(text=_("Password") + ":")
        passwordbox.pack_start(passwordlabel, False, False, 0)
        passwordentry = ui.entry(password=True)
        passwordentry.set_tooltip_text(
            _("Leave blank if no password is required."))
        passwordbox.pack_start(passwordentry, True, True, 10)
        mpd_labels = [namelabel, hostlabel, portlabel, passwordlabel, dirlabel]
        ui.set_widths_equal(mpd_labels)
        autoconnect = gtk.CheckButton(_("Autoconnect on start"))
        autoconnect.set_active(self.autoconnect)
        # Fill in entries with current profile:
        self.prefs_profile_chosen(profiles, nameentry, hostentry, portentry,
                                  passwordentry, direntry)
        # Update display if $MPD_HOST or $MPD_PORT is set:
        host, port, password = misc.mpd_env_vars()
        if host or port:
            using_mpd_env_vars = True
            if not host:
                host = ""
            if not port:
                port = ""
            if not password:
                password = ""
            hostentry.set_text(str(host))
            portentry.set_text(str(port))
            passwordentry.set_text(str(password))
            nameentry.set_text(_("Using MPD_HOST/PORT"))
            for widget in [
                    hostentry, portentry, passwordentry, nameentry, profiles,
                    add_profile, remove_profile
            ]:
                widget.set_sensitive(False)
        else:
            using_mpd_env_vars = False
            # remove_profile is properly set in populate_profile_combo:
            for widget in [
                    hostentry, portentry, passwordentry, nameentry, profiles,
                    add_profile
            ]:
                widget.set_sensitive(True)
            nameentry.connect('changed', self.prefs_nameentry_changed,
                              profiles, remove_profile)
            hostentry.connect('changed', self.prefs_hostentry_changed,
                              profiles)
            portentry.connect('changed', self.prefs_portentry_changed,
                              profiles)
            passwordentry.connect('changed', self.prefs_passwordentry_changed,
                                  profiles)
            profiles.connect('changed', self.prefs_profile_chosen, nameentry,
                             hostentry, portentry, passwordentry, direntry)
            add_profile.connect('clicked', self.prefs_add_profile, nameentry,
                                profiles, remove_profile)
            remove_profile.connect('clicked', self.prefs_remove_profile,
                                   profiles, remove_profile)
        mpd_frame = gtk.Frame()
        table = gtk.Table(6, 2, False)
        table.set_col_spacings(3)
        table.attach(ui.label(), 1, 3, 1, 2, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 10, 0)
        table.attach(namebox, 1, 3, 2, 3, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 10, 0)
        table.attach(hostbox, 1, 3, 3, 4, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 10, 0)
        table.attach(portbox, 1, 3, 4, 5, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 10, 0)
        table.attach(passwordbox, 1, 3, 5, 6, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 10, 0)
        table.attach(dirbox, 1, 3, 6, 7, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 10, 0)
        table.attach(ui.label(), 1, 3, 7, 8, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 10, 0)
        mpd_frame.add(table)
        mpd_frame.set_label_widget(controlbox)
        mpd_table = gtk.Table(9, 2, False)
        mpd_table.set_col_spacings(3)
        mpd_table.attach(ui.label(), 1, 3, 1, 2, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 10, 0)
        mpd_table.attach(mpdlabel, 1, 3, 2, 3, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 15, 0)
        mpd_table.attach(ui.label(), 1, 3, 3, 4, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 10, 0)
        mpd_table.attach(mpd_frame, 1, 3, 4, 10, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 30, 0)
        mpd_table.attach(ui.label(), 1, 3, 10, 11, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 30, 0)
        mpd_table.attach(autoconnect, 1, 3, 11, 12, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 30, 0)
        mpd_table.attach(ui.label(), 1, 3, 12, 13, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 30, 0)
        mpd_table.attach(ui.label(), 1, 3, 13, 14, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 30, 0)
        mpd_table.attach(ui.label(), 1, 3, 14, 15, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 30, 0)
        # Extras tab
        if not as_imported:
            self.as_enabled = False
        as_label = ui.label(markup='<b>' + _('Extras') + '</b>')
        as_frame = gtk.Frame()
        as_frame.set_label_widget(as_label)
        as_frame.set_shadow_type(gtk.SHADOW_NONE)
        as_frame.set_border_width(15)
        as_vbox = gtk.VBox()
        as_vbox.set_border_width(15)
        as_checkbox = gtk.CheckButton(_("Enable Audioscrobbler"))
        as_checkbox.set_active(self.as_enabled)
        as_vbox.pack_start(as_checkbox, False)
        as_table = gtk.Table(2, 2)
        as_table.set_col_spacings(3)
        as_user_label = ui.label(text="          " + _("Username:"******"          " + _("Password:"******"Popup notification on song changes"))
        display_notification.set_active(self.show_notification)
        notifhbox = gtk.HBox()
        notif_blank = ui.label(x=1)
        notifhbox.pack_start(notif_blank)

        time_names = []
        for i in popuptimes:
            if i != _('Entire song'):
                time_names.append(
                    i + ' ' + gettext.ngettext('second', 'seconds', int(i)))
            else:
                time_names.append(i)
        notification_options = ui.combo(
            items=time_names,
            active=self.popup_option,
            changed_cb=self.prefs_notiftime_changed)

        notification_locs = ui.combo(
            items=self.popuplocations,
            active=self.traytips_notifications_location,
            changed_cb=self.prefs_notiflocation_changed)
        display_notification.connect('toggled', prefs_notif_toggled, notifhbox)
        notifhbox.pack_start(notification_options, False, False, 2)
        notifhbox.pack_start(notification_locs, False, False, 2)
        if not self.show_notification:
            notifhbox.set_sensitive(False)
        crossfadecheck = gtk.CheckButton(_("Enable Crossfade"))
        crossfadespin = gtk.SpinButton()
        crossfadespin.set_digits(0)
        crossfadespin.set_range(1, 30)
        crossfadespin.set_value(self.xfade)
        crossfadespin.set_numeric(True)
        crossfadespin.set_increments(1, 5)
        crossfadespin.set_size_request(70, -1)
        crossfadelabel2 = ui.label(text=_("Fade length") + ":", x=1)
        crossfadelabel3 = ui.label(text=_("sec"))
        if not self.xfade_enabled:
            crossfadespin.set_sensitive(False)
            crossfadelabel2.set_sensitive(False)
            crossfadelabel3.set_sensitive(False)
            crossfadecheck.set_active(False)
        else:
            crossfadespin.set_sensitive(True)
            crossfadelabel2.set_sensitive(True)
            crossfadelabel3.set_sensitive(True)
            crossfadecheck.set_active(True)
        crossfadebox = gtk.HBox()
        crossfadebox.pack_start(crossfadelabel2)
        crossfadebox.pack_start(crossfadespin, False, False, 5)
        crossfadebox.pack_start(crossfadelabel3, False, False, 0)
        crossfadecheck.connect('toggled', self.prefs_crossfadecheck_toggled,
                               crossfadespin, crossfadelabel2, crossfadelabel3)
        as_table.attach(as_user_label, 0, 1, 0, 1)
        as_table.attach(as_user_entry, 1, 2, 0, 1)
        as_table.attach(as_pass_label, 0, 1, 1, 2)
        as_table.attach(as_pass_entry, 1, 2, 1, 2)
        as_table.attach(ui.label(), 0, 2, 2, 3)
        as_table.attach(display_notification, 0, 2, 3, 4)
        as_table.attach(notifhbox, 0, 2, 4, 5)
        as_table.attach(ui.label(), 0, 2, 5, 6)
        as_table.attach(crossfadecheck, 0, 2, 6, 7)
        as_table.attach(crossfadebox, 0, 2, 7, 8)
        as_table.attach(ui.label(), 0, 2, 8, 9)
        as_vbox.pack_start(as_table, False)
        as_frame.add(as_vbox)
        as_checkbox.connect('toggled', self.prefs_as_enabled_toggled,
                            as_user_entry, as_pass_entry, as_user_label,
                            as_pass_label)
        if not self.as_enabled or not as_imported:
            as_user_entry.set_sensitive(False)
            as_pass_entry.set_sensitive(False)
            as_user_label.set_sensitive(False)
            as_pass_label.set_sensitive(False)
        # Display tab
        table2 = gtk.Table(7, 2, False)
        displaylabel = ui.label(markup='<b>' + _('Display') + '</b>', y=1)
        display_art_hbox = gtk.HBox()
        display_art = gtk.CheckButton(_("Enable album art"))
        display_art.set_active(self.show_covers)
        display_stylized_combo = ui.combo(items=[_("Standard"),
                                                 _("Stylized")],
                                          active=self.covers_type,
                                          changed_cb=prefs_stylized_toggled)
        display_stylized_hbox = gtk.HBox()
        display_stylized_hbox.pack_start(
            ui.label(text=_("Artwork style:"), x=1))
        display_stylized_hbox.pack_start(display_stylized_combo, False, False,
                                         5)
        display_stylized_hbox.set_sensitive(self.show_covers)
        display_art_combo = ui.combo(
            items=[_("Local only"), _("Local and remote")],
            active=self.covers_pref)
        orderart_label = ui.label(text=_("Search locations:"), x=1)
        display_art_hbox.pack_start(orderart_label)
        display_art_hbox.pack_start(display_art_combo, False, False, 5)
        display_art_hbox.set_sensitive(self.show_covers)
        display_art_location_hbox = gtk.HBox()
        display_art_location_hbox.pack_start(
            ui.label(text=_("Save art to:"), x=1))

        art_paths = ["~/.covers/"]
        for item in [
                "/cover.jpg", "/album.jpg", "/folder.jpg", "/" + _("custom")
        ]:
            art_paths.append("../" + _("file_path") + item)
        display_art_location = ui.combo(
            items=art_paths,
            active=self.art_location,
            changed_cb=self.prefs_art_location_changed)

        display_art_location_hbox.pack_start(display_art_location, False,
                                             False, 5)
        display_art_location_hbox.set_sensitive(self.show_covers)
        display_art.connect('toggled', prefs_art_toggled, display_art_hbox,
                            display_art_location_hbox, display_stylized_hbox)
        display_playback = gtk.CheckButton(_("Enable playback/volume buttons"))
        display_playback.set_active(self.show_playback)
        display_playback.connect('toggled', prefs_playback_toggled)
        display_progress = gtk.CheckButton(_("Enable progressbar"))
        display_progress.set_active(self.show_progress)
        display_progress.connect('toggled', prefs_progress_toggled)
        display_statusbar = gtk.CheckButton(_("Enable statusbar"))
        display_statusbar.set_active(self.show_statusbar)
        display_statusbar.connect('toggled', prefs_statusbar_toggled)
        display_lyrics = gtk.CheckButton(_("Enable lyrics"))
        display_lyrics.set_active(self.show_lyrics)
        display_lyrics_location_hbox = gtk.HBox()
        savelyrics_label = ui.label(text=_("Save lyrics to:"), x=1)
        display_lyrics_location_hbox.pack_start(savelyrics_label)
        display_lyrics_location = ui.combo(
            items=["~/.lyrics/", "../" + _("file_path") + "/"],
            active=self.lyrics_location,
            changed_cb=self.prefs_lyrics_location_changed)
        display_lyrics_location_hbox.pack_start(display_lyrics_location, False,
                                                False, 5)
        display_lyrics_location_hbox.set_sensitive(self.show_lyrics)
        display_lyrics.connect('toggled', prefs_lyrics_toggled,
                               display_lyrics_location_hbox)
        display_trayicon = gtk.CheckButton(_("Enable system tray icon"))
        display_trayicon.set_active(self.show_trayicon)
        display_trayicon.set_sensitive(trayicon_available)
        table2.attach(ui.label(), 1, 3, 1, 2, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table2.attach(displaylabel, 1, 3, 2, 3, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table2.attach(ui.label(), 1, 3, 3, 4, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table2.attach(display_playback, 1, 3, 4, 5, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_progress, 1, 3, 5, 6, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_statusbar, 1, 3, 6, 7, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_trayicon, 1, 3, 7, 8, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_lyrics, 1, 3, 8, 9, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_lyrics_location_hbox, 1, 3, 9, 10,
                      gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_art, 1, 3, 10, 11, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_stylized_hbox, 1, 3, 11, 12,
                      gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_art_hbox, 1, 3, 12, 13, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(display_art_location_hbox, 1, 3, 13, 14,
                      gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 30, 0)
        table2.attach(ui.label(), 1, 3, 14, 15, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 75, 0)
        # Behavior tab
        table3 = gtk.Table()
        behaviorlabel = ui.label(markup='<b>' + _('Window Behavior') + '</b>',
                                 y=1)
        win_sticky = gtk.CheckButton(_("Show window on all workspaces"))
        win_sticky.set_active(self.sticky)
        win_ontop = gtk.CheckButton(_("Keep window above other windows"))
        win_ontop.set_active(self.ontop)
        update_start = gtk.CheckButton(_("Update MPD library on start"))
        update_start.set_active(self.update_on_start)
        update_start.set_tooltip_text(
            _("If enabled, Sonata will automatically update your MPD library when it starts up."
              ))
        exit_stop = gtk.CheckButton(_("Stop playback on exit"))
        exit_stop.set_active(self.stop_on_exit)
        exit_stop.set_tooltip_text(
            _("MPD allows playback even when the client is not open. If enabled, Sonata will behave like a more conventional music player and, instead, stop playback upon exit."
              ))
        minimize = gtk.CheckButton(
            _("Minimize to system tray on close/escape"))
        minimize.set_active(self.minimize_to_systray)
        minimize.set_tooltip_text(
            _("If enabled, closing Sonata will minimize it to the system tray. Note that it's currently impossible to detect if there actually is a system tray, so only check this if you have one."
              ))
        display_trayicon.connect('toggled', prefs_trayicon_toggled, minimize)
        minimize.set_sensitive(trayicon_in_use)
        infofilebox = gtk.HBox()
        infofile_usage = gtk.CheckButton(_("Write status file:"))
        infofile_usage.set_active(self.use_infofile)
        infofile_usage.set_tooltip_text(
            _("If enabled, Sonata will create a xmms-infopipe like file containing information about the current song. Many applications support the xmms-info file (Instant Messengers, IRC Clients...)"
              ))
        infopath_options = ui.entry(text=self.infofile_path)
        infopath_options.set_tooltip_text(
            _("If enabled, Sonata will create a xmms-infopipe like file containing information about the current song. Many applications support the xmms-info file (Instant Messengers, IRC Clients...)"
              ))
        if not self.use_infofile:
            infopath_options.set_sensitive(False)
        infofile_usage.connect('toggled', self.prefs_infofile_toggled,
                               infopath_options)
        infofilebox.pack_start(infofile_usage, False, False, 0)
        infofilebox.pack_start(infopath_options, True, True, 5)
        behaviorlabel2 = ui.label(markup='<b>' + _('Miscellaneous') + '</b>',
                                  y=1)
        table3.attach(ui.label(), 1, 3, 1, 2, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table3.attach(behaviorlabel, 1, 3, 2, 3, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table3.attach(ui.label(), 1, 3, 3, 4, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table3.attach(win_sticky, 1, 3, 4, 5, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(win_ontop, 1, 3, 5, 6, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(minimize, 1, 3, 6, 7, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(ui.label(), 1, 3, 7, 8, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table3.attach(behaviorlabel2, 1, 3, 8, 9, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table3.attach(ui.label(), 1, 3, 9, 10, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table3.attach(update_start, 1, 3, 10, 11, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(exit_stop, 1, 3, 11, 12, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(infofilebox, 1, 3, 12, 13, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(ui.label(), 1, 3, 13, 14, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(ui.label(), 1, 3, 14, 15, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(ui.label(), 1, 3, 15, 16, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(ui.label(), 1, 3, 16, 17, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(ui.label(), 1, 3, 17, 18, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table3.attach(ui.label(), 1, 3, 18, 19, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        # Format tab
        table4 = gtk.Table(9, 2, False)
        table4.set_col_spacings(3)
        formatlabel = ui.label(markup='<b>' + _('Song Formatting') + '</b>',
                               y=1)
        currentformatbox = gtk.HBox()
        currentlabel = ui.label(text=_("Current playlist:"))
        currentoptions = ui.entry(text=self.currentformat)
        currentformatbox.pack_start(currentlabel, False, False, 0)
        currentformatbox.pack_start(currentoptions, False, False, 10)
        libraryformatbox = gtk.HBox()
        librarylabel = ui.label(text=_("Library:"))
        libraryoptions = ui.entry(text=self.libraryformat)
        libraryformatbox.pack_start(librarylabel, False, False, 0)
        libraryformatbox.pack_start(libraryoptions, False, False, 10)
        titleformatbox = gtk.HBox()
        titlelabel = ui.label(text=_("Window title:"))
        titleoptions = ui.entry(text=self.titleformat)
        titleoptions.set_text(self.titleformat)
        titleformatbox.pack_start(titlelabel, False, False, 0)
        titleformatbox.pack_start(titleoptions, False, False, 10)
        currsongformatbox1 = gtk.HBox()
        currsonglabel1 = ui.label(text=_("Current song line 1:"))
        currsongoptions1 = ui.entry(text=self.currsongformat1)
        currsongformatbox1.pack_start(currsonglabel1, False, False, 0)
        currsongformatbox1.pack_start(currsongoptions1, False, False, 10)
        currsongformatbox2 = gtk.HBox()
        currsonglabel2 = ui.label(text=_("Current song line 2:"))
        currsongoptions2 = ui.entry(text=self.currsongformat2)
        currsongformatbox2.pack_start(currsonglabel2, False, False, 0)
        currsongformatbox2.pack_start(currsongoptions2, False, False, 10)
        formatlabels = [
            currentlabel, librarylabel, titlelabel, currsonglabel1,
            currsonglabel2
        ]
        for label in formatlabels:
            label.set_alignment(0, 0.5)
        ui.set_widths_equal(formatlabels)
        availableheading = ui.label(markup='<small>' + _('Available options') +
                                    ':</small>',
                                    y=0)
        availablevbox = gtk.VBox()
        availableformatbox = gtk.HBox()
        availableformatting = ui.label(
            markup='<small><span font_family="Monospace">%A</span> - ' +
            _('Artist name') + '\n<span font_family="Monospace">%B</span> - ' +
            _('Album name') + '\n<span font_family="Monospace">%T</span> - ' +
            _('Track name') + '\n<span font_family="Monospace">%N</span> - ' +
            _('Track number') +
            '\n<span font_family="Monospace">%D</span> - ' + _('Disc Number') +
            '\n<span font_family="Monospace">%Y</span> - ' + _('Year') +
            '</small>',
            y=0)
        availableformatting2 = ui.label(
            markup='<small><span font_family="Monospace">%G</span> - ' +
            _('Genre') + '\n<span font_family="Monospace">%F</span> - ' +
            _('File name') + '\n<span font_family="Monospace">%S</span> - ' +
            _('Stream name') + '\n<span font_family="Monospace">%L</span> - ' +
            _('Song length') + '\n<span font_family="Monospace">%E</span> - ' +
            _('Elapsed time (title only)') + '</small>',
            y=0)
        availableformatbox.pack_start(availableformatting)
        availableformatbox.pack_start(availableformatting2)
        availablevbox.pack_start(availableformatbox, False, False, 0)
        additionalinfo = ui.label(
            markup='<small>{ } - ' +
            _('Info displayed only if all enclosed tags are defined') + '\n' +
            '| - ' + _('Creates columns in the current playlist') + '</small>',
            y=0)
        availablevbox.pack_start(additionalinfo, False, False, 4)
        table4.attach(ui.label(), 1, 3, 1, 2, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table4.attach(formatlabel, 1, 3, 2, 3, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table4.attach(ui.label(), 1, 3, 3, 4, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 15, 0)
        table4.attach(currentformatbox, 1, 3, 4, 5, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table4.attach(libraryformatbox, 1, 3, 5, 6, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table4.attach(titleformatbox, 1, 3, 6, 7, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table4.attach(currsongformatbox1, 1, 3, 7, 8, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table4.attach(currsongformatbox2, 1, 3, 8, 9, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table4.attach(ui.label(), 1, 3, 9, 10, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table4.attach(availableheading, 1, 3, 10, 11, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table4.attach(availablevbox, 1, 3, 11, 12, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 45, 0)
        table4.attach(ui.label(), 1, 3, 12, 13, gtk.FILL | gtk.EXPAND,
                      gtk.FILL | gtk.EXPAND, 30, 0)
        table_names = [[_("_MPD"), mpd_table], [_("_Display"), table2],
                       [_("_Behavior"), table3], [_("_Format"), table4],
                       [_("_Extras"), as_frame]]
        for table_name in table_names:
            tmplabel = ui.label(textmn=table_name[0])
            prefsnotebook.append_page(table_name[1], tmplabel)
        hbox.pack_start(prefsnotebook, False, False, 10)
        prefswindow.vbox.pack_start(hbox, False, False, 10)
        close_button = prefswindow.add_button(gtk.STOCK_CLOSE,
                                              gtk.RESPONSE_CLOSE)
        prefswindow.show_all()
        close_button.grab_focus()
        prefswindow.connect('response', prefs_window_response, prefsnotebook,
                            exit_stop, win_ontop, display_art_combo,
                            win_sticky, direntry, minimize, update_start,
                            autoconnect, currentoptions, libraryoptions,
                            titleoptions, currsongoptions1, currsongoptions2,
                            crossfadecheck, crossfadespin, infopath_options,
                            using_mpd_env_vars, self.prev_host, self.prev_port,
                            self.prev_password)
        # Save previous connection properties to determine if we should try to
        # connect to MPD after prefs are closed:
        self.prev_host = self.host[self.profile_num]
        self.prev_port = self.port[self.profile_num]
        self.prev_password = self.password[self.profile_num]
        prefswindow.show()
Ejemplo n.º 30
0
    def __init__(
        self,
        config,
        client,
        TAB_CURRENT,
        on_current_button_press,
        parse_formatting_colnames,
        parse_formatting,
        connected,
        sonata_loaded,
        songinfo,
        update_statusbar,
        iterate_now,
        libsearchfilter_get_style,
    ):
        self.config = config
        self.client = client
        self.TAB_CURRENT = TAB_CURRENT
        self.on_current_button_press = on_current_button_press
        self.parse_formatting_colnames = parse_formatting_colnames
        self.parse_formatting = parse_formatting
        self.connected = connected
        self.sonata_loaded = sonata_loaded
        self.songinfo = songinfo
        self.update_statusbar = update_statusbar
        self.iterate_now = iterate_now
        self.libsearchfilter_get_style = libsearchfilter_get_style

        self.currentdata = None
        self.filterbox_visible = False
        self.current_update_skip = False
        self.filter_row_mapping = []  # Mapping between filter rows and self.currentdata rows
        self.columnformat = None
        self.columns = None

        self.current_songs = None
        self.filterbox_cmd_buf = None
        self.filterbox_cond = None
        self.filterbox_source = None
        self.column_sorted = (None, gtk.SORT_DESCENDING)  # TreeViewColumn, order
        self.total_time = 0
        self.edit_style_orig = None
        self.resizing_columns = None
        self.prev_boldrow = -1
        self.prevtodo = None
        self.plpos = None
        self.playlist_pos_before_filter = None
        self.sel_rows = None

        # Current tab
        self.current = ui.treeview(reorder=True, search=False, headers=True)
        self.current_selection = self.current.get_selection()
        self.expanderwindow = ui.scrollwindow(shadow=gtk.SHADOW_IN, add=self.current)
        self.filterpattern = ui.entry()
        self.filterbox = gtk.HBox()
        self.filterbox.pack_start(ui.label(text=_("Filter") + ":"), False, False, 5)
        self.filterbox.pack_start(self.filterpattern, True, True, 5)
        filterclosebutton = ui.button(img=ui.image(stock=gtk.STOCK_CLOSE), relief=gtk.RELIEF_NONE)
        self.filterbox.pack_start(filterclosebutton, False, False, 0)
        self.filterbox.set_no_show_all(True)
        self.vbox_current = gtk.VBox()
        self.vbox_current.pack_start(self.expanderwindow, True, True)
        self.vbox_current.pack_start(self.filterbox, False, False, 5)
        playlisthbox = gtk.HBox()
        playlisthbox.pack_start(ui.image(stock=gtk.STOCK_CDROM), False, False, 2)
        playlisthbox.pack_start(ui.label(text=self.TAB_CURRENT), False, False, 2)
        self.playlistevbox = ui.eventbox(add=playlisthbox)
        self.playlistevbox.show_all()

        self.current.connect("drag_data_received", self.on_dnd)
        self.current.connect("row_activated", self.on_current_click)
        self.current.connect("button_press_event", self.on_current_button_press)
        self.current.connect("drag-begin", self.on_current_drag_begin)
        self.current.connect_after("drag-begin", self.dnd_after_current_drag_begin)
        self.current.connect("button_release_event", self.on_current_button_release)

        self.filter_changed_handler = self.filterpattern.connect("changed", self.searchfilter_feed_loop)
        self.filterpattern.connect("activate", self.searchfilter_on_enter)
        self.filterpattern.connect("key-press-event", self.searchfilter_key_pressed)
        filterclosebutton.connect("clicked", self.searchfilter_toggle)

        # Set up current view
        self.initialize_columns()
        self.current_selection.set_mode(gtk.SELECTION_MULTIPLE)
        target_reorder = ("MY_TREE_MODEL_ROW", gtk.TARGET_SAME_WIDGET, 0)
        target_file_managers = ("text/uri-list", 0, 0)
        self.current.enable_model_drag_source(
            gtk.gdk.BUTTON1_MASK, [target_reorder, target_file_managers], gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_DEFAULT
        )
        self.current.enable_model_drag_dest(
            [target_reorder, target_file_managers], gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_DEFAULT
        )
        self.current.connect("drag-data-get", self.dnd_get_data_for_file_managers)
Ejemplo n.º 31
0
    def on_tags_edit(self, files, temp_mpdpaths, music_dir):
        """Display the editing dialog"""
        # Try loading module
        global tagpy
        if tagpy is None:
            try:
                import tagpy
            except ImportError:
                ui.show_msg(
                    self.window,
                    _("Taglib and/or tagpy not found, tag editing support disabled."
                      ),
                    _("Edit Tags"),
                    'editTagsError',
                    gtk.BUTTONS_CLOSE,
                    response_cb=ui.dialog_destroy)
                ui.change_cursor(None)
                return
            # Set default tag encoding to utf8.. fixes some reported bugs.
            import tagpy.id3v2 as id3v2
            id3v2.FrameFactory.instance().setDefaultTextEncoding(
                tagpy.StringType.UTF8)

        # Make sure tagpy is at least 0.91
        if hasattr(tagpy.Tag.title, '__call__'):
            ui.show_msg(
                self.window,
                _("Tagpy version < 0.91. Please upgrade to a newer version, tag editing support disabled."
                  ),
                _("Edit Tags"),
                'editTagsError',
                gtk.BUTTONS_CLOSE,
                response_cb=ui.dialog_destroy)
            ui.change_cursor(None)
            return

        if not os.path.isdir(misc.file_from_utf8(music_dir)):
            ui.show_msg(
                self.window,
                _("The path") + " " + music_dir + " " +
                _("does not exist. Please specify a valid music directory in preferences."
                  ),
                _("Edit Tags"),
                'editTagsError',
                gtk.BUTTONS_CLOSE,
                response_cb=ui.dialog_destroy)
            ui.change_cursor(None)
            return

# XXX file list was created here

        if len(files) == 0:
            ui.change_cursor(None)
            return

        # Initialize:
        self.tagnum = -1

        tags = [{
            'title': '',
            'artist': '',
            'album': '',
            'year': '',
            'track': '',
            'genre': '',
            'comment': '',
            'title-changed': False,
            'artist-changed': False,
            'album-changed': False,
            'year-changed': False,
            'track-changed': False,
            'genre-changed': False,
            'comment-changed': False,
            'fullpath': misc.file_from_utf8(filename),
            'mpdpath': path
        } for filename, path in zip(files, temp_mpdpaths)]

        if not os.path.exists(tags[0]['fullpath']):
            ui.change_cursor(None)
            ui.show_msg(
                self.window,
                _("File ") + "\"" + tags[0]['fullpath'] + "\"" +
                _(" not found. Please specify a valid music directory in preferences."
                  ),
                _("Edit Tags"),
                'editTagsError',
                gtk.BUTTONS_CLOSE,
                response_cb=ui.dialog_destroy)
            return
        if not self.tags_next_tag(tags):
            ui.change_cursor(None)
            ui.show_msg(self.window,
                        _("No music files with editable tags found."),
                        _("Edit Tags"),
                        'editTagsError',
                        gtk.BUTTONS_CLOSE,
                        response_cb=ui.dialog_destroy)
            return
        editwindow = ui.dialog(parent=self.window,
                               flags=gtk.DIALOG_MODAL,
                               role='editTags',
                               resizable=False,
                               separator=False)
        editwindow.set_size_request(375, -1)
        table = gtk.Table(9, 2, False)
        table.set_row_spacings(2)
        self.filelabel = ui.label(select=True, wrap=True)
        filehbox = gtk.HBox()
        sonataicon = ui.image(stock='sonata', stocksize=gtk.ICON_SIZE_DND, x=1)
        expandbutton = ui.button(" ")
        self.set_expandbutton_state(expandbutton)
        expandvbox = gtk.VBox()
        expandvbox.pack_start(ui.label(), True, True)
        expandvbox.pack_start(expandbutton, False, False)
        expandvbox.pack_start(ui.label(), True, True)
        expandbutton.connect('clicked', self.toggle_path)
        blanklabel = ui.label(w=5, h=12)
        filehbox.pack_start(sonataicon, False, False, 2)
        filehbox.pack_start(self.filelabel, True, True, 2)
        filehbox.pack_start(expandvbox, False, False, 2)
        filehbox.pack_start(blanklabel, False, False, 2)

        titlelabel, titleentry, titlebutton, titlehbox = self._create_label_entry_button_hbox(
            _("Title"))
        artistlabel, artistentry, artistbutton, artisthbox = self._create_label_entry_button_hbox(
            _("Artist"))
        albumlabel, albumentry, albumbutton, albumhbox = self._create_label_entry_button_hbox(
            _("Album"))
        yearlabel, yearentry, yearbutton, yearhbox = self._create_label_entry_button_hbox(
            _("Year"))
        yearentry.set_size_request(50, -1)
        tracklabel, trackentry, trackbutton, trackhbox = self._create_label_entry_button_hbox(
            "  " + _("Track"), True)
        trackentry.set_size_request(50, -1)
        yearandtrackhbox = gtk.HBox()
        yearandtrackhbox.pack_start(yearhbox, True, True, 0)
        yearandtrackhbox.pack_start(trackhbox, True, True, 0)

        yearentry.connect("insert_text", self.tags_win_entry_constraint, True)
        trackentry.connect("insert_text", self.tags_win_entry_constraint,
                           False)

        genrelabel = ui.label(text=_("Genre") + ":", x=1)
        genrecombo = ui.comboentry(items=self.tags_win_genres(), wrap=2)
        genreentry = genrecombo.get_child()
        genrehbox = gtk.HBox()
        genrebutton = ui.button()
        genrebuttonvbox = self.tags_win_create_apply_all_button(
            genrebutton, genreentry)
        genrehbox.pack_start(genrelabel, False, False, 2)
        genrehbox.pack_start(genrecombo, True, True, 2)
        genrehbox.pack_start(genrebuttonvbox, False, False, 2)

        commentlabel, commententry, commentbutton, commenthbox = self._create_label_entry_button_hbox(
            _("Comment"))

        ui.set_widths_equal([
            titlelabel, artistlabel, albumlabel, yearlabel, genrelabel,
            commentlabel, sonataicon
        ])
        genrecombo.set_size_request(-1, titleentry.size_request()[1])
        tablewidgets = [
            ui.label(), filehbox,
            ui.label(), titlehbox, artisthbox, albumhbox, yearandtrackhbox,
            genrehbox, commenthbox,
            ui.label()
        ]
        for i, widget in enumerate(tablewidgets):
            table.attach(widget, 1, 2, i + 1, i + 2, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 2, 0)
        editwindow.vbox.pack_start(table)
        saveall_button = None
        if len(files) > 1:
            # Only show save all button if more than one song being edited.
            saveall_button = ui.button(text=_("Save _All"))
            editwindow.action_area.pack_start(saveall_button)
        editwindow.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
        editwindow.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT)
        editwindow.connect('delete_event', self.tags_win_hide, tags)
        entries = [
            titleentry, artistentry, albumentry, yearentry, trackentry,
            genreentry, commententry
        ]
        buttons = [
            titlebutton, artistbutton, albumbutton, yearbutton, trackbutton,
            genrebutton, commentbutton
        ]
        entries_names = [
            "title", "artist", "album", "year", "track", "genre", "comment"
        ]
        editwindow.connect('response', self.tags_win_response, tags, entries,
                           entries_names)
        if saveall_button:
            saveall_button.connect('clicked', self.tags_win_save_all,
                                   editwindow, tags, entries, entries_names)

        for button, name, entry in zip(buttons, entries_names, entries):
            entry.connect('changed', self.tags_win_entry_changed)
            button.connect('clicked', self.tags_win_apply_all, name, tags,
                           entry)

        self.tags_win_update(editwindow, tags, entries, entries_names)
        ui.change_cursor(None)
        self.filelabel.set_size_request(
            editwindow.size_request()[0] - titlelabel.size_request()[0] - 70,
            -1)
        editwindow.show_all()