Commit fc85d509 authored by Johan Dahlin's avatar Johan Dahlin Committed by Johan Dahlin

Add Menu wrapper which makes it possible to implement submenus. #440026,

2008-01-11  Johan Dahlin  <johan@gnome.org>

	* examples/Makefile.am:
	* src/nautilus-python.c: (nautilus_python_init_python):
	* src/nautilus-python.h:
	* src/nautilus.defs:
	* examples/submenu.py:
	Add Menu wrapper which makes it possible to implement submenus.
	#440026, Lukáš Lalinský, Sylvain Baubeau, Erik Wien


svn path=/trunk/; revision=52
parent af0775e8
2008-01-11 Johan Dahlin <johan@gnome.org>
* examples/Makefile.am:
* src/nautilus-python.c: (nautilus_python_init_python):
* src/nautilus-python.h:
* src/nautilus.defs:
* examples/submenu.py:
Add Menu wrapper which makes it possible to implement submenus.
#440026, Lukáš Lalinský, Sylvain Baubeau, Erik Wien
2008-01-11 Scott Tsai <scottt.tw@gmail.com>
reviewed by: Johan Dahlin
......
......@@ -8,7 +8,8 @@ examples_DATA = \
background-image.py \
block-size-column.py \
open-terminal.py \
md5sum-property-page.py
md5sum-property-page.py \
submenu.py
EXTRA_DIST += $(examples_DATA)
......
import nautilus
class ExampleMenuProvider(nautilus.MenuProvider):
def get_file_items(self, window, files):
menuitem = nautilus.MenuItem('ExampleMenuProvider::Foo', 'Foo', '')
submenu = nautilus.Menu()
menuitem.set_submenu(submenu)
menuitem = nautilus.MenuItem('ExampleMenuProvider::Bar', 'Bar', '')
submenu.append_item(menuitem)
return menuitem,
# FIXME: Why isn't this working?
def get_background_items(self, window, file):
submenu = nautilus.Menu()
submenu.append_item(nautilus.MenuItem('ExampleMenuProvider::Bar', 'Bar', ''))
menuitem = nautilus.MenuItem('ExampleMenuProvider::Foo', 'Foo', '')
menuitem.set_submenu(submenu)
return menuitem,
......@@ -303,6 +303,7 @@ nautilus_python_init_python (void)
IMPORT(Column, "Column");
IMPORT(ColumnProvider, "ColumnProvider");
IMPORT(InfoProvider, "InfoProvider");
IMPORT(Menu, "Menu");
IMPORT(MenuItem, "MenuItem");
IMPORT(MenuProvider, "MenuProvider");
IMPORT(PropertyPage, "PropertyPage");
......
......@@ -55,6 +55,9 @@ PyTypeObject *_PyNautilusColumnProvider_Type;
PyTypeObject *_PyNautilusInfoProvider_Type;
#define PyNautilusInfoProvider_Type (*_PyNautilusInfoProvider_Type)
PyTypeObject *_PyNautilusMenu_Type;
#define PyNautilusMenu_Type (*_PyNautilusMenu_Type)
PyTypeObject *_PyNautilusMenuItem_Type;
#define PyNautilusMenuItem_Type (*_PyNautilusMenuItem_Type)
......
......@@ -25,6 +25,13 @@
(gtype-id "NAUTILUS_TYPE_INFO_PROVIDER")
)
(define-object Menu
(in-module "Nautilus")
(parent "GObject")
(c-name "NautilusMenu")
(gtype-id "NAUTILUS_TYPE_MENU")
)
(define-object MenuItem
(in-module "Nautilus")
(parent "GObject")
......@@ -214,6 +221,35 @@
(return-type "GType")
)
(define-function nautilus_menu_new
(c-name "nautilus_menu_new")
(is-constructor-of "NautilusMenu")
(return-type "NautilusMenu*")
)
(define-method append_item
(of-object "NautilusMenu")
(c-name "nautilus_menu_append_item")
(return-type "none")
(parameters
'("NautilusMenuItem*" "item")
)
)
(define-method get_items
(of-object "NautilusMenu")
(c-name "nautilus_menu_get_items")
(return-type "GList*")
)
(define-function nautilus_menu_item_list_free
(c-name "nautilus_menu_item_list_free")
(return-type "none")
(parameters
'("GList*", "item_list")
)
)
(define-function nautilus_menu_item_new
(c-name "nautilus_menu_item_new")
(is-constructor-of "NautilusMenuItem")
......@@ -226,13 +262,21 @@
)
)
(define-method set_submenu
(of-object "NautilusMenuItem")
(c-name "nautilus_menu_item_set_submenu")
(return-type "none")
(parameters
'("NautilusMenu*" "menu")
)
)
(define-method activate
(of-object "NautilusMenuItem")
(c-name "nautilus_menu_item_activate")
(return-type "none")
)
;; From /usr/include/nautilus/libnautilus-extension/nautilus-property-page.h
(define-function nautilus_property_page_get_type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment