-
Notifications
You must be signed in to change notification settings - Fork 344
Expand file tree
/
Copy pathnemo_action_layout_editor.py
More file actions
84 lines (64 loc) · 2.37 KB
/
nemo_action_layout_editor.py
File metadata and controls
84 lines (64 loc) · 2.37 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python3
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Nemo', '3.0')
from gi.repository import Gtk, Gdk, GLib, Gio, Nemo
import subprocess
import gettext
import locale
import os
import leconfig
locale.bindtextdomain("nemo", leconfig.LOCALE_DIR)
gettext.bindtextdomain("nemo", leconfig.LOCALE_DIR)
gettext.textdomain("nemo")
_ = gettext.gettext
USER_ACTIONS_DIR = os.path.join(GLib.get_user_data_dir(), "nemo", "actions")
class EditorWindow():
def __init__(self):
self.main_window = Gtk.Window()
self.main_window.set_default_size(800, 600)
self.main_window.set_icon_name("nemo")
header = Gtk.HeaderBar()
header.set_show_close_button(True)
header.set_title(_("Nemo Actions Layout Editor"))
self.main_window.set_titlebar(header)
self.hamburger_button = Gtk.MenuButton(
image=Gtk.Image.new_from_icon_name("xsi-open-menu-symbolic", Gtk.IconSize.BUTTON)
)
header.pack_start(self.hamburger_button)
menu = Gtk.Menu()
item = Gtk.ImageMenuItem(
label=_("Open user actions folder"),
image=Gtk.Image(icon_name="xsi-folder-symbolic", icon_size=Gtk.IconSize.MENU)
)
item.connect("activate", self.open_actions_folder_clicked)
menu.add(item)
item = Gtk.SeparatorMenuItem()
menu.add(item)
item = Gtk.MenuItem(label=_("Quit"))
item.connect("activate", self.quit)
menu.add(item)
menu.show_all()
self.hamburger_button.set_popup(menu)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, border_width=8)
self.main_window.add(vbox)
self.editor = Nemo.ActionLayoutEditor.new()
vbox.pack_start(self.editor, True, True, 0)
self.main_window.connect("delete-event", self.window_delete)
self.main_window.show_all()
self.main_window.present_with_time(0)
def quit(self, button):
Gtk.main_quit()
return True
def window_delete(self, window, event, data=None):
Gtk.main_quit()
return False
def open_actions_folder_clicked(self, button):
# Create actions directory if it doesn't exist
os.makedirs(USER_ACTIONS_DIR, exist_ok=True)
subprocess.Popen(["xdg-open", USER_ACTIONS_DIR])
if __name__ == "__main__":
import sys
EditorWindow()
Gtk.main()
sys.exit(0)