Exemple #1
0
    def __init__(self, name, manager):
        super().__init__(name, manager)

        self.unit_server.connect('notify::server-partition',
                                 self.notify_server_partition_cb)
        self.unit_server.ampd_client.connect('client-connected',
                                             self.client_connected_cb)

        self.outputs = []
        self.partitions = None

        self.output_menu = Gio.Menu()
        self.partition_section = Gio.Menu()

        self.new_resource_provider('app.action').add_resources(
            resource.ActionModel('partition-go',
                                 self.action_partition_go_del_cb,
                                 parameter_type=GLib.VariantType.new('s')),
            resource.ActionModel('partition-del',
                                 self.action_partition_go_del_cb,
                                 parameter_type=GLib.VariantType.new('s')),
            resource.ActionModel('partition-move-output',
                                 self.action_partition_move_output_cb,
                                 parameter_type=GLib.VariantType.new('(ss)')),
            resource.ActionModel('partition-new',
                                 self.action_partition_new_cb),
        )

        self.app_menu_provider = self.new_resource_provider('app.menu')
        self.app_menu_provider.add_resources(
            resource.MenuPath('server/server/partition/output',
                              _("Outputs (<Ctrl> to toggle)"),
                              instance=self.output_menu),
            resource.MenuPath('server/server/partition/parition',
                              instance=self.partition_section),
        )

        self.app_output_action_provider = self.new_resource_provider(
            'app.action')
        self.app_user_action_provider = self.new_resource_provider(
            'app.user-action')
Exemple #2
0
    def __init__(self, name, manager):
        super().__init__(name, manager)

        self.new_resource_provider('app.user-action').add_resources(
            resource.UserAction('mod.playlist-saveas(false)', _("Save as playlist"), 'edit/component'),
        )

        self.new_resource_provider('songlist.action').add_resources(
            resource.ActionModel('playlist-add', action_playlist_add_saveas_cb, parameter_type=GLib.VariantType.new('b')),
            resource.ActionModel('playlist-saveas', action_playlist_add_saveas_cb, parameter_type=GLib.VariantType.new('b'))
        )

        self.new_resource_provider('songlist.context.user-action').add_resources(
            resource.UserAction('mod.playlist-add(true)', _("Add to playlist"), 'other'),
        )

        self.new_resource_provider(Playlist.name + '.left-context.user-action').add_resources(
            resource.UserAction('mod.playlist-rename', _("Rename"), 'action'),
            resource.UserAction('mod.playlist-delete', _("Delete"), 'action'),
            resource.UserAction('mod.playlist-update-from-queue', _("Update from play queue"), 'action')
        )
Exemple #3
0
 def refresh_outputs(self, outputs):
     self.outputs = []
     for output in outputs:
         if output['plugin'] == 'dummy':
             continue
         output['action'] = 'output-' + output['outputid']
         self.app_output_action_provider.add_resource(
             resource.ActionModel(output['action'],
                                  self.action_output_activate_cb,
                                  state=GLib.Variant.new_boolean(
                                      int(output['outputenabled'])),
                                  dangerous=True))
         resource.MenuAction('app.' + output['action'],
                             output['outputname']).insert_into(
                                 self.output_menu)
         self.outputs.append(output)
Exemple #4
0
    def __init__(self, name, manager):
        super().__init__(name, manager)
        self.config.access('profiles', [
            {
                'name': self.LOCAL_HOST,
                'host': 'localhost',
                'port': 6600,
            },
        ])

        self.zeroconf_profiles = self.user_profiles = self.profiles = {}
        self.connect('notify::zeroconf-profiles', self.notify_profiles_cb)
        self.connect('notify::user-profiles', self.notify_profiles_cb)
        self.zeroconf_profile_menu = Gio.Menu()
        self.user_profile_menu = Gio.Menu()
        self.zeroconf_profiles_setup()
        self.user_profiles_setup()

        self.new_resource_provider('app.action').add_resources(
            resource.ActionModel('edit-user-profiles',
                                 self.edit_user_profiles_cb), )

        self.new_resource_provider('app.menu').add_resources(
            resource.MenuPath('server/profiles/profiles',
                              _("_Profiles"),
                              is_submenu=True),
            resource.MenuPath('server/profiles/profiles/zeroconf',
                              instance=self.zeroconf_profile_menu),
            resource.MenuPath('server/profiles/profiles/user',
                              instance=self.user_profile_menu),
            resource.MenuAction(
                'server/profiles/profiles/app.edit-user-profiles',
                _("Edit profiles")),
        )

        self.user_profiles_struct = ssde.List(
            label=_("Profiles"),
            substruct=ssde.Dict(label=_("Profile"),
                                substructs=[
                                    ssde.Text(name='name', label=_("Name")),
                                    ssde.Text(name='host', label=_("Host")),
                                    ssde.Integer(name='port',
                                                 label=_("Port"),
                                                 default=6600,
                                                 min_value=0),
                                ]))
