Exemplo n.º 1
0
    def __init__(self, mediator, provider, cfg_provider, default_cfg_provider,
                 eventManager, tooltipManager):

        self.version = APPVERSION
        self.mediator = mediator
        self.eventManager = eventManager
        self.log = logging.getLogger('radiotray')

        # initialize data provider
        self.provider = provider
        self.cfg_provider = cfg_provider
        self.tooltip = tooltipManager

        self.ignore_toggle = False

        # execute gui chooser
        try:
            from gi.repository import AppIndicator3
            self.gui_engine = self.cfg_provider.getConfigValue("gui_engine")
            if (self.gui_engine == None):
                self.gui_engine = default_cfg_provider.getConfigValue(
                    "gui_engine")

            if (self.gui_engine == None or self.gui_engine == "chooser"):
                self.log.debug('show chooser')
                chooser = GuiChooserConfiguration()
                self.gui_engine = chooser.run()

            self.cfg_provider.setConfigValue("gui_engine", self.gui_engine)

        except Exception as e:
            self.log.debug(
                'No appindicator support found. Choosing notification area...')
            self.gui_engine = "systray"

        if self.gui_engine == "appindicator":
            self.app_indicator_enabled = True
        else:
            self.app_indicator_enabled = False
            self.cfg_provider.setConfigValue(
                "enable_application_indicator_support", "false")

        if (self.app_indicator_enabled):
            self.log.debug('App Indicator selected')
            self.gui = AppIndicatorGui(self, self.mediator, self.cfg_provider,
                                       self.provider)

        else:
            self.log.debug('Systray selected')
            self.gui = SysTrayGui(self, self.mediator, self.cfg_provider,
                                  self.provider)

        self.tooltip.setGui(self.gui)
        self.tooltip.addSource(self.gui.getCommonTooltipData)

        self.gui.buildMenu()
Exemplo n.º 2
0
    def __init__(self, mediator, provider, cfg_provider, default_cfg_provider, eventManager, tooltipManager):

        self.version = APPVERSION
        self.mediator = mediator
        self.eventManager = eventManager
        self.log = logging.getLogger('radiotray')

        # initialize data provider
        self.provider = provider
        self.cfg_provider = cfg_provider
        self.tooltip = tooltipManager
        
            
        self.ignore_toggle = False

        # execute gui chooser
        try:
            import appindicator
            self.gui_engine = self.cfg_provider.getConfigValue("gui_engine")
            if(self.gui_engine == None):
                self.gui_engine = default_cfg_provider.getConfigValue("gui_engine")
 
            if(self.gui_engine == None or self.gui_engine == "chooser"):
                self.log.debug('show chooser')
                chooser = GuiChooserConfiguration()
                self.gui_engine = chooser.run()

            self.cfg_provider.setConfigValue("gui_engine", self.gui_engine)

        except Exception as e:
            self.log.debug('No appindicator support found. Choosing notification area...')
            self.gui_engine = "systray"




        if self.gui_engine == "appindicator":
            self.app_indicator_enabled  = True
        else:
            self.app_indicator_enabled = False
            self.cfg_provider.setConfigValue("enable_application_indicator_support", "false")

        if(self.app_indicator_enabled):
            self.log.debug('App Indicator selected')
            self.gui = AppIndicatorGui(self, self.mediator, self.cfg_provider, self.provider)
  
        else:
            self.log.debug('Systray selected')
            self.gui = SysTrayGui(self, self.mediator, self.cfg_provider, self.provider)
        
        self.tooltip.setGui(self.gui)
        self.tooltip.addSource(self.gui.getCommonTooltipData)

        self.gui.buildMenu()
Exemplo n.º 3
0
class SysTray(object):

    def __init__(self, mediator, provider, cfg_provider, default_cfg_provider, eventManager, tooltipManager):

        self.version = APPVERSION
        self.mediator = mediator
        self.eventManager = eventManager
        self.log = logging.getLogger('radiotray')

        # initialize data provider
        self.provider = provider
        self.cfg_provider = cfg_provider
        self.tooltip = tooltipManager
        
            
        self.ignore_toggle = False

        # execute gui chooser
        try:
            import appindicator
            self.gui_engine = self.cfg_provider.getConfigValue("gui_engine")
            if(self.gui_engine == None):
                self.gui_engine = default_cfg_provider.getConfigValue("gui_engine")
 
            if(self.gui_engine == None or self.gui_engine == "chooser"):
                self.log.debug('show chooser')
                chooser = GuiChooserConfiguration()
                self.gui_engine = chooser.run()

            self.cfg_provider.setConfigValue("gui_engine", self.gui_engine)

        except Exception as e:
            self.log.debug('No appindicator support found. Choosing notification area...')
            self.gui_engine = "systray"




        if self.gui_engine == "appindicator":
            self.app_indicator_enabled  = True
        else:
            self.app_indicator_enabled = False
            self.cfg_provider.setConfigValue("enable_application_indicator_support", "false")

        if(self.app_indicator_enabled):
            self.log.debug('App Indicator selected')
            self.gui = AppIndicatorGui(self, self.mediator, self.cfg_provider, self.provider)
  
        else:
            self.log.debug('Systray selected')
            self.gui = SysTrayGui(self, self.mediator, self.cfg_provider, self.provider)
        
        self.tooltip.setGui(self.gui)
        self.tooltip.addSource(self.gui.getCommonTooltipData)

        self.gui.buildMenu()
        
            
