Esempio n. 1
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        kwds = {"parent":None, "log":self.__log}
        super(PanucciGUI, self).__init__(**kwds)
        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 = QtWidgets.QApplication(["Panucci"])
        self.app.setWindowIcon(QtGui.QIcon(util.find_data_file('panucci.png')))
        self.app.aboutToQuit.connect(self.about_to_quit_callback)
        self.view = QtQuick.QQuickView()
        self.view.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView)
        self.view.setDefaultAlphaBuffer(True)
        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.SAILFISH:
            self.view.setSource(QtCore.QUrl(util.find_data_file("qml2/main_sailfish.qml")))
            self.view.showFullScreen()
        else:
            self.view.setSource(QtCore.QUrl(util.find_data_file("qml2/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"))
        #print self.view.size()
        self.app.exec_()
Esempio n. 2
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        interface.register_gui(self)
        self.config = settings.config
        self.playlist = playlist.Playlist(self.config)

        self.app = QtGui.QApplication(["Panucci"])
        self.app.setWindowIcon(QtGui.QIcon(util.find_data_file('panucci.png')))
        self.main_window = QtGui.QMainWindow(None)
        if platform.FREMANTLE:
            self.main_window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow)
        self.main_window.closeEvent = self.close_main_window_callback
        self.create_actions()
        self.__player_tab = PlayerTab(self)
        self.__playlist_tab = qtplaylist.PlaylistTab(self, self.playlist)
        if platform.MAEMO:
            self.create_maemo_menus()
        else:
            self.create_menus()
        widget = QtGui.QWidget()
        widget.setLayout(self.__player_tab.mainbox)
        self.main_window.setCentralWidget(widget)
        self.main_window.show()
        self.playlist.init(filepath=filename)
        self.app.exec_()
Esempio n. 3
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        interface.register_gui(self)
        self.config = settings.config
        self.playlist = playlist.Playlist(self.config)

        self.app = QtGui.QApplication(["Panucci"])
        self.app.setWindowIcon(QtGui.QIcon(util.find_data_file('panucci.png')))
        self.main_window = QtGui.QMainWindow(None)
        if platform.FREMANTLE:
            self.main_window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow)
        self.main_window.closeEvent = self.close_main_window_callback
        self.create_actions()
        self.__player_tab = PlayerTab(self)
        self.__playlist_tab = qtplaylist.PlaylistTab(self, self.playlist)
        if platform.HANDSET:
            self.create_handset_menus()
        else:
            self.create_menus()
        widget = QtGui.QWidget()
        widget.setLayout(self.__player_tab.mainbox)
        self.main_window.setCentralWidget(widget)
        if platform.HARMATTAN:
            self.main_window.setAttribute(
                QtCore.Qt.WA_LockLandscapeOrientation)
        self.main_window.show()
        self.playlist.init(filepath=filename)
        self.app.exec_()
Esempio n. 4
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        interface.register_gui(self)
        self.config = settings.config
        self.playlist = playlist.Playlist(self.config)

        window = gtk.Window(gtk.WindowType.TOPLEVEL)
        self.main_window = window
        window.set_title('Panucci')
        self.window_icon = util.find_data_file('panucci.png')
        if self.window_icon is not None:
            window.set_icon_from_file( self.window_icon )
        window.set_default_size(400, -1)
        window.set_border_width(0)
        window.connect("destroy", self.destroy)

        self.__player_tab = PlayerTab(self)
        self.__playlist_tab = gtkplaylist.PlaylistTab(self, self.playlist)

        self.create_actions()

        self.playlist_window = gtk.Window(gtk.WindowType.TOPLEVEL)
        self.playlist_window.connect('delete-event', gtk.Widget.hide_on_delete)
        self.playlist_window.set_title(_('Playlist'))
        self.playlist_window.set_transient_for(self.main_window)
        self.playlist_window.add(self.__playlist_tab)

        menu_vbox = gtk.Grid.new()
        menu_vbox.set_property("orientation", gtk.Orientation.VERTICAL)
        window.add(menu_vbox)
        menu_bar = gtk.MenuBar()
        self.create_desktop_menu(menu_bar)
        menu_vbox.add(menu_bar)
        menu_bar.show()
        menu_vbox.add(self.__player_tab)

        # Tie it all together!
        self.__ignore_queue_check = False
        self.__window_fullscreen = False

        self.main_window.connect('key-press-event', self.on_key_press)
        self.playlist.register( 'file_queued', self.on_file_queued )

        self.playlist.register( 'playlist-to-be-overwritten',
                                  self.check_queue )
        self.__player_tab.register( 'select-current-item-request',
                                    self.__select_current_item )

        self.main_window.show_all()

        # this should be done when the gui is ready
        self.playlist.init(filepath=filename)

        pos_int, dur_int = self.playlist.get_position_duration()
        # This prevents bogus values from being set while seeking
        if (pos_int > 10**9) and (dur_int > 10**9):
            self.__player_tab.set_progress_callback(pos_int, dur_int)

        gtk.main()
