[gedit-plugins/sessionsaver] Menu
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins/sessionsaver] Menu
- Date: Tue, 25 Jun 2019 07:27:56 +0000 (UTC)
commit 55f55ef40950fd2253a88e3adb0a176aabbeaa16
Author: Jordi Mas <jmas softcatala org>
Date: Mon Jun 24 20:47:35 2019 +0200
Menu
plugins/sessionsaver/sessionsaver/__init__.py | 28 +++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/plugins/sessionsaver/sessionsaver/__init__.py b/plugins/sessionsaver/sessionsaver/__init__.py
index b710846..a874211 100644
--- a/plugins/sessionsaver/sessionsaver/__init__.py
+++ b/plugins/sessionsaver/sessionsaver/__init__.py
@@ -47,13 +47,25 @@ class SessionSaverAppActivatable(GObject.Object, Gedit.AppActivatable):
item = Gio.MenuItem.new(_("_Manage saved sessions..."), "win.managedsession")
self.menu_ext.prepend_menu_item(item)
- item = Gio.MenuItem.new(_("_Save session"), "win.savesession")
+ item = Gio.MenuItem.new(_("_Save session..."), "win.savesession")
self.menu_ext.prepend_menu_item(item)
+ self._insert_session_menu()
+
def do_deactivate(self):
self.menu_ext = None
+ def _insert_session_menu(self):
+ print("_insert_session_menu\n")
+
+ self.sessions = XMLSessionStore()
+ for i, session in enumerate(self.sessions):
+ action_name = 'SessionSaver%X' % i
+ session_id = 'win.session_%u'.format(i)
+ item = Gio.MenuItem.new(_("Recover '%s' session") % session.name, session_id)
+ self.menu_ext.prepend_menu_item(item)
+
class SessionSaverWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Configurable):
@@ -73,8 +85,20 @@ class SessionSaverWindowActivatable(GObject.Object, Gedit.WindowActivatable, Pea
action = Gio.SimpleAction(name="savesession")
action.connect('activate', lambda a, p: self.on_save_session_action())
self.window.add_action(action)
+
+ self.sessions = XMLSessionStore()
+ for i, session in enumerate(self.sessions):
+ action_name = 'SessionSaver%X' % i
+ session_id = 'session_%u'.format(i)
+ action = Gio.SimpleAction(name=session_id)
+ action.connect('activate', self.capture_menu_action, self.window)
+ self.window.add_action(action)
+
+ def capture_menu_action(self, action, parameter, window):
+ print("capture_menu_action\n")
return
-
+
+
def do_deactivate(self):
return
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]