Exemple #5
0
    def __init__(self, name, manager):
        super().__init__(name, manager)

        self.new_resource_provider('app.action').add_resources(
            resource.ActionModel('play-or-pause',
                                 self.play_or_pause_cb,
                                 dangerous=True),
            resource.ActionModel('absolute-jump',
                                 self.absolute_jump_cb,
                                 dangerous=True,
                                 parameter_type=GLib.VariantType.new('i')),
            resource.ActionModel('relative-jump',
                                 self.relative_jump_cb,
                                 dangerous=True,
                                 parameter_type=GLib.VariantType.new('i')),
            *(resource.ActionModel(name, self.mpd_command_cb, dangerous=True)
              for name in ('play', 'stop', 'next', 'previous')),
            *(resource.ActionModel('fade-to-' + name, self.fade_to_action_cb)
              for name in ('next', 'stop')),
        )

        self.new_resource_provider('app.menu').add_resources(
            resource.MenuPath('playback/play'),
            resource.MenuPath('playback/move'),
            resource.MenuPath('playback/jump'),
        )

        self.new_resource_provider('app.user-action').add_resources(
            resource.UserAction('app.play-or-pause',
                                _("_Play/pause"),
                                'playback/play',
                                ['<Control>Up', 'AudioPlay', 'space'],
                                accels_fragile=True),
            resource.UserAction('app.stop',
                                _("_Stop"),
                                'playback/play',
                                ['<Control>Down', 'AudioStop'],
                                accels_fragile=True),
            resource.UserAction('app.fade-to-stop',
                                _("Fade to stop"),
                                'playback/play',
                                ['<Control><Shift>Down', '<Shift>AudioStop'],
                                accels_fragile=True),
            resource.UserAction('app.previous',
                                _("_Previous"),
                                'playback/move',
                                ['<Control>Left', 'AudioPrev'],
                                accels_fragile=True),
            resource.UserAction('app.next',
                                _("_Next"),
                                'playback/move',
                                ['<Control>Right', 'AudioNext'],
                                accels_fragile=True),
            resource.UserAction('app.fade-to-next',
                                _("_Fade to next"),
                                'playback/move', ['<Control><Shift>Right'],
                                accels_fragile=True),
            resource.UserAction('app.absolute-jump(0)',
                                _("Restart playback"),
                                'playback/jump', ['<Alt>Up'],
                                accels_fragile=True),
            resource.UserAction('app.absolute-jump(-15)',
                                _("End of song (-{} seconds)").format(15),
                                'playback/jump', ['<Alt>Down'],
                                accels_fragile=True),
            resource.UserAction('app.relative-jump(-5)',
                                _("Skip backwards ({} seconds)").format(5),
                                'playback/jump', ['<Alt>Left'],
                                accels_fragile=True),
            resource.UserAction('app.relative-jump(5)',
                                _("Skip forwards ({} seconds)").format(5),
                                'playback/jump', ['<Alt>Right'],
                                accels_fragile=True),
        )

        self.fading = None
