Ejemplo n.º 1
0
    def __init__(self, gui_root):
        self.__log = logging.getLogger('panucci.panucci.PlayerTab')
        self.__gui_root = gui_root
        self.config = gui_root.config
        self.playlist = gui_root.playlist
        self.metadata = None

        gtk.HBox.__init__(self)
        ObservableService.__init__(self, self.signals, self.__log)

        self.progress_timer_id = None
        self.recent_files = []
        self.make_player_tab()
        self.has_coverart = False
        self.reset_progress()

        self.playlist.register('stopped', self.on_player_stopped)
        self.playlist.register('playing', self.on_player_playing)
        self.playlist.register('paused', self.on_player_paused)
        self.playlist.register('end-of-playlist',
                               self.on_player_end_of_playlist)
        self.playlist.register('new-track-loaded', self.on_player_new_track)
        self.playlist.register('new-metadata-available',
                               self.on_player_new_metadata)
        self.playlist.register('reset-playlist', self.on_player_reset_playlist)
Ejemplo n.º 2
0
    def __init__(self, gui_root):
        self.__log = logging.getLogger('panucci.panucci.PlayerTab')
        self.__gui_root = gui_root
        self.config = gui_root.config
        self.playlist = gui_root.playlist

        gtk.HBox.__init__(self)
        ObservableService.__init__(self, self.signals, self.__log)

        # Timers
        self.progress_timer_id = None

        self.recent_files = []
        self.make_player_tab()
        self.has_coverart = False

        #settings.register( 'enable_dual_action_btn_changed',
        #                   self.on_dual_action_setting_changed )
        #settings.register( 'dual_action_button_delay_changed',
        #                   self.on_dual_action_setting_changed )
        #settings.register( 'scrolling_labels_changed', lambda v:
        #                   setattr( self.title_label, 'scrolling', v ) )

        self.playlist.player.register('stopped', self.on_player_stopped)
        self.playlist.player.register('playing', self.on_player_playing)
        self.playlist.player.register('paused', self.on_player_paused)
        #self.playlist.player.register( 'eof', self.on_player_eof )
        self.playlist.register('end-of-playlist',
                               self.on_player_end_of_playlist)
        self.playlist.register('new-track-loaded', self.on_player_new_track)
        self.playlist.register('new-metadata-available',
                               self.on_player_new_metadata)
        self.playlist.register('reset-playlist', self.on_player_reset_playlist)
Ejemplo n.º 3
0
    def __init__(self, gui_root):
        self.__log = logging.getLogger('panucci.panucci.PlayerTab')
        self.__gui_root = gui_root
        self.config = gui_root.config
        self.playlist = gui_root.playlist

        gtk.HBox.__init__(self)
        ObservableService.__init__(self, self.signals, self.__log)

        # Timers
        self.progress_timer_id = None

        self.recent_files = []
        self.make_player_tab()
        self.has_coverart = False

        #settings.register( 'enable_dual_action_btn_changed',
        #                   self.on_dual_action_setting_changed )
        #settings.register( 'dual_action_button_delay_changed',
        #                   self.on_dual_action_setting_changed )
        #settings.register( 'scrolling_labels_changed', lambda v:
        #                   setattr( self.title_label, 'scrolling', v ) )

        self.playlist.player.register( 'stopped', self.on_player_stopped )
        self.playlist.player.register( 'playing', self.on_player_playing )
        self.playlist.player.register( 'paused', self.on_player_paused )
        #self.playlist.player.register( 'eof', self.on_player_eof )
        self.playlist.register( 'end-of-playlist',
                                  self.on_player_end_of_playlist )
        self.playlist.register( 'new-track-loaded',
                                  self.on_player_new_track )
        self.playlist.register( 'new-metadata-available',
                                  self.on_player_new_metadata )
        self.playlist.register( 'reset-playlist',
                                  self.on_player_reset_playlist )
Ejemplo n.º 4
0
    def __init__(self, playlist_id):
        self.__log = logging.getLogger('panucci.playlist.Queue')
        ObservableService.__init__(self, self.signals, self.__log)

        self.playlist_id = playlist_id
        self.modified = False # Has the queue been modified?
        self.disable_notifications = False
        self.__current_item_position = 0
        # This is a hack and WILL BE REPLACED WITH SOMETHING BETTER.
        # it's here to speed up the get_item function
        self.__mapping_dict = {}
        list.__init__(self)
