Example #1
0
 def _make_convert_menu(self):
     convert_menu = []
     sections = conversion_manager.get_converters()
     for index, section in enumerate(sections):
         for converter in section[1]:
             def convert(converter=converter.identifier):
                 app.widgetapp.convert_items(converter)
             convert_menu.append((converter.displayname, convert))
         if index+1 < len(sections):
             convert_menu.append(None)
     convert_menu.append(None)
     convert_menu.append((_("Show Conversion Folder"),
                          app.widgetapp.reveal_conversions_folder))
     return convert_menu
Example #2
0
    def _make_convert_menu(self):
        convert_menu = []
        sections = conversion_manager.get_converters()
        for index, section in enumerate(sections):
            for converter in section[1]:

                def convert(converter=converter.identifier):
                    app.widgetapp.convert_items(converter)

                convert_menu.append((converter.displayname, convert))
            if index + 1 < len(sections):
                convert_menu.append(None)
        convert_menu.append(None)
        convert_menu.append((_("Show Conversion Folder"),
                             app.widgetapp.reveal_conversions_folder))
        return convert_menu
Example #3
0
 def __init__(self):
     widgetset.VBox.__init__(self)
     self.boxes = {}
     self.device = None
     audio_conversion_names = [_('Device Default')]
     self.audio_conversion_values = [None]
     video_conversion_names = [_('Device Default')]
     self.video_conversion_values = [None]
     for section_name, converters in conversion_manager.get_converters():
         for converter in converters:
             if converter.mediatype == 'video':
                 video_conversion_names.append(converter.name)
                 self.video_conversion_values.append(converter.identifier)
             elif converter.mediatype == 'audio':
                 audio_conversion_names.append(converter.name)
                 self.audio_conversion_values.append(converter.identifier)
     for text, setting, type_ in (
         (_("Name of Device"), 'name', 'text'),
         (_("Video Conversion"), 'video_conversion', 'video_conversion'),
         (_("Audio Conversion"), 'audio_conversion', 'audio_conversion'),
         (_("Video Location"), 'video_path', 'text'),
         (_("Audio Location"), 'audio_path', 'text'),
         (_("Always Show?"), 'always_show', 'bool')
         ):
         if type_ == 'text':
             widget = widgetset.TextEntry()
         elif type_.endswith('conversion'):
             if type_ == 'video_conversion':
                 options = video_conversion_names
             elif type_ == 'audio_conversion':
                 options = audio_conversion_names
             widget = widgetset.OptionMenu(options)
         elif type_== 'bool':
             widget = widgetset.Checkbox(text)
         else:
             raise RuntimeError('unknown settings widget: %r' % type_)
         self.boxes[setting] = widget
         if type_ != 'bool': # has a label already
             hbox = widgetset.HBox()
             hbox.pack_start(widgetset.Label(text))
             hbox.pack_start(widget)
             self.pack_start(hbox)
             widget.connect('changed', self.setting_changed, setting)
         else:
             self.pack_start(widget)
             widget.connect('toggled', self.setting_changed, setting)
Example #4
0
 def create_table(self):
     self.remove()
     def _get_conversion_name(id_):
         if id_ == 'copy':
             return _('Copy')
         else:
             return conversion_manager.lookup_converter(id_).name
     conversion_details = {
         'audio': _get_conversion_name(self.device.info.audio_conversion),
         'video': _get_conversion_name(self.device.info.video_conversion)
         }
     audio_conversion_names = [_('Device Default (%(audio)s)',
                                 conversion_details), _('Copy')]
     self.audio_conversion_values = [None, 'copy']
     video_conversion_names = [_('Device Default (%(video)s)',
                                 conversion_details), _('Copy')]
     self.video_conversion_values = [None, 'copy']
     for section_name, converters in conversion_manager.get_converters():
         for converter in converters:
             if converter.mediatype == 'video':
                 video_conversion_names.append(converter.name)
                 self.video_conversion_values.append(converter.identifier)
             elif converter.mediatype == 'audio':
                 audio_conversion_names.append(converter.name)
                 self.audio_conversion_values.append(converter.identifier)
     widgets = []
     for text, setting, type_ in (
         (_("Name of Device"), u'name', 'text'),
         (_("Video Conversion"), u'video_conversion', 'video_conversion'),
         (_("Audio Conversion"), u'audio_conversion', 'audio_conversion'),
         (_("Store video in this directory"), u'video_path', 'text'),
         (_("Store audio in this directory"), u'audio_path', 'text'),
         (_("Always show this device, even if "
            "'show all devices' is turned off"), u'always_show', 'bool')
         ):
         if type_ == 'text':
             widget = widgetset.TextEntry()
             widget.set_size_request(260, -1)
         elif type_.endswith('conversion'):
             if type_ == 'video_conversion':
                 options = video_conversion_names
             elif type_ == 'audio_conversion':
                 options = audio_conversion_names
             widget = widgetset.OptionMenu(options)
             widget.set_size_request(260, -1)
         elif type_== 'bool':
             widget = widgetset.Checkbox(text)
         else:
             raise RuntimeError('unknown settings widget: %r' % type_)
         self.boxes[setting] = widget
         if type_ != 'bool': # has a label already
             widgets.append((widgetset.Label(text), widget))
             if type_ == 'text':
                 widget.connect('focus-out', self.setting_changed, setting)
             else:
                 widget.connect('changed', self.setting_changed, setting)
         else:
             widgets.append((widget,))
             widget.connect('toggled', self.setting_changed, setting)
     table = widgetset.Table(2, len(widgets))
     for row, widget in enumerate(widgets):
         if len(widget) == 1: # checkbox
             table.pack(widget[0], 0, row, column_span=2)
         else:
             table.pack(widgetutil.align_right(widget[0]), 0, row)
             table.pack(widgetutil.align_left(widget[1]), 1, row)
     table.set_column_spacing(20)
     table.set_row_spacing(20)
     self.set_child(widgetutil.align(table, 0.5, top_pad=50))