Esempio n. 5
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        interface.register_gui(self)
        self.config = settings.config
        self.playlist = playlist.Playlist(self.config)

        window = gtk.Window(gtk.WindowType.TOPLEVEL)
        self.main_window = window
        window.set_title('Panucci')
        self.window_icon = util.find_data_file('panucci.png')
        if self.window_icon is not None:
            window.set_icon_from_file(self.window_icon)
        window.set_default_size(400, -1)
        window.set_border_width(0)
        window.connect("destroy", self.destroy)

        self.__player_tab = PlayerTab(self)
        self.__playlist_tab = gtkplaylist.PlaylistTab(self, self.playlist)

        self.create_actions()

        self.playlist_window = gtk.Window(gtk.WindowType.TOPLEVEL)
        self.playlist_window.connect('delete-event', gtk.Widget.hide_on_delete)
        self.playlist_window.set_title(_('Playlist'))
        self.playlist_window.set_transient_for(self.main_window)
        self.playlist_window.add(self.__playlist_tab)

        menu_vbox = gtk.Grid.new()
        menu_vbox.set_property("orientation", gtk.Orientation.VERTICAL)
        window.add(menu_vbox)
        menu_bar = gtk.MenuBar()
        self.create_desktop_menu(menu_bar)
        menu_vbox.add(menu_bar)
        menu_bar.show()
        menu_vbox.add(self.__player_tab)

        # Tie it all together!
        self.__ignore_queue_check = False
        self.__window_fullscreen = False

        self.main_window.connect('key-press-event', self.on_key_press)
        self.playlist.register('file_queued', self.on_file_queued)

        self.playlist.register('playlist-to-be-overwritten', self.check_queue)
        self.__player_tab.register('select-current-item-request',
                                   self.__select_current_item)

        self.main_window.show_all()

        # this should be done when the gui is ready
        self.playlist.init(filepath=filename)

        pos_int, dur_int = self.playlist.get_position_duration()
        # This prevents bogus values from being set while seeking
        if (pos_int > 10**9) and (dur_int > 10**9):
            self.__player_tab.set_progress_callback(pos_int, dur_int)

        gtk.main()
Esempio n. 6
0
 def notify(self, message):
     """ Sends a notification using pynotify, returns message """
     if platform.DESKTOP and have_pynotify:
         icon = util.find_data_file('panucci_64x64.png')
         notification = pynotify.Notification(self.main_window.get_title(), message, icon)
         notification.show()
     elif platform.FREMANTLE:
         hildon.hildon_banner_show_information(self.main_window, \
                 '', message)
     elif platform.MAEMO:
         # Note: This won't work if we're not in the gtk main loop
         markup = '<b>%s</b>\n<small>%s</small>' % (self.main_window.get_title(), message)
         hildon.hildon_banner_show_information_with_markup(self.main_window, None, markup)
Esempio n. 7
0
 def __init__(self):
     self.__log = logging.getLogger('panucci.settings.Settings')
     self.config = ConfigParser.SafeConfigParser()
     # Parse everything
     _file = open(util.find_data_file("default.conf"))
     self.config.readfp(_file)
     _file.close()
     # Parse non editable
     if os.path.exists(panucci.HOME + '/panucci-noedit.conf'):
         _file = open(panucci.HOME + "/panucci-noedit.conf")
         self.config.readfp(_file)
         _file.close()
     # Parse editable
     _file = open(panucci.SETTINGS_FILE)
     self.config.readfp(_file)
     _file.close()
Esempio n. 8
0
def generate_image(filename, is_stock=False):
    image = None
    if is_stock:
        image = gtk.image_new_from_stock(
            filename, gtk.icon_size_from_name('panucci-button') )
    else:
        filename = util.find_data_file(filename)
        if filename is not None:
            image = gtk.image_new_from_file(filename)
    if image is not None:
        if platform.MAEMO:
            image.set_padding(20, 20)
        else:
            image.set_padding(5, 5)
        image.show()
    return image
