コード例 #1
0
ファイル: torrent_actions.py プロジェクト: Ashod/Deluge
            def create_popup(status):
                cb = lambda result, ids=ids: _do_set_torrent_options(ids, result)
                option_popup = InputPopup(mode,"Set torrent options (Esc to cancel)",close_cb=cb, height_req=22)

                for (field, field_type) in torrent_options:
                    caption = "{!info!}" + torrent_options_to_names[field]
                    value = options[field]
                    if   field_type == str:
                        if not isinstance(value, basestring):
                            value = str(value)
                        option_popup.add_text_input(caption, field, value)
                    elif field_type == bool:
                        if options[field] == "multiple":
                            choices = (
                                ["Yes", "No", "Mixed"],
                                [True, False, None],
                                2
                            )
                        else:
                            choices = (
                                ["Yes", "No"],
                                [True, False],
                                [True, False].index(options[field])
                            )
                        option_popup.add_select_input(caption, field, choices[0], choices[1], choices[2])
                    elif field_type == float:
                        option_popup.add_float_spin_input(caption, field, value, min_val = -1)
                    elif field_type == int:
                        option_popup.add_int_spin_input(caption, field, value, min_val = -1)

                mode.set_popup(option_popup)
                mode.refresh()
コード例 #2
0
            def finish_up(status):
                status = map(lambda x: x[1], status)

                if len(ids) == 1:
                    rem_msg = "{!info!}Removing the following torrent:{!input!}"
                else:
                    rem_msg = "{!info!}Removing the following torrents:{!input!}"

                for i, (name, state) in enumerate(status):
                    color = colors.state_color[state]
                    rem_msg += "\n %s* {!input!}%s" % (color, name)
                    if i == 5:
                        if i < len(status):
                            rem_msg += "\n  {!red!}And %i more" % (
                                len(status) - 5)
                        break

                popup = InputPopup(mode,
                                   "(Esc to cancel, Enter to remove)",
                                   close_cb=do_remove)
                popup.add_text(rem_msg)
                popup.add_spaces(1)
                popup.add_select_input("{!info!}Torrent files:",
                                       'remove_files', ["Keep", "Remove"],
                                       [False, True], False)
                mode.set_popup(popup)
コード例 #3
0
ファイル: torrent_actions.py プロジェクト: Ashod/Deluge
            def finish_up(status):
                status = map(lambda x: x[1], status)

                if len(ids) == 1:
                    rem_msg = "{!info!}Removing the following torrent:{!input!}"
                else:
                    rem_msg = "{!info!}Removing the following torrents:{!input!}"

                for i, (name, state) in enumerate(status):
                    color = colors.state_color[state]
                    rem_msg += "\n %s* {!input!}%s" % (color, name)
                    if i == 5:
                        if i < len(status):
                            rem_msg += "\n  {!red!}And %i more" % (len(status) - 5)
                        break

                popup = InputPopup(mode, "(Esc to cancel, Enter to remove)", close_cb=do_remove)
                popup.add_text(rem_msg)
                popup.add_spaces(1)
                popup.add_select_input("{!info!}Torrent files:", 'remove_files', ["Keep", "Remove"], [False, True], False)
                mode.set_popup(popup)
コード例 #4
0
            def create_popup(status):
                cb = lambda result, ids=ids: _do_set_torrent_options(
                    ids, result)
                option_popup = InputPopup(
                    mode,
                    "Set torrent options (Esc to cancel)",
                    close_cb=cb,
                    height_req=22)

                for (field, field_type) in torrent_options:
                    caption = "{!info!}" + torrent_options_to_names[field]
                    value = options[field]
                    if field_type == str:
                        if not isinstance(value, basestring):
                            value = str(value)
                        option_popup.add_text_input(caption, field, value)
                    elif field_type == bool:
                        if options[field] == "multiple":
                            choices = (["Yes", "No",
                                        "Mixed"], [True, False, None], 2)
                        else:
                            choices = (["Yes", "No"], [True, False],
                                       [True, False].index(options[field]))
                        option_popup.add_select_input(caption, field,
                                                      choices[0], choices[1],
                                                      choices[2])
                    elif field_type == float:
                        option_popup.add_float_spin_input(caption,
                                                          field,
                                                          value,
                                                          min_val=-1)
                    elif field_type == int:
                        option_popup.add_int_spin_input(caption,
                                                        field,
                                                        value,
                                                        min_val=-1)

                mode.set_popup(option_popup)
                mode.refresh()