[gedit-plugins/gnome-3-22] plugins: fix popup item duplication
- From: Jeremy Bicha <jbicha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins/gnome-3-22] plugins: fix popup item duplication
- Date: Sun, 28 Jan 2018 22:30:58 +0000 (UTC)
commit cc9295fbe97f5a08c95f5df6b4332d7d4e77f99a
Author: asl97 <asl97 openmailbox org>
Date: Wed Mar 22 20:27:18 2017 +0800
plugins: fix popup item duplication
Disconnect the popup handler when it gets deactivated.
This fixes duplicate context menu items when the codecomment
or joinlines plugins are deactivated then reactivated.
https://bugzilla.gnome.org/show_bug.cgi?id=751345
plugins/codecomment/codecomment.py | 6 +++++-
plugins/joinlines/joinlines.py | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/plugins/codecomment/codecomment.py b/plugins/codecomment/codecomment.py
index f41b58a..4efd3fe 100644
--- a/plugins/codecomment/codecomment.py
+++ b/plugins/codecomment/codecomment.py
@@ -94,13 +94,17 @@ class CodeCommentViewActivatable(GObject.Object, Gedit.ViewActivatable):
view = GObject.Property(type=Gedit.View)
def __init__(self):
+ self.popup_handler_id = 0
GObject.Object.__init__(self)
def do_activate(self):
self.view.code_comment_view_activatable = self
- self.view.connect('populate-popup', self.populate_popup)
+ self.popup_handler_id = self.view.connect('populate-popup', self.populate_popup)
def do_deactivate(self):
+ if self.popup_handler_id != 0:
+ self.view.disconnect(self.popup_handler_id)
+ self.popup_handler_id = 0
delattr(self.view, "code_comment_view_activatable")
def populate_popup(self, view, popup):
diff --git a/plugins/joinlines/joinlines.py b/plugins/joinlines/joinlines.py
index e7bffd0..5548350 100644
--- a/plugins/joinlines/joinlines.py
+++ b/plugins/joinlines/joinlines.py
@@ -87,13 +87,17 @@ class JoinLinesViewActivatable(GObject.Object, Gedit.ViewActivatable):
view = GObject.Property(type=Gedit.View)
def __init__(self):
+ self.popup_handler_id = 0
GObject.Object.__init__(self)
def do_activate(self):
self.view.join_lines_view_activatable = self
- self.view.connect('populate-popup', self.populate_popup)
+ self.popup_handler_id = self.view.connect('populate-popup', self.populate_popup)
def do_deactivate(self):
+ if self.popup_handler_id != 0:
+ self.view.disconnect(self.popup_handler_id)
+ self.popup_handler_id = 0
delattr(self.view, "join_lines_view_activatable")
def populate_popup(self, view, popup):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]