diff options
author | ronie <ronie@users.noreply.github.com> | 2016-12-11 16:26:38 +0100 |
---|---|---|
committer | ronie <ronie@users.noreply.github.com> | 2016-12-11 16:26:38 +0100 |
commit | 831e48cff7530f14bcce7353565d4b980411534c (patch) | |
tree | 4ef24cf3baa77f86d96f194ea5d337874c6f05ff /plugin.library.node.editor | |
parent | 7c7a926de123220d47ae48b09f04b0b731b408d7 (diff) |
[plugin.library.node.editor] 1.0.5
Diffstat (limited to 'plugin.library.node.editor')
-rw-r--r--[-rwxr-xr-x] | plugin.library.node.editor/addon.py | 68 | ||||
-rw-r--r-- | plugin.library.node.editor/addon.xml | 2 | ||||
-rw-r--r-- | plugin.library.node.editor/changelog.txt | 3 | ||||
-rw-r--r-- | plugin.library.node.editor/resources/language/English/strings.po | 2 | ||||
-rw-r--r-- | plugin.library.node.editor/resources/lib/moveNodes.py | 98 | ||||
-rw-r--r-- | plugin.library.node.editor/resources/musicrules.xml | 3 |
6 files changed, 149 insertions, 27 deletions
diff --git a/plugin.library.node.editor/addon.py b/plugin.library.node.editor/addon.py index 597e838..b65eb54 100755..100644 --- a/plugin.library.node.editor/addon.py +++ b/plugin.library.node.editor/addon.py @@ -108,13 +108,24 @@ class Main: self.changeRootAttrib( self.PARAMS[ "actionPath" ], "visible", newVisibility ) else: return - elif self.PARAMS[ "type" ] == "editorder": - currentOrder = self.getRootAttrib( self.PARAMS[ "actionPath" ], "order" ) - # Get new label from keyboard dialog - neworder = xbmcgui.Dialog().numeric( 0, LANGUAGE( 30302 ), currentOrder ) - if neworder != "" and neworder != currentOrder: - # We've got a new label, update the xml file - self.changeRootAttrib( self.PARAMS[ "actionPath" ], "order", neworder ) + elif self.PARAMS[ "type" ] == "moveNode": + self.indexCounter = -1 + + # Get existing nodes + nodes = {} + self.listNodes( self.PARAMS[ "actionPath" ], nodes ) + + # Get updated order + newOrder = moveNodes.getNewOrder( nodes, int( self.PARAMS[ "actionItem" ] ) ) + + if newOrder is not None: + # Update the orders + for i, node in enumerate( newOrder, 1 ): + path = urllib.unquote( node[ 2 ] ) + if node[ 3 ] == "folder": + path = os.path.join( urllib.unquote( node[ 2 ] ), "index.xml" ) + self.changeRootAttrib( path, "order", str( i * 10 ) ) + elif self.PARAMS[ "type" ] == "newView": # Get new view name from keyboard dialog keyboard = xbmc.Keyboard( "", LANGUAGE( 30316 ), False ) @@ -274,7 +285,7 @@ class Main: else: self.listNodes( targetDir, nodes ) self.PATH = urllib.quote( self.PATH ) - for key in sorted( nodes ): + for i, key in enumerate( sorted( nodes ) ): # 0 = Label # 1 = Icon # 2 = Path @@ -287,9 +298,9 @@ class Main: label = nodes[ key ][ 0 ] # Create the listitem if nodes[ key ][ 3 ] == "folder": - listitem = xbmcgui.ListItem( label="(%s) %s >" % ( nodes[ key ][ 4 ], label ), label2=nodes[ key ][ 4 ], iconImage=nodes[ key ][ 1 ] ) + listitem = xbmcgui.ListItem( label="%s >" % ( label ), label2=nodes[ key ][ 4 ], iconImage=nodes[ key ][ 1 ] ) else: - listitem = xbmcgui.ListItem( label="(%s) %s" % ( nodes[ key ][ 4 ], label ), label2=nodes[ key ][ 4 ], iconImage=nodes[ key ][ 1 ] ) + listitem = xbmcgui.ListItem( label=label, label2=nodes[ key ][ 4 ], iconImage=nodes[ key ][ 1 ] ) # Add context menu items commands = [] commandsNode = [] @@ -297,13 +308,20 @@ class Main: commandsNode.append( ( LANGUAGE(30101), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=editlabel&actionPath=" % ltype + os.path.join( nodes[ key ][ 2 ], "index.xml" ) + "&label=" + nodes[ key ][ 0 ] + ")" ) ) commandsNode.append( ( LANGUAGE(30102), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=editIcon&actionPath=" % ltype + os.path.join( nodes[ key ][ 2 ], "index.xml" ) + "&value=" + nodes[ key ][ 1 ] + ")" ) ) commandsNode.append( ( LANGUAGE(30103), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=browseIcon&actionPath=" % ltype + os.path.join( nodes [ key ][ 2 ], "index.xml" ) + ")" ) ) - commandsNode.append( ( LANGUAGE(30104), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=editorder&actionPath=" % ltype + os.path.join( nodes[ key ][ 2 ], "index.xml" ) + ")" ) ) + if self.PATH == "": + commandsNode.append( ( LANGUAGE(30104), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=moveNode&actionPath=" % ltype + targetDir + "&actionItem=" + str( i ) + ")" ) ) + else: + commandsNode.append( ( LANGUAGE(30104), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=moveNode&actionPath=" % ltype + self.PATH + "&actionItem=" + str( i ) + ")" ) ) commandsNode.append( ( LANGUAGE(30105), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=editvisibility&actionPath=" % ltype + os.path.join( nodes[ key ][ 2 ], "index.xml" ) + ")" ) ) commandsNode.append( ( LANGUAGE(30100), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=delete&actionPath=" % ltype + nodes[ key ][ 2 ] + ")" ) ) + commandsView.append( ( LANGUAGE(30101), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=editlabel&actionPath=" % ltype + nodes[ key ][ 2 ] + "&label=" + nodes[ key ][ 0 ] + ")" ) ) commandsView.append( ( LANGUAGE(30102), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=editIcon&actionPath=" % ltype + nodes[ key ][ 2 ] + "&value=" + nodes[ key ][ 1 ] + ")" ) ) commandsView.append( ( LANGUAGE(30103), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=browseIcon&actionPath=" % ltype + nodes[ key ][ 2 ] + ")" ) ) - commandsView.append( ( LANGUAGE(30104), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=editorder&actionPath=" % ltype + nodes[ key ][ 2 ] + ")" ) ) + if self.PATH == "": + commandsView.append( ( LANGUAGE(30104), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=moveNode&actionPath=" % ltype + targetDir + "&actionItem=" + str( i ) + ")" ) ) + else: + commandsView.append( ( LANGUAGE(30104), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=moveNode&actionPath=" % ltype + self.PATH + "&actionItem=" + str( i ) + ")" ) ) commandsView.append( ( LANGUAGE(30105), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=editvisibility&actionPath=" % ltype + nodes[ key ][ 2 ] + ")" ) ) commandsView.append( ( LANGUAGE(30100), "XBMC.RunPlugin(plugin://plugin.library.node.editor?ltype=%s&type=delete&actionPath=" % ltype + nodes[ key ][ 2 ] + ")" ) ) if nodes[ key ][ 3 ] == "folder": @@ -340,16 +358,16 @@ class Main: else: xbmcplugin.addDirectoryItem( int(sys.argv[ 1 ]), action, listitem, isFolder=False ) # New rule - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=rule&actionPath=" % ltype + os.path.join( self.PATH, "index.xml" ) + "&rule=" + str( nextRule), xbmcgui.ListItem( label=LANGUAGE(30005) ), isFolder=True ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=rule&actionPath=" % ltype + os.path.join( self.PATH, "index.xml" ) + "&rule=" + str( nextRule), xbmcgui.ListItem( label="* %s" %( LANGUAGE(30005) ) ), isFolder=True ) showReset = False if self.PATH == "": self.PATH = urllib.quote( targetDir ) showReset = True # New view and node - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=newView&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label=LANGUAGE(30006) ), isFolder=False ) - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=newNode&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label=LANGUAGE(30007) ), isFolder=False ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=newView&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label="* %s" %( LANGUAGE(30006) ) ), isFolder=False ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=newNode&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label="* %s" %( LANGUAGE(30007) ) ), isFolder=False ) if showReset: - xbmcplugin.addDirectoryItem( int(sys.argv[ 1 ]), "plugin://plugin.library.node.editor?ltype=%s&type=delete&actionPath=" % ltype + targetDir, xbmcgui.ListItem( label=LANGUAGE(30008) ), isFolder=False ) + xbmcplugin.addDirectoryItem( int(sys.argv[ 1 ]), "plugin://plugin.library.node.editor?ltype=%s&type=delete&actionPath=" % ltype + targetDir, xbmcgui.ListItem( label="* %s" %( LANGUAGE(30008) ) ), isFolder=False ) xbmcplugin.setContent(int(sys.argv[1]), 'files') xbmcplugin.endOfDirectory(handle=int(sys.argv[1])) @@ -459,28 +477,28 @@ class Main: xbmcplugin.addDirectoryItem( int(sys.argv[ 1 ]), action, listitem, isFolder=False ) if not hasContent and not hasPath: # Add content - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=editContent&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label=LANGUAGE(30000) ) ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=editContent&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label="* %s" %( LANGUAGE(30000) ) ) ) if not hasOrder and hasContent: # Add order - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=orderby&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label=LANGUAGE(30002) ), isFolder=True ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=orderby&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label="* %s" %( LANGUAGE(30002) ) ), isFolder=True ) if not hasGroup and hasContent: # Add group - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=editGroup&actionPath=" % ltype + self.PATH + "&content=" + content, xbmcgui.ListItem( label=LANGUAGE(30004) ) ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=editGroup&actionPath=" % ltype + self.PATH + "&content=" + content, xbmcgui.ListItem( label="* %s" %( LANGUAGE(30004) ) ) ) if not hasLimit and hasContent: # Add limit - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=editLimit&actionPath=" % ltype + self.PATH + "&value=25", xbmcgui.ListItem( label=LANGUAGE(30003) ) ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=editLimit&actionPath=" % ltype + self.PATH + "&value=25", xbmcgui.ListItem( label="* %s" %( LANGUAGE(30003) ) ) ) if not hasPath and not hasContent: # Add path - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=addPath&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label=LANGUAGE(30001) ) ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=addPath&actionPath=" % ltype + self.PATH, xbmcgui.ListItem( label="* %s" %( LANGUAGE(30001) ) ) ) if hasContent: # Add rule - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=rule&actionPath=" % ltype + self.PATH + "&rule=" + str( nextRule ), xbmcgui.ListItem( label=LANGUAGE(30005) ), isFolder = True ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=rule&actionPath=" % ltype + self.PATH + "&rule=" + str( nextRule ), xbmcgui.ListItem( label="* %s" %( LANGUAGE(30005) ) ), isFolder = True ) if hasPath: if "plugin://" not in splitPath[0][0]: # Add component - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=pathRule&actionPath=%s&rule=%d" % ( ltype, self.PATH, x + 1 ), xbmcgui.ListItem( label=LANGUAGE(30009) ), isFolder = True ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=pathRule&actionPath=%s&rule=%d" % ( ltype, self.PATH, x + 1 ), xbmcgui.ListItem( label="* %s" %( LANGUAGE(30009) ) ), isFolder = True ) # Manually edit path - xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=editPath&actionPath=" % ltype + self.PATH + "&value=" + urllib.quote( rule[ 1 ] ), xbmcgui.ListItem( label=LANGUAGE(30010) ), isFolder = True ) + xbmcplugin.addDirectoryItem( int( sys.argv[ 1 ] ), "plugin://plugin.library.node.editor?ltype=%s&type=editPath&actionPath=" % ltype + self.PATH + "&value=" + urllib.quote( rule[ 1 ] ), xbmcgui.ListItem( label="* %s" %( LANGUAGE(30010) ) ), isFolder = True ) xbmcplugin.setContent(int(sys.argv[1]), 'files') xbmcplugin.endOfDirectory(handle=int(sys.argv[1])) @@ -817,7 +835,7 @@ if ( __name__ == "__main__" ): params = dict( arg.split( "=" ) for arg in sys.argv[ 2 ][1:].split( "&" ) ) ltype = params['ltype'] if ltype != '': - import rules, pathrules, viewattrib, orderby + import rules, pathrules, viewattrib, orderby, moveNodes RULE = rules.RuleFunctions() ATTRIB = viewattrib.ViewAttribFunctions() PATHRULE = pathrules.PathRuleFunctions() diff --git a/plugin.library.node.editor/addon.xml b/plugin.library.node.editor/addon.xml index e6a25cb..8f57e6d 100644 --- a/plugin.library.node.editor/addon.xml +++ b/plugin.library.node.editor/addon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<addon id="plugin.library.node.editor" name="Library Node Editor" version="1.0.4" provider-name="Unfledged, Team-Kodi"> +<addon id="plugin.library.node.editor" name="Library Node Editor" version="1.0.5" provider-name="Unfledged, Team-Kodi"> <requires> <import addon="xbmc.python" version="2.25.0"/> <import addon="script.module.unidecode" version="0.4.16"/> diff --git a/plugin.library.node.editor/changelog.txt b/plugin.library.node.editor/changelog.txt index 38ddb76..5720cac 100644 --- a/plugin.library.node.editor/changelog.txt +++ b/plugin.library.node.editor/changelog.txt @@ -1,3 +1,6 @@ +1.0.5 +- replace edit order with move node + 1.0.4 - support for flat video library diff --git a/plugin.library.node.editor/resources/language/English/strings.po b/plugin.library.node.editor/resources/language/English/strings.po index c3065de..d280fa8 100644 --- a/plugin.library.node.editor/resources/language/English/strings.po +++ b/plugin.library.node.editor/resources/language/English/strings.po @@ -91,7 +91,7 @@ msgid "Browse for icon" msgstr "" msgctxt "#30104" -msgid "Edit order" +msgid "Move node" msgstr "" msgctxt "#30105" diff --git a/plugin.library.node.editor/resources/lib/moveNodes.py b/plugin.library.node.editor/resources/lib/moveNodes.py new file mode 100644 index 0000000..32b7aec --- /dev/null +++ b/plugin.library.node.editor/resources/lib/moveNodes.py @@ -0,0 +1,98 @@ +# coding=utf-8 +import sys +import xbmc, xbmcaddon, xbmcgui + +ADDON = xbmcaddon.Addon() +LANGUAGE = ADDON.getLocalizedString + +def getNewOrder( currentPositions, indexToMove ): + # Show select dialog + w = ShowDialog( "DialogSelect.xml", sys.modules[ "__main__" ].CWD, order=currentPositions, focus=indexToMove, windowtitle=LANGUAGE(30104) ) + w.doModal() + newOrder = w.newOrder + del w + + return newOrder + +class ShowDialog( xbmcgui.WindowXMLDialog ): + def __init__( self, *args, **kwargs ): + xbmcgui.WindowXMLDialog.__init__( self ) + self.order = kwargs.get( "order" ) + self.windowtitle = kwargs.get( "windowtitle" ) + self.selectedItem = kwargs.get( "focus" ) + self.newOrder = [] + + def onInit(self): + self.list = self.getControl(3) + + # Set visibility + self.getControl(3).setVisible(True) + self.getControl(3).setEnabled(True) + self.getControl(5).setVisible(False) + self.getControl(6).setVisible(False) + self.getControl(1).setLabel(self.windowtitle) + + # Set Cancel label + self.getControl(7).setLabel(xbmc.getLocalizedString(222)) + + # Add all the items to the list + for i, key in enumerate( sorted( self.order ) ): + # Get the label and localise if necessary + label = self.order[ key ][ 0 ] + if label.isdigit(): + label = xbmc.getLocalizedString( int( label ) ) + if label == "": + label = self.order[ key ][ 0 ] + if self.order[ key ][ 3 ] == "folder": + label = "%s >" %( label ) + + # Create the listitem and add it + listitem = xbmcgui.ListItem( label=label ) + self.list.addItem( listitem ) + + # And add it to the list that we'll eventually return + self.newOrder.append( self.order[ key ] ) + + # If it's the item we're moving, save it separately + if i == self.selectedItem: + self.itemMoving = self.order[ key ] + + # Set focus + self.list.selectItem(self.selectedItem) + self.setFocus(self.list) + + def onAction(self, action): + # Check if the selected item has changed + if self.list.getSelectedPosition() != self.selectedItem: + # Remove the item we're moving from the list of items + self.newOrder.pop( self.selectedItem ) + + # Add the item we're moving at its new location + self.newOrder.insert( self.list.getSelectedPosition(), self.itemMoving ) + + # Update its current current position + self.selectedItem = self.list.getSelectedPosition() + + # Update the labels of all list items + for i in range( len( self.newOrder ) ): + item = self.list.getListItem( i ) + label = self.newOrder[ i ][ 0 ] + if label.isdigit(): + label = xbmc.getLocalizedString( int( label ) ) + if label == "": + label = self.newOrder[ i ][ 0 ] + if self.newOrder[ i ][ 3 ] == "folder": + label = "%s >" %( label ) + if item.getLabel() != label: + item.setLabel( label ) + + if action.getId() in ( 9, 10, 92, 216, 247, 257, 275, 61467, 61448, ): + self.close() + return + + def onClick(self, controlID): + if controlID == 7: + # Cancel button + self.newOrder = None + + self.close() diff --git a/plugin.library.node.editor/resources/musicrules.xml b/plugin.library.node.editor/resources/musicrules.xml index 770ebf9..c2e42d7 100644 --- a/plugin.library.node.editor/resources/musicrules.xml +++ b/plugin.library.node.editor/resources/musicrules.xml @@ -151,12 +151,15 @@ </match> <match name="path"> <label>573</label> + <albums>True</albums> + <artists>True</artists> <songs>True</songs> <operator>string</operator> <browse>True</browse> </match> <match name="lastplayed"> <label>568</label> + <albums>True</albums> <songs>True</songs> <operator>date</operator> </match> |