[gedit/wip/bug-705906] [snippets] Fix completion popup
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/bug-705906] [snippets] Fix completion popup
- Date: Sat, 12 Apr 2014 16:45:21 +0000 (UTC)
commit ee158baae07dc872f03c834f09aed5d00402e0dc
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Sat Apr 12 14:51:25 2014 +0200
[snippets] Fix completion popup
https://bugzilla.gnome.org/show_bug.cgi?id=705906
plugins/snippets/snippets/completion.py | 2 +-
plugins/snippets/snippets/document.py | 28 ++++++++++++----------------
2 files changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/plugins/snippets/snippets/completion.py b/plugins/snippets/snippets/completion.py
index 3f8bf51..4427f21 100644
--- a/plugins/snippets/snippets/completion.py
+++ b/plugins/snippets/snippets/completion.py
@@ -182,6 +182,6 @@ class Defaults(GObject.Object, GtkSource.CompletionProvider):
context.add_proposals(self, self.proposals, True)
def do_get_activation(self):
- return GtkSource.CompletionActivation.NONE
+ return GtkSource.CompletionActivation.USER_REQUESTED
# ex:ts=4:et:
diff --git a/plugins/snippets/snippets/document.py b/plugins/snippets/snippets/document.py
index ab41ecc..f98d864 100644
--- a/plugins/snippets/snippets/document.py
+++ b/plugins/snippets/snippets/document.py
@@ -18,7 +18,7 @@
import os
import re
-from gi.repository import Gtk, Gdk, Gio, GLib, Gedit, GObject
+from gi.repository import Gtk, Gdk, Gio, GLib, Gedit, GObject, GtkSource
from .library import Library
from .snippet import Snippet
@@ -54,7 +54,6 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
self.timeout_update_id = 0
self.provider = completion.Provider(_('Snippets'), self.language_id, self.on_proposal_activated)
- self.defaults_provider = completion.Defaults(self.on_default_activated)
def do_activate(self):
# Always have a reference to the global snippets
@@ -71,11 +70,7 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
self.update_language()
completion = self.view.get_completion()
-
completion.add_provider(self.provider)
- completion.add_provider(self.defaults_provider)
-
- self.connect_signal(completion, 'hide', self.on_completion_hide)
SharedData().register_controller(self.view, self)
@@ -102,7 +97,6 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
if completion:
completion.remove_provider(self.provider)
- completion.remove_provider(self.defaults_provider)
if self.language_id != 0:
Library().unref(self.language_id)
@@ -148,9 +142,11 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
self.apply_snippet(snippets[0])
else:
# Do the fancy completion dialog
- self.provider.set_proposals(snippets)
+ provider = completion.Provider(_('Snippets'), self.language_id, self.on_proposal_activated)
+ provider.set_proposals(snippets)
+
cm = self.view.get_completion()
- cm.show([self.provider], cm.create_context(None))
+ cm.show([provider], cm.create_context(None))
return True
@@ -284,10 +280,11 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
if next.__class__ == PlaceholderEnd:
last = next
elif len(next.defaults) > 1 and next.get_text() == next.default:
- self.defaults_provider.set_defaults(next.defaults)
+ provider = completion.Defaults(self.on_default_activated)
+ provider.set_defaults(next.defaults)
cm = self.view.get_completion()
- cm.show([self.defaults_provider], cm.create_context(None))
+ cm.show([provider], cm.create_context(None))
if last:
# This is the end of the placeholder, remove the snippet etc
@@ -653,10 +650,12 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
return self.apply_snippet(snippets[0], bounds[0], bounds[1])
else:
# Do the fancy completion dialog
- self.provider.set_proposals(snippets)
+ provider = completion.Provider(_('Snippets'), self.language_id, self.on_proposal_activated)
+ provider.set_proposals(snippets)
+
cm = self.view.get_completion()
+ cm.show([provider], cm.create_context(None))
- cm.show([self.provider], cm.create_context(None))
return True
return False
@@ -922,9 +921,6 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
return self.view.drag_dest_find_target(context, lst)
- def on_completion_hide(self, completion):
- self.provider.set_proposals(None)
-
def on_proposal_activated(self, proposal, piter):
if not self.view.get_editable():
return False
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]