Permalink
Browse files

integrated with GTKSourceCompletion

  • Loading branch information...
1 parent d4eb5e0 commit 4b9d02ca4c264b869ed4e4c2f9f3286e0295108c @nagaozen committed Jan 20, 2011
@@ -2,9 +2,8 @@
Loader=python
Module=autocomplete
IAge=2
-Name=AutoComplete-0.10.1
-Icon=gtk-clear
-Description=Suggests word completions
-Authors=Fabio Zendhi Nagao <nagaozen@hotmail.com>\nhttp://zend.lojcomm.com.br/\nVincent Petithory <vincent.petithory@gmail.com>\nhttp://blog.lunar-dev.net/
-Copyright=Copyright © 2009 Fabio Zendhi Nagao, Vincent Petithory\nCopyright © 2006 Alin Avasilcutei, Osmo Salomaa
+Name=AutoComplete (gedit-json-completion)
+Description=Suggests word completions based on a json library.
+Authors=Fabio Zendhi Nagao <nagaozen@hotmail.com>\nhttp://zend.lojcomm.com.br/
+Copyright=Copyright © 2011 Fabio Zendhi Nagao
Website=http://github.com/nagaozen/gedit-plugin-autocomplete/
View
@@ -1,6 +1,7 @@
-# gEdit AutoComplete
-# Copyright (C) 2009 Fabio Zendhi Nagao, Vincent Petithory
-# Copyright (C) 2006 Alin Avasilcutei, Osmo Salomaa
+# -*- coding: utf-8 -*-
+
+# gEdit AutoComplete (gedit-json-completion)
+# Copyright (C) 2011 Fabio Zendhi Nagao
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,30 +17,65 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import gedit
+import jsonprovider
-from plugin import AutoComplete
-from config import ConfigurationDialog
+class JSONCompletionWindowHelper:
+ def __init__(self, plugin, window):
+ self._window = window
+ self._plugin = plugin
+
+ self._provider = jsonprovider.JSONProvider(plugin)
+
+ # Add the provider to all the views
+ for view in self._window.get_views():
+ self.add_view(view)
+
+ self._tab_added_id = self._window.connect('tab-added', self.on_tab_added)
+ self._tab_removed_id = self._window.connect('tab-removed', self.on_tab_removed)
+
+ def deactivate(self):
+ # Remove the provider from all the views
+ for view in self._window.get_views():
+ view.get_completion().completion.remove_provider(self._provider)
+
+ self._window.disconnect(self._tab_added_id)
+ self._window.disconnect(self._tab_removed_id)
+
+ self._window = None
+ self._plugin = None
+
+ def update_ui(self):
+ pass
+
+ def add_view(self, view):
+ view.get_completion().add_provider(self._provider)
+
+ def remove_view(self, view):
+ view.get_completion().remove_provider(self._provider)
+
+ def on_tab_added(self, window, tab):
+ # Add provider to the new view
+ self.add_view(tab.get_view())
+
+ def on_tab_removed(self, window, tab):
+ # Remove provider from the view
+ self.remove_view(tab.get_view())
-class AutoCompletePlugin(gedit.Plugin):
+class JSONCompletionPlugin(gedit.Plugin):
+ WINDOW_DATA_KEY = "JSONCompletionPluginWindowData"
def __init__(self):
gedit.Plugin.__init__(self)
- self._instances = {}
def activate(self, window):
- self._instances[window] = AutoComplete(self, window)
+ helper = JSONCompletionWindowHelper(self, window)
+ window.set_data(self.WINDOW_DATA_KEY, helper)
def deactivate(self, window):
- self._instances[window].deactivate()
- del self._instances[window]
+ window.get_data(self.WINDOW_DATA_KEY).deactivate()
+ window.set_data(self.WINDOW_DATA_KEY, None)
def update_ui(self, window):
- self._instances[window].update_ui()
-
- def is_configurable(self):
- return True
-
- def create_configure_dialog(self):
- dialog = ConfigurationDialog(self)
- return dialog
-
+ window.get_data(self.WINDOW_DATA_KEY).update_ui()
+
+# ex:ts=4:et:
View
@@ -1,101 +0,0 @@
-# gEdit AutoComplete
-# Copyright (C) 2009 Fabio Zendhi Nagao, Vincent Petithory
-# Copyright (C) 2006 Alin Avasilcutei, Osmo Salomaa
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-from settings import SettingsModel
-
-class ConfigurationDialog(gtk.Dialog):
-
- def __init__(self, caller):
- self._plugin = caller
- self._model = SettingsModel(self)
- self._model.load()
-
- self.current_source = ""
-
- gtk.Dialog.__init__(self, "AutoComplete settings", None, gtk.DIALOG_DESTROY_WITH_PARENT)
- self.set_resizable(False)
-
- # Definitions
- source_label = gtk.Label("<b>Completion source:</b>")
- source_label.set_use_markup(True)
- source_label.set_justify(gtk.JUSTIFY_LEFT)
-
- self.mixed_radio = gtk.RadioButton(None, "Mixed")
- self.all_documents_radio = gtk.RadioButton(self.mixed_radio, "All documents")
- self.library_radio = gtk.RadioButton(self.mixed_radio, "Library")
-
- if self._model.get_source() == "ALL_DOCUMENTS":
- self.all_documents_radio.set_active(True)
- if self._model.get_source() == "LIBRARY":
- self.library_radio.set_active(True)
-
- self.mixed_radio.connect("toggled", self.source_change, "MIXED")
- self.all_documents_radio.connect("toggled", self.source_change, "ALL_DOCUMENTS")
- self.library_radio.connect("toggled", self.source_change, "LIBRARY")
-
- # Positioning
- option_a_box = gtk.HBox()
- option_b_box = gtk.HBox()
- option_c_box = gtk.HBox()
-
- option_a_box.pack_start(self.mixed_radio, False, False, 0)
- option_b_box.pack_start(self.all_documents_radio, False, False, 0)
- option_c_box.pack_start(self.library_radio, False, False, 0)
-
- self.vbox.pack_start(source_label, True, True, 10)
- self.vbox.pack_start(option_a_box, True, True, 0)
- self.vbox.pack_start(option_b_box, True, True, 0)
- self.vbox.pack_start(option_c_box, True, True, 0)
-
- # Buttons
- close_button = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
- close_button.grab_default()
- close_button.connect_object("clicked", gtk.Widget.destroy, self)
-
- help_button = self.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP)
- help_button.connect_object("clicked", self.show_help_dialog, None)
-
- # Display
- self.vbox.show_all()
- self.show()
-
- def source_change(self, widget, data=None):
- if widget.get_active():
- self._model.set_source(data)
- self._model.save()
-
- def show_help_dialog(self, gobject):
- dialog = gtk.Dialog("AutoComplete help")
-
- close_button = dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
- close_button.grab_default()
- close_button.connect_object("clicked", gtk.Widget.destroy, dialog)
-
- hbox = gtk.HBox(False, 0)
- hbox.set_border_width(40)
-
- label = gtk.Label("Help still isn't available yet...")
-
- hbox.pack_start(label, True, True, 0)
-
- dialog.vbox.pack_start(hbox, True, True, 0)
- dialog.show_all()
-
View
@@ -4,6 +4,7 @@
"identificators": [
"(?P<instance>[a-zA-Z0-9_]+)\\s*=\\s*Server.createObject\\(\\\"(?P<class>[a-zA-Z0-9_.]+)\\\"\\)",
"(?P<instance>[a-zA-Z0-9_]+)\\s*=\\s*new ActiveXObject\\(\\\"(?P<class>[a-zA-Z0-9_.]+)\\\"\\)",
+ "(?P<instance>[a-zA-Z0-9_]+)\\s*=\\s*new (?P<class>[a-zA-Z0-9_.]+)",
"(?P<instance>[a-zA-Z0-9_]+)\\s*=\\s*[a-zA-Z0-9_]+\\.(?P<class>getDrive)\\(",
"(?P<instance>[a-zA-Z0-9_]+)\\s*=\\s*[a-zA-Z0-9_]+\\.(?P<class>getFile)\\(",
"(?P<instance>[a-zA-Z0-9_]+)\\s*=\\s*[a-zA-Z0-9_]+\\.(?P<class>getFolder)\\(",
@@ -19,11 +20,57 @@
"ADODB.Record": "activeConnection Fields[] mode parentURL Properties[] recordType source state cancel() close() copyRecord([source,destination,userName,password,options,async]) deleteRecord([source,async]) getChildren() moveRecord([source,destination,userName,password,options,async]) open([source,activeConnection,mode,createOptions,options,userName,password])",
"ADODB.Recordset": "absolutePage absolutePosition activeCommand activeConnection bof eof bookmark cacheSize cursorLocation cursorType dataMember dataSource editMode Fields[] filter index lockType marshalOptions maxRecords pageCount pageSize Properties[] recordCount sort source state status stayInSync addNew([fieldList,values]) cancel() cancelBatch([affectedRecords]) cancelUpdate() clone([lockType]) close() compareBookmarks(bookmark1,bookmark2) delete([affectedRecords]) find(criteria[,skipRows,searchDirection,start]) getRows([rows,start,field]) getString(stringFormat[,numRows,columnDelimiter,rowDelimiter,nullExpr]) move(numRecords[,start]) moveFirst() moveLast() moveNext() movePrevious() nextRecordset([recordsAffected]) open([source,activeConnection,cursorType,lockType,options]) requery([options]) reSync([affectedRecords,reSyncValues]) save([destination,persistFormat]) seek(keyValues,seekOption) supports(cursorOptions) update([affectedRecords,preserveStatus]) updateBatch([fields,values])",
"ADODB.Stream": "charset eos lineSeparator mode position size state type cancel() close() copyTo(destStream[,numchars]) flush() loadFromFile(fileName) open([source,mode,openOptions,userName,password]) read([numbytes]) readText([numchars]) saveToFile(fileName[,saveOptions]) setEOS() skipLine() stat(statStg,statFlag) write(buffer) writeText(data[,options])",
+ "Scripting.Dictionary": "compareMode count item(key) key(key) add(key,value) exists(key) items() keys() remove(key) removeAll()",
"Scripting.FileSystemObject": "Drives[] buildPath(path,name) copyFile(source,destination[,overwrite]) copyFolder(source,destination[,overwrite]) createFolder(folderName) createTextFile(fileName[,overwrite,unicode]) deleteFile(fileSpec[,force]) deleteFolder(folderSpec[,force]) driveExists(driveSpec) fileExists(fileSpec) folderExists(folderSpec) getAbsolutePathName(pathSpec) getBaseName(path) getDrive(driveSpec) getDriveName(path) getExtensionName(path) getFile(fileSpec) getFileName(pathSpec) getFileVersion(pathSpec) getFolder(folderSpec) getParentFolderName(path) getSpecialFolder(folderSpec) getStandardStream(standardStreamType[,unicode]) getTempName() moveFile(source,destination) moveFolder(source,destination) openTextFile(fileName[,ioMode,create,format])",
"getDrive": "availableSpace driveLetter driveType fileSystem freeSpace isReady path rootFolder serialNumber shareName totalSize volumeName",
"getFile": "attributes dateCreated dateLastAccessed dateLastModified drive name parentFolder path shortName shortPath size type copy(destination[,overwrite]) delete([force]) move(destination) openAsTextStream([ioMode,format])",
"getFolder": "attributes dateCreated dateLastAccessed dateLastModified drive Files[] isRootFolder name parentFolder path shortName shortPath size SubFolders[] type copy(destination[,overwrite]) delete([force]) move(destination) createTextFile(fileName[,overwrite,unicode])",
- "createTextFile": "atEndOfLine atEndOfStream column line close() read(characters) readAll() readLine() skip(characters) skipLine() write(string) writeBlankLines(lines) writeLine([string])"
+ "createTextFile": "atEndOfLine atEndOfStream column line close() read(characters) readAll() readLine() skip(characters) skipLine() write(string) writeBlankLines(lines) writeLine([string])",
+ "CustomEvent": "classType classVersion Owner Arguments addHandler(fn) removeHandler(fn) fire() revealArguments()",
+ "Interface": "classType classVersion Implementation requireds check()",
+ "Kernel": "classType classVersion initialize() process() computeView() dispatch() cacheIndex(sController,sAction) loadShuttle(Sd) unloadShuttle() fileExists(sFilePath) loadTextFile(sFilePath) createFile(sFilePath,sContent) createLink(sController,sAction) str2xml(sXml) getXmlNodeValues(Xml,sXPath) strictTransform(Xml,Xslt) indentedTransform(Xml,Xslt,sOutput,sIndent) printerFriendlyCode(sCode) exception(message)",
+ "Json": "classType classVersion loadJson(sJson) getElement(sPath) setElement(sPath,value) removeElement(sPath) getChildNodes(sPath) serialize(path)",
+ "Markdown": "classType classVersion makeHtml(text)",
+ "Textile": "classType classVersion makeHtml(text)",
+ "MD5": "classType classVersion encryptData(sMessage)",
+ "Rijndael": "classType classVersion encryptData(bytMessage,bytPassword) decryptData(bytIn,bytPassword) string2bytes(string) bytes2string(bytes) bytes2hex(bytes) hex2bytes(hex)",
+ "SHA256": "classType classVersion encryptData(sMessage)",
+ "Akismet": "classType classVersion wpApiKey blog comment initialize(key,uri) setPermalink(value) setCommentType(value) setCommentAuthor(value) setCommentAuthorEmail(value) setCommentAuthorUrl(value) setCommentContent(value) isSpam() submitSpam() submitHam()",
+ "ReCaptcha": "classType classVersion domainName uriVerify publicKey privateKey theme lang status insert() verify(sChallenge,sResponse)",
+ "UnitTest": "classType classVersion container Properties assert(fn,argv,expected) test(fn,argv,expected)",
+ "Acl_Interface": "Parent Implementation(I) Implementation requireds check() classType classVersion load() save(content)",
+ "Acl_Media_Json": "Interface classType classVersion path encoding load() save(content)",
+ "Acl": "classType classVersion Media addRole(id,parent) remRole(id) addResource(id,parent) remResource(id) assign(id,roles) unassign(id,roles) allow(role,resource,privilege,assert) remAllow(role,resource,privilege) deny(role,resource,privilege,assert) remDeny(role,resource,privilege) isAllowed(user,resource,privilege) load() save()",
+ "Auth_Adapter_MSSQL": "Interface classType classVersion connectionString authenticate(usr,pwd)",
+ "Auth_Interface": "Parent Implementation(I) Implementation requireds check() classType classVersion authenticate(usr,pwd)",
+ "Auth": "classType classVersion Adapter authenticate(usr,pwd)",
+ "Base64": "classType classVersion getBinary(path) encode(bin) decode(base64) encodedSize(base64) decodedSize(bin)",
+ "Color": "classType classVersion invert(red,green,blue) mix(base,colors,percentage) rgb2hex(red,green,blue) hex2rgb(sharp) rgb2hsb(red,green,blue) hsb2rgb(hue,saturation,brightness) hex2hsb(sharp) hsb2hex(hue,saturation,brightness)",
+ "Email_Adapter_CDO": "Interface classType classVersion send(Email)",
+ "Email_Interface": "Parent Implementation(I) Implementation requireds check() classType classVersion send(Email)",
+ "Email": "classType classVersion Adapter from Tos Ccs Bccs ject body isHTML Attachments addTo(email) removeTo(email) addCC(email) removeCC(email) addBCC(email) removeBCC(email) addAttachment(path) removeAttachment(path) send()",
+ "Image": "classType classVersion imagerUri image width height compression output originalWidth originalHeight autoRotate whitespace bgColor rotation processExif processBinary forceNewCache useQueryString errorCode errorText Xml Class_initialize() Class_terminate() go() saveToFile(path,overwrite) getExif() getBinary() getMime() getFilename()",
+ "List": "classType classVersion count Head Foot unshift(Node) shift() push(Node) pop() search(assert) remove(assert)",
+ "List_Node": "classType classVersion data pPrev pNext hasPrev hasNext",
+ "Logger_Adapter_FirePHP": "Interface classType classVersion encoding addFilter(mixed) write(byvalmessage,tp)",
+ "Logger_Adapter_Response": "Interface classType classVersion addFilter(mixed) write(message,tp)",
+ "Logger_Adapter_Text": "Interface classType classVersion path encoding addFilter(mixed) write(message,tp)",
+ "Logger_Interface": "Parent Implementation(I) Implementation requireds check() classType classVersion Priorities write(message,tp)",
+ "Logger": "classType classVersion Priorities addAdapter(Adapter) addFilter(mixed) write(message,arguments,tp) emerg(message,arguments) alert(message,arguments) critical(message,arguments) error(message,arguments) warn(message,arguments) notice(message,arguments) info(message,arguments) debug(message,arguments)",
+ "Paginator": "classType classVersion all prv nxt visibles page pages url make()",
+ "StringBuilder": "classType classVersion reset() append(data) toString()",
+ "Template": "classType classVersion value separator setValue(s) substitute(saArgs) clean(saArgs) length(saArgs) toLowerCase(saArgs) toUpperCase(saArgs) capitalize(cSeparator,saArgs) camelize(cSeparator,saArgs) hyphenate(cSeparator,saArgs) charAt(i,saArgs) substr(iStart,iLength,saArgs) substring(iStart,iStop,saArgs) contains(sFragment,saArgs) test(sPattern,bIgnoreCase,bGlobal,saArgs)",
+ "Translator_Interface": "Parent Implementation(I) Implementation requireds check() classType classVersion load()",
+ "Translator_Media_Json": "Interface classType classVersion path encoding load()",
+ "Translator": "classType classVersion language Media getText(message) load()",
+ "Upload": "classType classVersion Form Files errorText",
+ "Upload_File": "classType classVersion name data contentType formName size() saveToFile(sPath)",
+ "XSession_Interface": "Parent Implementation(I) Implementation requireds check() classType classVersion load(id) save(id,content)",
+ "XSession_Media_Json": "Interface classType classVersion folder encoding load(id) save(id,content)",
+ "XSession_Media_MSSQL": "Interface classType classVersion connectionString load(id) save(id,content)",
+ "XSession": "classType classVersion id Media load() save()",
+ "Zip": "classType classVersion cbZipUri zipName Files go() extract(sTargetPath) extractWithoutFolders(sTargetPath) inspect()",
+ "Zip_File": "name compMethod compSize uncompSize compRatio crc32 isFolder uri fileName() fileExt() saveToFile(sPath)"
},
"tokenSeparator": "."
}
Oops, something went wrong.

0 comments on commit 4b9d02c

Please sign in to comment.