-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
32 lines (20 loc) · 1.02 KB
/
app.py
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
from gi.repository import GObject, Gio, Gedit
class MdAppActivatable(GObject.Object, Gedit.AppActivatable):
app = GObject.property(type=Gedit.App)
def __init__(self):
GObject.Object.__init__(self)
def do_activate(self):
self.app.add_accelerator("<Primary><Shift>M", "win.markdown_preview", None)
self.app.add_accelerator("<Primary><Alt>M", "win.markdown_settings", None)
self.menu_extension = self.extend_menu("tools-section")
item = Gio.MenuItem.new(_("Markdown"), None)
menu = Gio.Menu.new()
sub1 = Gio.MenuItem.new(_("Preview File"), "win.markdown_preview")
sub2 = Gio.MenuItem.new(_("Settings"), "win.markdown_settings")
menu.append_item(sub1)
menu.append_item(sub2)
item.set_submenu(menu)
self.menu_extension.append_menu_item(item)
def do_deactivate(self):
self.app.remove_accelerator("win.markdown_preview", None)
self.menu_extension = None