Philipp Hörist pushed to branch master at gajim / gajim
Commits: 3becd516 by Philipp Hörist at 2022-12-03T21:46:07+01:00 cq: Remove newline
- - - - - 0e53991c by Philipp Hörist at 2022-12-03T22:16:46+01:00 cq: Fix typing for cairo.Context
- - - - -
4 changed files:
- .ci/make_release.py - gajim/gtk/avatar.py - gajim/gtk/avatar_selector.py - gajim/gtk/types.py
Changes:
===================================== .ci/make_release.py ===================================== @@ -44,7 +44,6 @@ def create_release(project: Project, version: str) -> None: parser.add_argument('token', type=str, help='The API token') args = parser.parse_args()
- api = Gitlab(GITLAB_INSTANCE_URL, private_token=args.token) api.auth() project = api.projects.get(PROJECT_ID)
===================================== gajim/gtk/avatar.py ===================================== @@ -106,7 +106,7 @@ def generate_avatar(letters: str, context.set_operator(cairo.Operator.OVER) PangoCairo.show_layout(context, layout)
- return context.get_target() # pyright: ignore + return context.get_target()
@lru_cache(maxsize=None) @@ -183,7 +183,7 @@ def add_status_to_avatar(surface: cairo.ImageSurface, context.set_line_width(clip_radius / 4) context.stroke()
- return context.get_target() # pyright: ignore + return context.get_target()
@lru_cache(maxsize=128) @@ -220,7 +220,7 @@ def get_show_circle(show: Union[str, types.PresenceShowT], context.set_line_width(size / 10) context.stroke()
- return context.get_target() # pyright: ignore + return context.get_target()
def fit(surface: cairo.ImageSurface, size: int) -> cairo.ImageSurface: @@ -243,7 +243,7 @@ def fit(surface: cairo.ImageSurface, size: int) -> cairo.ImageSurface: context.scale(factor, factor) context.set_source_surface(square_surface, 0, 0) context.paint() - return context.get_target() # pyright: ignore + return context.get_target()
def square(surface: cairo.ImageSurface, size: int) -> cairo.ImageSurface: @@ -267,7 +267,7 @@ def square(surface: cairo.ImageSurface, size: int) -> cairo.ImageSurface:
context.set_source_surface(surface, x_pos, y_pos) context.paint() - return context.get_target() # pyright: ignore + return context.get_target()
def clip(surface: cairo.ImageSurface, mode: str) -> cairo.ImageSurface: @@ -297,7 +297,7 @@ def clip_circle(surface: cairo.ImageSurface) -> cairo.ImageSurface: context.clip() context.paint()
- return context.get_target() # pyright: ignore + return context.get_target()
def round_corners(surface: cairo.ImageSurface) -> cairo.ImageSurface: @@ -328,7 +328,7 @@ def round_corners(surface: cairo.ImageSurface) -> cairo.ImageSurface:
context.paint()
- return context.get_target() # pyright: ignore + return context.get_target()
def convert_to_greyscale(surface: cairo.ImageSurface) -> cairo.ImageSurface: @@ -341,7 +341,7 @@ def convert_to_greyscale(surface: cairo.ImageSurface) -> cairo.ImageSurface: context.set_source_rgba(1, 1, 1, 0.5) context.rectangle(0, 0, surface.get_width(), surface.get_height()) context.fill() - return context.get_target() # pyright: ignore + return context.get_target()
class AvatarStorage(metaclass=Singleton):
===================================== gajim/gtk/avatar_selector.py ===================================== @@ -34,6 +34,7 @@ from gajim.common.i18n import _ from gajim.common.helpers import get_file_path_from_dnd_dropped_uri
+from . import types from .dialogs import ErrorDialog from .filechoosers import AvatarChooserDialog from .util import scale_with_ratio @@ -286,7 +287,11 @@ def get_pixbuf(self) -> Optional[GdkPixbuf.Pixbuf]: return GdkPixbuf.Pixbuf.new_subpixbuf( self._browse_pixbuf, self._crop.x, self._crop.y, width, height)
- def _on_draw(self, _widget: Gtk.Widget, context: cairo.Context) -> bool: + def _on_draw(self, + _widget: Gtk.Widget, + context: cairo.Context[types.SomeSurface] + ) -> bool: + if self._browse_pixbuf is None: return False
===================================== gajim/gtk/types.py ===================================== @@ -16,6 +16,9 @@
from typing import Union from typing import TYPE_CHECKING +from typing import TypeVar + +import cairo
if TYPE_CHECKING: @@ -39,3 +42,5 @@ ControlT = Union['ChatControl']
ConversationViewT = Union['ConversationView'] + +SomeSurface = TypeVar('SomeSurface', bound=cairo.Surface)
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/52816f7f56526fce1da12692556aea70...