1
# -*- coding: utf-8 -*-
3
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
4
#Copyright (c) 2006 Ali Afshar aafshar@gmail.com
6
#Permission is hereby granted, free of charge, to any person obtaining a copy
7
#of this software and associated documentation files (the "Software"), to deal
8
#in the Software without restriction, including without limitation the rights
9
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
#copies of the Software, and to permit persons to whom the Software is
11
#furnished to do so, subject to the following conditions:
13
#The above copyright notice and this permission notice shall be included in
14
#all copies or substantial portions of the Software.
16
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
import pida.utils.vim.vimcom as vimcom
26
import pida.utils.vim.vimeditor as vimeditor
27
import pida.core.service as service
28
import pida.pidagtk.contentview as contentview
29
import pida.pidagtk.icons as icons
32
class vim_plugin_view(gtk.HBox):
33
"""View holding the vim controls."""
35
def __init__(self, service):
36
self.service = service
37
gtk.HBox.__init__(self, spacing=3)
38
icon = icons.icons.get_image('vim')
39
self.pack_start(icon, expand=False)
40
self.__serverlist = gtk.combo_box_new_text()
41
self.pack_start(self.__serverlist)
43
def set_serverlist(self, serverlist):
44
current = self.__serverlist.get_active_text()
45
self.__serverlist.get_model().clear()
47
for i, server in enumerate(serverlist):
48
self.__serverlist.append_text(server)
50
self.__serverlist.set_active(i)
53
self.__serverlist.append_text('no vim running')
54
self.__serverlist.set_sensitive(False)
56
self.__serverlist.set_sensitive(True)
57
if self.__serverlist.get_active() == -1:
58
self.__serverlist.set_active(0)
59
self.__serverlist.show_all()
61
def get_current_server(self):
62
return self.__serverlist.get_active_text()
63
current_server = property(get_current_server)
66
class vim_multi_editor(vimeditor.vim_editor, service.service):
68
display_name = 'External Vim'
71
self.__oldservers = []
72
self.view = vim_plugin_view(service=self)
73
self.__cw = vimcom.communication_window(self)
75
self.get_service('buffermanager').\
76
plugin_view.widget.pack_start(self.view, expand=False)
77
self.get_service('editormanager').events.emit('started')
79
def vim_new_serverlist(self, serverlist):
81
for server in serverlist:
82
if 'PIDA_EMBEDDED' not in server:
83
if server not in self.__oldservers:
84
self.__cw.init_server(server)
86
self.view.set_serverlist(_serverlist())
87
self.__oldservers = serverlist
90
return self.view.current_server
91
server = property(get_server)
94
Service = vim_multi_editor