Image event box addition
This commit is contained in:
parent
8178fe3490
commit
31bf0e00b5
|
@ -37,15 +37,28 @@ class PreviewScroll(Gtk.ScrolledWindow):
|
||||||
|
|
||||||
def _load_widgets(self):
|
def _load_widgets(self):
|
||||||
viewport = Gtk.Viewport()
|
viewport = Gtk.Viewport()
|
||||||
viewport.add(PreviewPane())
|
eve_box = Gtk.EventBox()
|
||||||
viewport.connect("size-allocate", self._scale_image)
|
|
||||||
|
eve_box.add(PreviewPane())
|
||||||
|
viewport.add(eve_box)
|
||||||
self.add(viewport)
|
self.add(viewport)
|
||||||
|
|
||||||
|
eve_box.connect("button-release-event", self._handle_clicks)
|
||||||
|
viewport.connect("size-allocate", self._scale_image)
|
||||||
|
|
||||||
def _scale_image(self, widget = None, allocation = None):
|
def _scale_image(self, widget = None, allocation = None):
|
||||||
child = widget.get_children()[0]
|
preview_image = widget.get_children()[0].get_children()[0]
|
||||||
if not child.pixbuf in ("", None):
|
|
||||||
pixbuf = child.scale_to_container(child.pixbuf)
|
if not preview_image.pixbuf in ("", None):
|
||||||
child.set_from_pixbuf(pixbuf)
|
pixbuf = preview_image.scale_to_container(preview_image.pixbuf)
|
||||||
|
preview_image.set_from_pixbuf(pixbuf)
|
||||||
|
|
||||||
|
def _handle_clicks(self, widget = None, eve = None):
|
||||||
|
preview_image = widget.get_children()[0]
|
||||||
|
|
||||||
|
if eve.button == 3 and not preview_image.file_name in ("", None):
|
||||||
|
event_system.emit("set_revert_data", (preview_image.file_name,))
|
||||||
|
event_system.emit("show_menu", (preview_image.file_name,))
|
||||||
|
|
||||||
|
|
||||||
class LeftBox(Gtk.Box):
|
class LeftBox(Gtk.Box):
|
||||||
|
|
|
@ -16,6 +16,7 @@ class PreviewPane(Gtk.Image):
|
||||||
super(PreviewPane, self).__init__()
|
super(PreviewPane, self).__init__()
|
||||||
|
|
||||||
self.pixbuf = None
|
self.pixbuf = None
|
||||||
|
self.file_name = None
|
||||||
|
|
||||||
self._setup_styling()
|
self._setup_styling()
|
||||||
self._setup_signals()
|
self._setup_signals()
|
||||||
|
@ -39,17 +40,18 @@ class PreviewPane(Gtk.Image):
|
||||||
def _load_widgets(self):
|
def _load_widgets(self):
|
||||||
self.unset_image_preview()
|
self.unset_image_preview()
|
||||||
|
|
||||||
def set_image_to_view(self, image_file):
|
def set_image_to_view(self, file_name):
|
||||||
if not image_file:
|
if not file_name:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.file_name = file_name
|
||||||
images_dir = settings.get_screenshots_dir()
|
images_dir = settings.get_screenshots_dir()
|
||||||
path = os.path.join(images_dir, image_file)
|
path = os.path.join(images_dir, file_name)
|
||||||
self.pixbuf = Gtk.Image.new_from_file(path).get_pixbuf()
|
self.pixbuf = Gtk.Image.new_from_file(path).get_pixbuf()
|
||||||
self.set_from_pixbuf( self.scale_to_container(self.pixbuf) )
|
self.set_from_pixbuf( self.scale_to_container(self.pixbuf) )
|
||||||
|
|
||||||
def scale_to_container(self, pixbuf):
|
def scale_to_container(self, pixbuf):
|
||||||
rect = self.get_parent().get_parent().get_allocated_size().allocation
|
rect = self.get_parent().get_parent().get_parent().get_allocated_size().allocation
|
||||||
pxw = pixbuf.get_width()
|
pxw = pixbuf.get_width()
|
||||||
pxh = pixbuf.get_height()
|
pxh = pixbuf.get_height()
|
||||||
h = rect.height
|
h = rect.height
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
.region-window {
|
.region-window {
|
||||||
background-color: rgba(0, 0, 0, 0.0);
|
background-color: rgba(0, 0, 0, 0.0);
|
||||||
/* border: 2px solid rgba(136, 204, 39, 1); */
|
|
||||||
/* Dark Bergundy */
|
/* Dark Bergundy */
|
||||||
border: 2px solid rgba(116, 0, 0, 1);
|
border: 2px solid rgba(116, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.expand-button {
|
.transparent-button {
|
||||||
background-color: rgba(0, 0, 0, 0.0);
|
background-color: rgba(0, 0, 0, 0.0);
|
||||||
border: 2px solid rgba(56, 56, 56, 1);
|
border: 2px solid rgba(96, 96, 96, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue