generated from itdominator/Python-With-Gtk-Template
Refactoring, added IOPopup widget, copy/delete files
This commit is contained in:
parent
79728cb706
commit
f708dedd2b
@ -12,13 +12,14 @@ from gi.repository import GLib
|
||||
# Application imports
|
||||
from utils.launcher import Launcher
|
||||
|
||||
from .mixins.signals_mixins import SignalsMixins
|
||||
from .controller_data import ControllerData
|
||||
from .mixins.signals_mixins import SignalsMixins
|
||||
from .query_controller import QueryController
|
||||
|
||||
from .widgets.create_notebook_widget import CreateNotebookWidget
|
||||
from .widgets.sections.sections_widget import Sections
|
||||
from .widgets.dialogs.message_widget import MessageWidget
|
||||
from .widgets.dialogs.section_header_updater_widget import SectionHeaderUpdater
|
||||
from .widgets.sections.sections_widget import Sections
|
||||
|
||||
|
||||
|
||||
|
@ -73,6 +73,8 @@ class IOWidget(Gtk.Box):
|
||||
status = self._file.move_finish(task)
|
||||
if self._action == "copy":
|
||||
status = self._file.copy_finish(task)
|
||||
if self._action == "delete":
|
||||
status = self._file.delete_finish(task)
|
||||
|
||||
if status:
|
||||
self.delete_self()
|
||||
|
@ -11,7 +11,7 @@ from gi.repository import GtkSource
|
||||
from gi.repository import Gio
|
||||
|
||||
# Application imports
|
||||
from .template.dynamic_widget_template import DynamicWidget
|
||||
from ..template.dynamic_widget_template import DynamicWidget
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .drag_area_widget import DragArea
|
||||
from .pages_tab_widget import PagesTabWidget
|
||||
from ..pages.pages_tab_widget import PagesTabWidget
|
||||
|
||||
|
||||
|
||||
@ -83,7 +83,8 @@ class Page(Gtk.ScrolledWindow):
|
||||
files = settings.clean_pages_list( os.listdir( path ) )
|
||||
for file in files:
|
||||
fpath = os.path.join(path, file)
|
||||
self._drag_area.load_path_to_widget(fpath)
|
||||
if not os.path.isdir(fpath):
|
||||
self._drag_area.load_path_to_widget(fpath)
|
||||
|
||||
def _update_header(self, widget = None, eve = None):
|
||||
self._name = widget.get_text()
|
@ -6,7 +6,7 @@ gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .template.tab_header_template import TabHeaderTemplate
|
||||
from ..template.tab_header_template import TabHeaderTemplate
|
||||
|
||||
|
||||
|
@ -7,8 +7,8 @@ gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..sections_tab_widget import SectionsTabWidget
|
||||
from ..page_widget import Page
|
||||
from ..sections.sections_tab_widget import SectionsTabWidget
|
||||
from ..page_body.page_widget import Page
|
||||
|
||||
|
||||
|
||||
|
3
src/core/widgets/popups/__init__.py
Normal file
3
src/core/widgets/popups/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
"""
|
||||
Popups module
|
||||
"""
|
48
src/core/widgets/popups/io_popup_widget.py
Normal file
48
src/core/widgets/popups/io_popup_widget.py
Normal file
@ -0,0 +1,48 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
class IOPopupWidget(Gtk.Popover):
|
||||
"""docstring for IOPopupWidget."""
|
||||
|
||||
def __init__(self):
|
||||
super(IOPopupWidget, self).__init__()
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._subscribe_to_events()
|
||||
self._load_widgets()
|
||||
|
||||
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_position(Gtk.PositionType.BOTTOM)
|
||||
self.set_size_request(320, 280)
|
||||
|
||||
def _setup_signals(self):
|
||||
...
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("show_io_popup", self.show_io_popup)
|
||||
event_system.subscribe("append_to_io_list", self.append_io_widget)
|
||||
|
||||
def _load_widgets(self):
|
||||
vbox = Gtk.Box()
|
||||
vbox.set_orientation(Gtk.Orientation.VERTICAL)
|
||||
|
||||
vbox.show()
|
||||
self.add(vbox)
|
||||
|
||||
def show_io_popup(self, widget = None, eve = None):
|
||||
self.popup()
|
||||
|
||||
def append_io_widget(self, io_widget):
|
||||
self.get_children()[0].add(io_widget)
|
||||
io_widget.show_all()
|
@ -95,7 +95,7 @@ class WidgetSelector(Gtk.Popover):
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_size_request(256, 480)
|
||||
|
||||
self.set_position(Gtk.PositionType.BOTTOM)
|
||||
|
||||
def _setup_signals(self):
|
||||
...
|
@ -9,7 +9,7 @@ from gi.repository import Gio
|
||||
|
||||
# Application imports
|
||||
from utils.widget_save_load_controller import WidgetSaveLoadController
|
||||
from ...io_widget import IOWidget
|
||||
from ....io_widget import IOWidget
|
||||
|
||||
|
||||
|
||||
@ -59,9 +59,9 @@ class FileWidget(WidgetSaveLoadController, Gtk.Box):
|
||||
def __init__(self):
|
||||
super(FileWidget, self).__init__()
|
||||
|
||||
self.label = None
|
||||
self._file = None
|
||||
self._file_name = "No File Selected..."
|
||||
self.label = None
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
@ -77,6 +77,19 @@ class FileWidget(WidgetSaveLoadController, Gtk.Box):
|
||||
widget = FileWidget()
|
||||
return widget
|
||||
|
||||
def delete_cleanup(self):
|
||||
working_page = settings.get_active_page().replace('MANIFEST', '')
|
||||
path = self._file.get_path()
|
||||
if not os.path.isdir(path) and working_page in path:
|
||||
logger.debug(f"Deleteing: {path}")
|
||||
io_widget = IOWidget("delete", self._file)
|
||||
|
||||
self._file.delete_async(io_priority = 75,
|
||||
cancellable = io_widget.cancle_eve,
|
||||
callback = io_widget.finish_callback)
|
||||
|
||||
event_system.emit("append_to_io_list", (io_widget,))
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_orientation(1)
|
||||
|
||||
@ -186,11 +199,11 @@ class FileWidget(WidgetSaveLoadController, Gtk.Box):
|
||||
gio_copy_file = Gio.File.new_for_path(copy_tgt_pth)
|
||||
|
||||
self._file.copy_async(destination = gio_copy_file,
|
||||
flags = Gio.FileCopyFlags.BACKUP,
|
||||
io_priority = 75,
|
||||
cancellable = io_widget.cancle_eve,
|
||||
progress_callback = io_widget.update_progress,
|
||||
callback = io_widget.finish_callback)
|
||||
flags = Gio.FileCopyFlags.BACKUP,
|
||||
io_priority = 75,
|
||||
cancellable = io_widget.cancle_eve,
|
||||
progress_callback = io_widget.update_progress,
|
||||
callback = io_widget.finish_callback)
|
||||
|
||||
event_system.emit("append_to_io_list", (io_widget,))
|
||||
self._file = gio_copy_file
|
@ -33,6 +33,9 @@ class TextAreaWidget(WidgetSaveLoadController, GtkSource.View):
|
||||
widget.buffer.set_text("Lorem ipsum dolor")
|
||||
return widget
|
||||
|
||||
def delete_cleanup(self):
|
||||
...
|
||||
|
||||
def _setup_styling(self):
|
||||
...
|
||||
|
@ -6,7 +6,7 @@ gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .template.tab_header_template import TabHeaderTemplate
|
||||
from ..template.tab_header_template import TabHeaderTemplate
|
||||
|
||||
|
||||
|
@ -8,7 +8,8 @@ from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..pages.pages_widget import Pages
|
||||
from ..widget_selector.widget_selector_grid import WidgetSelector
|
||||
from ..popups.widget_selector.widget_selector_grid import WidgetSelector
|
||||
from ..popups.io_popup_widget import IOPopupWidget
|
||||
|
||||
|
||||
class Sections(Gtk.Notebook):
|
||||
@ -49,6 +50,14 @@ class Sections(Gtk.Notebook):
|
||||
add_btn.set_always_show_image(True)
|
||||
add_btn.connect("released", self.create_section_view)
|
||||
|
||||
io_btn = Gtk.Button(label="I/O")
|
||||
io_btn.set_image( Gtk.Image.new_from_icon_name("gtk-stop", 4) )
|
||||
io_btn.set_always_show_image(True)
|
||||
io_btn.connect("released", self.show_io_collection)
|
||||
|
||||
io_popup = IOPopupWidget()
|
||||
io_popup.set_relative_to(io_btn)
|
||||
|
||||
widgets_btn = Gtk.Button()
|
||||
widgets_btn.set_image( Gtk.Image.new_from_icon_name("gtk-cdrom", 4) )
|
||||
widgets_btn.set_always_show_image(True)
|
||||
@ -56,9 +65,9 @@ class Sections(Gtk.Notebook):
|
||||
|
||||
widget_selector = WidgetSelector()
|
||||
widget_selector.set_relative_to(widgets_btn)
|
||||
widget_selector.set_position(3)
|
||||
|
||||
start_box.add(widgets_btn)
|
||||
start_box.add(io_btn)
|
||||
end_box.add(add_btn)
|
||||
end_box.add(search)
|
||||
|
||||
@ -116,5 +125,8 @@ class Sections(Gtk.Notebook):
|
||||
path = page.get_section_pth()
|
||||
settings.set_active_section(path)
|
||||
|
||||
def show_io_collection(self, widget = None, eve = None):
|
||||
event_system.emit("show_io_popup")
|
||||
|
||||
def show_widgets_selection(self, widget = None, eve = None):
|
||||
event_system.emit("show_widget_types")
|
||||
|
@ -109,6 +109,7 @@ class DynamicWidget(Gtk.Box):
|
||||
self.is_self_destroyed = True
|
||||
self.is_not_stop_watcher = False
|
||||
self._header_widget.destroy()
|
||||
self._body_widget.delete_cleanup()
|
||||
self._body_widget.destroy()
|
||||
self.destroy()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user