[gedit-plugins] codecomment: use de/activate to add/remove the actions



commit 799a1a3575aed727ffb055330e854101f33c9960
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Jan 11 13:43:35 2014 +0100

    codecomment: use de/activate to add/remove the actions

 plugins/codecomment/codecomment.py |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/plugins/codecomment/codecomment.py b/plugins/codecomment/codecomment.py
index 5974b35..aa589a2 100644
--- a/plugins/codecomment/codecomment.py
+++ b/plugins/codecomment/codecomment.py
@@ -60,10 +60,17 @@ class CodeCommentWindowActivatable(GObject.Object, Gedit.WindowActivatable):
         GObject.Object.__init__(self)
 
     def do_activate(self):
-        self._insert_menu()
+        action = Gio.SimpleAction(name="comment")
+        action.connect('activate', lambda a, p: self.do_comment())
+        self.window.add_action(action)
+
+        action = Gio.SimpleAction(name="uncomment")
+        action.connect('activate', lambda a, p: self.do_comment(True))
+        self.window.add_action(action)
 
     def do_deactivate(self):
-        self._remove_menu()
+        self.window.remove_action("comment")
+        self.window.remove_action("uncomment")
 
     def do_update_state(self):
         sensitive = False
@@ -74,19 +81,6 @@ class CodeCommentWindowActivatable(GObject.Object, Gedit.WindowActivatable):
         self.window.lookup_action('comment').set_enabled(sensitive)
         self.window.lookup_action('uncomment').set_enabled(sensitive)
 
-    def _remove_menu(self):
-        self.window.remove_action("comment")
-        self.window.remove_action("uncomment")
-
-    def _insert_menu(self):
-        action = Gio.SimpleAction(name="comment")
-        action.connect('activate', lambda a, p: self.do_comment())
-        self.window.add_action(action)
-
-        action = Gio.SimpleAction(name="uncomment")
-        action.connect('activate', lambda a, p: self.do_comment(True))
-        self.window.add_action(action)
-
     def do_comment(self, unindent=False):
         view = self.window.get_active_view()
         if view and view.code_comment_view_activatable:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]