1
0
Fork 0

Adding upstream version 2.1.2~dev0+20230918.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-17 07:42:17 +01:00
parent 1000cb7e81
commit 1d7b9e8193
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
13 changed files with 136 additions and 131 deletions

View file

@ -49,7 +49,7 @@ jobs:
cache: pip cache: pip
- name: Prepare pip - name: Prepare pip
run: python -m pip install wheel run: python -m pip install wheel setuptools==68.*
- name: Install GTK - name: Install GTK
run: | run: |
@ -62,11 +62,14 @@ jobs:
python -m pip install --no-index --find-links="C:\GTK\release\python" pycairo PyGObject python -m pip install --no-index --find-links="C:\GTK\release\python" pycairo PyGObject
- name: Install Python dependencies - name: Install Python dependencies
# Pillow no longer provides 32-bit wheels for Windows
# so specify only-binary to install old version.
run: > run: >
python -m pip install python -m pip install
twisted[tls]==22.4.0 --only-binary=pillow
twisted[tls]==22.8.0
libtorrent==${{ matrix.libtorrent }} libtorrent==${{ matrix.libtorrent }}
pyinstaller==4.10 pyinstaller
pygame pygame
-r requirements.txt -r requirements.txt

View file

@ -36,7 +36,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install --upgrade pip wheel pip install --upgrade pip wheel setuptools
pip install -r requirements.txt -r requirements-tests.txt pip install -r requirements.txt -r requirements-tests.txt
pip install -e . pip install -e .
@ -91,7 +91,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install --upgrade pip wheel pip install --upgrade pip wheel setuptools
pip install -r requirements.txt -r requirements-tests.txt pip install -r requirements.txt -r requirements-tests.txt
pip install -e . pip install -e .

View file

@ -5,6 +5,14 @@
# Required # Required
version: 2 version: 2
build:
os: ubuntu-22.04
tools:
python: "3.10"
jobs:
post_checkout:
- git fetch --unshallow || true
# Build documentation in the docs/ directory with Sphinx # Build documentation in the docs/ directory with Sphinx
sphinx: sphinx:
configuration: docs/source/conf.py configuration: docs/source/conf.py
@ -14,9 +22,8 @@ formats: all
# Optionally set the version of Python and requirements required to build your docs # Optionally set the version of Python and requirements required to build your docs
python: python:
version: 3.7
install: install:
- requirements: requirements.txt - requirements: requirements.txt
- requirements: docs/requirements.txt - requirements: docs/requirements.txt
- method: setuptools - method: pip
path: . path: .

View file

@ -6355,5 +6355,5 @@ msgstr "Temps estimat:"
msgid "Date Added:" msgid "Date Added:"
msgstr "Data d'addició" msgstr "Data d'addició"
#~ msgid "<b>Languge</b>" #~ msgid "<b>Language</b>"
#~ msgstr "<b>Idioma</b>" #~ msgstr "<b>Idioma</b>"

View file

@ -6307,5 +6307,5 @@ msgstr "Temps restant estimé :"
msgid "Date Added:" msgid "Date Added:"
msgstr "" msgstr ""
#~ msgid "<b>Languge</b>" #~ msgid "<b>Language</b>"
#~ msgstr "<b>Langue</b>" #~ msgstr "<b>Langue</b>"

View file

@ -6245,5 +6245,5 @@ msgstr ""
msgid "Date Added:" msgid "Date Added:"
msgstr "" msgstr ""
#~ msgid "<b>Languge</b>" #~ msgid "<b>Language</b>"
#~ msgstr "<b>Jezik</b>" #~ msgstr "<b>Jezik</b>"

View file

@ -6325,5 +6325,5 @@ msgstr "Tid kvar:"
msgid "Date Added:" msgid "Date Added:"
msgstr "Tillagd:" msgstr "Tillagd:"
#~ msgid "<b>Languge</b>" #~ msgid "<b>Language</b>"
#~ msgstr "<b>Språk</b>" #~ msgstr "<b>Språk</b>"

View file