Ejemplo n.º 5
0
    def __init__(self, playlist_id):
        self.__log = logging.getLogger('panucci.playlist.Queue')
        ObservableService.__init__(self, self.signals, self.__log)

        self.playlist_id = playlist_id
        self.modified = False  # Has the queue been modified?
        self.disable_notifications = False
        self.__current_item_position = 0
        # This is a hack and WILL BE REPLACED WITH SOMETHING BETTER.
        # it's here to speed up the get_item function
        self.__mapping_dict = {}
        list.__init__(self)
Ejemplo n.º 6
0
    def __init__(self, config):
        self.__log = logging.getLogger('panucci.playlist.Playlist')
        ObservableService.__init__(self, self.signals, self.__log)
        self.config = config
        
        self.player = player.PanucciPlayer(self)
        self.player.register( 'eof', self.on_player_eof )
        self.__queue = Queue(None)
        self.__queue.register(
            'current_item_changed', self.on_queue_current_item_changed )

        self.filepath = None
        self._id = None
Ejemplo n.º 7
0
    def __init__(self, config):
        self.__log = logging.getLogger('panucci.playlist.Playlist')
        ObservableService.__init__(self, self.signals, self.__log)
        self.config = config

        self.player = player.PanucciPlayer(self)
        self.player.register('eof', self.on_player_eof)
        self.__queue = Queue(None)
        self.__queue.register('current_item_changed',
                              self.on_queue_current_item_changed)

        self.filepath = None
        self._id = None
Ejemplo n.º 8
0
    def __init__(self, config):
        self.__log = logging.getLogger('panucci.playlist.Playlist')
        ObservableService.__init__(self, self.signals, self.__log)
        self.config = config
        self.filepath = panucci.PLAYLIST_FILE
        self._id = None

        self.__player = player.PanucciPlayer(self.config)
        self.__player.register('eof', self.on_player_eof)
        self.__player.register('playing', self.on_player_playing)
        self.__player.register('paused', self.on_player_paused)
        self.__player.register('stopped', self.on_player_stopped)
        self.__queue = Queue(self.id)
        self.__queue.register('current_item_changed', self.on_queue_current_item_changed)

        # Register the d-bus interface only once we're ready
        interface.register_playlist(self)
Ejemplo n.º 9
0
    def __init__(self, config):
        self.__log = logging.getLogger('panucci.playlist.Playlist')
        ObservableService.__init__(self, self.signals, self.__log)
        self.config = config
        self.filepath = panucci.PLAYLIST_FILE
        self._id = None

        self.__player = player.PanucciPlayer(self.config)
        self.__player.register('eof', self.on_player_eof)
        self.__player.register('playing', self.on_player_playing)
        self.__player.register('paused', self.on_player_paused)
        self.__player.register('stopped', self.on_player_stopped)
        self.__queue = Queue(self.id)
        self.__queue.register('current_item_changed',
                              self.on_queue_current_item_changed)

        # Register the d-bus interface only once we're ready
        interface.register_playlist(self)
Ejemplo n.º 10
0
    def __init__(self, gui_root):
        self.__log = logging.getLogger('panucci.panucci.PlayerTab')
        self.__gui_root = gui_root
        self.config = gui_root.config
        self.playlist = gui_root.playlist
        self.metadata = None

        gtk.HBox.__init__(self)
        ObservableService.__init__(self, self.signals, self.__log)

        self.progress_timer_id = None
        self.recent_files = []
        self.make_player_tab()
        self.has_coverart = False
        self.reset_progress()

        self.playlist.register('stopped', self.on_player_stopped)
        self.playlist.register('playing', self.on_player_playing)
        self.playlist.register('paused', self.on_player_paused )
        self.playlist.register('end-of-playlist', self.on_player_end_of_playlist)
        self.playlist.register('new-track-loaded', self.on_player_new_track)
        self.playlist.register('new-metadata-available', self.on_player_new_metadata)
        self.playlist.register('reset-playlist', self.on_player_reset_playlist )
