Setting template for copy and cut.

This commit is contained in:
itdominator 2021-11-21 14:50:32 -06:00
parent 15aa17a046
commit b175f02dcc
6 changed files with 68 additions and 45 deletions

View File

@ -0,0 +1,18 @@
#!/bin/bash
# . CONFIG.sh
# set -o xtrace ## To debug scripts
# set -o errexit ## To exit on error
# set -o errunset ## To exit if a variable is referenced but not set
function main() {
SCRIPTPATH="$( cd "$(dirname "")" >/dev/null 2>&1 ; pwd -P )"
cd "${SCRIPTPATH}"
echo "Working Dir: " $(pwd)
source "/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/bin/activate"
python .
}
main "$@";

View File

@ -429,7 +429,11 @@
<property name="scrollable">True</property>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
<object class="GtkIconView">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin">6</property>
</object>
</child>
<child type="tab">
<placeholder/>

View File

@ -36,6 +36,9 @@ class Signals(PaneMixin, WindowMixin):
self.window3 = self.builder.get_object("window3")
self.window4 = self.builder.get_object("window4")
self.notebooks = [self.window1, self.window2, self.window3, self.window4]
self.selected_files = []
self.to_copy_files = []
self.to_cut_files = []
self.single_click_open = False
self.is_pane1_hidden = False
@ -122,9 +125,13 @@ class Signals(PaneMixin, WindowMixin):
if self.ctrlDown and keyname == "h":
self.show_hide_hidden_files()
if self.ctrlDown and keyname == "c":
self.copy_file()
self.to_cut_files.clear()
self.copy_files()
if self.ctrlDown and keyname == "x":
self.to_copy_files.clear()
self.cut_files()
if self.ctrlDown and keyname == "v":
print("[paste] stub...")
self.paste_files()
def tear_down(self, widget=None, eve=None):

View File

@ -44,6 +44,7 @@ class TabMixin(WidgetMixin):
self.set_window_title()
def on_tab_switch_update(self, notebook, content=None, index=None):
self.selected_files.clear()
wid, tid = content.get_children()[0].get_name().split("|")
self.window_controller.set_active_data(wid, tid)
self.set_path_text(wid, tid)
@ -111,17 +112,6 @@ class TabMixin(WidgetMixin):
self.builder.get_object("refresh_view").released()
def get_uris(self, store, treePaths=None):
uris = []
for path in treePaths:
itr = store.get_iter(path)
file = store.get(itr, 1)[0]
fpath = f"file://{dir}/{file}"
uris.append(fpath)
return uris
def create_file(self):
pass
@ -142,28 +132,22 @@ class TabMixin(WidgetMixin):
def menu_bar_copy(self, widget, eve):
self.copy_file()
def copy_file(self):
def copy_files(self):
wid, tid = self.window_controller.get_active_data()
print(wid)
print(tid)
notebook = self.builder.get_object(f"window_{wid}")
iconview = self.get_tab_iconview_from_notebook(notebook)
print(iconview)
iconview = self.builder.get_object(f"{wid}|{tid}|iconview")
store = iconview.get_model()
treePaths = iconview.get_selected_items()
uris = self.format_to_uris(store, wid, tid, self.selected_files)
self.to_copy_files = uris
print(len(treePaths))
for path in treePaths:
itr = store.get_iter(path)
file = store.get(itr, 1)[0]
print(file)
def cut_files(self):
wid, tid = self.window_controller.get_active_data()
iconview = self.builder.get_object(f"{wid}|{tid}|iconview")
store = iconview.get_model()
uris = self.format_to_uris(store, wid, tid, self.selected_files)
self.to_cut_files = uris
# uris = self.get_uris(store, treePaths)
# print(uris)
def cut_file(self):
pass
def paste_file(self):
pass
def paste_files(self):
if len(self.to_copy_files):
pass
else:
pass

View File

@ -126,6 +126,7 @@ class WidgetMixin:
grid.connect("button_release_event", self.grid_icon_single_left_click)
grid.connect("item-activated", self.grid_icon_double_left_click)
grid.connect("selection-changed", self.grid_set_selected_items)
grid.connect("drag-data-get", self.grid_on_drag_set)
grid.connect("drag-data-received", self.grid_on_drag_data_received)
grid.connect("drag-motion", self.grid_on_drag_motion)
@ -140,6 +141,7 @@ class WidgetMixin:
grid.show_all()
scroll.add(grid)
grid.set_name(f"{wid}|{view.id}")
self.builder.expose_object(f"{wid}|{view.id}|iconview", grid)
self.builder.expose_object(f"{wid}|{view.id}", scroll)
return scroll, store

View File

@ -20,6 +20,19 @@ class WindowMixin(TabMixin):
def get_fm_window(self, wid):
return self.window_controller.get_window_by_nickname(f"window_{wid}")
def format_to_uris(self, store, wid, tid, treePaths):
view = self.get_fm_window(wid).get_view_by_id(tid)
dir = view.get_current_directory()
uris = []
for path in treePaths:
itr = store.get_iter(path)
file = store.get(itr, 1)[0]
fpath = f"file://{dir}/{file}"
uris.append(fpath)
return uris
def set_window_title(self):
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)
@ -31,6 +44,9 @@ class WindowMixin(TabMixin):
view = self.get_fm_window(wid).get_view_by_id(tid)
path_entry.set_text(view.get_current_directory())
def grid_set_selected_items(self, iconview):
self.selected_files = iconview.get_selected_items()
def grid_icon_single_left_click(self, iconview, eve):
try:
wid, tid = iconview.get_name().split("|")
@ -105,18 +121,10 @@ class WindowMixin(TabMixin):
def grid_on_drag_set(self, iconview, drag_context, data, info, time):
action = iconview.get_name()
wid, tid = action.split("|")
store = iconview.get_model()
treePaths = iconview.get_selected_items()
wid, tid = action.split("|")
view = self.get_fm_window(wid).get_view_by_id(tid)
dir = view.get_current_directory()
uris = []
for path in treePaths:
itr = store.get_iter(path)
file = store.get(itr, 1)[0]
fpath = f"file://{dir}/{file}"
uris.append(fpath)
uris = self.format_to_uris(store, wid, tid, treePaths)
data.set_uris(uris)
event_system.push_gui_event(["refresh_tab", None, action])