Exemple #6
0
    def __init__(self, name, manager):
        super().__init__(name, manager)
        self.ampd_client = ampd.ClientGLib()
        self.ampd_client.connect('client-connected', self.client_connected_cb)
        self.ampd_client.connect('client-disconnected',
                                 self.client_disconnected_cb)

        self.ampd = self.ampd_client.executor.sub_executor()

        self.ampd_server_properties = ampd.ServerPropertiesGLib(
            self.ampd_client.executor)
        self.ampd_server_properties.bind_property(
            'current-song', self, 'current-song',
            GObject.BindingFlags.SYNC_CREATE)
        self.ampd_server_properties.connect('server-error',
                                            self.server_error_cb)
        self.ampd_server_properties.connect('notify::updating-db',
                                            self.set_server_label)
        self.server_options = {
            name: ServerOption()
            for name in ampd.OPTION_NAMES
        }
        for name in ampd.OPTION_NAMES:
            self.ampd_server_properties.bind_property(
                name, self.server_options[name], 'value',
                GObject.BindingFlags.BIDIRECTIONAL
                | GObject.BindingFlags.SYNC_CREATE)

        self.host = self.port = None
        self.want_to_connect = False

        self.server_profile_desired = self.config.server.access(
            'profile-desired', self.unit_profiles.LOCAL_HOST)
        self.server_profile_previous = self.config.access(
            'server-profile-previous', self.server_profile_desired)
        self.server_profile_backup = self.server_profile_desired

        self.connect('notify::server-profile', self.notify_server_profile_cb)
        self.connect('notify::server-partition',
                     self.notify_server_partition_cb)
        self.connect('notify::server-profile-desired',
                     self.notify_server_profile_desired_cb)

        self.unit_profiles.connect('notify::profiles', self.notify_profiles_cb)

        self.separator_song = {'file': self.SEPARATOR_FILE}

        self.new_resource_provider('app.action').add_resources(
            resource.PropertyActionModel('server-profile-desired', self),
            resource.ActionModel('connect', self.ampd_connect),
            resource.ActionModel('disconnect', self.ampd_disconnect),
            resource.ActionModel('connect-to-previous',
                                 self.ampd_connect_to_previous),
            resource.ActionModel('update', self.update_cb),
            *(resource.PropertyActionModel(name,
                                           self.server_options[name],
                                           property_name='value')
              for name in ampd.OPTION_NAMES))

        self.new_resource_provider('app.menu').add_resources(
            resource.MenuPath('server/server/actions'),
            resource.MenuPath('server/server/options'),
            resource.MenuPath('server/server/partition'),
            resource.MenuPath('server/server/connection'),
        )

        self.new_resource_provider('app.user-action').add_resources(
            resource.UserAction('app.update', _("Update database"),
                                'server/server/actions'),
            resource.UserAction('app.random', _("Random mode"),
                                'server/server/options'),
            resource.UserAction('app.repeat', _("Repeat mode"),
                                'server/server/options'),
            resource.UserAction('app.consume', _("Consume mode"),
                                'server/server/options'),
            resource.UserAction('app.single', _("Single mode"),
                                'server/server/options'),
            resource.UserAction('app.connect', _("Connect"),
                                'server/server/connection', ['<Alt><Shift>c']),
            resource.UserAction('app.disconnect', _("Disconnect"),
                                'server/server/connection', ['<Alt><Shift>d']),
            resource.UserAction('app.connect-to-previous',
                                _("Connect to previous"),
                                'server/server/connection',
                                ['<Control><Alt>p']),
        )
Exemple #7
0
    def __init__(self, name, manager):
        super().__init__(name, manager)

        self.fields = data.FieldFamily(self.config.fields)
        self.fields.register_field(data.Field('Artist', _("Artist")))
        self.fields.register_field(data.Field('Genre', _("Genre")))
        self.fields.register_field(
            data.Field('Years_Min',
                       visible=False,
                       get_value=lambda tanda: min(
                           song.get('Date', '').split('-', 1)[0]
                           for song in tanda['_songs']) or '????'
                       if tanda.get('_songs') else None))
        self.fields.register_field(
            data.Field('Years_Max',
                       visible=False,
                       get_value=lambda tanda: max(
                           song.get('Date', '').split('-', 1)[0]
                           for song in tanda['_songs']) or '????'
                       if tanda.get('_songs') else None))
        self.fields.register_field(
            data.Field(
                'Years',
                _("Years"),
                get_value=lambda tanda:
                ('\'{}'.format(tanda['Years_Min'][2:])
                 if tanda['Years_Min'] == tanda['Years_Max'] else '\'{}-\'{}'.
                 format(tanda['Years_Min'][2:], tanda['Years_Max'][2:]))
                if 'Years_Min' in tanda and 'Years_Max' in tanda else '????'))
        self.fields.register_field(
            data.Field('First_Song',
                       _("First song"),
                       get_value=lambda tanda: tanda['_songs'][0]['Title']
                       if '_songs' in tanda else '???'))
        self.fields.register_field(data.Field('Performer', _("Performer")))
        self.fields.register_field(data.Field('Comment', _("Comment")))
        self.fields.register_field(data.Field('Description', _("Description")))
        self.fields.register_field(data.Field('Note', _("Note"), min_width=30))
        self.fields.register_field(
            data.Field('Rhythm', _("Rhythm"), min_width=30))
        self.fields.register_field(
            data.Field('Energy', _("Energy"), min_width=30))
        self.fields.register_field(
            data.Field('Speed', _("Speed"), min_width=30))
        self.fields.register_field(
            data.Field('Emotion', _("Emotion"), min_width=30))

        self.fields.register_field(
            data.Field('Drama', _("Drama"), min_width=30))
        self.fields.register_field(
            data.Field('Romance', _("Romance"), min_width=30))

        self.fields.register_field(
            data.Field('Last_Modified', _("Last modified")))
        self.fields.register_field(data.Field('Last_Played', _("Last played")))
        self.fields.register_field(
            data.Field('Last_Played_Weeks',
                       _("Weeks since last played"),
                       min_width=30,
                       get_value=get_last_played_weeks))
        self.fields.register_field(
            data.Field('n_songs',
                       _("Number of songs"),
                       min_width=30,
                       get_value=lambda tanda: 0
                       if not tanda.get('_songs') else None
                       if (len(tanda.get('_songs')) == 4 and tanda.get('Genre')
                           .startswith('Tango')) or
                       (len(tanda.get('_songs')) == 3 and tanda.get('Genre') in
                        {'Vals', 'Milonga'}) else len(tanda.get('_songs'))))
        self.fields.register_field(
            data.Field('Duration',
                       _("Duration"),
                       get_value=lambda tanda: data.format_time(
                           sum((int(song['Time']))
                               for song in tanda.get('_songs', [])))))

        self.db = TandaDatabase(self.fields, self)

        self.new_resource_provider('app.action').add_resources(
            resource.ActionModel('tanda-verify',
                                 self.db.action_tanda_verify_cb),
            resource.ActionModel('tanda-cleanup-db',
                                 self.db.action_cleanup_db_cb),
        )

        self.new_resource_provider('app.user-action').add_resources(
            resource.UserAction('mod.tanda-fill-field', _("Fill tanda field"),
                                'edit/component', ['<Control>z']),
            resource.UserAction('mod.tanda-reset-field',
                                _("Reset tanda field"), 'edit/component',
                                ['<Control><Shift>z']),
            resource.UserAction('mod.tanda-reset', _("Reset tanda"),
                                'edit/component', ['<Control><Shift>r']),
            resource.UserAction('mod.tanda-delete', _("Delete tanda"),
                                'edit/component', ['<Control>Delete']),
            resource.UserAction('supermod.tanda-switch-subcomponent',
                                _("Switch tanda view mode"), 'edit/component',
                                ['<Control>Tab']),
            resource.UserAction('supermod.tanda-verify',
                                _("Verify tanda database"), 'edit/component',
                                ['<Control><Shift>d']),
            resource.UserAction('supermod.tanda-cleanup-db',
                                _("Cleanup database"), 'edit/component'))

        self.new_resource_provider('songlist.action').add_resources(
            resource.ActionModel('tanda-define',
                                 self.db.action_tanda_define_cb), )

        self.new_resource_provider(
            'songlist.context.user-action').add_resources(
                resource.UserAction('mod.tanda-define', _("Define tanda"),
                                    'other'))

        self.new_resource_provider(
            'tanda-edit.left-context.user-action').add_resources(
                resource.UserAction('mod.tanda-delete', _("Delete tanda"),
                                    'edit'))

        self.setup_menu('tanda-edit', 'context', ['songlist'])
        self.setup_menu('tanda-edit', 'left-context', ['songlist'])
        self.setup_menu('tanda-view', 'context', ['songlist'])