Ejemplo n.º 11
0
    def __init__(self, gui_root):
        self.__log = logging.getLogger('panucci.panucci.PlayerTab')
        self.__gui_root = gui_root
        self.config = gui_root.config
        self.playlist = gui_root.playlist
        ObservableService.__init__(self, self.signals, self.__log)

        self.playlist.player.register( 'stopped', self.on_player_stopped )
        self.playlist.player.register( 'playing', self.on_player_playing )
        self.playlist.player.register( 'paused', self.on_player_paused )
        #self.playlist.player.register( 'eof', self.on_player_eof )
        self.playlist.register( 'end-of-playlist', self.on_player_end_of_playlist )
        self.playlist.register( 'new-track-loaded', self.on_player_new_track )
        self.playlist.register( 'new-metadata-available', self.on_player_new_metadata )
        self.playlist.register( 'reset-playlist', self.on_player_reset_playlist )

        self.mainbox = QtGui.QVBoxLayout()
        self.mainbox.setContentsMargins(0, 0, 0, 0)
        self.mainbox.setSpacing(0)

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self.label_cover = QtGui.QLabel()
        self.label_cover.setContentsMargins(0, 5, 2, 5)
        layout.addWidget(self.label_cover)
        vlayout = QtGui.QVBoxLayout()
        vlayout.setContentsMargins(0, 0, 0, 0)
        vlayout.setSpacing(0)
        vlayout.addStretch(5)
        self.label_artist = QtGui.QLabel()
        self.label_album = QtGui.QLabel()
        self.label_artist.setContentsMargins(3, 0, 5, 10)
        self.label_album.setContentsMargins(3, 0, 5, 10)
        self.label_title = qtwidgets.ScrollingLabel(self.config)
        self.label_title.setContentsMargins(0, 0, 0, 0)
        vlayout.addWidget(self.label_artist)
        vlayout.addWidget(self.label_album)
        vlayout.addWidget(self.label_title)
        vlayout.addStretch(5)
        layout.addLayout(vlayout, 2)
        self.mainbox.addLayout(layout, 8)

        self.progress = QtGui.QProgressBar()
        self.progress.setContentsMargins(0, 0, 0, 0)
        self.mainbox.addWidget(self.progress)
        self.progress.setTextVisible(True)
        self.progress.setFormat("00:00 / 00:00")
        self.progress.setValue(0)
        self.progress.mousePressEvent = self.on_progress_clicked
        self.progress.setFixedHeight(self.config.getint("options", "progress_height"))

        self.icon_play = QtGui.QIcon(util.find_data_file('media-playback-start.png'))
        self.icon_pause = QtGui.QIcon(util.find_data_file('media-playback-pause.png'))
        self.button_rrewind = qtwidgets.DualActionButton(self.config,
                                                      QtGui.QIcon(util.find_data_file('media-skip-backward.png')),
                                                      self.button_rrewind_callback,
                                         QtGui.QIcon("/usr/share/icons/gnome/24x24/actions/gtk-goto-first-ltr.png"),
                                         self.playlist.prev)
        self.button_rrewind.setFixedHeight(self.config.getint("options", "button_height"))
        self.button_rewind = QtGui.QPushButton(QtGui.QIcon(util.find_data_file('media-seek-backward.png')), "")
        self.button_rewind.clicked.connect(self.button_rewind_callback)
        self.button_rewind.setFixedHeight(self.config.getint("options", "button_height"))
        self.button_play = QtGui.QPushButton(self.icon_play, "")
        self.button_play.clicked.connect(self.button_play_callback)
        self.button_play.setFixedHeight(self.config.getint("options", "button_height"))
        self.button_forward = QtGui.QPushButton(QtGui.QIcon(util.find_data_file('media-seek-forward.png')), "")
        self.button_forward.clicked.connect(self.button_forward_callback)
        self.button_forward.setFixedHeight(self.config.getint("options", "button_height"))
        self.button_fforward = qtwidgets.DualActionButton(self.config,
                                                      QtGui.QIcon(util.find_data_file('media-skip-forward.png')),
                                                      self.button_fforward_callback,
                                         QtGui.QIcon("/usr/share/icons/gnome/24x24/actions/gtk-goto-last-ltr.png"),
                                         self.playlist.next)
        self.button_fforward.setFixedHeight(self.config.getint("options", "button_height"))
        self.button_bookmark = QtGui.QPushButton(QtGui.QIcon(util.find_data_file('bookmark-new.png')), "")
        self.button_bookmark.clicked.connect(self.button_bookmark_callback)
        self.button_bookmark.setFixedHeight(self.config.getint("options", "button_height"))

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 4, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self.button_rrewind)
        layout.addWidget(self.button_rewind)
        layout.addWidget(self.button_play)
        layout.addWidget(self.button_forward)
        layout.addWidget(self.button_fforward)
        layout.addWidget(self.button_bookmark)
        self.mainbox.addLayout(layout)

        self.timer = QtCore.QTimer()
        self.timer.setInterval(1000); 
        self.timer.timeout.connect(self.timer_callback)
