Skip to content

Commit

Permalink
Remove: hook_attach_context_menu
Browse files Browse the repository at this point in the history
Each node is responsible for his own menu, base class can be called to
attach default item
  • Loading branch information
showi committed Dec 30, 2012
1 parent c70e59e commit 7438046
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .pydevproject
Expand Up @@ -3,8 +3,8 @@


<pydev_project> <pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/plugin.audio.qobuzgithub</path> <path>/plugin.audio.qobuz</path>
<path>/plugin.audio.qobuzgithub/resources/lib/qobuz</path> <path>/plugin.audio.qobuz/resources/lib/qobuz</path>
</pydev_pathproperty> </pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
Expand Down
5 changes: 4 additions & 1 deletion resources/lib/qobuz/node/friend.py
Expand Up @@ -136,10 +136,13 @@ def _build_down(self, xbmc_directory, lvl, flag = None):
self.add_child(node) self.add_child(node)
return True return True


def hook_attach_context_menu(self, item, menuItems): def attach_context_menu(self, item, menuItems = []):
colorItem = qobuz.addon.getSetting('color_item') colorItem = qobuz.addon.getSetting('color_item')
colorWarn = qobuz.addon.getSetting('color_item_caution') colorWarn = qobuz.addon.getSetting('color_item_caution')


''' Delete friend''' ''' Delete friend'''
url = self.make_url(mode=Mode.FRIEND_REMOVE) url = self.make_url(mode=Mode.FRIEND_REMOVE)
menuItems.append((color(colorItem, 'Remove friend (i8n)' + ': ') + self.name, "XBMC.RunPlugin("+url+")")) menuItems.append((color(colorItem, 'Remove friend (i8n)' + ': ') + self.name, "XBMC.RunPlugin("+url+")"))

''' Calling base class '''
super(Node_friend, self).attach_context_menu(item, menuItems)
5 changes: 4 additions & 1 deletion resources/lib/qobuz/node/friend_list.py
Expand Up @@ -69,11 +69,14 @@ def _build_down(self, xbmc_directory, lvl, flag = None):
node.set_name(str(name)) node.set_name(str(name))
self.add_child(node) self.add_child(node)


def hook_attach_context_menu(self, item, menuItems): def attach_context_menu(self, item, menuItems = []):
colorItem = qobuz.addon.getSetting('color_item') colorItem = qobuz.addon.getSetting('color_item')
color_warn = qobuz.addon.getSetting('color_item_caution') color_warn = qobuz.addon.getSetting('color_item_caution')
label = self.get_label() label = self.get_label()


''' SET AS CURRENT ''' ''' SET AS CURRENT '''
url = self.make_url(mode=Mode.FRIEND_ADD) url = self.make_url(mode=Mode.FRIEND_ADD)
menuItems.append((color(colorItem, 'Add friend (i8n)' + ': ') + label, "XBMC.RunPlugin("+url+")")) menuItems.append((color(colorItem, 'Add friend (i8n)' + ': ') + label, "XBMC.RunPlugin("+url+")"))

''' Calling base class '''
super(Node_friend_list, self).attach_context_menu(item, menuItems)
16 changes: 4 additions & 12 deletions resources/lib/qobuz/node/node.py
Expand Up @@ -311,14 +311,13 @@ def build_down(self,xbmc_directory,lvl=1,whiteFlag=NodeFlag.TYPE_NODE):
def _build_down(self,xbmc_directory,lvl,flag): def _build_down(self,xbmc_directory,lvl,flag):
pass pass


def attach_context_menu(self,item): def attach_context_menu(self, item, menuItems = []):
colorItem = qobuz.addon.getSetting('color_item') colorItem = qobuz.addon.getSetting('color_item')
menuItems = []
cmd = '' cmd = ''


''' ADD AS NEW ''' ''' TEST'''
cmd = "XBMC.Container.Update(%s)" % (self.make_url(mode=Mode.TEST)) # cmd = "XBMC.Container.Update(%s)" % (self.make_url(mode=Mode.TEST))
menuItems.append((color(colorItem,"TEST WINDOW"),cmd)) # menuItems.append((color(colorItem,"TEST WINDOW"),cmd))