@ -6337,5 +6337,5 @@ msgstr "ETA:"
msgid "Date Added:" msgid "Date Added:"
msgstr "Дата додавання:" msgstr "Дата додавання:"
#~ msgid "<b>Languge</b>" #~ msgid "<b>Language</b>"
#~ msgstr "<b>Мова</b>" #~ msgstr "<b>Мова</b>"

View file

@ -6203,5 +6203,5 @@ msgstr "估计剩余时间:"
msgid "Date Added:" msgid "Date Added:"
msgstr "添加日期:" msgstr "添加日期:"
#~ msgid "<b>Languge</b>" #~ msgid "<b>Language</b>"
#~ msgstr "<b>语言</b>" #~ msgstr "<b>语言</b>"

View file

@ -156,8 +156,6 @@ def setup_logger(
else: else:
handler = logging.StreamHandler(stream=output_stream) handler = logging.StreamHandler(stream=output_stream)
handler.setLevel(level)
formatter = logging.Formatter( formatter = logging.Formatter(
DEFAULT_LOGGING_FORMAT % MAX_LOGGER_NAME_LENGTH, datefmt='%H:%M:%S' DEFAULT_LOGGING_FORMAT % MAX_LOGGER_NAME_LENGTH, datefmt='%H:%M:%S'
) )

View file

@ -104,20 +104,19 @@ def set_stats(self, stats):
def set_interval(self, interval): def set_interval(self, interval):
self.interval = interval self.interval = interval
def draw_to_context(self, context, width, height): def draw_to_context(self, ctx, width, height):
self.ctx = context
self.width, self.height = width, height self.width, self.height = width, height
self.draw_rect(white, 0, 0, self.width, self.height) self.draw_rect(ctx, white, 0, 0, self.width, self.height)
self.draw_graph() self.draw_graph(ctx)
return self.ctx
def draw(self, width, height): def draw(self, width, height):
"""Create surface with context for use in tests"""
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
ctx = cairo.Context(surface) ctx = cairo.Context(surface)
self.draw_to_context(ctx, width, height) self.draw_to_context(ctx, width, height)
return surface return surface
def draw_x_axis(self, bounds): def draw_x_axis(self, ctx, bounds):
(left, top, right, bottom) = bounds (left, top, right, bottom) = bounds
duration = self.length * self.interval duration = self.length * self.interval
start = self.last_update - duration start = self.last_update - duration
@ -142,13 +141,13 @@ def draw_x_axis(self, bounds):
) )
# + 0.5 to allign x to nearest pixel # + 0.5 to allign x to nearest pixel
x = int(ratio * (seconds_to_step + i * x_step) + left) + 0.5 x = int(ratio * (seconds_to_step + i * x_step) + left) + 0.5
self.draw_x_text(text, x, bottom) self.draw_x_text(ctx, text, x, bottom)
self.draw_dotted_line(gray, x, top - 0.5, x, bottom + 0.5) self.draw_dotted_line(ctx, gray, x, top - 0.5, x, bottom + 0.5)
self.draw_line(gray, left, bottom + 0.5, right, bottom + 0.5) self.draw_line(ctx, gray, left, bottom + 0.5, right, bottom + 0.5)
def draw_graph(self): def draw_graph(self, ctx):
font_extents = self.ctx.font_extents() font_extents = ctx.font_extents()
x_axis_space = font_extents[2] + 2 + self.line_size / 2 x_axis_space = font_extents[2] + 2 + self.line_size / 2
plot_height = self.height - x_axis_space plot_height = self.height - x_axis_space
# lets say we need 2n-1*font height pixels to plot the y ticks # lets say we need 2n-1*font height pixels to plot the y ticks
@ -171,18 +170,18 @@ def draw_graph(self):
# find the width of the y_ticks # find the width of the y_ticks
y_tick_text = [self.left_axis['formatter'](tick) for tick in y_ticks] y_tick_text = [self.left_axis['formatter'](tick) for tick in y_ticks]
def space_required(text): def space_required(ctx, text):
te = self.ctx.text_extents(text) te = ctx.text_extents(text)
return math.ceil(te[4] - te[0]) return math.ceil(te[4] - te[0])
y_tick_width = max(space_required(text) for text in y_tick_text) y_tick_width = max(space_required(ctx, text) for text in y_tick_text)
top = font_extents[2] / 2 top = font_extents[2] / 2
# bounds(left, top, right, bottom) # bounds(left, top, right, bottom)
bounds = (y_tick_width + 4, top + 2, self.width, self.height - x_axis_space) bounds = (y_tick_width + 4, top + 2, self.width, self.height - x_axis_space)
self.draw_x_axis(bounds) self.draw_x_axis(ctx, bounds)
self.draw_left_axis(bounds, y_ticks, y_tick_text) self.draw_left_axis(ctx, bounds, y_ticks, y_tick_text)
def intervalise(self, x, limit=None): def intervalise(self, x, limit=None):
"""Given a value x create an array of tick points to got with the graph """Given a value x create an array of tick points to got with the graph
@ -229,7 +228,7 @@ def intervalise(self, x, limit=None):
] ]
return intervals return intervals
def draw_left_axis(self, bounds, y_ticks, y_tick_text): def draw_left_axis(self, ctx, bounds, y_ticks, y_tick_text):
(left, top, right, bottom) = bounds (left, top, right, bottom) = bounds
stats = {} stats = {}
for stat in self.stat_info: for stat in self.stat_info:
@ -246,29 +245,36 @@ def draw_left_axis(self, bounds, y_ticks, y_tick_text):
for i, y_val in enumerate(y_ticks): for i, y_val in enumerate(y_ticks):
y = int(bottom - y_val * ratio) - 0.5 y = int(bottom - y_val * ratio) - 0.5
if i != 0: if i != 0:
self.draw_dotted_line(gray, left, y, right, y) self.draw_dotted_line(ctx, gray, left, y, right, y)
self.draw_y_text(y_tick_text[i], left, y) self.draw_y_text(ctx, y_tick_text[i], left, y)
self.draw_line(gray, left, top, left, bottom) self.draw_line(ctx, gray, left, top, left, bottom)
for stat, info in stats.items(): for stat, info in stats.items():
if len(info['values']) > 0: if len(info['values']) > 0:
self.draw_value_poly(info['values'], info['color'], max_value, bounds)
self.draw_value_poly( self.draw_value_poly(
info['values'], info['fill_color'], max_value, bounds, info['fill'] ctx, info['values'], info['color'], max_value, bounds
)
self.draw_value_poly(
ctx,
info['values'],
info['fill_color'],
max_value,
bounds,
info['fill'],
) )
def draw_legend(self): def draw_legend(self):
pass pass
def trace_path(self, values, max_value, bounds): def trace_path(self, ctx, values, max_value, bounds):
(left, top, right, bottom) = bounds (left, top, right, bottom) = bounds
ratio = (bottom - top) / max_value ratio = (bottom - top) / max_value
line_width = self.line_size line_width = self.line_size
self.ctx.set_line_width(line_width) ctx.set_line_width(line_width)
self.ctx.move_to(right, bottom) ctx.move_to(right, bottom)
self.ctx.line_to(right, int(bottom - values[0] * ratio)) ctx.line_to(right, int(bottom - values[0] * ratio))
x = right x = right
step = (right - left) / (self.length - 1) step = (right - left) / (self.length - 1)
@ -276,64 +282,62 @@ def trace_path(self, values, max_value, bounds):
if i == self.length - 1: if i == self.length - 1:
x = left x = left
self.ctx.line_to(x, int(bottom - value * ratio)) ctx.line_to(x, int(bottom - value * ratio))
x -= step x -= step
self.ctx.line_to(int(right - (len(values) - 1) * step), bottom) ctx.line_to(int(right - (len(values) - 1) * step), bottom)
self.ctx.close_path() ctx.close_path()
def draw_value_poly(self, values, color, max_value, bounds, fill=False): def draw_value_poly(self, ctx, values, color, max_value, bounds, fill=False):
self.trace_path(values, max_value, bounds) self.trace_path(ctx, values, max_value, bounds)
self.ctx.set_source_rgba(*color) ctx.set_source_rgba(*color)
if fill: if fill:
self.ctx.fill() ctx.fill()
else: else:
self.ctx.stroke() ctx.stroke()
def draw_x_text(self, text, x, y): def draw_x_text(self, ctx, text, x, y):
"""Draws text below and horizontally centered about x,y""" """Draws text below and horizontally centered about x,y"""
fe = self.ctx.font_extents() fe = ctx.font_extents()
te = self.ctx.text_extents(text) te = ctx.text_extents(text)
height = fe[2] height = fe[2]
x_bearing = te[0] x_bearing = te[0]
width = te[2] width = te[2]
self.ctx.move_to(int(x - width / 2 + x_bearing), int(y + height)) ctx.move_to(int(x - width / 2 + x_bearing), int(y + height))
self.ctx.set_source_rgba(*self.black) ctx.set_source_rgba(*self.black)
self.ctx.show_text(text) ctx.show_text(text)
def draw_y_text(self, text, x, y): def draw_y_text(self, ctx, text, x, y):
"""Draws text left of and vertically centered about x,y""" """Draws text left of and vertically centered about x,y"""
fe = self.ctx.font_extents() fe = ctx.font_extents()
te = self.ctx.text_extents(text) te = ctx.text_extents(text)
descent = fe[1] descent = fe[1]
ascent = fe[0] ascent = fe[0]
x_bearing = te[0] x_bearing = te[0]
width = te[4] width = te[4]
self.ctx.move_to( ctx.move_to(int(x - width - x_bearing - 2), int(y + (ascent - descent) / 2))
int(x - width - x_bearing - 2), int(y + (ascent - descent) / 2) ctx.set_source_rgba(*self.black)
) ctx.show_text(text)
self.ctx.set_source_rgba(*self.black)
self.ctx.show_text(text)
def draw_rect(self, color, x, y, height, width): def draw_rect(self, ctx, color, x, y, height, width):
self.ctx.set_source_rgba(*color) ctx.set_source_rgba(*color)
self.ctx.rectangle(x, y, height, width) ctx.rectangle(x, y, height, width)
self.ctx.fill() ctx.fill()
def draw_line(self, color, x1, y1, x2, y2): def draw_line(self, ctx, color, x1, y1, x2, y2):
self.ctx.set_source_rgba(*color) ctx.set_source_rgba(*color)
self.ctx.set_line_width(1) ctx.set_line_width(1)
self.ctx.move_to(x1, y1) ctx.move_to(x1, y1)
self.ctx.line_to(x2, y2) ctx.line_to(x2, y2)
self.ctx.stroke() ctx.stroke()
def draw_dotted_line(self, color, x1, y1, x2, y2): def draw_dotted_line(self, ctx, color, x1, y1, x2, y2):
self.ctx.set_source_rgba(*color) ctx.set_source_rgba(*color)
self.ctx.set_line_width(1) ctx.set_line_width(1)
dash, offset = self.ctx.get_dash() dash, offset = ctx.get_dash()
self.ctx.set_dash(self.dash_length, 0) ctx.set_dash(self.dash_length, 0)
self.ctx.move_to(x1, y1) ctx.move_to(x1, y1)
self.ctx.line_to(x2, y2) ctx.line_to(x2, y2)
self.ctx.stroke() ctx.stroke()
self.ctx.set_dash(dash, offset) ctx.set_dash(dash, offset)