Ejemplo n.º 12
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        QtCore.QObject.__init__(self)
        ObservableService.__init__(self, [], self.__log)
        self.config = settings.config
        interface.register_gui(self)
        self.playlist = playlist.Playlist(self.config)
        self.time_str = "00:00 / 00:00"
        self.progress_fraction = 0
        self.metadata = None

        self.app = QtGui.QApplication(["Panucci"])
        self.app.setWindowIcon(QtGui.QIcon(util.find_data_file('panucci.png')))
        self.view = QtDeclarative.QDeclarativeView()
        self.view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView)
        self.view.closeEvent = self.close_main_window_callback
        self.context = self.view.rootContext()
        self.context.setContextProperty('main', self)
        self.context.setContextProperty('config', self.make_config())
        self.theme_controller = ThemeController(self.config)
        self.context.setContextProperty('themeController', self.theme_controller)
        self.context.setContextProperty('themes', self.theme_controller.get_themes())
        self.create_actions()
        engine = self.context.engine()
        self.image_provider = ImageProvider(self)
        engine.addImageProvider("cover", self.image_provider)

        self.playlist.register( 'stopped', self.on_player_stopped )
        self.playlist.register( 'playing', self.on_player_playing )
        self.playlist.register( 'paused', self.on_player_paused )
        self.playlist.register( 'end-of-playlist', self.on_player_end_of_playlist )
        self.playlist.register( 'new-track-loaded', self.on_player_new_track )
        self.playlist.register( 'new-metadata-available', self.on_player_new_metadata )
        self.playlist.register( 'reset-playlist', self.on_player_reset_playlist )

        self.timer = QtCore.QTimer()
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.timer_callback)
        if platform.HARMATTAN:
            self.view.setSource(util.find_data_file("main_harmattan.qml"))
            self.view.showFullScreen()
        elif platform.FREMANTLE:
            self.view.setSource(util.find_data_file("main_fremantle.qml"))
            self.view.showFullScreen()
        else:
            self.view.setSource(util.find_data_file("main_default.qml"))
            self.view.show()

        self.playlist.init(filepath=filename)
        self.view.rootObject().property("root").start_scrolling_timer(self.config.getboolean("options", "scrolling_labels"))

        if platform.HANDSET:
            import dbus
            # Enable play/pause with headset button
            #interface.headset_device.connect_to_signal('Condition', \
            #        self.handle_headset_button)

            system_bus = dbus.SystemBus()
            self.headset_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input'
            self.headset_bt_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input'
            if platform.HARMATTAN:
                self.headset_bt_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input_0'
            elif platform.FREMANTLE:
                self.headset_bt_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input_1'

            # Monitor connection state of headset
            system_bus.add_signal_receiver(self.handle_headset_connection_state, 'DeviceAdded', \
                    'org.freedesktop.Hal.Manager', None, '/org/freedesktop/Hal/Manager')

            # Monitor connection state of BT headset
            system_bus.add_signal_receiver(self.handle_headset_bt_connection_state, 'DeviceAdded', \
                    'org.freedesktop.Hal.Manager', None, '/org/freedesktop/Hal/Manager')

            # Monitor headset buttons
            system_bus.add_signal_receiver(self.handle_headset_button, 'Condition', \
                    'org.freedesktop.Hal.Device', None, self.headset_path)

            # Monitor BT headset buttons
            system_bus.add_signal_receiver(self.handle_headset_bt_button, 'Condition', \
                    'org.freedesktop.Hal.Device', None, self.headset_bt_path)

        self.app.exec_()