Esempio n. 9
0
 def __init__(self):
     self.__log = logging.getLogger('panucci.settings.Settings')
     self.config = ConfigParser.SafeConfigParser()
     # Parse everything
     _file = open(util.find_data_file("default.conf"))
     self.config.readfp(_file)
     _file.close()
     # Parse non editable
     if os.path.exists(panucci.HOME + '/panucci-noedit.conf'):
         _file = open(panucci.HOME + "/panucci-noedit.conf")
         self.config.readfp(_file)
         _file.close()
     # Parse editable
     _file = open(panucci.SETTINGS_FILE)
     self.config.readfp(_file)
     _file.close()
Esempio n. 10
0
 def __init__(self):
     self.__log = logging.getLogger('panucci.settings.Settings')
     self.config = ConfigParser.SafeConfigParser()
     # Parse everything
     _file = open(util.find_data_file("panucci-all.conf"))
     self.config.readfp(_file)
     _file.close()
     # Parse non editable 
     if os.path.exists(CONFIG_FOLDER + '/panucci-noedit.conf'):
         _file = open(CONFIG_FOLDER + "/panucci-noedit.conf")
         self.config.readfp(_file)
         _file.close()
     # Parse editable
     _file = open(CONFIG_FOLDER + "/panucci.conf")
     self.config.readfp(_file)
     _file.close()
Esempio n. 11
0
 def notify(self, message):
     """ Sends a notification using pynotify, returns message """
     if platform.DESKTOP and have_pynotify:
         icon = util.find_data_file('panucci_64x64.png')
         notification = pynotify.Notification(self.main_window.get_title(),
                                              message, icon)
         notification.show()
     elif platform.FREMANTLE:
         hildon.hildon_banner_show_information(self.main_window, \
                 '', message)
     elif platform.MAEMO:
         # Note: This won't work if we're not in the gtk main loop
         markup = '<b>%s</b>\n<small>%s</small>' % (
             self.main_window.get_title(), message)
         hildon.hildon_banner_show_information_with_markup(
             self.main_window, None, markup)
Esempio n. 12
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        interface.register_gui(self)
        self.config = settings.config
        self.playlist = playlist.Playlist(self.config)

        # Build the base ui (window and menubar)
        if platform.MAEMO:
            self.app = hildon.Program()
            if platform.FREMANTLE:
                window = hildon.StackableWindow()
            else:
                window = hildon.Window()
            self.app.add_window(window)
        else:
            window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.main_window = window
        window.set_title('Panucci')
        self.window_icon = util.find_data_file('panucci.png')
        if self.window_icon is not None:
            window.set_icon_from_file( self.window_icon )
        window.set_default_size(400, -1)
        window.set_border_width(0)
        window.connect("destroy", self.destroy)

        # Add the tabs (they are private to prevent us from trying to do
        # something like gui_root.player_tab.some_function() from inside
        # playlist_tab or vice-versa)
        self.__player_tab = PlayerTab(self)
        self.__playlist_tab = gtkplaylist.PlaylistTab(self, self.playlist)

        self.create_actions()

        if platform.FREMANTLE:
            self.playlist_window = hildon.StackableWindow()
            self.playlist_window.set_app_menu(self.create_playlist_app_menu())
        else:
            self.playlist_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.playlist_window.connect('delete-event', gtk.Widget.hide_on_delete)
        self.playlist_window.set_title(_('Playlist'))
        self.playlist_window.set_transient_for(self.main_window)
        self.playlist_window.add(self.__playlist_tab)

        if platform.MAEMO:
            if platform.FREMANTLE:
                window.set_app_menu(self.create_app_menu())
            else:
                window.set_menu(self.create_menu())
            window.add(self.__player_tab)
        else:
            menu_vbox = gtk.VBox()
            menu_vbox.set_spacing(0)
            window.add(menu_vbox)
            menu_bar = gtk.MenuBar()
            self.create_desktop_menu(menu_bar)
            menu_vbox.pack_start(menu_bar, False, False, 0)
            menu_bar.show()
            menu_vbox.pack_end(self.__player_tab, True, True, 6)

        # Tie it all together!
        self.__ignore_queue_check = False
        self.__window_fullscreen = False

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

            PATH = '/org/freedesktop/Hal/devices/computer_logicaldev_input_1'
            # Monitor connection state of BT headset
            system_bus.add_signal_receiver(self.handle_connection_state, 'DeviceAdded', \
                    'org.freedesktop.Hal.Manager', None, '/org/freedesktop/Hal/Manager')

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

        self.main_window.connect('key-press-event', self.on_key_press)
        self.playlist.register( 'file_queued', self.on_file_queued )

        self.playlist.register( 'playlist-to-be-overwritten',
                                  self.check_queue )
        self.__player_tab.register( 'select-current-item-request',
                                    self.__select_current_item )

        self.main_window.show_all()

        # this should be done when the gui is ready
        self.playlist.init(filepath=filename)

        pos_int, dur_int = self.playlist.get_position_duration()
        # This prevents bogus values from being set while seeking
        if (pos_int > 10**9) and (dur_int > 10**9):
            self.__player_tab.set_progress_callback(pos_int, dur_int)

        gtk.main()
