[gedit-latex] Use SnippetManager with the completion popups
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-latex] Use SnippetManager with the completion popups
- Date: Wed, 5 Oct 2011 12:50:30 +0000 (UTC)
commit 97e8acd395719e5006a8ae3a4dbabdd476231ab5
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Oct 5 14:50:06 2011 +0200
Use SnippetManager with the completion popups
latex/bibtex/completion.py | 11 +++++------
latex/editor.py | 3 ++-
latex/latex/completion.py | 15 +++++++--------
3 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/latex/bibtex/completion.py b/latex/bibtex/completion.py
index 2ddc448..150778a 100644
--- a/latex/bibtex/completion.py
+++ b/latex/bibtex/completion.py
@@ -28,7 +28,6 @@ from gi.repository import Gdk, GdkPixbuf
from ..preferences import Preferences
from ..resources import Resources
-from ..template import Template
from ..completion import ICompletionHandler, Proposal
from ..issues import MockIssueHandler
from model import BibTeXModel
@@ -55,16 +54,16 @@ class BibTeXEntryTypeProposal(Proposal):
def _generate(self):
"""
- Generate Template and details string
+ Generate snippet and details string
"""
- template = "@%s{${Identifier}" % self._type.name
+ snippet = "@%s{${Identifier}" % self._type.name
self._details = "@%s{<span color='%s'>Identifier</span>" % (self._type.name, self._color)
for field in self._type.required_fields:
- template += ",\n\t%s = {${%s}}" % (field.name, field.label)
+ snippet += ",\n\t%s = {${%s}}" % (field.name, field.label)
self._details += ",\n\t%s = {<span color='%s'>%s</span>}" % (field.name, self._color, field.label)
- template += "\n}"
+ snippet += "\n}"
self._details += "\n}"
- self._source = Template(template)
+ self._source = snippet
@property
def source(self):
diff --git a/latex/editor.py b/latex/editor.py
index 8594e5f..bf3607a 100644
--- a/latex/editor.py
+++ b/latex/editor.py
@@ -28,6 +28,7 @@ from gi.repository import GObject, Gtk, Gdk
from .completion import CompletionDistributor
from .templates import TemplateDelegate
from .template import Template
+from .snippetmanager import SnippetManager
LOG = logging.getLogger(__name__)
@@ -317,7 +318,7 @@ class Editor(object):
if type(source) is Template:
self._template_delegate.insert(source)
else:
- self._text_buffer.insert_at_cursor(str(source))
+ SnippetManager().insert_at_cursor(self, str(source))
# grab the focus again (necessary e.g. after symbol insert)
self._text_view.grab_focus()
diff --git a/latex/latex/completion.py b/latex/latex/completion.py
index e221f17..7eddd09 100644
--- a/latex/latex/completion.py
+++ b/latex/latex/completion.py
@@ -28,7 +28,6 @@ from logging import getLogger
from gi.repository import Gdk, GdkPixbuf
from ..resources import Resources
-from ..template import Template
from ..completion import ICompletionHandler, Proposal
@@ -37,15 +36,15 @@ class LaTeXCommandProposal(Proposal):
A proposal inserting a Template when activated
"""
- def __init__(self, overlap, template, label):
- self._template = template
+ def __init__(self, overlap, snippet, label):
+ self._snippet = snippet
self._label = label
self._overlap = overlap
self._icon = GdkPixbuf.Pixbuf.new_from_file(Resources().get_icon("i_command.png"))
@property
def source(self):
- return self._template
+ return self._snippet
@property
def label(self):
@@ -247,15 +246,15 @@ class PrefixModelParser(object):
for command in commands:
label = command.name
- templateSource = "\\" + command.name
+ snippet = "\\" + command.name
for argument in command.children:
if type(argument) is MandatoryArgument:
label += "{<span color='%s'>%s</span>}" % (self.__light_foreground, argument.label)
- templateSource += "{${%s}}" % argument.label
+ snippet += "{${%s}}" % argument.label
elif type(argument) is OptionalArgument:
label += "[<span color='%s'>%s</span>]" % (self.__light_foreground, argument.label)
- templateSource += "[${%s}]" % argument.label
+ snippet += "[${%s}]" % argument.label
if command.package:
label += " <small><b>%s</b></small>" % command.package
@@ -266,7 +265,7 @@ class PrefixModelParser(object):
packages = []
else:
packages = [command.package]
- proposal = LaTeXCommandProposal(overlap, LaTeXSource(Template(templateSource), packages), label)
+ proposal = LaTeXCommandProposal(overlap, LaTeXSource(snippet, packages), label)
proposals.append(proposal)
return proposals
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]