Ejemplo n.º 13
0
    def __init__(self, gui_root):
        self.__log = logging.getLogger('panucci.panucci.PlayerTab')
        self.__gui_root = gui_root
        self.config = gui_root.config
        self.playlist = gui_root.playlist
        ObservableService.__init__(self, self.signals, self.__log)
        self.metadata = None

        self.playlist.register('stopped', self.on_player_stopped)
        self.playlist.register('playing', self.on_player_playing)
        self.playlist.register('paused', self.on_player_paused)
        self.playlist.register('end-of-playlist',
                               self.on_player_end_of_playlist)
        self.playlist.register('new-track-loaded', self.on_player_new_track)
        self.playlist.register('new-metadata-available',
                               self.on_player_new_metadata)
        self.playlist.register('reset-playlist', self.on_player_reset_playlist)

        self.mainbox = QtGui.QVBoxLayout()
        self.mainbox.setContentsMargins(0, 0, 0, 0)
        self.mainbox.setSpacing(0)

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self.label_cover = QtGui.QLabel()
        self.label_cover.setContentsMargins(0, 5, 2, 5)
        self.label_cover.mousePressEvent = self.label_cover_callback
        layout.addWidget(self.label_cover)
        vlayout = QtGui.QVBoxLayout()
        vlayout.setContentsMargins(0, 0, 0, 0)
        vlayout.setSpacing(0)
        vlayout.addStretch(5)
        self.label_artist = QtGui.QLabel()
        self.label_album = QtGui.QLabel()
        self.label_artist.setContentsMargins(3, 0, 5, 10)
        self.label_album.setContentsMargins(3, 0, 5, 10)
        self.label_title = qtwidgets.ScrollingLabel(self.config)
        self.label_title.setContentsMargins(0, 0, 0, 0)
        vlayout.addWidget(self.label_artist)
        vlayout.addWidget(self.label_album)
        vlayout.addWidget(self.label_title)
        vlayout.addStretch(5)
        layout.addLayout(vlayout, 2)
        self.mainbox.addLayout(layout, 8)

        self.progress = QtGui.QProgressBar()
        self.progress.setContentsMargins(0, 0, 0, 0)
        self.mainbox.addWidget(self.progress)
        self.progress.setTextVisible(True)
        self.progress.setFormat("00:00 / 00:00")
        self.progress.setValue(0)
        self.progress.mousePressEvent = self.on_progress_clicked
        progress_height = self.config.getint("options", "progress_height")
        if progress_height != -1:
            self.progress.setFixedHeight(progress_height)

        self.icon_play = QtGui.QIcon(
            util.find_data_file('media-playback-start.png'))
        self.icon_pause = QtGui.QIcon(
            util.find_data_file('media-playback-pause.png'))

        self.button_rrewind = qtwidgets.DualActionButton(
            self.config,
            QtGui.QIcon(util.find_data_file('media-skip-backward.png')),
            self.button_rrewind_callback,
            QtGui.QIcon(util.find_data_file("gtk-goto-first-ltr.png")),
            self.playlist.prev)
        self.button_rewind = QtGui.QPushButton(
            QtGui.QIcon(util.find_data_file('media-seek-backward.png')), "")
        self.button_rewind.clicked.connect(self.button_rewind_callback)
        self.button_play = QtGui.QPushButton(self.icon_play, "")
        self.button_play.clicked.connect(self.button_play_callback)
        self.button_forward = QtGui.QPushButton(
            QtGui.QIcon(util.find_data_file('media-seek-forward.png')), "")
        self.button_forward.clicked.connect(self.button_forward_callback)
        self.button_fforward = qtwidgets.DualActionButton(
            self.config,
            QtGui.QIcon(util.find_data_file('media-skip-forward.png')),
            self.button_fforward_callback,
            QtGui.QIcon(util.find_data_file("gtk-goto-last-ltr.png")),
            self.playlist.next)
        self.button_bookmark = QtGui.QPushButton(
            QtGui.QIcon(util.find_data_file('bookmark-new.png')), "")
        self.button_bookmark.clicked.connect(self.button_bookmark_callback)

        button_height = self.config.getint("options", "button_height")
        if button_height != -1:
            self.button_rrewind.setFixedHeight(button_height)
            self.button_rewind.setFixedHeight(button_height)
            self.button_play.setFixedHeight(button_height)
            self.button_forward.setFixedHeight(button_height)
            self.button_fforward.setFixedHeight(button_height)
            self.button_bookmark.setFixedHeight(button_height)

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 4, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self.button_rrewind)
        layout.addWidget(self.button_rewind)
        layout.addWidget(self.button_play)
        layout.addWidget(self.button_forward)
        layout.addWidget(self.button_fforward)
        layout.addWidget(self.button_bookmark)
        self.mainbox.addLayout(layout)

        self.timer = QtCore.QTimer()
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.timer_callback)
Ejemplo n.º 14
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        QtCore.QObject.__init__(self)
        ObservableService.__init__(self, [], self.__log)
        self.config = settings.config
        interface.register_gui(self)
        self.playlist = playlist.Playlist(self.config)
        self.time_str = "00:00 / 00:00"
        self.progress_fraction = 0
        self.metadata = None

        self.app = QtGui.QApplication(["Panucci"])
        self.app.setWindowIcon(QtGui.QIcon(util.find_data_file('panucci.png')))
        self.view = QtDeclarative.QDeclarativeView()
        self.view.setResizeMode(
            QtDeclarative.QDeclarativeView.SizeRootObjectToView)
        self.view.closeEvent = self.close_main_window_callback
        self.context = self.view.rootContext()
        self.context.setContextProperty('main', self)
        self.context.setContextProperty('config', self.make_config())
        self.theme_controller = ThemeController(self.config)
        self.context.setContextProperty('themeController',
                                        self.theme_controller)
        self.context.setContextProperty('themes',
                                        self.theme_controller.get_themes())
        self.create_actions()
        engine = self.context.engine()
        self.image_provider = ImageProvider(self)
        engine.addImageProvider("cover", self.image_provider)

        self.playlist.register('stopped', self.on_player_stopped)
        self.playlist.register('playing', self.on_player_playing)
        self.playlist.register('paused', self.on_player_paused)
        self.playlist.register('end-of-playlist',
                               self.on_player_end_of_playlist)
        self.playlist.register('new-track-loaded', self.on_player_new_track)
        self.playlist.register('new-metadata-available',
                               self.on_player_new_metadata)
        self.playlist.register('reset-playlist', self.on_player_reset_playlist)

        self.timer = QtCore.QTimer()
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.timer_callback)
        if platform.HARMATTAN:
            self.view.setSource(util.find_data_file("qml/main_harmattan.qml"))
            self.view.showFullScreen()
        elif platform.FREMANTLE:
            self.view.setSource(util.find_data_file("qml/main_fremantle.qml"))
            self.view.showFullScreen()
        else:
            self.view.setSource(util.find_data_file("qml/main_default.qml"))
            self.view.show()

        self.playlist.init(filepath=filename)
        self.view.rootObject().property("root").start_scrolling_timer(
            self.config.getboolean("options", "scrolling_labels"))

        if platform.HANDSET:
            import dbus
            # Enable play/pause with headset button
            #interface.headset_device.connect_to_signal('Condition', \
            #        self.handle_headset_button)

            system_bus = dbus.SystemBus()
            self.headset_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input'
            self.headset_bt_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input'
            if platform.HARMATTAN:
                self.headset_bt_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input_0'
            elif platform.FREMANTLE:
                self.headset_bt_path = '/org/freedesktop/Hal/devices/computer_logicaldev_input_1'

            # Monitor connection state of headset
            system_bus.add_signal_receiver(self.handle_headset_connection_state, 'DeviceAdded', \
                    'org.freedesktop.Hal.Manager', None, '/org/freedesktop/Hal/Manager')

            # Monitor connection state of BT headset
            system_bus.add_signal_receiver(self.handle_headset_bt_connection_state, 'DeviceAdded', \
                    'org.freedesktop.Hal.Manager', None, '/org/freedesktop/Hal/Manager')

            # Monitor headset buttons
            system_bus.add_signal_receiver(self.handle_headset_button, 'Condition', \
                    'org.freedesktop.Hal.Device', None, self.headset_path)

            # Monitor BT headset buttons
            system_bus.add_signal_receiver(self.handle_headset_bt_button, 'Condition', \
                    'org.freedesktop.Hal.Device', None, self.headset_bt_path)

        self.app.exec_()