Get rid of cairo dependency

This commit is contained in:
Philipp Hörist 2017-04-19 16:58:16 +02:00
parent 86e29fb7f4
commit 358d410d5e
2 changed files with 4 additions and 20 deletions

View File

@ -34,7 +34,6 @@ from gi.repository import Gdk
from gi.repository import GdkPixbuf from gi.repository import GdkPixbuf
from gi.repository import GObject from gi.repository import GObject
from gi.repository import GLib from gi.repository import GLib
import cairo
import os import os
import nbxmpp import nbxmpp
import time import time
@ -5688,28 +5687,21 @@ class BigAvatarWindow(Gtk.Window):
self.callback = callback self.callback = callback
self.screen = self.get_screen() self.screen = self.get_screen()
self.visual = self.screen.get_rgba_visual() self.visual = self.screen.get_rgba_visual()
if self.visual != None and self.screen.is_composited(): if self.visual is not None and self.screen.is_composited():
self.set_visual(self.visual) self.set_visual(self.visual)
self.set_app_paintable(True) self.set_app_paintable(True)
self.set_size_request(width, height) self.set_size_request(width, height)
self.move(pos_x, pos_y) self.move(pos_x, pos_y)
self.connect("draw", self.area_draw)
# we should hide the window # we should hide the window
self.connect('leave_notify_event', self._on_window_avatar_leave_notify) self.connect('leave_notify_event', self._on_window_avatar_leave_notify)
self.connect('motion-notify-event', self._on_window_motion_notify) self.connect('motion-notify-event', self._on_window_motion_notify)
self.realize() self.realize()
# make the cursor invisible so we can see the image # make the cursor invisible so we can see the image
invisible_cursor = gtkgui_helpers.get_invisible_cursor() self.get_window().set_cursor(
self.get_window().set_cursor(invisible_cursor) Gdk.Cursor.new(Gdk.CursorType.BLANK_CURSOR))
self.add(Gtk.Image.new_from_pixbuf(self.avatar))
self.show_all() self.show_all()
def area_draw(self, widget, cr):
cr.set_source_rgba(.2, .2, .2, 0.0)
cr.set_operator(cairo.OPERATOR_SOURCE)
Gdk.cairo_set_source_pixbuf(cr, self.avatar, 0, 0)
cr.paint()
cr.set_operator(cairo.OPERATOR_OVER)
def _on_window_avatar_leave_notify(self, widget, event): def _on_window_avatar_leave_notify(self, widget, event):
""" """
Just left the popup window that holds avatar Just left the popup window that holds avatar

View File

@ -486,14 +486,6 @@ def get_pixbuf_from_data(file_data, want_type = False):
else: else:
return pixbuf return pixbuf
def get_invisible_cursor():
import cairo
s = cairo.ImageSurface(cairo.FORMAT_A1, 1, 1)
cursor_pixbuf = Gdk.pixbuf_get_from_surface(s, 0, 0, 1, 1)
cursor = Gdk.Cursor.new_from_pixbuf(Gdk.Display.get_default(), \
cursor_pixbuf, 0, 0)
return cursor
def get_cursor(attr): def get_cursor(attr):
display = Gdk.Display.get_default() display = Gdk.Display.get_default()
cursor = getattr(Gdk.CursorType, attr) cursor = getattr(Gdk.CursorType, attr)