Package plugins :: Package vfs :: Package fileinfo :: Module main |
[hide private]
[frames] | no frames]

# Source Code for Module plugins.vfs.fileinfo.main

     1  #-*- coding: utf8 -*
     2  #
     3  # Max E. Kuznecov 2008
     4  #
     5
     6  from libxyz.core.plugins import BasePlugin
     7  from libxyz.core.utils import ustring
     8
     9  from libxyz.ui import lowui
    10  from libxyz.ui import XYZListBox
    11
    12 -class XYZPlugin(BasePlugin):
    13      "Plugin fileinfo"
    14
    15      NAME = u"fileinfo"
    16      AUTHOR = u"Max E. Kuznecov"
    17      VERSION = u"0.1"
    18      BRIEF_DESCRIPTION = u"Show VFS object information"
    19      FULL_DESCRIPTION = u"Show detailed information provided by VFS layer"
    20      NAMESPACE = u"vfs"
    21      MIN_XYZ_VERSION = None
    22      DOC = None
    23      HOMEPAGE = u"xyzcmd.syhpoon.name"
    24      EVENTS = [("fileinfo",
    25                 "Event is fired upon showing file-info dialog.\n"\
    26                 "Arguments: Currently selected VFSObject instance"),
    27                ]
    28
    29 -    def __init__(self, xyz):
    30          super(XYZPlugin, self).__init__(xyz)
    31
    32          self.export(self.fileinfo)
    33
    34      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    35
    36 -    def fileinfo(self):
    37          """
    38          Show VFS object info
    39          """
    40
    41          _selected = self.xyz.pm.from_load(":sys:panel", "get_selected")()
    42          self.fire_event("fileinfo", _selected)
    43
    44          _data = []
    45          _na = lambda x: lowui.Text(u"%-30s: N/A" % x)
    46
    47          for _name, _value in _selected.attributes:
    48              if _value in (None, ""):
    49                  _data.append(_na(_name))
    50              else:
    51                  if not isinstance(_value, basestring):
    52                      _value = ustring(str(_value))
    53
    54                  _data.append(lowui.Text(u"%-30s: %s" % (_name, _value)))
    55
    56          _walker = lowui.SimpleListWalker(_data)
    57          _dim = tuple([x - 2 for x in self.xyz.screen.get_cols_rows()])
    58
    59          XYZListBox(self.xyz, self.xyz.top, _walker, _(u"VFS Object Info"),
    60                     _dim).show()
    61