Completed rewrite
This commit is contained in:
@@ -1,7 +1,79 @@
|
||||
import builtins
|
||||
# Python imports
|
||||
import builtins, threading
|
||||
|
||||
class Builtins:
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from utils.pyautogui_control import ControlMixin
|
||||
|
||||
|
||||
|
||||
# NOTE: Threads WILL NOT die with parent's destruction.
|
||||
def threaded_wrapper(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=False).start()
|
||||
return wrapper
|
||||
|
||||
# NOTE: Threads WILL die with parent's destruction.
|
||||
def daemon_threaded_wrapper(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
|
||||
|
||||
class EndpointRegistry():
|
||||
def __init__(self):
|
||||
self._endpoints = {}
|
||||
|
||||
def register(self, rule, **options):
|
||||
def decorator(f):
|
||||
self._endpoints[rule] = f
|
||||
return f
|
||||
|
||||
return decorator
|
||||
|
||||
def get_endpoints(self):
|
||||
return self._endpoints
|
||||
|
||||
class Pyautogui_Controller(ControlMixin):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
builtins.app_name = "Mouse_Keyboard"
|
||||
|
||||
|
||||
keys_json = {
|
||||
"keys": {
|
||||
"row1": {
|
||||
"pKeys": ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
|
||||
"sKeys": ['~', '^', '#', '$', '%', '&', '-', '_', '(', ')'],
|
||||
},
|
||||
"row2": {
|
||||
"pKeys": ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'],
|
||||
"sKeys": ['\\', '/', '|', ':', '=', '+', '"', '*', '<', '>'],
|
||||
},
|
||||
"row3": {
|
||||
"pKeys": ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', "'"],
|
||||
"sKeys": ['`', '', '', '', '', '', '', '', '[', ']'],
|
||||
},
|
||||
"row4": {
|
||||
"pKeys": ['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '?'],
|
||||
"sKeys": ['', '', '', '', '', '', ';', '!', '{', '}']
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# NOTE: Just reminding myself we can add to builtins two different ways...
|
||||
# __builtins__.update({"event_system": Builtins()})
|
||||
builtins.app_name = "Mouse Keyboard"
|
||||
builtins.endpoint_registry = EndpointRegistry()
|
||||
builtins.typwriter = Pyautogui_Controller()
|
||||
builtins.threaded = threaded_wrapper
|
||||
builtins.daemon_threaded = daemon_threaded_wrapper
|
||||
builtins.keys_set = keys_json
|
||||
builtins.trace_debug = False
|
||||
builtins.debug = False
|
||||
builtins.app_settings = None
|
||||
|
@@ -1,34 +1,3 @@
|
||||
# Python imports
|
||||
import inspect
|
||||
|
||||
|
||||
# Gtk imports
|
||||
|
||||
|
||||
# Application imports
|
||||
from utils.settings import Settings
|
||||
from signal_classes.signals import Signals
|
||||
from __builtins__ import Builtins
|
||||
|
||||
|
||||
class Main(Builtins):
|
||||
def __init__(self, args):
|
||||
settings = Settings()
|
||||
builder = settings.returnBuilder()
|
||||
|
||||
# Gets the methods from the classes and sets to handler.
|
||||
# Then, builder connects to any signals it needs.
|
||||
classes = [Signals(settings)]
|
||||
|
||||
handlers = {}
|
||||
for c in classes:
|
||||
methods = None
|
||||
try:
|
||||
methods = inspect.getmembers(c, predicate=inspect.ismethod)
|
||||
handlers.update(methods)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
builder.connect_signals(handlers)
|
||||
window = settings.createWindow()
|
||||
window.show()
|
||||
"""
|
||||
Base module
|
||||
"""
|
||||
|
@@ -2,31 +2,41 @@
|
||||
|
||||
|
||||
# Python imports
|
||||
import argparse
|
||||
import argparse, faulthandler, traceback
|
||||
from setproctitle import setproctitle
|
||||
|
||||
# Gtk imports
|
||||
import gi, faulthandler, signal
|
||||
import tracemalloc
|
||||
tracemalloc.start()
|
||||
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GLib
|
||||
|
||||
# Application imports
|
||||
from __init__ import Main
|
||||
from app import Application
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
""" Set process title, get arguments, and create GTK main thread. """
|
||||
|
||||
try:
|
||||
# import web_pdb
|
||||
# web_pdb.set_trace()
|
||||
|
||||
setproctitle('Mouse Keyboard')
|
||||
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, Gtk.main_quit)
|
||||
faulthandler.enable() # For better debug info
|
||||
parser = argparse.ArgumentParser()
|
||||
# Add long and short arguments
|
||||
parser.add_argument("--file", "-f", default="default", help="JUST SOME FILE ARG.")
|
||||
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.")
|
||||
|
||||
# Read arguments (If any...)
|
||||
args = parser.parse_args()
|
||||
main = Main(args)
|
||||
args, unknownargs = parser.parse_known_args()
|
||||
|
||||
Application(args, unknownargs)
|
||||
Gtk.main()
|
||||
except Exception as e:
|
||||
print( repr(e) )
|
||||
traceback.print_exc()
|
||||
quit()
|
||||
|
20
src/app.py
Normal file
20
src/app.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Python imports
|
||||
import inspect
|
||||
|
||||
|
||||
# Gtk imports
|
||||
|
||||
|
||||
# Application imports
|
||||
from __builtins__ import *
|
||||
from core.window import Window
|
||||
|
||||
|
||||
|
||||
|
||||
class Application(object):
|
||||
def __init__(self, args, unknownargs):
|
||||
try:
|
||||
Window(args, unknownargs)
|
||||
except Exception as e:
|
||||
raise
|
3
src/core/__init__.py
Normal file
3
src/core/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Core module
|
||||
"""
|
21
src/core/bottom_key_row.py
Normal file
21
src/core/bottom_key_row.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .widgets.defined_keys import Esc_Key, AT_Key, Space_Key, COM_Key
|
||||
|
||||
|
||||
|
||||
|
||||
class Bottom_Key_Row(Gtk.Box):
|
||||
def __init__(self):
|
||||
super(Bottom_Key_Row, self).__init__()
|
||||
|
||||
self.set_property("homogeneous", True)
|
||||
|
||||
for key in [Esc_Key(), Space_Key(), AT_Key(), COM_Key()]:
|
||||
self.add(key)
|
4
src/core/columns/__init__.py
Normal file
4
src/core/columns/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .left_column import Left_Column
|
||||
from .keys_column import Keys_Column
|
||||
from .right_column import Right_Column
|
||||
from .controls_column import Controls_Column
|
102
src/core/columns/controls_column.py
Normal file
102
src/core/columns/controls_column.py
Normal file
@@ -0,0 +1,102 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..widgets.defined_keys import Del_Key, Ctrl_Key, Shift_Key, Alt_Key, PrtSc_Key, Up_Key, Down_Key, Left_Key, Right_Key
|
||||
|
||||
|
||||
|
||||
|
||||
class Button_Box(Gtk.ButtonBox):
|
||||
"""docstring for Button_Box."""
|
||||
|
||||
def __init__(self):
|
||||
super(Button_Box, self).__init__()
|
||||
|
||||
for key in [Del_Key(), Ctrl_Key(), Shift_Key(), Alt_Key(), PrtSc_Key()]:
|
||||
self.add(key)
|
||||
|
||||
class List_Box(Gtk.ScrolledWindow):
|
||||
"""docstring for List_Box."""
|
||||
|
||||
def __init__(self):
|
||||
super(List_Box, self).__init__()
|
||||
|
||||
tree, store = self.create_treeview()
|
||||
|
||||
self.add(tree)
|
||||
self.set_size_request(360, 240)
|
||||
|
||||
|
||||
def create_treeview(self):
|
||||
tree = Gtk.TreeView()
|
||||
store = Gtk.ListStore(str)
|
||||
column = Gtk.TreeViewColumn("Commands")
|
||||
name = Gtk.CellRendererText()
|
||||
selec = tree.get_selection()
|
||||
|
||||
tree.set_model(store)
|
||||
selec.set_mode(2)
|
||||
|
||||
column.pack_start(name, True)
|
||||
column.add_attribute(name, "text", 0)
|
||||
column.set_expand(False)
|
||||
|
||||
tree.append_column(column)
|
||||
tree.set_search_column(0)
|
||||
tree.set_headers_visible(True)
|
||||
tree.set_enable_tree_lines(False)
|
||||
|
||||
tree.columns_autosize()
|
||||
return tree, store
|
||||
|
||||
class Grid_Box(Gtk.Grid):
|
||||
"""docstring for Grid_Box."""
|
||||
|
||||
def __init__(self):
|
||||
super(Grid_Box, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
|
||||
self.insert_row(0)
|
||||
self.insert_row(1)
|
||||
self.insert_row(2)
|
||||
self.insert_column(0)
|
||||
self.insert_column(1)
|
||||
self.insert_column(2)
|
||||
|
||||
# NOTE: Widget, left, top, width, height
|
||||
self.attach(Up_Key(), 1, 0, 1, 1)
|
||||
self.attach(Down_Key(), 1, 2, 1, 1)
|
||||
self.attach(Left_Key(), 0, 1, 1, 1)
|
||||
self.attach(Right_Key(), 2, 1, 1, 1)
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_hexpand(True)
|
||||
self.set_margin_top(5)
|
||||
self.set_margin_bottom(5)
|
||||
self.set_column_homogeneous(True)
|
||||
|
||||
|
||||
class Controls_Column(Gtk.Box):
|
||||
"""docstring for Controls_Column."""
|
||||
|
||||
def __init__(self):
|
||||
super(Controls_Column, self).__init__()
|
||||
|
||||
self. setup_styling()
|
||||
|
||||
for key in [Button_Box(), List_Box(), Grid_Box()]:
|
||||
self.add(key)
|
||||
|
||||
self.show_all()
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_orientation(1) # HORIZONTAL = 0, VERTICAL = 1
|
||||
self.set_vexpand(True)
|
||||
self.set_margin_start(10)
|
||||
self.set_margin_end(10)
|
59
src/core/columns/keys_column.py
Normal file
59
src/core/columns/keys_column.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..widgets.key import Key
|
||||
from ..bottom_key_row import Bottom_Key_Row
|
||||
|
||||
|
||||
class KeyboardRowMatchError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Keys_Column(Gtk.Box):
|
||||
"""docstring for Keys_Column."""
|
||||
|
||||
def __init__(self):
|
||||
super(Keys_Column, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
self.setup_key_buttons()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_orientation(1) # HORIZONTAL = 0, VERTICAL = 1
|
||||
self.set_property("homogeneous", True)
|
||||
self.set_hexpand(True)
|
||||
|
||||
def setup_key_buttons(self):
|
||||
keys = keys_set["keys"]
|
||||
children = keys.keys()
|
||||
|
||||
for child in children:
|
||||
pKeys = keys[child]["pKeys"]
|
||||
sKeys = keys[child]["sKeys"]
|
||||
|
||||
row_box = self.add_row()
|
||||
if len(pKeys) == len(sKeys):
|
||||
for i in range(10):
|
||||
pkey = pKeys[i]
|
||||
sKey = sKeys[i]
|
||||
row_box.add(Key(pkey, sKey))
|
||||
else:
|
||||
raise KeyboardRowMatchError("A row in keys_json has missmatched pKeys and sKeys lengths.")
|
||||
|
||||
self.add(Bottom_Key_Row())
|
||||
|
||||
|
||||
def add_row(self):
|
||||
row_box = Gtk.Box()
|
||||
row_box.set_property("homogeneous", True)
|
||||
self.add(row_box)
|
||||
|
||||
return row_box
|
28
src/core/columns/left_column.py
Normal file
28
src/core/columns/left_column.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..widgets.defined_keys import Symbols_Key, CAPS_Key
|
||||
|
||||
|
||||
|
||||
|
||||
class Left_Column(Gtk.Box):
|
||||
"""docstring for Left_Column."""
|
||||
|
||||
def __init__(self):
|
||||
super(Left_Column, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
|
||||
for key in [Symbols_Key(), CAPS_Key()]:
|
||||
self.add(key)
|
||||
|
||||
self.show_all()
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_orientation(1) # HORIZONTAL = 0, VERTICAL = 1
|
28
src/core/columns/right_column.py
Normal file
28
src/core/columns/right_column.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..widgets.defined_keys import Backspace_Key, Enter_Key
|
||||
|
||||
|
||||
|
||||
|
||||
class Right_Column(Gtk.Box):
|
||||
"""docstring for Right_Column."""
|
||||
|
||||
def __init__(self):
|
||||
super(Right_Column, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
|
||||
for key in [Backspace_Key(), Enter_Key()]:
|
||||
self.add(key)
|
||||
|
||||
self.show_all()
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_orientation(1) # HORIZONTAL = 0, VERTICAL = 1
|
97
src/core/container.py
Normal file
97
src/core/container.py
Normal file
@@ -0,0 +1,97 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .columns import Left_Column, Keys_Column, Right_Column, Controls_Column
|
||||
|
||||
|
||||
|
||||
|
||||
class Auto_Type(Gtk.Box):
|
||||
"""docstring for Auto_Type."""
|
||||
|
||||
def __init__(self):
|
||||
super(Auto_Type, self).__init__()
|
||||
|
||||
pad1 = Gtk.Label()
|
||||
pad2 = Gtk.Label()
|
||||
self._auto_typer = Gtk.SearchEntry()
|
||||
self._type_btn = Gtk.Button(label="Type")
|
||||
|
||||
self._auto_typer.set_placeholder_text("Autotype Field...")
|
||||
# self._auto_typer.set_icon_from_icon_name(0, "gtk-go-forward") # PRIMARY = 0, SECONDARY = 1
|
||||
self._auto_typer.set_icon_from_stock(0, "gtk-go-forward") # PRIMARY = 0, SECONDARY = 1
|
||||
self._auto_typer.set_can_focus(True)
|
||||
self._auto_typer.set_hexpand(True)
|
||||
|
||||
pad1.set_hexpand(True)
|
||||
pad2.set_hexpand(True)
|
||||
|
||||
self.add(pad1)
|
||||
self.add(self._auto_typer)
|
||||
self.add(self._type_btn)
|
||||
self.add(pad2)
|
||||
|
||||
self.setup_styling()
|
||||
|
||||
self.setup_signals()
|
||||
self.show_all()
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_margin_bottom(5)
|
||||
|
||||
def setup_signals(self):
|
||||
self._type_btn.connect("released", self.type_out)
|
||||
|
||||
def type_out(self, widget = None, eve = None):
|
||||
text = self._auto_typer.get_text()
|
||||
typwriter.type_string(text)
|
||||
|
||||
class Main_Container(Gtk.Box):
|
||||
"""docstring for Main_Container."""
|
||||
|
||||
def __init__(self):
|
||||
super(Main_Container, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
self.add_columns()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_orientation(0) # HORIZONTAL = 0, VERTICAL = 1
|
||||
self.set_vexpand(True)
|
||||
|
||||
def add_columns(self):
|
||||
self.add(Left_Column())
|
||||
self.add(Keys_Column())
|
||||
self.add(Right_Column())
|
||||
self.add(Controls_Column())
|
||||
|
||||
class Container(Gtk.Box):
|
||||
"""docstring for Container."""
|
||||
|
||||
def __init__(self):
|
||||
super(Container, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
self.add_content()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_orientation(1) # HORIZONTAL = 0, VERTICAL = 1
|
||||
self.set_vexpand(True)
|
||||
self.set_margin_start(5)
|
||||
self.set_margin_top(5)
|
||||
self.set_margin_bottom(5)
|
||||
|
||||
def add_content(self):
|
||||
self.add(Auto_Type())
|
||||
self.add(Main_Container())
|
18
src/core/signals_mixin.py
Normal file
18
src/core/signals_mixin.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
from gi.repository import GObject
|
||||
|
||||
|
||||
# Application imports
|
||||
from .widgets.key import Key
|
||||
|
||||
|
||||
|
||||
|
||||
class SignalsMixin:
|
||||
"""docstring for SignalsMixin."""
|
||||
|
||||
def setup_custom_event_signals(self):
|
||||
GObject.signal_new('toggle-caps', Key, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
||||
GObject.signal_new('toggle-symbol-keys', Key, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
3
src/core/widgets/__init__.py
Normal file
3
src/core/widgets/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Widgets module
|
||||
"""
|
175
src/core/widgets/defined_keys.py
Normal file
175
src/core/widgets/defined_keys.py
Normal file
@@ -0,0 +1,175 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .key import Key
|
||||
|
||||
|
||||
|
||||
|
||||
############################ Left_Column Keys ############################
|
||||
|
||||
class Symbols_Key(Key):
|
||||
def __init__(self):
|
||||
super(Symbols_Key, self).__init__("Symbols", "Symbols")
|
||||
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._clicked)
|
||||
|
||||
def _clicked(self, widget = None):
|
||||
key_columns = self.get_parent().get_parent().get_children()[1]
|
||||
|
||||
for row in key_columns.get_children():
|
||||
for key in row:
|
||||
key.emit("toggle-symbol-keys", ())
|
||||
|
||||
class CAPS_Key(Gtk.ToggleButton):
|
||||
def __init__(self):
|
||||
super(CAPS_Key, self).__init__("Caps", "Caps")
|
||||
|
||||
self.set_vexpand(True)
|
||||
|
||||
self.setup_signals()
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("clicked", self._clicked)
|
||||
|
||||
def _clicked(self, widget = None):
|
||||
key_columns = self.get_parent().get_parent().get_children()[1]
|
||||
|
||||
for row in key_columns.get_children():
|
||||
for key in row:
|
||||
key.emit("toggle-caps", ())
|
||||
|
||||
|
||||
############################ Right_Column Keys ############################
|
||||
|
||||
class Backspace_Key(Key):
|
||||
def __init__(self):
|
||||
super(Backspace_Key, self).__init__("Backspace", "Backspace")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._clicked)
|
||||
|
||||
def _clicked(self, widget = None):
|
||||
typwriter.press_special_keys(self.get_label())
|
||||
|
||||
class Enter_Key(Key):
|
||||
def __init__(self):
|
||||
super(Enter_Key, self).__init__("Enter", "Enter")
|
||||
|
||||
self.setup_styling()
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_vexpand(True)
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._clicked)
|
||||
|
||||
def _clicked(self, widget = None):
|
||||
typwriter.press_special_keys(self.get_label())
|
||||
|
||||
|
||||
############################ Bottom_Key_Row Keys ############################
|
||||
|
||||
class AT_Key(Key):
|
||||
def __init__(self):
|
||||
super(AT_Key, self).__init__("@", "@")
|
||||
|
||||
|
||||
class Space_Key(Key):
|
||||
def __init__(self):
|
||||
super(Space_Key, self).__init__("Space", "Space")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
class COM_Key(Key):
|
||||
def __init__(self):
|
||||
super(COM_Key, self).__init__(".com", ".com")
|
||||
|
||||
|
||||
############################ Controls_Column Keys ############################
|
||||
|
||||
class Esc_Key(Key):
|
||||
def __init__(self):
|
||||
super(Esc_Key, self).__init__("Esc", "Esc")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
|
||||
class Del_Key(Key):
|
||||
def __init__(self):
|
||||
super(Del_Key, self).__init__("Del", "Del")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
|
||||
class Ctrl_Key(Key):
|
||||
def __init__(self):
|
||||
super(Ctrl_Key, self).__init__("Ctrl", "Ctrl")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
|
||||
class Shift_Key(Key):
|
||||
def __init__(self):
|
||||
super(Shift_Key, self).__init__("Shift", "Shift")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
|
||||
class Alt_Key(Key):
|
||||
def __init__(self):
|
||||
super(Alt_Key, self).__init__("Alt", "Alt")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
|
||||
class PrtSc_Key(Key):
|
||||
def __init__(self):
|
||||
super(PrtSc_Key, self).__init__("PrtSc", "PrtSc")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
|
||||
class Up_Key(Key):
|
||||
def __init__(self):
|
||||
super(Up_Key, self).__init__("Up", "Up")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
class Down_Key(Key):
|
||||
def __init__(self):
|
||||
super(Down_Key, self).__init__("Down", "Down")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
class Left_Key(Key):
|
||||
def __init__(self):
|
||||
super(Left_Key, self).__init__("Left", "Left")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
||||
|
||||
class Right_Key(Key):
|
||||
def __init__(self):
|
||||
super(Right_Key, self).__init__("Right", "Right")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_press_special_key)
|
46
src/core/widgets/key.py
Normal file
46
src/core/widgets/key.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
class Key(Gtk.Button):
|
||||
def __init__(self, primary = "NULL", secondary = "NULL"):
|
||||
super(Key, self).__init__()
|
||||
|
||||
self._primary_symbol = primary
|
||||
self._secondary_symbol = secondary
|
||||
self._is_upper = False
|
||||
self._is_symbol = False
|
||||
|
||||
self.set_label(self._primary_symbol)
|
||||
self.setup_signals()
|
||||
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._do_type)
|
||||
self.connect("toggle-caps", self.toggle_caps)
|
||||
self.connect("toggle-symbol-keys", self.toggle_symbol_keys)
|
||||
|
||||
def _do_type(self, widget = None):
|
||||
key = self.get_label().strip()
|
||||
typwriter.type(key)
|
||||
|
||||
def _do_press_special_key(self, widget = None):
|
||||
typwriter.press_special_keys(self.get_label())
|
||||
|
||||
def toggle_symbol_keys(self, widget = None, eve = None):
|
||||
self._is_symbol = not self._is_symbol
|
||||
if self._is_symbol:
|
||||
self.set_label(self._secondary_symbol)
|
||||
else:
|
||||
self.set_label(self._primary_symbol.upper()) if self._is_upper else self.set_label(self._primary_symbol.lower())
|
||||
|
||||
def toggle_caps(self, widget = None, eve = None):
|
||||
self._is_upper = not self._is_upper
|
||||
if not self._is_symbol:
|
||||
self.set_label(self._primary_symbol.upper()) if self._is_upper else self.set_label(self._primary_symbol.lower())
|
73
src/core/window.py
Normal file
73
src/core/window.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# Python imports
|
||||
import os
|
||||
|
||||
# Lib imports
|
||||
import gi, cairo
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
|
||||
# Application imports
|
||||
from .signals_mixin import SignalsMixin
|
||||
from .container import Container
|
||||
|
||||
|
||||
|
||||
class Window(SignalsMixin, Gtk.ApplicationWindow):
|
||||
"""docstring for Window."""
|
||||
|
||||
def __init__(self, args, unknownargs):
|
||||
super(Window, self).__init__()
|
||||
|
||||
self._SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
|
||||
self._ICON_FILE = f"{self._SCRIPT_PTH}/../resources/icon.png"
|
||||
self._CSS_FILE = f"{self._SCRIPT_PTH}/../resources/stylesheet.css"
|
||||
|
||||
|
||||
self.setup_win_settings()
|
||||
self.setup_styling()
|
||||
self.setup_signals()
|
||||
self.setup_custom_event_signals()
|
||||
self.add(Container())
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("delete-event", Gtk.main_quit)
|
||||
|
||||
def setup_win_settings(self):
|
||||
self.set_icon_from_file(self._ICON_FILE)
|
||||
self.set_title(app_name)
|
||||
self.set_default_size(800, 200)
|
||||
self.set_keep_above(True)
|
||||
self.set_accept_focus(False)
|
||||
self.set_skip_taskbar_hint(True)
|
||||
self.set_skip_pager_hint(True)
|
||||
self.set_type_hint(3) # 3 = TOOLBAR
|
||||
self.set_gravity(8) # 5 = CENTER, 8 = SOUTH
|
||||
self.set_position(1) # 1 = CENTER, 4 = CENTER_ALWAYS
|
||||
self.stick()
|
||||
|
||||
def setup_styling(self):
|
||||
screen = self.get_screen()
|
||||
visual = screen.get_rgba_visual()
|
||||
|
||||
if visual != None and screen.is_composited():
|
||||
self.set_visual(visual)
|
||||
self.set_app_paintable(True)
|
||||
self.connect("draw", self._area_draw)
|
||||
|
||||
css_provider = Gtk.CssProvider()
|
||||
css_provider.load_from_path(self._CSS_FILE)
|
||||
screen = Gdk.Screen.get_default()
|
||||
style_context = Gtk.StyleContext()
|
||||
style_context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
|
||||
def _area_draw(self, widget, cr):
|
||||
cr.set_source_rgba(0, 0, 0, 0.54)
|
||||
cr.set_operator(cairo.OPERATOR_SOURCE)
|
||||
cr.paint()
|
||||
cr.set_operator(cairo.OPERATOR_OVER)
|
18
src/debugger.sh
Executable file
18
src/debugger.sh
Executable 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/gtk-apps-venv/venv/bin/activate'
|
||||
python -m pudb $(pwd)/__main__.py; bash
|
||||
}
|
||||
main "$@";
|
1593
src/resources/Unicode Emoji List.txt
Normal file
1593
src/resources/Unicode Emoji List.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/* * {
|
||||
background: rgba(0, 0, 0, 0.14);
|
||||
background: rgba(0, 0, 0, 0.64);
|
||||
color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
|
||||
|
@@ -1,94 +0,0 @@
|
||||
# Python imports
|
||||
import pyautogui
|
||||
|
||||
# Gtk imports
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
# Let piautogui make updates as quick as it can...
|
||||
pyautogui.FAILSAFE = False # If we hit corner, that's ok
|
||||
pyautogui.MINIMUM_DURATION = 0
|
||||
pyautogui.PAUSE = 0
|
||||
|
||||
|
||||
class KeyboardMixin:
|
||||
|
||||
def typeString(self, widget = None, data = None):
|
||||
text = self.autoTypeField.get_text()
|
||||
for char in text:
|
||||
self.do_insert(char)
|
||||
|
||||
def insert(self, widget = None, data = None, key = None):
|
||||
if not key:
|
||||
key = widget.get_label().strip()
|
||||
|
||||
if self.is_keypress_type(key):
|
||||
return
|
||||
|
||||
if self.isCapsLockOn:
|
||||
key = key.upper()
|
||||
|
||||
self.do_insert(key)
|
||||
|
||||
|
||||
def do_insert(self, key):
|
||||
if self.isCtrlOn or self.isShiftOn or self.isAltOn:
|
||||
self.set_hotkeys()
|
||||
|
||||
pyautogui.typewrite(key)
|
||||
|
||||
if self.isCtrlOn or self.isShiftOn or self.isAltOn:
|
||||
self.unset_hotkeys()
|
||||
|
||||
|
||||
def is_keypress_type(self, key):
|
||||
if key in ["Esc", "Tab", "Space", "Del", "Up", "Down", "Left", "Right", "PrtSc"]:
|
||||
pyautogui.press(key.lower())
|
||||
return True
|
||||
|
||||
for i in range(1, 13):
|
||||
fkey = 'F' + str(i)
|
||||
if key == fkey:
|
||||
pyautogui.press(key.lower())
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def set_hotkeys(self):
|
||||
if self.isCtrlOn:
|
||||
pyautogui.keyDown('ctrl')
|
||||
if self.isShiftOn:
|
||||
pyautogui.keyDown('shiftleft')
|
||||
pyautogui.keyDown('shiftright')
|
||||
if self.isAltOn:
|
||||
pyautogui.keyDown('alt')
|
||||
|
||||
|
||||
def unset_hotkeys(self):
|
||||
pyautogui.keyUp('ctrl')
|
||||
pyautogui.keyUp('shiftleft')
|
||||
pyautogui.keyUp('shiftright')
|
||||
pyautogui.keyUp('alt')
|
||||
|
||||
|
||||
def toggleCaps(self, widget, data=None):
|
||||
self.isCapsLockOn = False if self.isCapsLockOn else True
|
||||
|
||||
def tgglCtrl(self, widget, data=None):
|
||||
self.isCtrlOn = False if self.isCtrlOn else True
|
||||
|
||||
def tgglShift(self, widget, data=None):
|
||||
self.isShiftOn = False if self.isShiftOn else True
|
||||
|
||||
def tgglAlt(self, widget, data=None):
|
||||
self.isAltOn = False if self.isAltOn else True
|
||||
|
||||
|
||||
def enter(self, widget, data=None):
|
||||
pyautogui.press("enter")
|
||||
|
||||
|
||||
def backspace(self, widget, data=None):
|
||||
pyautogui.press("backspace")
|
@@ -1,107 +0,0 @@
|
||||
# Python imports
|
||||
import threading, subprocess, os
|
||||
|
||||
# Gtk imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .mixins.keyboardmixin import KeyboardMixin
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
class Signals(KeyboardMixin):
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
self.builder = self.settings.returnBuilder()
|
||||
self.autoTypeField = self.builder.get_object("autoTypeField")
|
||||
self.commandsStore = self.builder.get_object("commands")
|
||||
self.specialsStore = self.builder.get_object("specials")
|
||||
self.specialsTree = self.builder.get_object("specialsTree")
|
||||
main_keys = self.builder.get_object("main_keys")
|
||||
|
||||
self.isCapsLockOn = False
|
||||
self.isCtrlOn = False
|
||||
self.isShiftOn = False
|
||||
self.isAltOn = False
|
||||
|
||||
special_characters = "<>()[]{}/\!?#$%&@*:^|'\"-_=+~`"
|
||||
self.generate_keys(special_characters, self.specialsStore)
|
||||
self.specialsStore.show_all()
|
||||
main_keys.show_all()
|
||||
|
||||
row1_characters = "1234567890"
|
||||
row1 = Gtk.Box()
|
||||
self.generate_keys(["Esc",], row1)
|
||||
self.generate_keys(row1_characters, row1)
|
||||
self.generate_keys(["Backspace",], row1)
|
||||
row1.set_homogeneous(True)
|
||||
row1.show_all()
|
||||
main_keys.add(row1)
|
||||
|
||||
row2_characters = "qwertyuiop"
|
||||
row2 = Gtk.Box()
|
||||
self.generate_keys(["Tab",], row2)
|
||||
self.generate_keys(row2_characters, row2)
|
||||
row2.set_homogeneous(True)
|
||||
row2.show_all()
|
||||
main_keys.add(row2)
|
||||
|
||||
row3_characters = "asdfghjkl"
|
||||
row3 = Gtk.Box()
|
||||
self.generate_keys(["Caps Lock",], row3)
|
||||
self.generate_keys(row3_characters, row3)
|
||||
self.generate_keys(["Enter",], row3)
|
||||
row3.set_homogeneous(True)
|
||||
row3.show_all()
|
||||
main_keys.add(row3)
|
||||
|
||||
row4_characters = "zxcvbnm,.:"
|
||||
row4 = Gtk.Box()
|
||||
self.generate_keys(row4_characters, row4)
|
||||
row4.set_homogeneous(True)
|
||||
row4.show_all()
|
||||
main_keys.add(row4)
|
||||
|
||||
row5_characters = "Space"
|
||||
row5 = Gtk.Box()
|
||||
self.generate_keys([row5_characters,], row5)
|
||||
row5.set_homogeneous(True)
|
||||
row5.show_all()
|
||||
main_keys.add(row5)
|
||||
|
||||
|
||||
def generate_keys(self, labels, target):
|
||||
for label in labels:
|
||||
button = Gtk.Button.new_with_label(label)
|
||||
if label not in ["Enter", "Backspace", "Caps Lock"]:
|
||||
button.connect("clicked", self.insert)
|
||||
else:
|
||||
if label == "Enter":
|
||||
button.connect("clicked", self.enter)
|
||||
if label == "Backspace":
|
||||
button.connect("clicked", self.backspace)
|
||||
if label == "Caps Lock":
|
||||
button = Gtk.ToggleButton.new_with_label(label)
|
||||
button.connect("toggled", self.toggleCaps)
|
||||
|
||||
target.add(button)
|
||||
|
||||
|
||||
def getClipboardData(self):
|
||||
proc = subprocess.Popen(['xclip','-selection', 'clipboard', '-o'], stdout=subprocess.PIPE)
|
||||
retcode = proc.wait()
|
||||
data = proc.stdout.read()
|
||||
return data.decode("utf-8").strip()
|
||||
|
||||
def setClipboardData(self, data):
|
||||
proc = subprocess.Popen(['xclip','-selection','clipboard'], stdin=subprocess.PIPE)
|
||||
proc.stdin.write(data)
|
||||
proc.stdin.close()
|
||||
retcode = proc.wait()
|
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Utils module
|
||||
"""
|
||||
|
@@ -5,51 +5,51 @@ import os, logging
|
||||
|
||||
|
||||
class Logger:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get_logger(self, loggerName = "NO_LOGGER_NAME_PASSED", createFile = True):
|
||||
"""
|
||||
Create a new logging object and return it.
|
||||
:note:
|
||||
NOSET # Don't know the actual log level of this... (defaulting or literally none?)
|
||||
Log Levels (From least to most)
|
||||
"""
|
||||
Create a new logging object and return it.
|
||||
:note:
|
||||
NOSET # Don't know the actual log level of this... (defaulting or literally none?)
|
||||
Log Levels (From least to most)
|
||||
Type Value
|
||||
CRITICAL 50
|
||||
ERROR 40
|
||||
WARNING 30
|
||||
INFO 20
|
||||
DEBUG 10
|
||||
:param loggerName: Sets the name of the logger object. (Used in log lines)
|
||||
:param createFile: Whether we create a log file or just pump to terminal
|
||||
:param loggerName: Sets the name of the logger object. (Used in log lines)
|
||||
:param createFile: Whether we create a log file or just pump to terminal
|
||||
|
||||
:return: the logging object we created
|
||||
"""
|
||||
:return: the logging object we created
|
||||
"""
|
||||
|
||||
globalLogLvl = logging.DEBUG # Keep this at highest so that handlers can filter to their desired levels
|
||||
chLogLevel = logging.CRITICAL # Prety musch the only one we change ever
|
||||
fhLogLevel = logging.DEBUG
|
||||
def __init__(self, config_path: str, _ch_log_lvl = logging.CRITICAL, _fh_log_lvl = logging.INFO):
|
||||
self._CONFIG_PATH = config_path
|
||||
self.global_lvl = logging.DEBUG # Keep this at highest so that handlers can filter to their desired levels
|
||||
self.ch_log_lvl = _ch_log_lvl # Prety much the only one we ever change
|
||||
self.fh_log_lvl = _fh_log_lvl
|
||||
|
||||
def get_logger(self, loggerName: str = "NO_LOGGER_NAME_PASSED", createFile: bool = True) -> logging.Logger:
|
||||
log = logging.getLogger(loggerName)
|
||||
log.setLevel(globalLogLvl)
|
||||
log.setLevel(self.global_lvl)
|
||||
|
||||
# Set our log output styles
|
||||
fFormatter = logging.Formatter('[%(asctime)s] %(pathname)s:%(lineno)d %(levelname)s - %(message)s', '%m-%d %H:%M:%S')
|
||||
cFormatter = logging.Formatter('%(pathname)s:%(lineno)d] %(levelname)s - %(message)s')
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(level=chLogLevel)
|
||||
ch.setLevel(level=self.ch_log_lvl)
|
||||
ch.setFormatter(cFormatter)
|
||||
log.addHandler(ch)
|
||||
|
||||
if createFile:
|
||||
folder = "logs"
|
||||
file = folder + "/application.log"
|
||||
folder = self._CONFIG_PATH
|
||||
file = f"{folder}/application.log"
|
||||
|
||||
if not os.path.exists(folder):
|
||||
os.mkdir(folder)
|
||||
|
||||
fh = logging.FileHandler(file)
|
||||
fh.setLevel(level=fhLogLevel)
|
||||
fh.setLevel(level=self.fh_log_lvl)
|
||||
fh.setFormatter(fFormatter)
|
||||
log.addHandler(fh)
|
||||
|
||||
|
124
src/utils/pyautogui_control.py
Normal file
124
src/utils/pyautogui_control.py
Normal file
@@ -0,0 +1,124 @@
|
||||
# Python imports
|
||||
import pyautogui
|
||||
|
||||
# Gtk imports
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
# Let piautogui make updates as quick as it can...
|
||||
pyautogui.FAILSAFE = False # If we hit corner, that's ok
|
||||
pyautogui.MINIMUM_DURATION = 0
|
||||
pyautogui.PAUSE = 0
|
||||
|
||||
|
||||
class ControlMixin:
|
||||
|
||||
def type(self, key):
|
||||
pyautogui.typewrite(key)
|
||||
|
||||
def enter(self, widget = None, data = None):
|
||||
pyautogui.press("enter")
|
||||
|
||||
def backspace(self, widget = None, data=None):
|
||||
pyautogui.press("backspace")
|
||||
|
||||
def press_special_keys(self, key):
|
||||
if key in ["Backspace", "Enter", "Esc", "Tab", "Space", "Del", "Up", "Down", "Left", "Right", "PrtSc"]:
|
||||
pyautogui.press(key.lower())
|
||||
return True
|
||||
|
||||
for i in range(1, 13):
|
||||
fkey = 'F' + str(i)
|
||||
if key == fkey:
|
||||
pyautogui.press(key.lower())
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def type_string(self, text):
|
||||
for char in text:
|
||||
pyautogui.typewrite(char)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# def typeString(self, widget = None, data = None):
|
||||
# text = self.autoTypeField.get_text()
|
||||
# for char in text:
|
||||
# self.do_insert(char)
|
||||
#
|
||||
# def insert(self, widget = None, data = None, key = None):
|
||||
# if not key:
|
||||
# key = widget.get_label().strip()
|
||||
#
|
||||
# if self.is_keypress_type(key):
|
||||
# return
|
||||
#
|
||||
# if self.isCapsLockOn:
|
||||
# key = key.upper()
|
||||
#
|
||||
# self.do_insert(key)
|
||||
#
|
||||
#
|
||||
# def do_insert(self, key):
|
||||
# if self.isCtrlOn or self.isShiftOn or self.isAltOn:
|
||||
# self.set_hotkeys()
|
||||
#
|
||||
# pyautogui.typewrite(key)
|
||||
#
|
||||
# if self.isCtrlOn or self.isShiftOn or self.isAltOn:
|
||||
# self.unset_hotkeys()
|
||||
#
|
||||
#
|
||||
# def is_keypress_type(self, key):
|
||||
# if key in ["Esc", "Tab", "Space", "Del", "Up", "Down", "Left", "Right", "PrtSc"]:
|
||||
# pyautogui.press(key.lower())
|
||||
# return True
|
||||
#
|
||||
# for i in range(1, 13):
|
||||
# fkey = 'F' + str(i)
|
||||
# if key == fkey:
|
||||
# pyautogui.press(key.lower())
|
||||
# return True
|
||||
#
|
||||
# return False
|
||||
#
|
||||
#
|
||||
# def set_hotkeys(self):
|
||||
# if self.isCtrlOn:
|
||||
# pyautogui.keyDown('ctrl')
|
||||
# if self.isShiftOn:
|
||||
# pyautogui.keyDown('shiftleft')
|
||||
# pyautogui.keyDown('shiftright')
|
||||
# if self.isAltOn:
|
||||
# pyautogui.keyDown('alt')
|
||||
#
|
||||
#
|
||||
# def unset_hotkeys(self):
|
||||
# pyautogui.keyUp('ctrl')
|
||||
# pyautogui.keyUp('shiftleft')
|
||||
# pyautogui.keyUp('shiftright')
|
||||
# pyautogui.keyUp('alt')
|
||||
#
|
||||
#
|
||||
# def toggleCaps(self, widget, data=None):
|
||||
# self.isCapsLockOn = False if self.isCapsLockOn else True
|
||||
#
|
||||
# def tgglCtrl(self, widget, data=None):
|
||||
# self.isCtrlOn = False if self.isCtrlOn else True
|
||||
#
|
||||
# def tgglShift(self, widget, data=None):
|
||||
# self.isShiftOn = False if self.isShiftOn else True
|
||||
#
|
||||
# def tgglAlt(self, widget, data=None):
|
||||
# self.isAltOn = False if self.isAltOn else True
|
||||
#
|
||||
#
|
||||
# def enter(self, widget, data=None):
|
||||
# pyautogui.press("enter")
|
||||
#
|
||||
#
|
||||
# def backspace(self, widget, data=None):
|
||||
# pyautogui.press("backspace")
|
@@ -1,97 +0,0 @@
|
||||
# Python imports
|
||||
import os
|
||||
|
||||
# Gtk imports
|
||||
import gi, cairo
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
class Settings:
|
||||
def __init__(self):
|
||||
self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
|
||||
self._USER_HOME = os.path.expanduser('~')
|
||||
self._CONFIG_PATH = f"{self._USER_HOME}/.config/{app_name.lower()}"
|
||||
self._GLADE_FILE = f"{self._CONFIG_PATH}/Main_Window.glade"
|
||||
self._CSS_FILE = f"{self._CONFIG_PATH}/stylesheet.css"
|
||||
self._USR_PATH = f"/usr/share/{app_name.lower()}"
|
||||
|
||||
if not os.path.exists(self._CONFIG_PATH):
|
||||
os.mkdir(self._CONFIG_PATH)
|
||||
if not os.path.exists(self._GLADE_FILE):
|
||||
self._GLADE_FILE = f"{self._USR_PATH}/Main_Window.glade"
|
||||
if not os.path.exists(self._CSS_FILE):
|
||||
self._CSS_FILE = f"{self._USR_PATH}/stylesheet.css"
|
||||
|
||||
# 'Filters'
|
||||
self.office = ('.doc', '.docx', '.xls', '.xlsx', '.xlt', '.xltx', '.xlm',
|
||||
'.ppt', 'pptx', '.pps', '.ppsx', '.odt', '.rtf')
|
||||
self.vids = ('.mkv', '.avi', '.flv', '.mov', '.m4v', '.mpg', '.wmv',
|
||||
'.mpeg', '.mp4', '.webm')
|
||||
self.txt = ('.txt', '.text', '.sh', '.cfg', '.conf')
|
||||
self.music = ('.psf', '.mp3', '.ogg' , '.flac')
|
||||
self.images = ('.png', '.jpg', '.jpeg', '.gif')
|
||||
self.pdf = ('.pdf')
|
||||
|
||||
self.builder = Gtk.Builder()
|
||||
self.builder.add_from_file(self._GLADE_FILE)
|
||||
|
||||
|
||||
def createWindow(self):
|
||||
# Get window and connect signals
|
||||
window = self.builder.get_object("Main_Window")
|
||||
window.connect("delete-event", Gtk.main_quit)
|
||||
self.setWindowData(window, False)
|
||||
return window
|
||||
|
||||
def setWindowData(self, window, paintable):
|
||||
screen = window.get_screen()
|
||||
visual = screen.get_rgba_visual()
|
||||
|
||||
if visual != None and screen.is_composited():
|
||||
window.set_visual(visual)
|
||||
|
||||
# bind css file
|
||||
cssProvider = Gtk.CssProvider()
|
||||
cssProvider.load_from_path(self._CSS_FILE)
|
||||
screen = Gdk.Screen.get_default()
|
||||
styleContext = Gtk.StyleContext()
|
||||
styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
|
||||
window.set_app_paintable(paintable)
|
||||
if paintable:
|
||||
window.connect("draw", self.area_draw)
|
||||
|
||||
def getMonitorData(self):
|
||||
screen = self.builder.get_object("Main_Window").get_screen()
|
||||
monitors = []
|
||||
for m in range(screen.get_n_monitors()):
|
||||
monitors.append(screen.get_monitor_geometry(m))
|
||||
|
||||
for monitor in monitors:
|
||||
print("{}x{}+{}+{}".format(monitor.width, monitor.height, monitor.x, monitor.y))
|
||||
|
||||
return monitors
|
||||
|
||||
def area_draw(self, widget, cr):
|
||||
cr.set_source_rgba(0, 0, 0, 0.54)
|
||||
cr.set_operator(cairo.OPERATOR_SOURCE)
|
||||
cr.paint()
|
||||
cr.set_operator(cairo.OPERATOR_OVER)
|
||||
|
||||
|
||||
def returnBuilder(self): return self.builder
|
||||
|
||||
# Filter returns
|
||||
def returnOfficeFilter(self): return self.office
|
||||
def returnVidsFilter(self): return self.vids
|
||||
def returnTextFilter(self): return self.txt
|
||||
def returnMusicFilter(self): return self.music
|
||||
def returnImagesFilter(self): return self.images
|
||||
def returnPdfFilter(self): return self.pdf
|
Reference in New Issue
Block a user