44 lines
928 B
Python
44 lines
928 B
Python
|
# Python imports
|
||
|
|
||
|
# Lib imports
|
||
|
import gi
|
||
|
gi.require_version('Gtk', '3.0')
|
||
|
from gi.repository import Gtk
|
||
|
|
||
|
# Application imports
|
||
|
|
||
|
|
||
|
|
||
|
class Image(Gtk.EventBox):
|
||
|
def __init__(self, path = None):
|
||
|
super(Image, self).__init__()
|
||
|
|
||
|
self.image = None
|
||
|
self.path = path
|
||
|
|
||
|
self._setup_styling()
|
||
|
self._setup_signals()
|
||
|
self._load_widgets()
|
||
|
|
||
|
|
||
|
def _setup_styling(self):
|
||
|
...
|
||
|
|
||
|
def _setup_signals(self):
|
||
|
self.connect("button-release-event", self.set_image_to_view)
|
||
|
|
||
|
def _subscribe_to_events(self):
|
||
|
...
|
||
|
|
||
|
def _load_widgets(self):
|
||
|
self.image = Gtk.Image()
|
||
|
self.image.show()
|
||
|
self.add(self.image)
|
||
|
|
||
|
def set_from_pixbuf(self, pixbuf):
|
||
|
self.image.set_from_pixbuf(pixbuf)
|
||
|
|
||
|
def set_image_to_view(self, widget = None, eve = None):
|
||
|
if eve.button == 1:
|
||
|
event_system.emit("handle_file_from_dnd", (self.path, ))
|