Exemplo n.º 1
0
    def __init__(self, task_options, expander_label):
        LoggingMixin.__init__(self)

        self._settings = _Settings('com.kissuki.yaner.task', delay=True)
        self._task_options = task_options.copy()

        expander = AlignedExpander(expander_label)
        self._uris_expander = expander

        vbox = Box(VERTICAL)
        expander.add(vbox)
        self._content_box = vbox
Exemplo n.º 2
0
    def __init__(self, task_options, expander_label):
        LoggingMixin.__init__(self)

        self._settings = _Settings('com.kissuki.yaner.task', delay=True)
        self._task_options = task_options.copy()

        expander = AlignedExpander(expander_label)
        self._uris_expander = expander

        vbox = Box(VERTICAL)
        expander.add(vbox)
        self._content_box = vbox
Exemplo n.º 3
0
    def __init__(self, pool_model, *args, **kwargs):
        Gtk.Dialog.__init__(self, title=_('Create New Task'), *args, **kwargs)
        LoggingMixin.__init__(self)

        self._ui = None
        self._default_ui = None
        self._normal_ui = None
        self._bt_ui = None
        self._ml_ui = None

        self._task_options = {}

        ### Action Area
        action_area = self.get_action_area()
        action_area.set_layout(Gtk.ButtonBoxStyle.START)

        button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        self.add_action_widget(button, Gtk.ResponseType.CANCEL)
        action_area.set_child_secondary(button, True)

        image = Gtk.Image.new_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.BUTTON)
        button = Gtk.Button(_('_Download'), image=image, use_underline=True)
        self.add_action_widget(button, Gtk.ResponseType.OK)
        action_area.set_child_secondary(button, True)

        advanced_buttons = []

        image = Gtk.Image.new_from_stock(Gtk.STOCK_UNDO, Gtk.IconSize.BUTTON)
        button = Gtk.Button(_('_Reset Settings'), image=image, use_underline=True)
        button.set_no_show_all(True)
        self.add_action_widget(button, _RESPONSE_RESET)
        advanced_buttons.append(button)

        image = Gtk.Image.new_from_stock(Gtk.STOCK_SAVE, Gtk.IconSize.BUTTON)
        button = Gtk.Button(_('_Save Settings'), image=image, use_underline=True)
        button.set_no_show_all(True)
        self.add_action_widget(button, _RESPONSE_SAVE)
        advanced_buttons.append(button)

        ### Content Area
        content_area = self.get_content_area()

        vbox = Box(VERTICAL)
        content_area.add(vbox)
        self._main_vbox = vbox

        ## Save to
        expander = AlignedExpander(_('<b>Save to...</b>'))
        expander.connect_after('activate', self.update_size)
        vbox.pack_start(expander)
        self.save_expander = expander

        hbox = Box(HORIZONTAL)
        expander.add(hbox)

        # Directory
        tooltip = _('Select the directory to save files')
        entry = FileChooserEntry(_('Select download directory'),
                                 self,
                                 Gtk.FileChooserAction.SELECT_FOLDER,
                                 tooltip_text=tooltip
                                )
        hbox.pack_end(entry)
        self._task_options['dir'] = _Option(entry, 'text', _Option.string_mapper)

        model = CategoryFilterModel(pool_model)
        combo_box = CategoryComboBox(model, self)
        combo_box.connect('changed', self._on_category_cb_changed, entry)
        combo_box.set_active(0)
        hbox.pack_start(combo_box)
        self._task_options['category'] = _Option(combo_box, 'category',
                                                 _Option.default_mapper)

        ## Advanced
        expander = AlignedExpander(_('<b>Advanced</b>'), expanded=False)
        expander.connect_after('activate',
                               self._on_advanced_expander_activated,
                               advanced_buttons)
        expander.connect_after('activate', self.update_size)
        vbox.pack_end(expander)
        self.advanced_expander = expander

        notebook = Gtk.Notebook()
        expander.add(notebook)

        ## Normal Task Page
        label = Gtk.Label(_('Normal Task'))
        vbox = Box(VERTICAL, border_width=5)
        notebook.append_page(vbox, label)

        grid = Grid()
        vbox.pack_start(grid, expand=False)

        # Speed Limit
        tooltip = _('Upload speed limit, in KiB/s.')

        label = RightAlignedLabel(_('Upload Limit:'), tooltip_text=tooltip)
        grid.attach(label, 0, 0)

        adjustment = Gtk.Adjustment(lower=0, upper=4096, step_increment=10)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 0)
        self._task_options['max-upload-limit'] = _Option(spin_button, 'value',
                                                         _Option.kib_mapper)

        tooltip = _('Download speed limit, in KiB/s.')

        label = RightAlignedLabel(_('Download Limit:'), tooltip_text=tooltip)
        grid.attach(label, 2, 0)

        adjustment = Gtk.Adjustment(lower=0, upper=4096, step_increment=10)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 0)
        self._task_options['max-download-limit'] = _Option(spin_button, 'value',
                                                           _Option.kib_mapper)

        # Retry
        tooltip = _('Number of retries.')

        label = RightAlignedLabel(_('Max Retries:'), tooltip_text=tooltip)
        grid.attach(label, 0, 1)

        adjustment = Gtk.Adjustment(lower=0, upper=60, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 1)
        self._task_options['max-tries'] = _Option(spin_button, 'value',
                                                  _Option.int_mapper)

        tooltip = _('Time to wait before retries, in seconds.')

        label = RightAlignedLabel(_('Retry Interval:'), tooltip_text=tooltip)
        grid.attach(label, 2, 1)

        adjustment = Gtk.Adjustment(lower=0, upper=60, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 1)
        self._task_options['retry-wait'] = _Option(spin_button, 'value',
                                                   _Option.int_mapper)

        # Timeout
        tooltip = _('Download timeout, in seconds.')

        label = RightAlignedLabel(_('Timeout:'), tooltip_text=tooltip)
        grid.attach(label, 0, 2)

        adjustment = Gtk.Adjustment(lower=1, upper=300, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 2)
        self._task_options['timeout'] = _Option(spin_button, 'value',
                                                _Option.int_mapper)

        tooltip = _('Timeout to connect HTTP/FTP/proxy server, in seconds.')

        label = RightAlignedLabel(_('Connect Timeout:'), tooltip_text=tooltip)
        grid.attach(label, 2, 2)

        adjustment = Gtk.Adjustment(lower=1, upper=300, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 2)
        self._task_options['connect-timeout'] = _Option(spin_button, 'value',
                                                        _Option.int_mapper)

        # Split and Connections
        tooltip = _('Minimal size to split the file into pieces, in MiB.')

        label = RightAlignedLabel(_('Split Size:'), tooltip_text=tooltip)
        grid.attach(label, 0, 3)

        adjustment = Gtk.Adjustment(lower=1, upper=1024, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 3)
        self._task_options['min-split-size'] = _Option(spin_button, 'value',
                                                       _Option.mib_mapper)

        tooltip = _('Max connections per server.')
        label = RightAlignedLabel(_('Per Server Connections:'), tooltip_text=tooltip)
        grid.attach(label, 2, 3)

        adjustment = Gtk.Adjustment(lower=1, upper=10, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 3)
        self._task_options['max-connection-per-server'] = _Option(
            spin_button, 'value', _Option.int_mapper)

        # Referer
        tooltip = _('The referrer page of the download.')
        label = RightAlignedLabel(_('Referer:'), tooltip_text=tooltip)
        grid.attach(label, 0, 4)

        entry = Gtk.Entry(activates_default=True, tooltip_text=tooltip)
        grid.attach(entry, 1, 4, 3, 1)
        self._task_options['referer'] = _Option(entry, 'text',
                                                _Option.string_mapper)

        # Header
        label = RightAlignedLabel(_('HTTP Header:'))
        grid.attach(label, 0, 5)

        entry = Gtk.Entry(activates_default=True)
        grid.attach(entry, 1, 5, 3, 1)
        self._task_options['header'] = _Option(entry, 'text',
                                               _Option.string_mapper)

        ## BT Task Page
        label = Gtk.Label(_('BitTorrent'))
        vbox = Box(VERTICAL, border_width=5)
        notebook.append_page(vbox, label)

        grid = Grid()
        vbox.pack_start(grid, expand=False)

        # Limit
        label = RightAlignedLabel(_('Max open files:'))
        grid.attach(label, 0, 0)

        adjustment = Gtk.Adjustment(lower=1, upper=1024, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True)
        grid.attach(spin_button, 1, 0)
        self._task_options['bt-max-open-files'] = _Option(spin_button, 'value',
                                                          _Option.int_mapper)

        label = RightAlignedLabel(_('Max peers:'))
        grid.attach(label, 2, 0)

        adjustment = Gtk.Adjustment(lower=1, upper=1024, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True)
        grid.attach(spin_button, 3, 0)
        self._task_options['bt-max-peers'] = _Option(spin_button, 'value',
                                                     _Option.int_mapper)

        # Seed
        tooltip = _('Seed time, in minutes')

        label = RightAlignedLabel(_('Seed time:'), tooltip_text=tooltip)
        grid.attach(label, 0, 1)

        adjustment = Gtk.Adjustment(lower=0, upper=7200, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 1)
        self._task_options['seed-time'] = _Option(spin_button, 'value',
                                                  _Option.int_mapper)

        label = RightAlignedLabel(_('Seed ratio:'))
        grid.attach(label, 2, 1)

        adjustment = Gtk.Adjustment(lower=0, upper=20, step_increment=.1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True, digits=1)
        grid.attach(spin_button, 3, 1)
        self._task_options['seed-ratio'] = _Option(spin_button, 'value',
                                                   _Option.float_mapper)

        # Timeout
        tooltip = _('Download timeout, in seconds.')

        label = RightAlignedLabel(_('Timeout:'), tooltip_text=tooltip)
        grid.attach(label, 0, 2)

        adjustment = Gtk.Adjustment(lower=1, upper=300, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 2)
        self._task_options['bt-tracker-timeout'] = _Option(spin_button, 'value',
                                                           _Option.int_mapper)

        tooltip = _('Timeout to establish connection to trackers, in seconds.')

        label = RightAlignedLabel(_('Connect Timeout:'), tooltip_text=tooltip)
        grid.attach(label, 2, 2)

        adjustment = Gtk.Adjustment(lower=1, upper=300, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 2)
        self._task_options['bt-tracker-connect-timeout'] = _Option(
            spin_button, 'value', _Option.int_mapper)

        tooltip = _('Try to download first and last pieces first.')
        label = RightAlignedLabel(_('Preview Mode:'), tooltip_text=tooltip)
        grid.attach(label, 0, 3)
        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 1, 3)
        self._task_options['bt-prioritize-piece'] = _Option(
            switch, 'active', _Option.prioritize_mapper)

        tooltip = _('Convert downloaded torrent files to BitTorrent tasks.')
        label = RightAlignedLabel(_('Follow Torrent:'), tooltip_text=tooltip)
        grid.attach(label, 2, 3)
        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 3, 3)
        self._task_options['follow-torrent'] = _Option(switch, 'active',
                                                       _Option.bool_mapper)

        # Mirrors
        tooltip = _('For single file torrents, a mirror can be a ' \
                    'complete URI pointing to the resource or if the mirror ' \
                    'ends with /, name in torrent file is added. For ' \
                    'multi-file torrents, name and path in torrent are ' \
                    'added to form a URI for each file.')
        expander = AlignedExpander(_('Mirrors'), expanded=False, tooltip_text=tooltip)
        expander.connect_after('activate', self.update_size)
        grid.attach(expander, 0, 4, 4, 1)
        #vbox.pack_start(expander, expand=False)

        uris_view = URIsView()
        uris_view.set_size_request(-1, 70)
        expander.add(uris_view)
        self._task_options['uris'] = _Option(uris_view, 'uris',
                                             _Option.default_mapper)

        ## Metalink Page
        label = Gtk.Label(_('Metalink'))
        vbox = Box(VERTICAL, border_width=5)
        notebook.append_page(vbox, label)

        grid = Grid(halign=Gtk.Align.CENTER)
        vbox.pack_start(grid, expand=False)

        label = RightAlignedLabel(_('Preferred locations:'))
        grid.attach(label, 0, 0)

        entry = Gtk.Entry()
        grid.attach(entry, 1, 0)
        self._task_options['metalink-location'] = _Option(entry, 'text',
                                                          _Option.string_mapper)

        label = RightAlignedLabel(_('Language:'))
        grid.attach(label, 0, 1)

        entry = Gtk.Entry()
        grid.attach(entry, 1, 1)
        self._task_options['metalink-language'] = _Option(entry, 'text',
                                                          _Option.string_mapper)

        label = RightAlignedLabel(_('Version:'))
        grid.attach(label, 0, 2)

        entry = Gtk.Entry()
        grid.attach(entry, 1, 2)
        self._task_options['metalink-version'] = _Option(entry, 'text',
                                                         _Option.string_mapper)

        label = RightAlignedLabel(_('OS:'))
        grid.attach(label, 0, 3)

        entry = Gtk.Entry()
        grid.attach(entry, 1, 3)
        self._task_options['metalink-os'] = _Option(entry, 'text',
                                                    _Option.string_mapper)

        tooltip = _('Convert downloaded metalink files to Metalink tasks.')

        label = RightAlignedLabel(_('Follow Metalink:'), tooltip_text=tooltip)
        grid.attach(label, 0, 4)

        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 1, 4)
        self._task_options['follow-metalink'] = _Option(switch, 'active',
                                                        _Option.bool_mapper)

        ## Miscellaneous Page
        label = Gtk.Label(_('Miscellaneous'))
        vbox = Box(VERTICAL, border_width=5)
        notebook.append_page(vbox, label)

        grid = Grid()
        vbox.pack_start(grid, expand=False)

        # Overwrite and Rename
        tooltip = _("Restart download from scratch if the corresponding"
                    " control file doesn't exist.")

        label = RightAlignedLabel(_('Allow Overwrite:'), tooltip_text=tooltip)
        grid.attach(label, 0, 0)

        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 1, 0)
        self._task_options['allow-overwrite'] = _Option(switch, 'active',
                                                        _Option.bool_mapper)

        tooltip = _('Rename file name if the same file already exists.')

        label = RightAlignedLabel(_('Auto Rename Files:'), tooltip_text=tooltip)
        grid.attach(label, 2, 0)

        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 3, 0)
        self._task_options['auto-file-renaming'] = _Option(switch, 'active',
                                                           _Option.bool_mapper)

        tooltip = _('Format: [http://][USER:PASSWORD@]HOST[:PORT]')
        label = RightAlignedLabel(_('Proxy:'), tooltip_text=tooltip)
        grid.attach(label, 0, 1)

        entry = Gtk.Entry(activates_default=True, tooltip_text=tooltip)
        entry.set_placeholder_text(tooltip)
        grid.attach(entry, 1, 1, 3, 1)
        self._task_options['all-proxy'] = _Option(entry, 'text',
                                                  _Option.string_mapper)

        # Authorization
        expander = AlignedExpander(_('Authorization'), expanded=False)
        expander.connect_after('activate', self.update_size)
        vbox.pack_start(expander, expand=False)

        grid = Grid()
        expander.add(grid)

        label = RightAlignedLabel(_('HTTP User:'******'http-user'] = _Option(entry, 'text',
                                                  _Option.string_mapper)

        label = RightAlignedLabel(_('Password:'******'http-passwd'] = _Option(entry, 'text',
                                                    _Option.string_mapper)

        label = RightAlignedLabel(_('FTP User:'******'ftp-user'] = _Option(entry, 'text',
                                                 _Option.string_mapper)

        label = RightAlignedLabel(_('Password:'******'ftp-passwd'] = _Option(entry, 'text',
                                                   _Option.string_mapper)

        self.show_all()
Exemplo n.º 4
0
    def __init__(self, pool_model, *args, **kwargs):
        Gtk.Dialog.__init__(self, title=_('Create New Task'), *args, **kwargs)
        LoggingMixin.__init__(self)

        self._ui = None
        self._default_ui = None
        self._normal_ui = None
        self._bt_ui = None
        self._ml_ui = None

        self._task_options = {}

        ### Action Area
        action_area = self.get_action_area()
        action_area.set_layout(Gtk.ButtonBoxStyle.START)

        button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        self.add_action_widget(button, Gtk.ResponseType.CANCEL)
        action_area.set_child_secondary(button, True)

        image = Gtk.Image.new_from_stock(Gtk.STOCK_GO_DOWN,
                                         Gtk.IconSize.BUTTON)
        button = Gtk.Button(_('_Download'), image=image, use_underline=True)
        self.add_action_widget(button, Gtk.ResponseType.OK)
        action_area.set_child_secondary(button, True)

        advanced_buttons = []

        image = Gtk.Image.new_from_stock(Gtk.STOCK_UNDO, Gtk.IconSize.BUTTON)
        button = Gtk.Button(_('_Reset Settings'),
                            image=image,
                            use_underline=True)
        button.set_no_show_all(True)
        self.add_action_widget(button, _RESPONSE_RESET)
        advanced_buttons.append(button)

        image = Gtk.Image.new_from_stock(Gtk.STOCK_SAVE, Gtk.IconSize.BUTTON)
        button = Gtk.Button(_('_Save Settings'),
                            image=image,
                            use_underline=True)
        button.set_no_show_all(True)
        self.add_action_widget(button, _RESPONSE_SAVE)
        advanced_buttons.append(button)

        ### Content Area
        content_area = self.get_content_area()

        vbox = Box(VERTICAL)
        content_area.add(vbox)
        self._main_vbox = vbox

        ## Save to
        expander = AlignedExpander(_('<b>Save to...</b>'))
        expander.connect_after('activate', self.update_size)
        vbox.pack_start(expander)
        self.save_expander = expander

        hbox = Box(HORIZONTAL)
        expander.add(hbox)

        # Directory
        tooltip = _('Select the directory to save files')
        entry = FileChooserEntry(_('Select download directory'),
                                 self,
                                 Gtk.FileChooserAction.SELECT_FOLDER,
                                 tooltip_text=tooltip)
        hbox.pack_end(entry)
        self._task_options['dir'] = _Option(entry, 'text',
                                            _Option.string_mapper)

        model = CategoryFilterModel(pool_model)
        combo_box = CategoryComboBox(model, self)
        combo_box.connect('changed', self._on_category_cb_changed, entry)
        combo_box.set_active(0)
        hbox.pack_start(combo_box)
        self._task_options['category'] = _Option(combo_box, 'category',
                                                 _Option.default_mapper)

        ## Advanced
        expander = AlignedExpander(_('<b>Advanced</b>'), expanded=False)
        expander.connect_after('activate',
                               self._on_advanced_expander_activated,
                               advanced_buttons)
        expander.connect_after('activate', self.update_size)
        vbox.pack_end(expander)
        self.advanced_expander = expander

        notebook = Gtk.Notebook()
        expander.add(notebook)

        ## Normal Task Page
        label = Gtk.Label(_('Normal Task'))
        vbox = Box(VERTICAL, border_width=5)
        notebook.append_page(vbox, label)

        grid = Grid()
        vbox.pack_start(grid, expand=False)

        # Speed Limit
        tooltip = _('Upload speed limit, in KiB/s.')

        label = RightAlignedLabel(_('Upload Limit:'), tooltip_text=tooltip)
        grid.attach(label, 0, 0)

        adjustment = Gtk.Adjustment(lower=0, upper=4096, step_increment=10)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 0)
        self._task_options['max-upload-limit'] = _Option(
            spin_button, 'value', _Option.kib_mapper)

        tooltip = _('Download speed limit, in KiB/s.')

        label = RightAlignedLabel(_('Download Limit:'), tooltip_text=tooltip)
        grid.attach(label, 2, 0)

        adjustment = Gtk.Adjustment(lower=0, upper=4096, step_increment=10)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 0)
        self._task_options['max-download-limit'] = _Option(
            spin_button, 'value', _Option.kib_mapper)

        # Retry
        tooltip = _('Number of retries.')

        label = RightAlignedLabel(_('Max Retries:'), tooltip_text=tooltip)
        grid.attach(label, 0, 1)

        adjustment = Gtk.Adjustment(lower=0, upper=60, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 1)
        self._task_options['max-tries'] = _Option(spin_button, 'value',
                                                  _Option.int_mapper)

        tooltip = _('Time to wait before retries, in seconds.')

        label = RightAlignedLabel(_('Retry Interval:'), tooltip_text=tooltip)
        grid.attach(label, 2, 1)

        adjustment = Gtk.Adjustment(lower=0, upper=60, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 1)
        self._task_options['retry-wait'] = _Option(spin_button, 'value',
                                                   _Option.int_mapper)

        # Timeout
        tooltip = _('Download timeout, in seconds.')

        label = RightAlignedLabel(_('Timeout:'), tooltip_text=tooltip)
        grid.attach(label, 0, 2)

        adjustment = Gtk.Adjustment(lower=1, upper=300, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 2)
        self._task_options['timeout'] = _Option(spin_button, 'value',
                                                _Option.int_mapper)

        tooltip = _('Timeout to connect HTTP/FTP/proxy server, in seconds.')

        label = RightAlignedLabel(_('Connect Timeout:'), tooltip_text=tooltip)
        grid.attach(label, 2, 2)

        adjustment = Gtk.Adjustment(lower=1, upper=300, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 2)
        self._task_options['connect-timeout'] = _Option(
            spin_button, 'value', _Option.int_mapper)

        # Split and Connections
        tooltip = _('Minimal size to split the file into pieces, in MiB.')

        label = RightAlignedLabel(_('Split Size:'), tooltip_text=tooltip)
        grid.attach(label, 0, 3)

        adjustment = Gtk.Adjustment(lower=1, upper=1024, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 3)
        self._task_options['min-split-size'] = _Option(spin_button, 'value',
                                                       _Option.mib_mapper)

        tooltip = _('Max connections per server.')
        label = RightAlignedLabel(_('Per Server Connections:'),
                                  tooltip_text=tooltip)
        grid.attach(label, 2, 3)

        adjustment = Gtk.Adjustment(lower=1, upper=10, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 3)
        self._task_options['max-connection-per-server'] = _Option(
            spin_button, 'value', _Option.int_mapper)

        # Referer
        tooltip = _('The referrer page of the download.')
        label = RightAlignedLabel(_('Referer:'), tooltip_text=tooltip)
        grid.attach(label, 0, 4)

        entry = Gtk.Entry(activates_default=True, tooltip_text=tooltip)
        grid.attach(entry, 1, 4, 3, 1)
        self._task_options['referer'] = _Option(entry, 'text',
                                                _Option.string_mapper)

        # Header
        label = RightAlignedLabel(_('HTTP Header:'))
        grid.attach(label, 0, 5)

        entry = Gtk.Entry(activates_default=True)
        grid.attach(entry, 1, 5, 3, 1)
        self._task_options['header'] = _Option(entry, 'text',
                                               _Option.string_mapper)

        ## BT Task Page
        label = Gtk.Label(_('BitTorrent'))
        vbox = Box(VERTICAL, border_width=5)
        notebook.append_page(vbox, label)

        grid = Grid()
        vbox.pack_start(grid, expand=False)

        # Limit
        label = RightAlignedLabel(_('Max open files:'))
        grid.attach(label, 0, 0)

        adjustment = Gtk.Adjustment(lower=1, upper=1024, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True)
        grid.attach(spin_button, 1, 0)
        self._task_options['bt-max-open-files'] = _Option(
            spin_button, 'value', _Option.int_mapper)

        label = RightAlignedLabel(_('Max peers:'))
        grid.attach(label, 2, 0)

        adjustment = Gtk.Adjustment(lower=1, upper=1024, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment, numeric=True)
        grid.attach(spin_button, 3, 0)
        self._task_options['bt-max-peers'] = _Option(spin_button, 'value',
                                                     _Option.int_mapper)

        # Seed
        tooltip = _('Seed time, in minutes')

        label = RightAlignedLabel(_('Seed time:'), tooltip_text=tooltip)
        grid.attach(label, 0, 1)

        adjustment = Gtk.Adjustment(lower=0, upper=7200, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 1)
        self._task_options['seed-time'] = _Option(spin_button, 'value',
                                                  _Option.int_mapper)

        label = RightAlignedLabel(_('Seed ratio:'))
        grid.attach(label, 2, 1)

        adjustment = Gtk.Adjustment(lower=0, upper=20, step_increment=.1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     digits=1)
        grid.attach(spin_button, 3, 1)
        self._task_options['seed-ratio'] = _Option(spin_button, 'value',
                                                   _Option.float_mapper)

        # Timeout
        tooltip = _('Download timeout, in seconds.')

        label = RightAlignedLabel(_('Timeout:'), tooltip_text=tooltip)
        grid.attach(label, 0, 2)

        adjustment = Gtk.Adjustment(lower=1, upper=300, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 1, 2)
        self._task_options['bt-tracker-timeout'] = _Option(
            spin_button, 'value', _Option.int_mapper)

        tooltip = _('Timeout to establish connection to trackers, in seconds.')

        label = RightAlignedLabel(_('Connect Timeout:'), tooltip_text=tooltip)
        grid.attach(label, 2, 2)

        adjustment = Gtk.Adjustment(lower=1, upper=300, step_increment=1)
        spin_button = Gtk.SpinButton(adjustment=adjustment,
                                     numeric=True,
                                     tooltip_text=tooltip)
        grid.attach(spin_button, 3, 2)
        self._task_options['bt-tracker-connect-timeout'] = _Option(
            spin_button, 'value', _Option.int_mapper)

        tooltip = _('Try to download first and last pieces first.')
        label = RightAlignedLabel(_('Preview Mode:'), tooltip_text=tooltip)
        grid.attach(label, 0, 3)
        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 1, 3)
        self._task_options['bt-prioritize-piece'] = _Option(
            switch, 'active', _Option.prioritize_mapper)

        tooltip = _('Convert downloaded torrent files to BitTorrent tasks.')
        label = RightAlignedLabel(_('Follow Torrent:'), tooltip_text=tooltip)
        grid.attach(label, 2, 3)
        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 3, 3)
        self._task_options['follow-torrent'] = _Option(switch, 'active',
                                                       _Option.bool_mapper)

        # Mirrors
        tooltip = _('For single file torrents, a mirror can be a ' \
                    'complete URI pointing to the resource or if the mirror ' \
                    'ends with /, name in torrent file is added. For ' \
                    'multi-file torrents, name and path in torrent are ' \
                    'added to form a URI for each file.')
        expander = AlignedExpander(_('Mirrors'),
                                   expanded=False,
                                   tooltip_text=tooltip)
        expander.connect_after('activate', self.update_size)
        grid.attach(expander, 0, 4, 4, 1)
        #vbox.pack_start(expander, expand=False)

        uris_view = URIsView()
        uris_view.set_size_request(-1, 70)
        expander.add(uris_view)
        self._task_options['uris'] = _Option(uris_view, 'uris',
                                             _Option.default_mapper)

        ## Metalink Page
        label = Gtk.Label(_('Metalink'))
        vbox = Box(VERTICAL, border_width=5)
        notebook.append_page(vbox, label)

        grid = Grid(halign=Gtk.Align.CENTER)
        vbox.pack_start(grid, expand=False)

        label = RightAlignedLabel(_('Preferred locations:'))
        grid.attach(label, 0, 0)

        entry = Gtk.Entry()
        grid.attach(entry, 1, 0)
        self._task_options['metalink-location'] = _Option(
            entry, 'text', _Option.string_mapper)

        label = RightAlignedLabel(_('Language:'))
        grid.attach(label, 0, 1)

        entry = Gtk.Entry()
        grid.attach(entry, 1, 1)
        self._task_options['metalink-language'] = _Option(
            entry, 'text', _Option.string_mapper)

        label = RightAlignedLabel(_('Version:'))
        grid.attach(label, 0, 2)

        entry = Gtk.Entry()
        grid.attach(entry, 1, 2)
        self._task_options['metalink-version'] = _Option(
            entry, 'text', _Option.string_mapper)

        label = RightAlignedLabel(_('OS:'))
        grid.attach(label, 0, 3)

        entry = Gtk.Entry()
        grid.attach(entry, 1, 3)
        self._task_options['metalink-os'] = _Option(entry, 'text',
                                                    _Option.string_mapper)

        tooltip = _('Convert downloaded metalink files to Metalink tasks.')

        label = RightAlignedLabel(_('Follow Metalink:'), tooltip_text=tooltip)
        grid.attach(label, 0, 4)

        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 1, 4)
        self._task_options['follow-metalink'] = _Option(
            switch, 'active', _Option.bool_mapper)

        ## Miscellaneous Page
        label = Gtk.Label(_('Miscellaneous'))
        vbox = Box(VERTICAL, border_width=5)
        notebook.append_page(vbox, label)

        grid = Grid()
        vbox.pack_start(grid, expand=False)

        # Overwrite and Rename
        tooltip = _("Restart download from scratch if the corresponding"
                    " control file doesn't exist.")

        label = RightAlignedLabel(_('Allow Overwrite:'), tooltip_text=tooltip)
        grid.attach(label, 0, 0)

        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 1, 0)
        self._task_options['allow-overwrite'] = _Option(
            switch, 'active', _Option.bool_mapper)

        tooltip = _('Rename file name if the same file already exists.')

        label = RightAlignedLabel(_('Auto Rename Files:'),
                                  tooltip_text=tooltip)
        grid.attach(label, 2, 0)

        switch = Gtk.Switch(tooltip_text=tooltip)
        grid.attach(switch, 3, 0)
        self._task_options['auto-file-renaming'] = _Option(
            switch, 'active', _Option.bool_mapper)

        tooltip = _('Format: [http://][USER:PASSWORD@]HOST[:PORT]')
        label = RightAlignedLabel(_('Proxy:'), tooltip_text=tooltip)
        grid.attach(label, 0, 1)

        entry = Gtk.Entry(activates_default=True, tooltip_text=tooltip)
        entry.set_placeholder_text(tooltip)
        grid.attach(entry, 1, 1, 3, 1)
        self._task_options['all-proxy'] = _Option(entry, 'text',
                                                  _Option.string_mapper)

        # Authorization
        expander = AlignedExpander(_('Authorization'), expanded=False)
        expander.connect_after('activate', self.update_size)
        vbox.pack_start(expander, expand=False)

        grid = Grid()
        expander.add(grid)

        label = RightAlignedLabel(_('HTTP User:'******'http-user'] = _Option(entry, 'text',
                                                  _Option.string_mapper)

        label = RightAlignedLabel(_('Password:'******'http-passwd'] = _Option(entry, 'text',
                                                    _Option.string_mapper)

        label = RightAlignedLabel(_('FTP User:'******'ftp-user'] = _Option(entry, 'text',
                                                 _Option.string_mapper)

        label = RightAlignedLabel(_('Password:'******'ftp-passwd'] = _Option(entry, 'text',
                                                   _Option.string_mapper)

        self.show_all()