Moved variables to data file, added alert message widget
This commit is contained in:
parent
489288204c
commit
2ea9768d27
@ -1048,7 +1048,7 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<object class="GtkBox" id="controll_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
@ -1338,6 +1338,22 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="message_widget">
|
||||
<property name="width-request">320</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="relative-to">controll_box</property>
|
||||
<property name="position">bottom</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="message_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="justify">center</property>
|
||||
<attributes>
|
||||
<attribute name="scale" value="2"/>
|
||||
</attributes>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="trash_img">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
|
@ -9,8 +9,7 @@ from gi.repository import GLib
|
||||
|
||||
# Application imports
|
||||
from .mixins import *
|
||||
from shellfm import WindowController
|
||||
from . import ShowHideMixin, KeyboardSignalsMixin
|
||||
from . import ShowHideMixin, KeyboardSignalsMixin, Controller_Data
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
@ -19,37 +18,11 @@ def threaded(fn):
|
||||
return wrapper
|
||||
|
||||
|
||||
class Controller(ShowHideMixin, KeyboardSignalsMixin, WidgetFileActionMixin, PaneMixin, WindowMixin):
|
||||
def __init__(self, args, unknownargs, settings):
|
||||
self.settings = settings
|
||||
self.builder = self.settings.builder
|
||||
self.logger = self.settings.logger
|
||||
|
||||
self.window_controller = WindowController()
|
||||
self.state = self.window_controller.load_state()
|
||||
|
||||
self.window = self.settings.getMainWindow()
|
||||
self.window1 = self.builder.get_object("window_1")
|
||||
self.window2 = self.builder.get_object("window_2")
|
||||
self.window3 = self.builder.get_object("window_3")
|
||||
self.window4 = self.builder.get_object("window_4")
|
||||
self.notebooks = [self.window1, self.window2, self.window3, self.window4]
|
||||
self.selected_files = []
|
||||
self.to_rename_files = []
|
||||
self.to_copy_files = []
|
||||
self.to_cut_files = []
|
||||
|
||||
self.single_click_open = False
|
||||
self.is_pane1_hidden = False
|
||||
self.is_pane2_hidden = False
|
||||
self.is_pane3_hidden = False
|
||||
self.is_pane4_hidden = False
|
||||
|
||||
self.skip_edit = False
|
||||
self.cancel_edit = False
|
||||
self.ctrlDown = False
|
||||
self.shiftDown = False
|
||||
self.altDown = False
|
||||
class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, WidgetFileActionMixin, \
|
||||
PaneMixin, WindowMixin):
|
||||
def __init__(self, args, unknownargs, _settings):
|
||||
self.settings = _settings
|
||||
self.setup_controller_data()
|
||||
|
||||
self.window.show()
|
||||
self.generate_windows(self.state)
|
||||
@ -89,11 +62,21 @@ class Controller(ShowHideMixin, KeyboardSignalsMixin, WidgetFileActionMixin, Pan
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
|
||||
def has_method(self, o, name):
|
||||
return callable(getattr(o, name, None))
|
||||
|
||||
|
||||
|
||||
def display_message(self, type, text, seconds=3):
|
||||
markup = "<span foreground='" + type + "'>" + text + "</span>"
|
||||
self.message_label.set_markup(markup)
|
||||
self.message_widget.popup()
|
||||
self.hide_message_timeout(seconds)
|
||||
|
||||
@threaded
|
||||
def hide_message_timeout(self, seconds=3):
|
||||
time.sleep(seconds)
|
||||
GLib.idle_add(self.message_widget.popdown)
|
||||
|
||||
|
||||
|
||||
def do_edit_files(self, widget=None, eve=None):
|
||||
self.to_rename_files = self.selected_files
|
||||
|
@ -0,0 +1,48 @@
|
||||
# Python imports
|
||||
|
||||
# Gtk imports
|
||||
|
||||
# Application imports
|
||||
from shellfm import WindowController
|
||||
|
||||
|
||||
class Controller_Data:
|
||||
def has_method(self, o, name):
|
||||
return callable(getattr(o, name, None))
|
||||
|
||||
def setup_controller_data(self):
|
||||
self.window_controller = WindowController()
|
||||
self.state = self.window_controller.load_state()
|
||||
|
||||
self.builder = self.settings.builder
|
||||
self.logger = self.settings.logger
|
||||
|
||||
self.window = self.settings.getMainWindow()
|
||||
self.window1 = self.builder.get_object("window_1")
|
||||
self.window2 = self.builder.get_object("window_2")
|
||||
self.window3 = self.builder.get_object("window_3")
|
||||
self.window4 = self.builder.get_object("window_4")
|
||||
self.message_widget = self.builder.get_object("message_widget")
|
||||
self.message_label = self.builder.get_object("message_label")
|
||||
|
||||
self.notebooks = [self.window1, self.window2, self.window3, self.window4]
|
||||
self.selected_files = []
|
||||
self.to_rename_files = []
|
||||
self.to_copy_files = []
|
||||
self.to_cut_files = []
|
||||
|
||||
self.single_click_open = False
|
||||
self.is_pane1_hidden = False
|
||||
self.is_pane2_hidden = False
|
||||
self.is_pane3_hidden = False
|
||||
self.is_pane4_hidden = False
|
||||
|
||||
self.skip_edit = False
|
||||
self.cancel_edit = False
|
||||
self.ctrlDown = False
|
||||
self.shiftDown = False
|
||||
self.altDown = False
|
||||
|
||||
self.success = "#88cc27"
|
||||
self.warning = "#ffa800"
|
||||
self.error = "#ff0000"
|
@ -19,7 +19,7 @@ class KeyboardSignalsMixin:
|
||||
if "shift" in keyname:
|
||||
self.shiftDown = True
|
||||
if "alt" in keyname:
|
||||
self.altDown = True
|
||||
self.altDown = True
|
||||
|
||||
# NOTE: Yes, this should actually be mapped to some key controller setting
|
||||
# file or something. Sue me.
|
||||
|
@ -5,4 +5,5 @@ from .mixins import *
|
||||
from .DBusControllerMixin import DBusControllerMixin
|
||||
from .KeyboardSignalsMixin import KeyboardSignalsMixin
|
||||
from .ShowHideMixin import ShowHideMixin
|
||||
from .Controller_Data import Controller_Data
|
||||
from .Controller import Controller
|
||||
|
@ -245,9 +245,11 @@ class WidgetFileActionMixin:
|
||||
state = view.move_file(fPath, tPath)
|
||||
|
||||
if not state:
|
||||
raise Exception("Failed to perform requested dir/file action!")
|
||||
raise GObject.GError("Failed to perform requested dir/file action!")
|
||||
except GObject.GError as e:
|
||||
raise OSError(e.message)
|
||||
if debug:
|
||||
print(repr(e))
|
||||
self.display_message(self.error, f"{e.message}")
|
||||
|
||||
def preprocess_paths(self, paths):
|
||||
if not isinstance(paths, list):
|
||||
|
Loading…
Reference in New Issue
Block a user