Fixed some bugs regarding setting paths and incorrect selections
This commit is contained in:
@@ -91,17 +91,20 @@ class ChangeView(Gtk.Box, CommonWidgetGeneratorMixin, CommonActionsMixin):
|
|||||||
return self._active_path
|
return self._active_path
|
||||||
|
|
||||||
def _set_active_path(self, _file):
|
def _set_active_path(self, _file):
|
||||||
if os.path.isdir(_file) :
|
if not os.path.isdir(_file) : return
|
||||||
self._from_changes.clear()
|
|
||||||
self._active_path = _file
|
|
||||||
for f in os.listdir(_file):
|
|
||||||
self._from_changes.append(f)
|
|
||||||
|
|
||||||
self._from_changes.sort(key=self._natural_keys)
|
event_system.emit("set-file-chooser-path", (_file,))
|
||||||
self._to_changes = self._from_changes
|
|
||||||
|
|
||||||
event_system.emit("update-from")
|
self._active_path = _file
|
||||||
event_system.emit("update-to")
|
self._from_changes.clear()
|
||||||
|
for f in os.listdir(_file):
|
||||||
|
self._from_changes.append(f)
|
||||||
|
|
||||||
|
self._from_changes.sort(key=self._natural_keys)
|
||||||
|
self._to_changes = self._from_changes
|
||||||
|
|
||||||
|
event_system.emit("update-from")
|
||||||
|
event_system.emit("update-to")
|
||||||
|
|
||||||
def get_from_list(self):
|
def get_from_list(self):
|
||||||
return self._from_changes
|
return self._from_changes
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class Controller(Gtk.Box, CommonWidgetGeneratorMixin):
|
|||||||
def __init__(self, args, unknownargs):
|
def __init__(self, args, unknownargs):
|
||||||
super(Controller, self).__init__()
|
super(Controller, self).__init__()
|
||||||
|
|
||||||
# # Add header
|
|
||||||
self.change_view = None
|
self.change_view = None
|
||||||
self.copy_window = None
|
self.copy_window = None
|
||||||
self.store = None
|
self.store = None
|
||||||
@@ -37,9 +36,12 @@ class Controller(Gtk.Box, CommonWidgetGeneratorMixin):
|
|||||||
for arg in unknownargs:
|
for arg in unknownargs:
|
||||||
if os.path.isdir(arg):
|
if os.path.isdir(arg):
|
||||||
event_system.emit("set-active-path", (arg,))
|
event_system.emit("set-active-path", (arg,))
|
||||||
|
self._set_file_chooser_path(arg)
|
||||||
|
|
||||||
if args.path and os.path.isdir(args.path):
|
if args.path and os.path.isdir(args.path):
|
||||||
event_system.emit("set-active-path", (args.path,))
|
event_system.emit("set-active-path", (args.path,))
|
||||||
|
self._set_file_chooser_path(args.path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
@@ -55,6 +57,7 @@ class Controller(Gtk.Box, CommonWidgetGeneratorMixin):
|
|||||||
|
|
||||||
def _subscribe_to_events(self):
|
def _subscribe_to_events(self):
|
||||||
event_system.subscribe("handle-gui-event", self._handle_gui_event)
|
event_system.subscribe("handle-gui-event", self._handle_gui_event)
|
||||||
|
event_system.subscribe("set-file-chooser-path", self._set_file_chooser_path)
|
||||||
|
|
||||||
def _load_widgets(self):
|
def _load_widgets(self):
|
||||||
self.change_view = ChangeView()
|
self.change_view = ChangeView()
|
||||||
@@ -106,6 +109,9 @@ class Controller(Gtk.Box, CommonWidgetGeneratorMixin):
|
|||||||
self.add(run_button)
|
self.add(run_button)
|
||||||
|
|
||||||
|
|
||||||
|
def _set_file_chooser_path(self, path):
|
||||||
|
self.get_children()[0].set_filename(path)
|
||||||
|
|
||||||
def update_dir_path(self, widget):
|
def update_dir_path(self, widget):
|
||||||
path = widget.get_filename()
|
path = widget.get_filename()
|
||||||
event_system.emit("set-active-path", (path,))
|
event_system.emit("set-active-path", (path,))
|
||||||
|
|||||||
@@ -69,9 +69,11 @@ class CommonWidgetGeneratorMixin:
|
|||||||
grid = Gtk.ListBox()
|
grid = Gtk.ListBox()
|
||||||
viewport = Gtk.Viewport()
|
viewport = Gtk.Viewport()
|
||||||
|
|
||||||
grid.show_all()
|
grid.set_selection_mode( Gtk.SelectionMode.NONE )
|
||||||
|
scroll.set_size_request(360, 200)
|
||||||
|
|
||||||
viewport.add(grid)
|
viewport.add(grid)
|
||||||
scroll.add(viewport)
|
scroll.add(viewport)
|
||||||
|
grid.show_all()
|
||||||
|
|
||||||
scroll.set_size_request(360, 200)
|
|
||||||
return scroll, grid
|
return scroll, grid
|
||||||
|
|||||||
Reference in New Issue
Block a user