![]() |
![]() |
![]() |
![]() |
Thunarx.MenuProviderThunarx.MenuProvider — Thunarx.MenuProvider Reference |
Thunarx.MenuProvider {get_file_menu_items(window,
files);get_folder_menu_items(window,
folder);get_dnd_menu_items(window,
folder,
files);
}
Example 2. A Thunarx.MenuProvider plugin (without submenus)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from gi.repository import GObject, Gtk, Thunarx class ThunarxMenuProviderPlugin(GObject.GObject, Thunarx.MenuProvider): def __init__(self): pass def get_file_menu_items(self, window, files): item = Thunarx.MenuItem(name="TMP:TestFileAction", label="Python File Action", tooltip='', icon=Gtk.STOCK_FILE) item.connect("activate", self.__do_something, window) return [item] def get_folder_menu_items(self, window, folder): return [Thunarx.MenuItem(name="TMP:TestFolderAction", label="Python Folder Action", tooltip='', icon=Gtk.STOCK_OPEN)] def __do_something(self, item, window): print("Doing something") |
Example 3. A Thunarx.MenuProvider plugin (with submenus)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
from gi.repository import GObject, Gtk, Thunarx class ThunarxSubMenuProviderPlugin(GObject.GObject, Thunarx.MenuProvider): def __init__(self): pass def get_file_menu_items(self, window, files): item = Thunarx.MenuItem(name="TMP:Item1", label="Python File Action", tooltip='', icon=Gtk.STOCK_FILE) submenu = Thunarx.Menu() subitem1 = Thunarx.MenuItem(name='TMP::Subitem1', label='Subitem1', tooltip='First tip', icon=Gtk.STOCK_DND) subitem1.connect("activate", self.__subitem1_callback, window) submenu.append_item(subitem1) subitem2 = Thunarx.MenuItem(name='TMP::Subitem2', label='Subitem2', tooltip='Second tip', icon=Gtk.STOCK_FULLSCREEN) subitem2.connect("activate", self.__subitem2_callback, window) submenu.append_item(subitem2) item.set_menu(submenu) item2 = Thunarx.MenuItem(name='TMP::Item2', label='Another item', tooltip='', icon=Gtk.STOCK_OK) return item,item2 def __subitem1_callback(self, item, window): print("Subitem1 call") def __subitem2_callback(self, item, window): print("Subitem2 call") |
get_file_menu_items(window,
files);
|
the current Gtk.Window instance |
|
a list of Thunarx.FileInfo objects. |
Returns : |
a list of Thunarx.MenuItem objects |
The get_file_menu_items
() method returns a list of
Thunarx.MenuItem objects.
get_folder_menu_items(window,
folder);
|
the current Gtk.Window instance |
|
the current folder, as a Thunarx.FileInfo object. |
Returns : |
a list of Thunarx.MenuItem objects |
The get_folder_menu_items
() method returns a list of
Thunarx.MenuItem objects.
get_dnd_menu_items(window,
folder,
files);
|
the current Gtk.Window instance |
|
the current folder, as a Thunarx.FileInfo object. |
|
a list of the currently selected files, as a Thunarx.FileInfo objects. |
Returns : |
a list of Thunarx.MenuItem objects |
The get_dnd_menu_items
() method returns a list of
Thunarx.MenuItem objects.