-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnautilus-code.py.in
33 lines (23 loc) · 1.01 KB
/
nautilus-code.py.in
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
import gettext
def _setup_gettext():
gettext.bindtextdomain('nautilus-code', '@localedir@')
gettext.textdomain('nautilus-code')
_setup_gettext()
from gi.repository import Nautilus, GObject
from NautilusCode.program_list import progs
class Extension (GObject.Object, Nautilus.MenuProvider):
def _get_items (self, folder, *, id_prefix='', is_file=False):
_setup_gettext()
folder_path = folder.get_location().get_path()
return progs.get_menu_items(folder_path, id_prefix=id_prefix, is_file=is_file)
def get_background_items (self, *args):
current_folder = args[-1]
return self._get_items(current_folder)
def get_file_items (self, *args):
selected_files = args[-1]
if len(selected_files) != 1:
return
if selected_files[0].is_directory():
return self._get_items(selected_files[0], id_prefix='selected.')
else:
return self._get_items(selected_files[0], id_prefix='selected.', is_file=True)