Example #5
0
    def create_table(self):
        self._background.remove()

        def _get_conversion_name(id_):
            if id_ == 'copy':
                return _('Copy')
            else:
                return conversion_manager.lookup_converter(id_).name

        conversion_details = {
            'audio': _get_conversion_name(self.device.info.audio_conversion),
            'video': _get_conversion_name(self.device.info.video_conversion)
        }
        audio_conversion_names = [
            _('Device Default (%(audio)s)', conversion_details),
            _('Copy')
        ]
        self.audio_conversion_values = [None, 'copy']
        video_conversion_names = [
            _('Device Default (%(video)s)', conversion_details),
            _('Copy')
        ]
        self.video_conversion_values = [None, 'copy']
        for section_name, converters in conversion_manager.get_converters():
            for converter in converters:
                if converter.mediatype == 'video':
                    video_conversion_names.append(converter.name)
                    self.video_conversion_values.append(converter.identifier)
                elif converter.mediatype == 'audio':
                    audio_conversion_names.append(converter.name)
                    self.audio_conversion_values.append(converter.identifier)
        widgets = []
        for text, setting, type_ in (
            (_("Name of Device"), u'name', 'text'),
            (_("Video Conversion"), u'video_conversion', 'video_conversion'),
            (_("Audio Conversion"), u'audio_conversion', 'audio_conversion'),
            (_("Store video in this directory"), u'video_path',
             'text'), (_("Store audio in this directory"), u'audio_path',
                       'text'), (_("Always show this device, even if "
                                   "'show all devices' is turned off"),
                                 u'always_show', 'bool'),
            (_("Always convert videos before copying to this device, even "
               "if the video can play without conversion\n(may reduce video "
               "file sizes, but makes syncing much slower)"),
             u"always_sync_videos", 'bool')):
            if type_ == 'text':
                widget = widgetset.TextEntry()
                widget.set_size_request(260, -1)
            elif type_.endswith('conversion'):
                if type_ == 'video_conversion':
                    options = video_conversion_names
                elif type_ == 'audio_conversion':
                    options = audio_conversion_names
                widget = widgetset.OptionMenu(options)
                widget.set_size_request(260, -1)
            elif type_ == 'bool':
                widget = widgetset.Checkbox(text)
                widget.set_size_request(400, -1)
            else:
                raise RuntimeError('unknown settings widget: %r' % type_)
            self.boxes[setting] = widget
            if type_ != 'bool':  # has a label already
                widgets.append((widgetset.Label(text), widget))
                if type_ == 'text':
                    widget.connect('focus-out', self.setting_changed, setting)
                else:
                    widget.connect('changed', self.setting_changed, setting)
            else:
                widgets.append((widget, ))
                widget.connect('toggled', self.setting_changed, setting)
        table = widgetset.Table(2, len(widgets))
        for row, widget in enumerate(widgets):
            if len(widget) == 1:  # checkbox
                table.pack(widget[0], 0, row, column_span=2)
            else:
                table.pack(widgetutil.align_right(widget[0]), 0, row)
                table.pack(widgetutil.align_left(widget[1]), 1, row)
        table.set_column_spacing(20)
        table.set_row_spacing(20)
        self._background.set_child(
            widgetutil.align_center(table, 20, 20, 20, 20))