###### Action Events #######

    def scroll(self,widget, event):
        if event.direction == gtk.gdk.SCROLL_UP:
            self.mediator.volume_up()
            
        if event.direction == gtk.gdk.SCROLL_DOWN:
            self.mediator.volume_down()
    def volume_up(self, menu_item):
        self.mediator.volume_up()
    def volume_down(self, menu_item):
        self.mediator.volume_down()

    

    def on_preferences(self, data):
        config = BookmarkConfiguration(self.provider, self.update_radios)

    def on_quit(self, data):
        self.log.info('Exiting...')
        gtk.main_quit()

    def on_about(self, data):
        about_dialog(parent=None)

    def on_turn_on_off(self, data):
        if self.mediator.context.state == 'playing' or self.mediator.context.state == 'connecting':
            self.mediator.stop()
        else:
            self.mediator.play(self.mediator.context.station)

    def on_start(self, data, radio):
        self.mediator.context.resetSongInfo()
        self.mediator.play(radio)
    
        
    def updateTooltip(self):
        self.tooltip.update()
    
    

		

    def update_radios(self):
        self.gui.update_radios()
    
        
    def run(self):
        gtk.gdk.threads_init()
        gtk.main()


    

            
    def reload_bookmarks(self, data):
        self.provider.loadFromFile()
        self.update_radios()
        self.eventManager.notify(EventManager.BOOKMARKS_RELOADED, {})
        

    
    def on_state_changed(self, data):

        if(data['state'] == Context.STATE_PAUSED and self.mediator.context.station == Context.UNKNOWN_RADIO):
            self.mediator.context.station = ''

        self.gui.state_changed(data)
        self.updateTooltip()

    def on_volume_changed(self, volume):
        self.updateTooltip()
      
    def on_song_changed(self, data):
        self.updateTooltip()


    def on_plugin_preferences(self, data):
        config = PluginConfiguration(self.pluginManager, self.cfg_provider)


    def getPluginMenu(self):
        return self.gui.getPluginMenu()

    def setPluginManager(self, pluginManager):
        self.pluginManager = pluginManager
Exemplo n.º 4
0
class SysTray(object):
    def __init__(self, mediator, provider, cfg_provider, default_cfg_provider,
                 eventManager, tooltipManager):

        self.version = APPVERSION
        self.mediator = mediator
        self.eventManager = eventManager
        self.log = logging.getLogger('radiotray')

        # initialize data provider
        self.provider = provider
        self.cfg_provider = cfg_provider
        self.tooltip = tooltipManager

        self.ignore_toggle = False

        # execute gui chooser
        try:
            from gi.repository import AppIndicator3
            self.gui_engine = self.cfg_provider.getConfigValue("gui_engine")
            if (self.gui_engine == None):
                self.gui_engine = default_cfg_provider.getConfigValue(
                    "gui_engine")

            if (self.gui_engine == None or self.gui_engine == "chooser"):
                self.log.debug('show chooser')
                chooser = GuiChooserConfiguration()
                self.gui_engine = chooser.run()

            self.cfg_provider.setConfigValue("gui_engine", self.gui_engine)

        except Exception as e:
            self.log.debug(
                'No appindicator support found. Choosing notification area...')
            self.gui_engine = "systray"

        if self.gui_engine == "appindicator":
            self.app_indicator_enabled = True
        else:
            self.app_indicator_enabled = False
            self.cfg_provider.setConfigValue(
                "enable_application_indicator_support", "false")

        if (self.app_indicator_enabled):
            self.log.debug('App Indicator selected')
            self.gui = AppIndicatorGui(self, self.mediator, self.cfg_provider,
                                       self.provider)

        else:
            self.log.debug('Systray selected')
            self.gui = SysTrayGui(self, self.mediator, self.cfg_provider,
                                  self.provider)

        self.tooltip.setGui(self.gui)
        self.tooltip.addSource(self.gui.getCommonTooltipData)

        self.gui.buildMenu()

###### Action Events #######

    def scroll(self, widget, event):
        if event.direction == Gdk.ScrollDirection.UP:
            self.mediator.volume_up()

        if event.direction == Gdk.ScrollDirection.DOWN:
            self.mediator.volume_down()

    def volume_up(self, menu_item):
        self.mediator.volume_up()

    def volume_down(self, menu_item):
        self.mediator.volume_down()

    def on_preferences(self, data):
        config = BookmarkConfiguration(self.provider, self.update_radios)

    def on_quit(self, data):
        self.log.info('Exiting...')
        Gtk.main_quit()

    def on_about(self, data):
        about_dialog(parent=None)

    def on_turn_on_off(self, data):
        if self.mediator.context.state == 'playing' or self.mediator.context.state == 'connecting':
            self.mediator.stop()
        else:
            self.mediator.play(self.mediator.context.station)

    def on_start(self, data, radio):
        self.mediator.context.resetSongInfo()
        self.mediator.play(radio)

    def updateTooltip(self):
        self.tooltip.update()

    def update_radios(self):
        self.gui.update_radios()

    def run(self):
        Gdk.threads_init()
        Gdk.threads_enter()
        Gtk.main()

    def reload_bookmarks(self, data):
        self.provider.loadFromFile()
        self.update_radios()
        self.eventManager.notify(EventManager.BOOKMARKS_RELOADED, {})

    def on_state_changed(self, data):

        if (data['state'] == Context.STATE_PAUSED
                and self.mediator.context.station == Context.UNKNOWN_RADIO):
            self.mediator.context.station = ''

        self.gui.state_changed(data)
        self.updateTooltip()

    def on_volume_changed(self, volume):
        self.updateTooltip()

    def on_song_changed(self, data):
        self.updateTooltip()

    def on_plugin_preferences(self, data):
        config = PluginConfiguration(self.pluginManager, self.cfg_provider)

    def getPluginMenu(self):
        return self.gui.getPluginMenu()

    def setPluginManager(self, pluginManager):
        self.pluginManager = pluginManager