Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Garcia <cristian99garcia@gmail.com>2013-05-13 22:24:46 (GMT)
committer Cristian Garcia <cristian99garcia@gmail.com>2013-05-13 22:24:46 (GMT)
commit556d98b2520b25c3afbc34599e4d235c87800e8a (patch)
treeef5d9c338a40911e381f0b2995d62e272cd821e2
parent4b859ed3f61657a6eba7cadfa20a9c3173741e09 (diff)
Agregando auto-completado
-rw-r--r--WorkPanel.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/WorkPanel.py b/WorkPanel.py
index 8d6331e..e0b6e27 100644
--- a/WorkPanel.py
+++ b/WorkPanel.py
@@ -167,6 +167,9 @@ class SourceView(GtkSource.View):
self.set_buffer(self.buffer)
+ completion = self.get_completion()
+ completion.add_provider(AutoCompletado(self.buffer))
+
self.show_all()
def set_archivo(self, archivo):
@@ -234,3 +237,56 @@ class SourceView(GtkSource.View):
"""
self.buffer.set_text(texto)
+
+class AutoCompletado(GObject.Object, GtkSource.CompletionProvider):
+ __gtype_name__ = 'AutoCompletado'
+
+ def __init__(self, buffer):
+ GObject.Object.__init__(self)
+
+ self.modulo = None
+
+ self.priority = 1
+ self.buffer = buffer
+
+ def do_get_name(self):
+ return "Nombre del módulo"
+
+ def do_populate(self, context):
+ inicio = self.buffer.get_start_iter()
+ fin = self.buffer.get_iter_at_mark(self.buffer.get_insert())
+ texto = self.buffer.get_text(inicio, fin, True)
+
+ self.modulo = None
+
+ Tema = Gtk.IconTheme.get_default()
+ Icono = Tema.load_icon(Gtk.STOCK_DIALOG_INFO, 16, 0)
+
+ if texto and texto[-1] == '.':
+
+ if ' ' in texto:
+ palabras = texto.split(' ')
+ modulo = palabras[-1].replace('.', '')
+
+ else:
+ modulo = texto.replace('.', '')
+
+ try:
+ mod = __import__("gi.repository.%s" % modulo)
+ self.modulo = mod.importer.modules.get(modulo)
+
+ except:
+ try:
+ if modulo != 'gtk' and modulo != 'gobject':
+ self.modulo = __import__(modulo)
+
+ except:
+ pass
+
+ self.resultados = []
+
+ if self.modulo:
+ for Resultado in dir(self.modulo):
+ self.resultados.append(GtkSource.CompletionItem.new(Resultado, Resultado, Icono, "Descripción - PygiHack"))
+
+ context.add_proposals(self, self.resultados, True)