Compare commits
2 Commits
ca855712b1
...
52aa14dcb4
Author | SHA1 | Date |
---|---|---|
itdominator | 52aa14dcb4 | |
itdominator | 7534bf141e |
|
@ -72,6 +72,34 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
|||
self.plugins.set_message_on_plugin(type, data)
|
||||
|
||||
|
||||
def save_load_session(self, action="save_session"):
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
save_load_dialog = self.builder.get_object("save_load_dialog")
|
||||
save_load_dialog.set_current_folder(view.get_current_directory())
|
||||
save_load_dialog.set_current_name("session.json")
|
||||
|
||||
if action == "save_session":
|
||||
save_load_dialog.set_action(Gtk.FileChooserAction.SAVE)
|
||||
elif action == "load_session":
|
||||
save_load_dialog.set_action(Gtk.FileChooserAction.OPEN)
|
||||
|
||||
|
||||
response = save_load_dialog.run()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
path = f"{save_load_dialog.get_current_folder()}/{save_load_dialog.get_current_name()}"
|
||||
|
||||
if action == "save_session":
|
||||
self.window_controller.save_state(path)
|
||||
elif action == "load_session":
|
||||
session_json = self.window_controller.load_state(path)
|
||||
print(session_json)
|
||||
if (response == Gtk.ResponseType.CANCEL) or (response == Gtk.ResponseType.DELETE_EVENT):
|
||||
pass
|
||||
|
||||
save_load_dialog.hide()
|
||||
|
||||
|
||||
def do_action_from_menu_controls(self, widget, eventbutton):
|
||||
action = widget.get_name()
|
||||
self.ctrlDown = True
|
||||
|
@ -104,7 +132,7 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
|||
if action == "trash":
|
||||
self.trash_files()
|
||||
if action == "go_to_trash":
|
||||
self.builder.get_object("path_entry").set_text(self.trash_files_path)
|
||||
self.path_entry.set_text(self.trash_files_path)
|
||||
if action == "restore_from_trash":
|
||||
self.restore_trash_files()
|
||||
if action == "empty_trash":
|
||||
|
@ -112,5 +140,7 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
|||
|
||||
if action == "create":
|
||||
self.create_files()
|
||||
if action in ["save_session", "load_session"]:
|
||||
self.save_load_session(action)
|
||||
|
||||
self.ctrlDown = False
|
||||
|
|
|
@ -36,13 +36,14 @@ class Controller_Data:
|
|||
self.message_buffer = self.builder.get_object("message_buffer")
|
||||
self.arc_command_buffer = self.builder.get_object("arc_command_buffer")
|
||||
|
||||
self.exists_file_rename_bttn = self.builder.get_object("exists_file_rename_bttn")
|
||||
self.warning_alert = self.builder.get_object("warning_alert")
|
||||
self.edit_file_menu = self.builder.get_object("edit_file_menu")
|
||||
self.file_exists_dialog = self.builder.get_object("file_exists_dialog")
|
||||
self.exists_file_label = self.builder.get_object("exists_file_label")
|
||||
self.exists_file_field = self.builder.get_object("exists_file_field")
|
||||
self.path_menu = self.builder.get_object("path_menu")
|
||||
self.exists_file_rename_bttn = self.builder.get_object("exists_file_rename_bttn")
|
||||
self.path_entry = self.builder.get_object("path_entry")
|
||||
|
||||
self.bottom_size_label = self.builder.get_object("bottom_size_label")
|
||||
self.bottom_file_count_label = self.builder.get_object("bottom_file_count_label")
|
||||
|
|
|
@ -151,7 +151,10 @@ class WindowController:
|
|||
|
||||
|
||||
|
||||
def save_state(self):
|
||||
def save_state(self, session_file = None):
|
||||
if not session_file:
|
||||
session_file = self.session_file
|
||||
|
||||
windows = []
|
||||
for window in self.windows:
|
||||
views = []
|
||||
|
@ -172,10 +175,13 @@ class WindowController:
|
|||
]
|
||||
)
|
||||
|
||||
with open(self.session_file, 'w') as outfile:
|
||||
with open(session_file, 'w') as outfile:
|
||||
json.dump(windows, outfile, separators=(',', ':'), indent=4)
|
||||
|
||||
def load_state(self):
|
||||
if path.isfile(self.session_file):
|
||||
with open(self.session_file) as infile:
|
||||
def load_state(self, session_file = None):
|
||||
if not session_file:
|
||||
session_file = self.session_file
|
||||
|
||||
if path.isfile(session_file):
|
||||
with open(session_file) as infile:
|
||||
return json.load(infile)
|
||||
|
|
|
@ -1124,6 +1124,16 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
<class name="alert-border"/>
|
||||
</style>
|
||||
</object>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="stock">gtk-save-as</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="stock">gtk-file</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
|
@ -1146,6 +1156,64 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
<property name="can-focus">False</property>
|
||||
<property name="stock">gtk-edit</property>
|
||||
</object>
|
||||
<object class="GtkFileChooserDialog" id="save_load_dialog">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
<property name="do-overwrite-confirmation">True</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button11">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button12">
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-6">button11</action-widget>
|
||||
<action-widget response="-5">button12</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
<object class="GtkImage" id="skip_img">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
|
@ -1386,6 +1454,30 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem">
|
||||
<property name="label">Save Session</property>
|
||||
<property name="name">save_session</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="tooltip-text" translatable="yes">New File/Folder...</property>
|
||||
<property name="image">image1</property>
|
||||
<property name="use-stock">False</property>
|
||||
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem">
|
||||
<property name="label">Load Session</property>
|
||||
<property name="name">load_session</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="tooltip-text" translatable="yes">New File/Folder...</property>
|
||||
<property name="image">image2</property>
|
||||
<property name="use-stock">False</property>
|
||||
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem">
|
||||
<property name="visible">True</property>
|
||||
|
|
Loading…
Reference in New Issue