Cleared out old files
This commit is contained in:
3
src/core/containers/__init__.py
Normal file
3
src/core/containers/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Containers Module
|
||||
"""
|
44
src/core/containers/base_container.py
Normal file
44
src/core/containers/base_container.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .left_box import LeftBox
|
||||
from .right_box import RightBox
|
||||
from ..widgets.button_controls import ButtonControls
|
||||
from ..widgets.path_label import PathLabel
|
||||
|
||||
|
||||
class BaseContainer(Gtk.Box):
|
||||
def __init__(self):
|
||||
super(BaseContainer, self).__init__()
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._load_widgets()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_orientation(Gtk.Orientation.VERTICAL)
|
||||
|
||||
def _setup_signals(self):
|
||||
...
|
||||
|
||||
def _load_widgets(self):
|
||||
box = Gtk.Box()
|
||||
box2 = Gtk.Box()
|
||||
box.set_orientation(Gtk.Orientation.VERTICAL)
|
||||
box2.set_orientation(Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
box.add(ButtonControls())
|
||||
box.add(PathLabel())
|
||||
box2.add(LeftBox())
|
||||
box2.add(RightBox())
|
||||
|
||||
self.add(box)
|
||||
self.add(box2)
|
80
src/core/containers/image_list_scroll.py
Normal file
80
src/core/containers/image_list_scroll.py
Normal file
@@ -0,0 +1,80 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..widgets.image_list import ImageList
|
||||
|
||||
|
||||
|
||||
class ImageListScroll(Gtk.ScrolledWindow):
|
||||
def __init__(self):
|
||||
super(ImageListScroll, self).__init__()
|
||||
|
||||
self.image_list_widget = None
|
||||
self.size = 0
|
||||
self.start = 0
|
||||
self.end = settings.get_max_ring_thumbnail_list()
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._subscribe_to_events()
|
||||
self._load_widgets()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_vexpand(True)
|
||||
self.set_overlay_scrolling(False)
|
||||
|
||||
def _setup_signals(self):
|
||||
self.connect("edge-reached", self._handle_edge_reached)
|
||||
self.connect("edge-overshot", self._handle_edge_reached)
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("update_list_size_constraints", self._update_list_size_constraints)
|
||||
|
||||
def _load_widgets(self):
|
||||
self.image_list_widget = ImageList()
|
||||
self.add(self.image_list_widget)
|
||||
|
||||
# TODO: Setup to load range start/end values from settings,
|
||||
# NOTE: Must align with ImageList start/end limits too
|
||||
def _update_list_size_constraints(self, size):
|
||||
self.size = size
|
||||
self.start = 0
|
||||
self.end = settings.get_max_ring_thumbnail_list()
|
||||
|
||||
def _handle_edge_reached(self, widget, edge):
|
||||
children = self.image_list_widget.get_children()
|
||||
vadjustment = self.get_vadjustment()
|
||||
vvalue = vadjustment.get_value()
|
||||
|
||||
if edge == Gtk.PositionType.TOP:
|
||||
if self.start >= 1:
|
||||
self.start -= 1
|
||||
self._unload_image(children[self.end])
|
||||
children[self.start].show()
|
||||
self.end -= 1
|
||||
|
||||
vadjustment.set_value(vvalue + 1)
|
||||
if edge == Gtk.PositionType.BOTTOM:
|
||||
if (self.end + 1) < self.size:
|
||||
self.end += 1
|
||||
self._unload_image(children[self.start])
|
||||
|
||||
if not children[self.end].is_loaded:
|
||||
children[self.end].load_pixbuf()
|
||||
|
||||
children[self.end].show()
|
||||
self.start += 1
|
||||
vadjustment.set_value(vvalue - 1)
|
||||
|
||||
def _unload_image(self, child):
|
||||
child.hide()
|
||||
# child.image.clear()
|
||||
child.is_loaded = False
|
109
src/core/containers/image_view_scroll.py
Normal file
109
src/core/containers/image_view_scroll.py
Normal file
@@ -0,0 +1,109 @@
|
||||
# Python imports
|
||||
import os
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
|
||||
# Application imports
|
||||
from ..widgets.image_view import ImageView
|
||||
|
||||
|
||||
|
||||
class ImageViewScroll(Gtk.ScrolledWindow):
|
||||
def __init__(self):
|
||||
super(ImageViewScroll, self).__init__()
|
||||
|
||||
self.fimages = settings.get_images_filter()
|
||||
self.curent_dir = None
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._subscribe_to_events()
|
||||
self._load_widgets()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def _setup_styling(self):
|
||||
ctx = self.get_style_context()
|
||||
ctx.add_class("image-view")
|
||||
self.set_vexpand(True)
|
||||
self.set_hexpand(True)
|
||||
|
||||
def _setup_signals(self):
|
||||
self._set_up_dnd()
|
||||
self.connect("size-allocate", self._size_request_change)
|
||||
|
||||
def _load_widgets(self):
|
||||
self.add(ImageView())
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("do_filter_open", self._do_filter_open)
|
||||
|
||||
def _set_up_dnd(self):
|
||||
flags = Gtk.DestDefaults.ALL
|
||||
URI_TARGET_TYPE = 80
|
||||
|
||||
uri_target = Gtk.TargetEntry.new('text/uri-list', Gtk.TargetFlags(0), URI_TARGET_TYPE)
|
||||
targets = [ uri_target ]
|
||||
action = Gdk.DragAction.COPY
|
||||
|
||||
self.drag_dest_set(flags, targets, action)
|
||||
self.connect("drag-data-received", self._on_drag_data_received)
|
||||
|
||||
def _on_drag_data_received(self, widget, drag_context, _x, _y, data, info, time):
|
||||
if info == 80:
|
||||
uris = data.get_uris()
|
||||
if len(uris) == 0:
|
||||
uris = data.get_text().split("\n")
|
||||
|
||||
self._do_filter_open(uris)
|
||||
|
||||
|
||||
def _do_filter_open(self, uris: [] = []):
|
||||
if len(uris) == 0:
|
||||
return
|
||||
|
||||
has_loaded_image, path, img_list = self.filter_for_images(uris)
|
||||
self._handle_open(has_loaded_image, path, img_list)
|
||||
|
||||
def filter_for_images(self, files):
|
||||
path = files[0].replace("file://", "")
|
||||
img_list = []
|
||||
listedDir = False
|
||||
has_loaded_image = False
|
||||
|
||||
if not os.path.isdir(path):
|
||||
event_system.emit("handle_file_from_dnd", (path,))
|
||||
path = os.path.dirname(path)
|
||||
has_loaded_image = True
|
||||
|
||||
if not self.curent_dir or not self.curent_dir == path:
|
||||
files = os.listdir(path)
|
||||
self.curent_dir = path
|
||||
else:
|
||||
files = []
|
||||
|
||||
for file in files:
|
||||
if file.endswith(self.fimages):
|
||||
img_list.append(file)
|
||||
|
||||
return has_loaded_image, path, img_list
|
||||
|
||||
def _handle_open(self, has_loaded_image, path, img_list):
|
||||
if len(img_list) == 0:
|
||||
return
|
||||
|
||||
if not has_loaded_image:
|
||||
img = img_list[0]
|
||||
target = os.path.join(path, img)
|
||||
event_system.emit("handle_file_from_dnd", target)
|
||||
|
||||
event_system.emit("load_image_list", (path, img_list))
|
||||
|
||||
def _size_request_change(self, widget = None, eve = None):
|
||||
event_system.emit("size_allocate")
|
33
src/core/containers/left_box.py
Normal file
33
src/core/containers/left_box.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .image_list_scroll import ImageListScroll
|
||||
|
||||
|
||||
|
||||
class LeftBox(Gtk.Box):
|
||||
def __init__(self):
|
||||
super(LeftBox, self).__init__()
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._load_widgets()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_orientation(Gtk.Orientation.VERTICAL)
|
||||
self.set_size_request(settings.get_thumbnail_with() + 15, -1)
|
||||
self.set_vexpand(True)
|
||||
|
||||
def _setup_signals(self):
|
||||
...
|
||||
|
||||
def _load_widgets(self):
|
||||
self.add(ImageListScroll())
|
35
src/core/containers/right_box.py
Normal file
35
src/core/containers/right_box.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
|
||||
# Application imports
|
||||
from .image_view_scroll import ImageViewScroll
|
||||
|
||||
|
||||
|
||||
class RightBox(Gtk.Box):
|
||||
def __init__(self):
|
||||
super(RightBox, self).__init__()
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._load_widgets()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_vexpand(True)
|
||||
self.set_hexpand(True)
|
||||
self.set_orientation(Gtk.Orientation.VERTICAL)
|
||||
|
||||
def _setup_signals(self):
|
||||
...
|
||||
|
||||
def _load_widgets(self):
|
||||
self.add(ImageViewScroll())
|
Reference in New Issue
Block a user