Esempio n. 13
0
    def __init__(self, settings, filename=None):
        self.__log = logging.getLogger('panucci.panucci.PanucciGUI')
        interface.register_gui(self)
        self.config = settings.config
        self.playlist = playlist.Playlist(self.config)

        # Build the base ui (window and menubar)
        if platform.MAEMO:
            self.app = hildon.Program()
            if platform.FREMANTLE:
                window = hildon.StackableWindow()
            else:
                window = hildon.Window()
            self.app.add_window(window)
        else:
            window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.main_window = window
        window.set_title('Panucci')
        self.window_icon = util.find_data_file('panucci.png')
        if self.window_icon is not None:
            window.set_icon_from_file(self.window_icon)
        window.set_default_size(400, -1)
        window.set_border_width(0)
        window.connect("destroy", self.destroy)

        # Add the tabs (they are private to prevent us from trying to do
        # something like gui_root.player_tab.some_function() from inside
        # playlist_tab or vice-versa)
        self.__player_tab = PlayerTab(self)
        self.__playlist_tab = gtkplaylist.PlaylistTab(self, self.playlist)

        self.create_actions()

        if platform.FREMANTLE:
            self.playlist_window = hildon.StackableWindow()
            self.playlist_window.set_app_menu(self.create_playlist_app_menu())
        else:
            self.playlist_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.playlist_window.connect('delete-event', gtk.Widget.hide_on_delete)
        self.playlist_window.set_title(_('Playlist'))
        self.playlist_window.set_transient_for(self.main_window)
        self.playlist_window.add(self.__playlist_tab)

        if platform.MAEMO:
            if platform.FREMANTLE:
                window.set_app_menu(self.create_app_menu())
            else:
                window.set_menu(self.create_menu())
            window.add(self.__player_tab)
        else:
            menu_vbox = gtk.VBox()
            menu_vbox.set_spacing(0)
            window.add(menu_vbox)
            menu_bar = gtk.MenuBar()
            self.create_desktop_menu(menu_bar)
            menu_vbox.pack_start(menu_bar, False, False, 0)
            menu_bar.show()
            menu_vbox.pack_end(self.__player_tab, True, True, 6)

        # Tie it all together!
        self.__ignore_queue_check = False
        self.__window_fullscreen = False

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

            # Monitor connection state of BT headset
            # I haven't seen this option before "settings.play_on_headset"
            PATH = '/org/freedesktop/Hal/devices/computer_logicaldev_input_1'

            def handler_func(device_path):
                if device_path == PATH and settings.play_on_headset and not self.playlist.player.playing:
                    self.playlist.player.play()
            system_bus.add_signal_receiver(handler_func, 'DeviceAdded', \
                    'org.freedesktop.Hal.Manager', None, \
                    '/org/freedesktop/Hal/Manager')

            # End Monitor connection state of BT headset

            # Monitor BT headset buttons
            def handle_bt_button(signal, button):
                # See http://bugs.maemo.org/8283 for details
                if signal == 'ButtonPressed':
                    if button == 'play-cd':
                        self.playlist.player.play_pause_toggle()
                    elif button == 'pause-cd':
                        self.playlist.player.pause()
                    elif button == 'next-song':
                        self.__player_tab.do_seek(
                            self.config.getint("options", "seek_short"))
                    elif button == 'previous-song':
                        self.__player_tab.do_seek(
                            -1 * self.config.getint("options", "seek_short"))

            system_bus.add_signal_receiver(handle_bt_button, 'Condition', \
                    'org.freedesktop.Hal.Device', None, PATH)
            # End Monitor BT headset buttons

        self.main_window.connect('key-press-event', self.on_key_press)
        self.playlist.register('file_queued', self.on_file_queued)

        self.playlist.register('playlist-to-be-overwritten', self.check_queue)
        self.__player_tab.register('select-current-item-request',
                                   self.__select_current_item)

        self.main_window.show_all()

        # this should be done when the gui is ready
        self.playlist.init(filepath=filename)

        pos_int, dur_int = self.playlist.player.get_position_duration()
        # This prevents bogus values from being set while seeking
        if (pos_int > 10**9) and (dur_int > 10**9):
            self.set_progress_callback(pos_int, dur_int)

        gtk.main()
