aboutsummaryrefslogtreecommitdiffstats
path: root/tagit/actions
diff options
context:
space:
mode:
Diffstat (limited to 'tagit/actions')
-rw-r--r--tagit/actions/__init__.py16
-rw-r--r--tagit/actions/misc.kv35
-rw-r--r--tagit/actions/misc.py167
-rw-r--r--tagit/actions/planes.kv15
-rw-r--r--tagit/actions/planes.py57
5 files changed, 282 insertions, 8 deletions
diff --git a/tagit/actions/__init__.py b/tagit/actions/__init__.py
index 444bd73..9fd6342 100644
--- a/tagit/actions/__init__.py
+++ b/tagit/actions/__init__.py
@@ -15,9 +15,9 @@ from tagit.utils.builder import BuilderBase
from . import filter
from . import grouping
#from . import library
-#from . import misc
+from . import misc
#from . import objects
-#from . import planes
+from . import planes
from . import search
#from . import session
#from . import tabs
@@ -88,9 +88,9 @@ class ActionBuilder(BuilderBase):
#'ShellDrop': misc.ShellDrop,
#'OpenExternal': misc.OpenExternal,
#'Menu': misc.Menu,
- #'ShowConsole': misc.ShowConsole,
- #'ShowHelp': misc.ShowHelp,
- #'ShowSettings': misc.ShowSettings,
+ 'ShowConsole': misc.ShowConsole,
+ 'ShowHelp': misc.ShowHelp,
+ 'ShowSettings': misc.ShowSettings,
#'ClipboardCopy': misc.ClipboardCopy,
#'ClipboardPaste': misc.ClipboardPaste,
## objects
@@ -105,9 +105,9 @@ class ActionBuilder(BuilderBase):
#'SetRank4': objects.SetRank4,
#'SetRank5': objects.SetRank5,
## planes
- #'ShowDashboard': planes.ShowDashboard,
- #'ShowBrowsing': planes.ShowBrowsing,
- #'ShowCodash': planes.ShowCodash,
+ 'ShowDashboard': planes.ShowDashboard,
+ 'ShowBrowsing': planes.ShowBrowsing,
+ 'ShowCodash': planes.ShowCodash,
## search
#'Search': search.Search,
#'ShowSelected': search.ShowSelected,
diff --git a/tagit/actions/misc.kv b/tagit/actions/misc.kv
new file mode 100644
index 0000000..f9d5157
--- /dev/null
+++ b/tagit/actions/misc.kv
@@ -0,0 +1,35 @@
+#:import resource_find kivy.resources.resource_find
+
+<Menu>:
+ source: resource_find('atlas://misc/menu')
+ tooltip: 'Open the menu'
+
+<ShellDrop>:
+ source: resource_find('atlas://misc/shell')
+ tooltip: 'Open a terminal shell'
+
+<OpenExternal>:
+ source: resource_find('atlas://misc/open_external')
+ tooltip: 'Open selected items in an external application'
+
+<ShowConsole>:
+ source: resource_find('atlas://misc/console')
+ tooltip: 'Open the log console'
+
+<ShowHelp>:
+ source: resource_find('atlas://misc/help')
+ tooltip: 'Open the help'
+
+<ShowSettings>:
+ source: resource_find('atlas://misc/settings')
+ tooltip: 'Open the settings menu'
+
+<ClipboardCopy>:
+ source: resource_find('atlas://misc/clip_copy')
+ tooltip: 'Copy selected items to the clipboard'
+
+<ClipboardPaste>:
+ source: resource_find('atlas://misc/clip_paste')
+ tooltip: 'Import files from the clipboard'
+
+## EOF ##
diff --git a/tagit/actions/misc.py b/tagit/actions/misc.py
new file mode 100644
index 0000000..dc939ca
--- /dev/null
+++ b/tagit/actions/misc.py
@@ -0,0 +1,167 @@
+"""
+
+Part of the tagit module.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# standard imports
+import logging
+import os
+
+# kivy imports
+from kivy.core.clipboard import Clipboard
+from kivy.lang import Builder
+import kivy.properties as kp
+import webbrowser
+
+# tagit imports
+from tagit import config
+#from tagit.io_.sync import export # FIXME: mb/port
+#from tagit.utils import fileopen # FIXME: mb/port
+from tagit.widgets import Binding
+
+# inner-module imports
+from .action import Action
+
+# constants
+HELP_URL = 'https://www.igsor.net/projects/tagit/'
+
+# exports
+__all__ = []
+
+
+## code ##
+
+logger = logging.getLogger(__name__)
+
+# load kv
+Builder.load_file(os.path.join(os.path.dirname(__file__), 'misc.kv'))
+
+# classes
+class Menu(Action):
+ """Open the menu."""
+ text = kp.StringProperty('Menu')
+
+ def ktrigger(self, evt):
+ return Binding.check(evt, self.cfg('bindings', 'misc', 'menu'))
+
+ def apply(self):
+ x = self.pos[0] + self.width
+ y = self.pos[1] + self.height
+ self.root.context.show(x, y)
+
+
+class ShellDrop(Action):
+ """Open a terminal shell."""
+ text = kp.StringProperty('Shell')
+
+ def apply(self):
+ from tagit import debug
+ debug(locals(), globals())
+
+
+class OpenExternal(Action):
+ """Open the selected items in an external application."""
+ text = kp.StringProperty('Open')
+
+ def ktrigger(self, evt):
+ # FIXME: Triggered on Shift + Click (Interferes with selection!)
+ # Triggered on <Enter> when tags are edited.
+ return Binding.check(evt, self.cfg('bindings', 'misc', 'open'))
+
+ def apply(self):
+ with self.root.browser as browser:
+ if browser.cursor is None:
+ logger.error('No file selected')
+ elif os.path.exists(browser.cursor.path):
+ fileopen(browser.cursor.path)
+ else:
+ logger.error('File unavailable')
+
+
+class ShowConsole(Action):
+ """Open the log console."""
+ text = kp.StringProperty('Console')
+
+ def apply(self):
+ self.root.status.console()
+
+
+class ShowHelp(Action):
+ """Show some help."""
+ text = kp.StringProperty('Help')
+
+ def ktrigger(self, evt):
+ return Binding.check(evt, self.cfg('bindings', 'misc', 'help'))
+
+ def apply(self):
+ webbrowser.open(HELP_URL)
+
+
+class ShowSettings(Action):
+ """Open the settings menu."""
+ text = kp.StringProperty('Settings')
+
+ def ktrigger(self, evt):
+ return Binding.check(evt, self.cfg('bindings', 'misc', 'settings'))
+
+ def apply(self):
+ from kivy.app import App
+ App.get_running_app().open_settings()
+
+
+class ClipboardCopy(Action):
+ """Copy selected items into the clipboard."""
+ text = kp.StringProperty('Copy to clipboard')
+
+ def ktrigger(self, evt):
+ return Binding.check(evt, self.cfg('bindings', 'clipboard', 'copy'))
+
+ def apply(self):
+ browser = self.root.browser
+ paths = [obj.path for obj in browser.selection]
+ Clipboard.copy('\n'.join(paths))
+
+
+class ClipboardPaste(Action):
+ """Import items from the clipboard."""
+ text = kp.StringProperty('Paste from clipboard')
+
+ def ktrigger(self, evt):
+ return Binding.check(evt, self.cfg('bindings', 'clipboard', 'paste'))
+
+ def apply(self):
+ paths = Clipboard.paste()
+ paths = paths.split('\n')
+ self.root.trigger('ImportObjects', paths)
+
+
+## config ##
+
+# keybindings
+
+config.declare(('bindings', 'misc', 'menu'),
+ config.Keybind(), Binding.simple(Binding.CMD, None, Binding.mALL),
+ __name__, Menu.text.defaultvalue, Menu.__doc__)
+
+config.declare(('bindings', 'misc', 'open'),
+ config.Keybind(), Binding.simple(Binding.ENTER, None, Binding.mALL),
+ __name__, OpenExternal.text.defaultvalue, OpenExternal.__doc__)
+
+config.declare(('bindings', 'misc', 'help'),
+ config.Keybind(), Binding.simple('/', Binding.mSHIFT),
+ __name__, ShowHelp.text.defaultvalue, ShowHelp.__doc__)
+
+config.declare(('bindings', 'misc', 'settings'),
+ config.Keybind(), Binding.simple(Binding.F1), # also the kivy default
+ __name__, ShowSettings.text.defaultvalue, ShowSettings.__doc__)
+
+config.declare(('bindings', 'clipboard', 'copy'),
+ config.Keybind(), Binding.simple('c', Binding.mCTRL),
+ __name__, ClipboardCopy.text.defaultvalue, ClipboardCopy.__doc__)
+
+config.declare(('bindings', 'clipboard', 'paste'),
+ config.Keybind(), Binding.simple('v', Binding.mCTRL),
+ __name__, ClipboardPaste.text.defaultvalue, ClipboardPaste.__doc__)
+
+## EOF ##
diff --git a/tagit/actions/planes.kv b/tagit/actions/planes.kv
new file mode 100644
index 0000000..184f949
--- /dev/null
+++ b/tagit/actions/planes.kv
@@ -0,0 +1,15 @@
+#:import resource_find kivy.resources.resource_find
+
+<ShowDashboard>:
+ source: resource_find('atlas://planes/dashboard')
+ tooltip: 'Switch to the Dashboard'
+
+<ShowBrowsing>:
+ source: resource_find('atlas://planes/browsing')
+ tooltip: 'Switch to the browsing plane'
+
+<ShowCodash>:
+ source: resource_find('atlas://planes/codash')
+ tooltip: 'Switch to the contextual dashboard'
+
+## EOF ##
diff --git a/tagit/actions/planes.py b/tagit/actions/planes.py
new file mode 100644
index 0000000..89f93bb
--- /dev/null
+++ b/tagit/actions/planes.py
@@ -0,0 +1,57 @@
+"""
+
+Part of the tagit module.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# standard imports
+import os
+
+# kivy imports
+from kivy.lang import Builder
+import kivy.properties as kp
+
+# inner-module imports
+from .action import Action
+
+# exports
+__all__ = []
+
+
+## code ##
+
+# load kv
+Builder.load_file(os.path.join(os.path.dirname(__file__), 'planes.kv'))
+
+# classes
+
+class ShowDashboard(Action):
+ """Switch to the dashboard."""
+ text = kp.StringProperty('Dashboard')
+
+ def apply(self):
+ planes = self.root.planes
+ if planes.current_slide != planes.dashboard:
+ planes.load_slide(planes.dashboard)
+
+
+class ShowBrowsing(Action):
+ """Switch to the browsing plane."""
+ text = kp.StringProperty('Browsing')
+
+ def apply(self):
+ planes = self.root.planes
+ if planes.current_slide != planes.browsing:
+ planes.load_slide(planes.browsing)
+
+
+class ShowCodash(Action):
+ """Switch to the contextual dashboard."""
+ text = kp.StringProperty('Context')
+
+ def apply(self):
+ planes = self.root.planes
+ if planes.current_slide != planes.codash:
+ planes.load_slide(planes.codash)
+
+## EOF ##