''' VIEW BIG DIR ''' ''' VIEW BIG DIR '''
path = self.make_url(mode=Mode.VIEW_BIG_DIR) path = self.make_url(mode=Mode.VIEW_BIG_DIR)
Expand Down Expand Up @@ -365,10 +364,6 @@ def attach_context_menu(self,item):
''' CREATE ''' ''' CREATE '''
cmd = xbmcRunPlugin(self.make_url(mode=Mode.PLAYLIST_CREATE)) cmd = xbmcRunPlugin(self.make_url(mode=Mode.PLAYLIST_CREATE))
menuItems.append((color(colorItem,lang(39008)), cmd)) menuItems.append((color(colorItem,lang(39008)), cmd))
'''
Give a chance to our siblings to attach their items
'''
self.hook_attach_context_menu(item,menuItems)


''' SCAN ''' ''' SCAN '''
if qobuz.addon.getSetting('enable_scan_feature') == 'true': if qobuz.addon.getSetting('enable_scan_feature') == 'true':
Expand All @@ -389,6 +384,3 @@ def attach_context_menu(self,item):


if len(menuItems) > 0: if len(menuItems) > 0:
item.addContextMenuItems(menuItems,replaceItems=False) item.addContextMenuItems(menuItems,replaceItems=False)

def hook_attach_context_menu(self,item,menuItems):
pass
6 changes: 4 additions & 2 deletions resources/lib/qobuz/node/playlist.py
Expand Up @@ -126,7 +126,7 @@ def make_XbmcListItem(self):
self.attach_context_menu(item) self.attach_context_menu(item)
return item return item


def hook_attach_context_menu(self, item, menuItems): def attach_context_menu(self, item, menuItems = []):
colorItem = qobuz.addon.getSetting('color_item') colorItem = qobuz.addon.getSetting('color_item')
colorWarn = qobuz.addon.getSetting('color_item_caution') colorWarn = qobuz.addon.getSetting('color_item_caution')
label = self.get_label() label = self.get_label()
Expand All @@ -150,7 +150,9 @@ def hook_attach_context_menu(self, item, menuItems):
''' REMOVE ''' ''' REMOVE '''
url = self.make_url(mode=Mode.PLAYLIST_REMOVE) url = self.make_url(mode=Mode.PLAYLIST_REMOVE)
menuItems.append((color(colorWarn, lang(39010) + ': ') + label, "XBMC.RunPlugin("+url+")")) menuItems.append((color(colorWarn, lang(39010) + ': ') + label, "XBMC.RunPlugin("+url+")"))


''' Calling base class '''
super(Node_playlist, self).attach_context_menu(item, menuItems)


def remove_tracks(self, tracks_id): def remove_tracks(self, tracks_id):
import qobuz, xbmc import qobuz, xbmc
Expand Down
5 changes: 4 additions & 1 deletion resources/lib/qobuz/node/track.py
Expand Up @@ -261,7 +261,7 @@ def make_XbmcListItem(self):
self.attach_context_menu(item) self.attach_context_menu(item)
return item return item


def hook_attach_context_menu(self, item, menuItems): def attach_context_menu(self, item, menuItems = []):
colorItem = qobuz.addon.getSetting('color_item') colorItem = qobuz.addon.getSetting('color_item')
if self.parent and self.parent.type & NodeFlag.TYPE_PLAYLIST: if self.parent and self.parent.type & NodeFlag.TYPE_PLAYLIST:
url = self.parent.make_url(mode=Mode.PLAYLIST_REMOVE_TRACK) + '&track-id=' + str(self.get_property('playlist_track_id')) url = self.parent.make_url(mode=Mode.PLAYLIST_REMOVE_TRACK) + '&track-id=' + str(self.get_property('playlist_track_id'))
Expand All @@ -271,3 +271,6 @@ def hook_attach_context_menu(self, item, menuItems):
''' REMOVE ''' ''' REMOVE '''
url = self.make_url(mode=Mode.FAVORITE_DELETE) url = self.make_url(mode=Mode.FAVORITE_DELETE)
menuItems.append((color(colorItem, 'Remove from favorite') + self.label, "XBMC.RunPlugin("+url+")")) menuItems.append((color(colorItem, 'Remove from favorite') + self.label, "XBMC.RunPlugin("+url+")"))

''' Calling base class '''
super(Node_track, self).attach_context_menu(item, menuItems)

0 comments on commit 7438046

Please sign in to comment.