View file

@ -51,7 +51,6 @@ def __init__(self):
self.text = self.prev_text = '' self.text = self.prev_text = ''
self.fraction = self.prev_fraction = 0 self.fraction = self.prev_fraction = 0
self.progress_overlay = self.text_overlay = self.pieces_overlay = None self.progress_overlay = self.text_overlay = self.pieces_overlay = None
self.cr = None
self.connect('size-allocate', self.do_size_allocate_event) self.connect('size-allocate', self.do_size_allocate_event)
self.show() self.show()
@ -63,34 +62,30 @@ def do_size_allocate_event(self, widget, size):
self.height = size.height self.height = size.height
# Handle the draw by drawing # Handle the draw by drawing
def do_draw(self, event): def do_draw(self, ctx):
# Create cairo context ctx.set_line_width(max(ctx.device_to_user_distance(0.5, 0.5)))
self.cr = self.props.window.cairo_create()
self.cr.set_line_width(max(self.cr.device_to_user_distance(0.5, 0.5)))
# Restrict Cairo to the exposed area; avoid extra work # Restrict Cairo to the exposed area; avoid extra work
self.roundcorners_clipping() self.roundcorners_clipping(ctx)
self.draw_pieces() self.draw_pieces(ctx)
self.draw_progress_overlay() self.draw_progress_overlay(ctx)
self.write_text() self.write_text(ctx)
self.roundcorners_border() self.roundcorners_border(ctx)
# Drawn once, update width, height # Drawn once, update width, height
if self.resized(): if self.resized():
self.prev_width = self.width self.prev_width = self.width
self.prev_height = self.height self.prev_height = self.height
def roundcorners_clipping(self): def roundcorners_clipping(self, ctx):
self.create_roundcorners_subpath(self.cr, 0, 0, self.width, self.height) self.create_roundcorners_subpath(ctx, 0, 0, self.width, self.height)
self.cr.clip() ctx.clip()
def roundcorners_border(self): def roundcorners_border(self, ctx):
self.create_roundcorners_subpath( self.create_roundcorners_subpath(ctx, 0.5, 0.5, self.width - 1, self.height - 1)
self.cr, 0.5, 0.5, self.width - 1, self.height - 1 ctx.set_source_rgba(0, 0, 0, 0.9)
) ctx.stroke()
self.cr.set_source_rgba(0, 0, 0, 0.9)
self.cr.stroke()
@staticmethod @staticmethod
def create_roundcorners_subpath(ctx, x, y, width, height): def create_roundcorners_subpath(ctx, x, y, width, height):
@ -106,11 +101,9 @@ def create_roundcorners_subpath(ctx, x, y, width, height):
ctx.arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees) ctx.arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees)
ctx.arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees) ctx.arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees)
ctx.close_path() ctx.close_path()
return ctx
def draw_pieces(self): def draw_pieces(self, ctx):
if not self.num_pieces: if not self.num_pieces:
# Nothing to draw.
return return
if ( if (
@ -122,7 +115,7 @@ def draw_pieces(self):
self.pieces_overlay = cairo.ImageSurface( self.pieces_overlay = cairo.ImageSurface(
cairo.FORMAT_ARGB32, self.width, self.height cairo.FORMAT_ARGB32, self.width, self.height
) )
ctx = cairo.Context(self.pieces_overlay) pieces_ctx = cairo.Context(self.pieces_overlay)
if self.pieces: if self.pieces:
pieces = self.pieces pieces = self.pieces
@ -139,17 +132,16 @@ def draw_pieces(self):
for state in COLOR_STATES for state in COLOR_STATES
] ]
for state in pieces: for state in pieces:
ctx.set_source_rgb(*pieces_colors[state]) pieces_ctx.set_source_rgb(*pieces_colors[state])
ctx.rectangle(start_pos, 0, piece_width, self.height) pieces_ctx.rectangle(start_pos, 0, piece_width, self.height)
ctx.fill() pieces_ctx.fill()
start_pos += piece_width start_pos += piece_width
self.cr.set_source_surface(self.pieces_overlay) ctx.set_source_surface(self.pieces_overlay)
self.cr.paint() ctx.paint()
def draw_progress_overlay(self): def draw_progress_overlay(self, ctx):
if not self.text: if not self.text:
# Nothing useful to draw, return now!
return return
if ( if (
@ -161,16 +153,15 @@ def draw_progress_overlay(self):
self.progress_overlay = cairo.ImageSurface( self.progress_overlay = cairo.ImageSurface(
cairo.FORMAT_ARGB32, self.width, self.height cairo.FORMAT_ARGB32, self.width, self.height
) )
ctx = cairo.Context(self.progress_overlay) progress_ctx = cairo.Context(self.progress_overlay)
ctx.set_source_rgba(0.1, 0.1, 0.1, 0.3) # Transparent progress_ctx.set_source_rgba(0.1, 0.1, 0.1, 0.3) # Transparent
ctx.rectangle(0, 0, self.width * self.fraction, self.height) progress_ctx.rectangle(0, 0, self.width * self.fraction, self.height)
ctx.fill() progress_ctx.fill()
self.cr.set_source_surface(self.progress_overlay) ctx.set_source_surface(self.progress_overlay)
self.cr.paint() ctx.paint()
def write_text(self): def write_text(self, ctx):
if not self.text: if not self.text:
# Nothing useful to draw, return now!
return return
if self.resized() or self.text != self.prev_text or self.text_overlay is None: if self.resized() or self.text != self.prev_text or self.text_overlay is None:
@ -178,8 +169,8 @@ def write_text(self):
self.text_overlay = cairo.ImageSurface( self.text_overlay = cairo.ImageSurface(
cairo.FORMAT_ARGB32, self.width, self.height cairo.FORMAT_ARGB32, self.width, self.height
) )
ctx = cairo.Context(self.text_overlay) text_ctx = cairo.Context(self.text_overlay)
pl = PangoCairo.create_layout(ctx) pl = PangoCairo.create_layout(text_ctx)
pl.set_font_description(self.text_font) pl.set_font_description(self.text_font)
pl.set_width(-1) # No text wrapping pl.set_width(-1) # No text wrapping
pl.set_text(self.text, -1) pl.set_text(self.text, -1)
@ -188,12 +179,14 @@ def write_text(self):
text_height = plsize[1] // SCALE text_height = plsize[1] // SCALE
area_width_without_text = self.width - text_width area_width_without_text = self.width - text_width
area_height_without_text = self.height - text_height area_height_without_text = self.height - text_height
ctx.move_to(area_width_without_text // 2, area_height_without_text // 2) text_ctx.move_to(
ctx.set_source_rgb(1, 1, 1) area_width_without_text // 2, area_height_without_text // 2
PangoCairo.update_layout(ctx, pl) )
PangoCairo.show_layout(ctx, pl) text_ctx.set_source_rgb(1, 1, 1)
self.cr.set_source_surface(self.text_overlay) PangoCairo.update_layout(text_ctx, pl)
self.cr.paint() PangoCairo.show_layout(text_ctx, pl)
ctx.set_source_surface(self.text_overlay)
ctx.paint()
def resized(self): def resized(self):
return self.prev_width != self.width or self.prev_height != self.height return self.prev_width != self.width or self.prev_height != self.height
@ -226,7 +219,6 @@ def clear(self):
self.text = self.prev_text = '' self.text = self.prev_text = ''
self.fraction = self.prev_fraction = 0 self.fraction = self.prev_fraction = 0
self.progress_overlay = self.text_overlay = self.pieces_overlay = None self.progress_overlay = self.text_overlay = self.pieces_overlay = None
self.cr = None
self.update() self.update()
def update(self): def update(self):

View file

@ -4,9 +4,10 @@ rencode
pyopenssl pyopenssl
pyxdg pyxdg
pillow pillow
pillow<=9; python_version=="3.7"
mako mako
setuptools setuptools
chardet==4.0.0 chardet
setproctitle setproctitle
pywin32; sys_platform == 'win32' pywin32; sys_platform == 'win32'
certifi; sys_platform == 'win32' certifi; sys_platform == 'win32'
@ -14,4 +15,4 @@ windows-curses; sys_platform == 'win32'
zope.interface>=4.4.2 zope.interface>=4.4.2
distro; 'linux' in sys_platform or 'bsd' in sys_platform distro; 'linux' in sys_platform or 'bsd' in sys_platform
pygeoip pygeoip
ifaddr==0.2.0 ifaddr>=0.2.0