develop #5
|
@ -22,16 +22,13 @@ if __name__ == "__main__":
|
||||||
""" Set process title, get arguments, and create GTK main thread. """
|
""" Set process title, get arguments, and create GTK main thread. """
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# import web_pdb
|
|
||||||
# web_pdb.set_trace()
|
|
||||||
|
|
||||||
setproctitle('SolarFM')
|
setproctitle('SolarFM')
|
||||||
faulthandler.enable() # For better debug info
|
faulthandler.enable() # For better debug info
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
# Add long and short arguments
|
# Add long and short arguments
|
||||||
parser.add_argument("--new-tab", "-t", default="", help="Open a file into new tab.")
|
parser.add_argument("--new-tab", "-t", default="", help="Open a file into new tab.")
|
||||||
parser.add_argument("--new-window", "-w", default="", help="Open a file into a new window.")
|
parser.add_argument("--new-window", "-w", default="", help="Open a file into a new window.")
|
||||||
|
|
||||||
# Read arguments (If any...)
|
# Read arguments (If any...)
|
||||||
args, unknownargs = parser.parse_known_args()
|
args, unknownargs = parser.parse_known_args()
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
||||||
if action == "empty_trash":
|
if action == "empty_trash":
|
||||||
self.empty_trash()
|
self.empty_trash()
|
||||||
if action == "create":
|
if action == "create":
|
||||||
self.show_new_file_menu()
|
self.create_files()
|
||||||
if action in ["save_session", "save_session_as", "load_session"]:
|
if action in ["save_session", "save_session_as", "load_session"]:
|
||||||
self.save_load_session(action)
|
self.save_load_session(action)
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ class Controller_Data:
|
||||||
|
|
||||||
self.exists_file_rename_bttn = self.builder.get_object("exists_file_rename_bttn")
|
self.exists_file_rename_bttn = self.builder.get_object("exists_file_rename_bttn")
|
||||||
self.warning_alert = self.builder.get_object("warning_alert")
|
self.warning_alert = self.builder.get_object("warning_alert")
|
||||||
|
self.new_file_menu = self.builder.get_object("new_file_menu")
|
||||||
self.edit_file_menu = self.builder.get_object("edit_file_menu")
|
self.edit_file_menu = self.builder.get_object("edit_file_menu")
|
||||||
self.file_exists_dialog = self.builder.get_object("file_exists_dialog")
|
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_label = self.builder.get_object("exists_file_label")
|
||||||
|
@ -110,6 +111,7 @@ class Controller_Data:
|
||||||
self.search_icon_grid = None
|
self.search_icon_grid = None
|
||||||
self.search_tab = None
|
self.search_tab = None
|
||||||
|
|
||||||
|
self.cancel_creation = False
|
||||||
self.skip_edit = False
|
self.skip_edit = False
|
||||||
self.cancel_edit = False
|
self.cancel_edit = False
|
||||||
self.ctrl_down = False
|
self.ctrl_down = False
|
||||||
|
|
|
@ -108,22 +108,23 @@ class ShowHideMixin:
|
||||||
def hide_context_menu(self, widget=None, eve=None):
|
def hide_context_menu(self, widget=None, eve=None):
|
||||||
self.builder.get_object("context_menu_popup").hide()
|
self.builder.get_object("context_menu_popup").hide()
|
||||||
|
|
||||||
|
|
||||||
def show_new_file_menu(self, widget=None, eve=None):
|
def show_new_file_menu(self, widget=None, eve=None):
|
||||||
context_menu_fname = self.builder.get_object("context_menu_fname")
|
if widget:
|
||||||
context_menu_fname.set_text("")
|
widget.set_text("")
|
||||||
context_menu_fname.grab_focus()
|
widget.grab_focus()
|
||||||
|
|
||||||
new_file_menu = self.builder.get_object("new_file_menu")
|
response = self.new_file_menu.run()
|
||||||
response = new_file_menu.run()
|
|
||||||
if response == Gtk.ResponseType.APPLY:
|
|
||||||
self.create_files()
|
|
||||||
if response == Gtk.ResponseType.CANCEL:
|
if response == Gtk.ResponseType.CANCEL:
|
||||||
self.hide_new_file_menu()
|
self.cancel_creation = True
|
||||||
|
|
||||||
def hide_new_file_menu(self, widget=None, eve=None):
|
def hide_new_file_menu(self, widget=None, eve=None):
|
||||||
self.builder.get_object("new_file_menu").hide()
|
self.builder.get_object("new_file_menu").hide()
|
||||||
|
|
||||||
|
def hide_new_file_menu_enter_key(self, widget=None, eve=None):
|
||||||
|
keyname = Gdk.keyval_name(eve.keyval).lower()
|
||||||
|
if keyname in ["return", "enter"]:
|
||||||
|
self.builder.get_object("new_file_menu").hide()
|
||||||
|
|
||||||
def show_edit_file_menu(self, widget=None, eve=None):
|
def show_edit_file_menu(self, widget=None, eve=None):
|
||||||
if widget:
|
if widget:
|
||||||
widget.grab_focus()
|
widget.grab_focus()
|
||||||
|
|
|
@ -248,7 +248,13 @@ class WidgetFileActionMixin:
|
||||||
|
|
||||||
|
|
||||||
def create_files(self):
|
def create_files(self):
|
||||||
fname_field = self.builder.get_object("context_menu_fname")
|
fname_field = self.builder.get_object("new_fname_field")
|
||||||
|
self.show_new_file_menu(fname_field)
|
||||||
|
|
||||||
|
if self.cancel_creation:
|
||||||
|
self.cancel_creation = False
|
||||||
|
return
|
||||||
|
|
||||||
file_name = fname_field.get_text().strip()
|
file_name = fname_field.get_text().strip()
|
||||||
type = self.builder.get_object("context_menu_type_toggle").get_state()
|
type = self.builder.get_object("context_menu_type_toggle").get_state()
|
||||||
|
|
||||||
|
@ -264,11 +270,14 @@ class WidgetFileActionMixin:
|
||||||
else: # Create Folder
|
else: # Create Folder
|
||||||
self.handle_files([path], "create_dir")
|
self.handle_files([path], "create_dir")
|
||||||
|
|
||||||
|
self.cancel_creation = False
|
||||||
self.hide_new_file_menu()
|
self.hide_new_file_menu()
|
||||||
|
|
||||||
|
|
||||||
def move_files(self, files, target):
|
def move_files(self, files, target):
|
||||||
self.handle_files(files, "move", target)
|
self.handle_files(files, "move", target)
|
||||||
|
|
||||||
|
|
||||||
# NOTE: Gtk recommends using fail flow than pre check which is more
|
# NOTE: Gtk recommends using fail flow than pre check which is more
|
||||||
# race condition proof. They're right; but, they can't even delete
|
# race condition proof. They're right; but, they can't even delete
|
||||||
# directories properly. So... f**k them. I'll do it my way.
|
# directories properly. So... f**k them. I'll do it my way.
|
||||||
|
|
Loading…
Reference in New Issue