aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tagit/apps/desktop.py2
-rw-r--r--tagit/apps/port-config.yaml2
-rw-r--r--tagit/tiles/__init__.py12
-rw-r--r--tagit/tiles/buttons.py50
-rw-r--r--tagit/tiles/cursor_tags.py60
-rw-r--r--tagit/tiles/info.py1
-rw-r--r--tagit/tiles/selection_tags.py60
7 files changed, 177 insertions, 10 deletions
diff --git a/tagit/apps/desktop.py b/tagit/apps/desktop.py
index 1412da9..94acbf2 100644
--- a/tagit/apps/desktop.py
+++ b/tagit/apps/desktop.py
@@ -70,14 +70,12 @@ class TagitApp(App):
n1 = store.node(ns.bsfs.File, URI('http://example.com/me/entity#02')) \
.set(ns.bse.filename, 'document.pdf') \
.set(ns.bse.filesize, 200) \
- .set(ns.bse.author, 'me') \
.set(ns.bse.tag, t_world) \
.set(ns.bse.tag, t_foobar) \
.set(ns.bse.group, grp)
n2 = store.node(ns.bsfs.File, URI('http://example.com/me/entity#03')) \
.set(ns.bse.filename, 'document.odt') \
.set(ns.bse.filesize, 300) \
- .set(ns.bse.author, 'you') \
.set(ns.bse.tag, t_world)
n3 = store.node(ns.bsfs.File, URI('http://example.com/me/entity#04')) \
.set(ns.bse.filename, 'image.jpg') \
diff --git a/tagit/apps/port-config.yaml b/tagit/apps/port-config.yaml
index 7335c16..872ac29 100644
--- a/tagit/apps/port-config.yaml
+++ b/tagit/apps/port-config.yaml
@@ -131,7 +131,7 @@ ui:
#Tagcloud: {}
sidebar_right:
Info: {}
- #CursorTags: {}
+ CursorTags: {}
BrowserTags: {}
#Venn: {}
window_size: 1024x768
diff --git a/tagit/tiles/__init__.py b/tagit/tiles/__init__.py
index 11f4a82..7817339 100644
--- a/tagit/tiles/__init__.py
+++ b/tagit/tiles/__init__.py
@@ -13,15 +13,15 @@ from tagit.utils.builder import BuilderBase
# inner-module imports
##from .anomalies import Anomalies # FIXME: skeleton only
from .browser_tags import BrowserTags
-#from .buttons import Buttons
-#from .cursor_tags import CursorTags
+from .buttons import Buttons
+from .cursor_tags import CursorTags
#from .entity_histogram import EntityHistogram
#from .geo import Map
#from .hints import Hints
from .info import Info
#from .libsummary import LibSummary
#from .searchtree import Searchtree
-#from .selection_tags import SelectionTags
+from .selection_tags import SelectionTags
#from .suggested_tags import SuggestedTags
#from .tag_distribution import TagDistribution
#from .tag_histogram import TagHistogram
@@ -41,15 +41,15 @@ class TileBuilder(BuilderBase):
_factories = {
# #'Anomalies': Anomalies,
'BrowserTags': BrowserTags,
-# 'Buttons': Buttons,
-# 'CursorTags': CursorTags,
+ 'Buttons': Buttons,
+ 'CursorTags': CursorTags,
# 'EntityHistogram': EntityHistogram,
# 'Geo': Map,
# 'Hints': Hints,
'Info': Info,
# 'LibSummary': LibSummary,
# 'Searchtree': Searchtree,
-# 'SelectionTags': SelectionTags,
+ 'SelectionTags': SelectionTags,
# 'SuggestedTags': SuggestedTags,
# 'TagDistribution': TagDistribution,
# 'TagHistogram': TagHistogram,
diff --git a/tagit/tiles/buttons.py b/tagit/tiles/buttons.py
new file mode 100644
index 0000000..2a13911
--- /dev/null
+++ b/tagit/tiles/buttons.py
@@ -0,0 +1,50 @@
+"""
+
+Part of the tagit module.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+
+"""
+# kivy imports
+from kivy.lang import Builder
+import kivy.properties as kp
+
+# inner-module imports
+from .tile import Tile
+
+# exports
+__all__ = ('Buttons', )
+
+## code ##
+
+# load kv
+# NOTE: ButtonDock doesn't need to be imported... why?!
+Builder.load_string('''
+<Buttons>:
+ title: 'Actions'
+ tooltip: 'Some buttons'
+
+ # content
+ slim: False
+ btns: btns
+ ButtonDock:
+ root: root.root
+ orientation: 'lr-tb'
+ id: btns
+ # space between childs
+ spacing: (5, 0) if root.slim else (30, 5)
+ # space between ButtonDock and its children
+ padding: (0, 0) if root.slim else (10, 5)
+''')
+
+# classes
+class Buttons(Tile):
+ """A container for buttons to trigger some action."""
+ buttons = kp.ListProperty()
+
+ def update(self):
+ if self.visible and len(self.btns.children) == 0:
+ self.btns.clear_widgets()
+ self.btns.populate(self.buttons)
+
+## EOF ##
diff --git a/tagit/tiles/cursor_tags.py b/tagit/tiles/cursor_tags.py
new file mode 100644
index 0000000..2ab2f30
--- /dev/null
+++ b/tagit/tiles/cursor_tags.py
@@ -0,0 +1,60 @@
+"""
+
+Part of the tagit module.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# kivy imports
+from kivy.lang import Builder
+
+# tagit imports
+from tagit.widgets.browser import BrowserAwareMixin
+
+# inner-module imports
+from .tile import TileWithLabel
+
+# exports
+__all__ = ('CursorTags', )
+
+
+## code ##
+
+# load kv
+Builder.load_string('''
+<CursorTags>:
+ title: "Cursor's tags"
+ tooltip: 'Tags at the cursor'
+''')
+
+
+# classes
+class CursorTags(TileWithLabel, BrowserAwareMixin):
+ """Show tags of cursor item."""
+
+ def on_browser(self, sender, browser):
+ # remove old binding
+ if self.browser is not None:
+ self.browser.unbind(cursor=self.update)
+ # add new binding
+ self.browser = browser
+ if self.browser is not None:
+ self.browser.bind(cursor=self.update)
+ self.update()
+
+ def __del__(self):
+ if self.browser is not None:
+ self.browser.unbind(cursor=self.update)
+ self.browser = None
+
+ def update(self, *args):
+ cursor = self.root.browser.cursor
+ if not self.visible or cursor is None:
+ # no cursor, nothing to do
+ self.text = ''
+ else:
+ tags = cursor.tag.label()
+ tags = {tag.title() for tag in tags} # nice display
+ tags = sorted(tags)
+ self.text = ', '.join(tags)
+
+## EOF ##
diff --git a/tagit/tiles/info.py b/tagit/tiles/info.py
index 2221b60..725e098 100644
--- a/tagit/tiles/info.py
+++ b/tagit/tiles/info.py
@@ -65,7 +65,6 @@ class Info(TileTabular, BrowserAwareMixin):
ns.bse.filesize,
ns.bse.filename,
ns.bse.comment,
- ns.bse.author,
)
self.tabledata = OrderedDict({
'Date' : ttime.from_timestamp_utc(
diff --git a/tagit/tiles/selection_tags.py b/tagit/tiles/selection_tags.py
new file mode 100644
index 0000000..7951cfe
--- /dev/null
+++ b/tagit/tiles/selection_tags.py
@@ -0,0 +1,60 @@
+"""
+
+Part of the tagit module.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# kivy imports
+from kivy.lang import Builder
+
+# tagit imports
+from tagit.widgets.browser import BrowserAwareMixin
+
+# inner-module imports
+from .tile import TileWithLabel
+
+# exports
+__all__ = ('SelectionTags', )
+
+
+## code ##
+
+# load kv
+Builder.load_string('''
+<SelectionTags>:
+ title: "Selection's tags"
+ default_size: None, 50
+''')
+
+# classes
+class SelectionTags(TileWithLabel, BrowserAwareMixin):
+ """Show tags of selected items."""
+
+ def on_browser(self, sender, browser):
+ # remove old binding
+ if self.browser is not None:
+ self.browser.unbind(selection=self.update)
+ # add new binding
+ self.browser = browser
+ if self.browser is not None:
+ self.browser.bind(selection=self.update)
+ self.update()
+
+ def __del__(self):
+ if self.browser is not None:
+ self.browser.unbind(selection=self.update)
+ self.browser = None
+
+ def update(self, *args):
+ browser = self.root.browser
+ selection = browser.unfold(browser.selection)
+ if not self.visible or len(selection) == 0:
+ # nothing selected, nothing to do
+ self.text = ''
+ else:
+ tags = selection.tag.label(node=False)
+ tags = {tag.title() for tag in tags} # nice display
+ tags = sorted(tags)
+ self.text = ', '.join(tags)
+
+## EOF ##