Esempio 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_()
Esempio n. 15
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)
Esempio n. 16
0
    def __init__(self, parent, version):
        self.ad = QtGui.QDialog(parent)
        self.ad.setWindowTitle(_("About").decode("utf-8"))
        main_layout = QtGui.QVBoxLayout()
        self.ad.setLayout(main_layout)

        hlayout = QtGui.QHBoxLayout()
        label = QtGui.QLabel()
        pixmap = QtGui.QPixmap(util.find_data_file('panucci_64x64.png'))
        label.setPixmap(pixmap)
        hlayout.addWidget(label)

        vlayout = QtGui.QVBoxLayout()
        label = QtGui.QLabel()
        label.setText('<b><big>' + about.about_name + " " + version + '</b></big>')
        vlayout.addWidget(label, 2)
        label = QtGui.QLabel()
        label.setText(about.about_text.decode("utf-8"))
        vlayout.addWidget(label, 2)
        label = QtGui.QLabel(about.about_copyright)
        vlayout.addWidget(label, 2)
        label = QtGui.QLabel("<qt><a href='%s'>"%(about.about_website) + about.about_website + "</a></qt>")
        label.setOpenExternalLinks(True)
        vlayout.addWidget(label, 2)
        hlayout.addLayout(vlayout, 2)
        main_layout.addLayout(hlayout)

        layout = QtGui.QHBoxLayout()
        layout.addStretch(2)
        button = QtGui.QPushButton(_("Credits").decode("utf-8"))
        button.clicked.connect(self.show_credits)
        layout.addWidget(button)
        button = QtGui.QPushButton(_("Close").decode("utf-8"))
        button.clicked.connect(self.close)
        layout.addWidget(button)
        main_layout.addLayout(layout)

        self.cd = QtGui.QDialog(self.ad)
        self.cd.setWindowTitle(_("Credits").decode("utf-8"))
        self.cd.setModal(True)
        layout = QtGui.QVBoxLayout()
        self.cd.setLayout(layout)

        tw = QtGui.QTabWidget()
        layout.addWidget(tw)
        te = QtGui.QTextEdit()
        tw.addTab(te, _("Authors").decode("utf-8"))
        te.setReadOnly(True)
        for i in about.about_authors:
            te.append(i)
        te = QtGui.QTextEdit()
        tw.addTab(te, _("Contributors").decode("utf-8"))
        te.setReadOnly(True)
        for i in about.about_contributors:
            te.append(i)

        hlayout = QtGui.QHBoxLayout()
        label = QtGui.QLabel()
        hlayout.addWidget(label, 2)
        button = QtGui.QPushButton(_("Close").decode("utf-8"))
        button.clicked.connect(self.close_credits)
        hlayout.addWidget(button)

        layout.addLayout(hlayout)
        self.ad.exec_()
Esempio n. 17
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_()
Esempio n. 18
0
#
# You should have received a copy of the GNU General Public License
# along with Panucci.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import

import logging
import os.path
import ConfigParser

import panucci
from panucci import util

if not os.path.exists(panucci.SETTINGS_FILE):
    import shutil
    _filepath = util.find_data_file("panucci.conf")
    shutil.copy(_filepath, panucci.HOME)

if not os.path.exists(panucci.THEME_FILE):
    import shutil
    _filepath = util.find_data_file("theme.conf")
    shutil.copy(_filepath, panucci.HOME)


class Settings(object):
    def __init__(self):
        self.__log = logging.getLogger('panucci.settings.Settings')
        self.config = ConfigParser.SafeConfigParser()
        # Parse everything
        _file = open(util.find_data_file("default.conf"))
        self.config.readfp(_file)
Esempio n. 19
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)
Esempio n. 20
0
#
# You should have received a copy of the GNU General Public License
# along with Panucci.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import

import logging
import os.path
import ConfigParser

import panucci
from panucci import util

if not os.path.exists(panucci.SETTINGS_FILE):
    import shutil
    _filepath = util.find_data_file("panucci.conf")
    shutil.copy(_filepath, panucci.HOME)

if not os.path.exists(panucci.THEME_FILE):
    import shutil
    _filepath = util.find_data_file("theme.conf")
    shutil.copy(_filepath, panucci.HOME)

class Settings(object):
    def __init__(self):
        self.__log = logging.getLogger('panucci.settings.Settings')
        self.config = ConfigParser.SafeConfigParser()
        # Parse everything
        _file = open(util.find_data_file("default.conf"))
        self.config.readfp(_file)
        _file.close()