Exemple #8
0
    def __init__(self, name, manager):
        super().__init__(name, manager)

        self.new_resource_provider('app.user-action').add_resources(
            resource.UserAction('mod.playqueue-shuffle', _("Shuffle"),
                                'edit/component'),
            resource.UserAction('mod.playqueue-go-to-current',
                                _("Go to current song"), 'edit/component',
                                ['<Control>z']))

        self.new_resource_provider('songlist.action').add_resources(
            resource.ActionModel('playqueue-ext-add-high-priority',
                                 action_playqueue_add_high_priority_cb,
                                 dangerous=True,
                                 parameter_type=GLib.VariantType.new('b')),
            *(resource.ActionModel('playqueue-ext' + verb,
                                   action_playqueue_add_replace_cb,
                                   dangerous=(verb == '-replace'),
                                   parameter_type=GLib.VariantType.new('b'))
              for verb in ('-add', '-replace')),
        )

        for name, parameter in (('context', '(true)'), ('left-context',
                                                        '(false)')):
            self.new_resource_provider(
                'songlist.{name}.user-action'.format(name=name)).add_resources(
                    resource.UserAction('mod.playqueue-ext-add' + parameter,
                                        _("Add to play queue"), 'action'),
                    resource.UserAction(
                        'mod.playqueue-ext-replace' + parameter,
                        _("Replace play queue"), 'action'),
                    resource.UserAction(
                        'mod.playqueue-ext-add-high-priority' + parameter,
                        _("Add to play queue with high priority"), 'action'),
                )

        self.new_resource_provider(PlayQueue.name +
                                   '.context.menu').add_resources(
                                       resource.MenuPath(
                                           'other/playqueue-priority',
                                           _("Priority for random mode"),
                                           is_submenu=True), )

        self.new_resource_provider(PlayQueue.name +
                                   '.context.user-action').add_resources(
                                       resource.UserAction(
                                           'mod.playqueue-high-priority',
                                           _("High"),
                                           'other/playqueue-priority'),
                                       resource.UserAction(
                                           'mod.playqueue-normal-priority',
                                           _("Normal"),
                                           'other/playqueue-priority'),
                                       resource.UserAction(
                                           'mod.playqueue-choose-priority',
                                           _("Choose"),
                                           'other/playqueue-priority'),
                                       resource.UserAction(
                                           'mod.playqueue-shuffle',
                                           _("Shuffle"), 'other'),
                                   )