In extension, context menu items are showing up in random order



hi all,

I'm working on the NautilusSvn python extension (http://code.google.com/p/nautilussvn) and have an issue with our context menus.

We set up our context menus by defining a list of items, each having a condition method.  When the get_file_items and get_background_items are called, we call a third method that constructs the menu and returns it to the first two methods.  The construction method works like this...

menu_definition = [
    {
        "identifier": "NautilusSvn::Commit",
        ....,
        "condition": self.condition_commit
    },
    ...
]

menu = []
for item in menu_definition:
    if item["condition"]():
       menu.append(item)
return menu

So if the condition method returns True, the menu item is added, if False it is not added.

This seems to work, except for one problem.  When the context menu is drawn, the menu items are sometimes in a seemingly random order.  So if our menu list is like this: ['Item 1', 'Item 2', 'Item 3'], it will show up in the context menu like so: ['Item 3', 'Item 2', 'Item 1'].  Just to see if we could narrow it down somewhat, we changed the line "if item["condition"]():" to "if True:".  When we did this, the menu items all showed up in the correct order.  I also tried printing out the menu list just prior to returning it, and it always shows the correct ordering.

It seems that there may be something going on with Nautilus or the nautilus-python extension that is causing this mis-ordering.  But I'm not sure.  I'm hoping there may be some gurus on this list that may be able to provide an insight or help.

Thanks!

Adam Plumb


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]