diff options
Diffstat (limited to 'examples/submenu.py')
-rw-r--r-- | examples/submenu.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/submenu.py b/examples/submenu.py new file mode 100644 index 0000000..7b91459 --- /dev/null +++ b/examples/submenu.py @@ -0,0 +1,29 @@ +import caja + +class ExampleMenuProvider(caja.MenuProvider): + + # Caja crashes if a plugin doesn't implement the __init__ method. + # See Bug #374958 + def __init__(self): + pass + + def get_file_items(self, window, files): + top_menuitem = caja.MenuItem('ExampleMenuProvider::Foo', 'Foo', '') + + submenu = caja.Menu() + top_menuitem.set_submenu(submenu) + + sub_menuitem = caja.MenuItem('ExampleMenuProvider::Bar', 'Bar', '') + submenu.append_item(sub_menuitem) + + return top_menuitem, + + def get_background_items(self, window, file): + submenu = caja.Menu() + submenu.append_item(caja.MenuItem('ExampleMenuProvider::Bar', 'Bar', '')) + + menuitem = caja.MenuItem('ExampleMenuProvider::Foo', 'Foo', '') + menuitem.set_submenu(submenu) + + return menuitem, + |