generated from itdominator/Python-With-Gtk-Template
Opening file on IPC call; css changes; renamed core widget
This commit is contained in:
parent
4e06bc3334
commit
362267fa69
@ -14,9 +14,9 @@ from .editors_container import EditorsContainer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CoreWidget(Gtk.Box):
|
class BaseContainer(Gtk.Box):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(CoreWidget, self).__init__()
|
super(BaseContainer, self).__init__()
|
||||||
|
|
||||||
builder = settings_manager.get_builder()
|
builder = settings_manager.get_builder()
|
||||||
self.ctx = self.get_style_context()
|
self.ctx = self.get_style_context()
|
@ -11,7 +11,10 @@ from gi.repository import GLib
|
|||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
from ..mixins.signals_mixins import SignalsMixins
|
from ..mixins.signals_mixins import SignalsMixins
|
||||||
from ..containers.core_widget import CoreWidget
|
|
||||||
|
from ..containers.base_container import BaseContainer
|
||||||
|
# from ..containers.core_widget import CoreWidget
|
||||||
|
|
||||||
from .base_controller_data import BaseControllerData
|
from .base_controller_data import BaseControllerData
|
||||||
from .bridge_controller import BridgeController
|
from .bridge_controller import BridgeController
|
||||||
|
|
||||||
@ -52,7 +55,6 @@ class BaseController(SignalsMixins, BaseControllerData):
|
|||||||
|
|
||||||
def _subscribe_to_events(self):
|
def _subscribe_to_events(self):
|
||||||
event_system.subscribe("shutting_down", lambda: print("Shutting down..."))
|
event_system.subscribe("shutting_down", lambda: print("Shutting down..."))
|
||||||
event_system.subscribe("handle_file_from_ipc", self.handle_file_from_ipc)
|
|
||||||
event_system.subscribe("set_active_src_view", self.set_active_src_view)
|
event_system.subscribe("set_active_src_view", self.set_active_src_view)
|
||||||
event_system.subscribe("get_active_src_view", self.get_active_src_view)
|
event_system.subscribe("get_active_src_view", self.get_active_src_view)
|
||||||
|
|
||||||
@ -65,10 +67,9 @@ class BaseController(SignalsMixins, BaseControllerData):
|
|||||||
self.builder.expose_object("main_window", self.window)
|
self.builder.expose_object("main_window", self.window)
|
||||||
|
|
||||||
settings_manager.set_builder(self.builder)
|
settings_manager.set_builder(self.builder)
|
||||||
self.core_widget = CoreWidget()
|
self.core_widget = BaseContainer()
|
||||||
|
|
||||||
settings_manager.register_signals_to_builder([self, self.core_widget])
|
settings_manager.register_signals_to_builder([self, self.core_widget])
|
||||||
|
|
||||||
def get_core_widget(self):
|
def get_core_widget(self):
|
||||||
return self.core_widget
|
return self.core_widget
|
||||||
|
|
@ -27,9 +27,10 @@ class FilesController:
|
|||||||
|
|
||||||
def _subscribe_to_events(self):
|
def _subscribe_to_events(self):
|
||||||
event_system.subscribe(f"set_pre_drop_dnd_{self.INDEX}", self.set_pre_drop_dnd)
|
event_system.subscribe(f"set_pre_drop_dnd_{self.INDEX}", self.set_pre_drop_dnd)
|
||||||
|
event_system.subscribe("handle_file_from_ipc", self.handle_file_from_ipc)
|
||||||
event_system.subscribe(f"handle_file_event_{self.INDEX}", self.handle_file_event)
|
event_system.subscribe(f"handle_file_event_{self.INDEX}", self.handle_file_event)
|
||||||
|
|
||||||
def set_pre_drop_dnd(self, gfiles):
|
def set_pre_drop_dnd(self, gfiles, line: int = 0):
|
||||||
for gfile in gfiles:
|
for gfile in gfiles:
|
||||||
fname = gfile.get_basename()
|
fname = gfile.get_basename()
|
||||||
fpath = gfile.get_path()
|
fpath = gfile.get_path()
|
||||||
@ -46,10 +47,30 @@ class FilesController:
|
|||||||
ftype,
|
ftype,
|
||||||
fname,
|
fname,
|
||||||
fpath,
|
fpath,
|
||||||
content
|
content,
|
||||||
|
line
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def handle_file_from_ipc(self, path: str) -> None:
|
||||||
|
logger.debug(f"Path From IPC: {path}")
|
||||||
|
line = "0"
|
||||||
|
fpath = ""
|
||||||
|
|
||||||
|
try:
|
||||||
|
fpath, line = path.split(":")
|
||||||
|
except:
|
||||||
|
fpath = path
|
||||||
|
|
||||||
|
print(fpath)
|
||||||
|
gfile = Gio.File.new_for_path(fpath)
|
||||||
|
|
||||||
|
try:
|
||||||
|
logger.info(f"Line: {line}")
|
||||||
|
self.set_pre_drop_dnd([gfile], int(line))
|
||||||
|
except Exception as e:
|
||||||
|
logger.info(repr(e))
|
||||||
|
|
||||||
def handle_file_event(self, event):
|
def handle_file_event(self, event):
|
||||||
match event.topic:
|
match event.topic:
|
||||||
case "save":
|
case "save":
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
# Python imports
|
|
||||||
|
|
||||||
# Lib imports
|
|
||||||
|
|
||||||
# Application imports
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class IPCSignalsMixin:
|
|
||||||
""" IPCSignalsMixin handle messages from another starting solarfm process. """
|
|
||||||
|
|
||||||
def print_to_console(self, message=None):
|
|
||||||
print(message)
|
|
||||||
|
|
||||||
def handle_file_from_ipc(self, path: any) -> None:
|
|
||||||
logger.debug(f"Path From IPC: {path}")
|
|
||||||
event_system.emit("create_view", (path,))
|
|
@ -1,7 +1,6 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
from .signals.ipc_signals_mixin import IPCSignalsMixin
|
|
||||||
from .signals.keyboard_signals_mixin import KeyboardSignalsMixin
|
from .signals.keyboard_signals_mixin import KeyboardSignalsMixin
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
@ -9,5 +8,5 @@ from .signals.keyboard_signals_mixin import KeyboardSignalsMixin
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SignalsMixins(KeyboardSignalsMixin, IPCSignalsMixin):
|
class SignalsMixins(KeyboardSignalsMixin):
|
||||||
...
|
...
|
||||||
|
@ -80,8 +80,8 @@ class AceEditor(WebKit2.WebView):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
|
|
||||||
def load_file(self, ftype: str, fname: str, fpath: str, content: str):
|
def load_file(self, ftype: str, fname: str, fpath: str, content: str, line: int = 0):
|
||||||
command = f"loadFile('{ftype}', '{fname}', '{fpath}', '{content}')"
|
command = f"loadFile('{ftype}', '{fname}', '{fpath}', '{content}', '{line}')"
|
||||||
self.run_javascript(command, None, None)
|
self.run_javascript(command, None, None)
|
||||||
|
|
||||||
def new_session(self):
|
def new_session(self):
|
||||||
@ -119,6 +119,8 @@ class WebkitUISettings(WebKit2.Settings):
|
|||||||
# Note: Highly insecure setup but most "app" like setup I could think of.
|
# Note: Highly insecure setup but most "app" like setup I could think of.
|
||||||
# Audit heavily any scripts/links ran/clicked under this setup!
|
# Audit heavily any scripts/links ran/clicked under this setup!
|
||||||
def _set_default_settings(self):
|
def _set_default_settings(self):
|
||||||
|
# self.set_enable_xss_auditor(True)
|
||||||
|
# self.set_enable_hyperlink_auditing(True)
|
||||||
self.set_enable_xss_auditor(False)
|
self.set_enable_xss_auditor(False)
|
||||||
self.set_enable_hyperlink_auditing(False)
|
self.set_enable_hyperlink_auditing(False)
|
||||||
self.set_allow_file_access_from_file_urls(True)
|
self.set_allow_file_access_from_file_urls(True)
|
||||||
@ -137,4 +139,6 @@ class WebkitUISettings(WebKit2.Settings):
|
|||||||
self.set_enable_webaudio(True)
|
self.set_enable_webaudio(True)
|
||||||
self.set_enable_accelerated_2d_canvas(True)
|
self.set_enable_accelerated_2d_canvas(True)
|
||||||
|
|
||||||
self.set_user_agent(f"{app_name}")
|
self.set_user_agent(f"Mozilla/5.0 {app_name}")
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
import gi
|
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
|
|
||||||
|
@ -38,10 +38,11 @@
|
|||||||
<script src="resources/js/libs/ace_editor/ace-linters.js"></script>
|
<script src="resources/js/libs/ace_editor/ace-linters.js"></script>
|
||||||
|
|
||||||
<!-- For Application... -->
|
<!-- For Application... -->
|
||||||
|
<script src="resources/js/newton/globals.js"></script>
|
||||||
|
|
||||||
<!-- <script src="resources/js/newton/ajax.js"></script> -->
|
<!-- <script src="resources/js/newton/ajax.js"></script> -->
|
||||||
<!-- <script src="resources/js/newton/post-ajax.js"></script> -->
|
<!-- <script src="resources/js/newton/post-ajax.js"></script> -->
|
||||||
|
|
||||||
<script src="resources/js/newton/globals.js"></script>
|
|
||||||
<script src="resources/js/newton/utils.js"></script>
|
<script src="resources/js/newton/utils.js"></script>
|
||||||
<script src="resources/js/newton/keybinding-newton.js"></script>
|
<script src="resources/js/newton/keybinding-newton.js"></script>
|
||||||
<script src="resources/js/newton/ui-logic.js"></script>
|
<script src="resources/js/newton/ui-logic.js"></script>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* IDs */
|
||||||
|
|
||||||
#editor {
|
#editor {
|
||||||
background-color: #00000000;
|
background-color: #00000000;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -110,6 +112,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Other message text colors */
|
/* Other message text colors */
|
||||||
.errorTxt { color: rgb(170, 18, 18); }
|
.error { color: rgb(170, 18, 18); }
|
||||||
.warningTxt { color: rgb(255, 168, 0); }
|
.warning { color: rgb(255, 168, 0); }
|
||||||
.successTxt { color: rgb(136, 204, 39); }
|
.success { color: rgb(136, 204, 39); }
|
@ -11,4 +11,4 @@ body {
|
|||||||
|
|
||||||
ul, li {
|
ul, li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
@ -14,6 +14,6 @@ window.onerror = function(msg, url, line, col, error) {
|
|||||||
|
|
||||||
sendMessage("error", "", data)
|
sendMessage("error", "", data)
|
||||||
|
|
||||||
// If you return true, then error alerts (like in older versions of Internet Explorer) will be suppressed.
|
// If you return true, then error alerts (like in older versions of Internet Explorer) will be suppressed.
|
||||||
return suppressErrorAlert;
|
return suppressErrorAlert;
|
||||||
};
|
};
|
@ -76,7 +76,7 @@ const removeSession = (fhash) => {
|
|||||||
delete aceSessions[fhash];
|
delete aceSessions[fhash];
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadFile = (ftype, fname, fpath, content) => {
|
const loadFile = (ftype, fname, fpath, content, line = 0) => {
|
||||||
let fhash = Date.now().toString();
|
let fhash = Date.now().toString();
|
||||||
session = ace.createEditSession( atob(content) );
|
session = ace.createEditSession( atob(content) );
|
||||||
aceSessions[fhash] = {"ftype": ftype, "fname": fname, "fpath": fpath, "session": session};
|
aceSessions[fhash] = {"ftype": ftype, "fname": fname, "fpath": fpath, "session": session};
|
||||||
|
Loading…
Reference in New Issue
Block a user