Remove ContextMenuItems?

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
f3ar007 Offline
Member
Posts: 57
Joined: Apr 2009
Reputation: 0
Question  Remove ContextMenuItems? Post: #1
Hi,

Is it possible to remove context menu items such as 'Go to root' within a plugin?

f3ar007
find quote
rwparris2 Offline
Team-XBMC Python Developer
Posts: 1,341
Joined: Jan 2008
Reputation: 2
Location: US
Post: #2
yep checkout http://trac.xbmc.org/changeset/16314

addContextMenuItems(items, replaceItems = True)

Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
find quote
jingai Offline
Skilled Skinner
Posts: 888
Joined: Mar 2010
Reputation: 8
Post: #3
Sorry to dredge up such an old thread, but it seemed an appropriate place to ask this:

Is it possible to remove some, but not all, of the existing context menu items? And if not, is it possible to re-add a default item? Can I get at the built-in string for "Add-on Settings" button for instance so I can re-add it?

I could add my own string in strings.xml but I'd rather use the existing one if possible for consistency.

-j
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 24,570
Joined: Oct 2003
Reputation: 138
Post: #4
Nope - it's all or nothing.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
sphere Offline
Posting Freak
Posts: 808
Joined: Jul 2009
Reputation: 36
Location: Germany
Post: #5
jmarshall Wrote:Nope - it's all or nothing.

I also noticed that. Would a feature request (at least re-adding "Add to favourites") have a chance?

regards,
sphere
find quote
jingai Offline
Skilled Skinner
Posts: 888
Joined: Mar 2010
Reputation: 8
Post: #6
sphere Wrote:I also noticed that. Would a feature request (at least re-adding "Add to favourites") have a chance?

Curious about that myself. I basically have a ticket out for this here, but it could probably be worded in a more generic fashion.

FWIW, I achieved what I wanted in my own plugin like so:

Code:
commands.append((xbmc.getLocalizedString(1045), "XBMC.RunPlugin(\""+BASE_URL+"?action=settings\")",))

String 1045 is "Add-on settings" and in my action handler for "settings" it calls xbmcplugin.openSettings(). This works, but it'd be nice to be able to add it back using the default handler and without hardcoding the string ID.

The thing is, a great majority of the default context menu items really don't apply to most addons. The all-or-nothing approach means most of us are probably going to go for "nothing," and that has the potential to ruin UI consistency between plugins and between the plugin and XBMC itself.

-j
(This post was last modified: 2012-02-17 16:07 by jingai.)
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 24,570
Joined: Oct 2003
Reputation: 138
Post: #7
Agreed that it's not ideal - basically the design of this was never considered in any detail - it was popped in as-is without too much thought to satisfy a particular use case back in the days when we were more carefree about what and how we exposed stuff to python. Smile

Currently how the context menu works is before it's shown we run through and add buttons if they make sense according to the internal rules. I propose we change this so that instead what happens is each view has it's default buttons, and then a routine runs which filters out the ones that don't make sense (and possible adds in some extras). This could then be done by the plugin if the plugin wishes to do so.

XBMC then displays the menu. If it's a plugin-specific action, it calls back into the plugin to do it's thing (as is done already).

We "just" have to determine a suitable manner to do this (we probably need a nicer way to pass stuff from XBMC to the plugin - using a single string URL is really nasty).

Cheers,
Jonathan

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
jingai Offline
Skilled Skinner
Posts: 888
Joined: Mar 2010
Reputation: 8
Post: #8
jmarshall Wrote:Agreed that it's not ideal - basically the design of this was never considered in any detail - it was popped in as-is without too much thought to satisfy a particular use case back in the days when we were more carefree about what and how we exposed stuff to python. Smile

Certainly not trying to complain too much. UI consistency is, IMHO, a big thing though. Addons have gained so much in popularity that anything we can do to make them feel like an integral part of XBMC is a good thing.

jmarshall Wrote:Currently how the context menu works is before it's shown we run through and add buttons if they make sense according to the internal rules. I propose we change this so that instead what happens is each view has it's default buttons, and then a routine runs which filters out the ones that don't make sense (and possible adds in some extras). This could then be done by the plugin if the plugin wishes to do so.

We "just" have to determine a suitable manner to do this (we probably need a nicer way to pass stuff from XBMC to the plugin - using a single string URL is really nasty).

Calling back to the plugin with a single-string URL is a bit ugly, but it's not a show-stopper at the moment I don't think.

I'm not entirely sure how the filter should work, though. I suppose it could be as simple as a bit mask with some constants defined (e.g., CONTEXT_MENU_SLIDESHOW)? Seems like the easy way to do it anyway, but you know more about the internals than I do Smile

-j
find quote
jingai Offline
Skilled Skinner
Posts: 888
Joined: Mar 2010
Reputation: 8
Post: #9
How can I currently recreate the "Picture information" (string id 13406) and "Start slideshow here" (string id 13422) context menu items from within my plugin?

-j
find quote
jingai Offline
Skilled Skinner
Posts: 888
Joined: Mar 2010
Reputation: 8
Post: #10
I managed to somewhat recreate the "Start slideshow from here" context menu item with:

Code:
commands.append((xbmc.getLocalizedString(13422), "XBMC.SendClick(6)",))

That works, but doesn't start it from "here;" instead, it starts it from the first image in the current list.

As for "Picture information," I'm still clueless how to get at this via an add-on.

Is there a way to access or reproduce these two functions from within an add-on?

-j
find quote