[gedit-list] gedit crash on tab creation with python



Hi,

Attached you find a VERY SIMPLE python gedit plugin.
Edit the hardcoded filename in the code first!
It crashes my gedit 2.18.1 in ubuntu.
Weirdest is, sometimes it does not crash (very rarely
thou).

I want to create a plugin that needs to open files
in a similar way. I cannot go on until this is solved.

Could anyone look at it and tell me what causes the
problem? I would really appreciate it.

Also, window.create_tab_from_uri() complains if
the encoding is None. Should not it use default
encoding then?

Thanks,
Gabor

PS: im not on the list.
-- 
  
  feketga fastmail fm

-- 
http://www.fastmail.fm - Send your email first class

from gettext import gettext as _
import gtk
import gedit
import gobject

class Cece(object):
	def __init__(self, plugin, geditWindow):
		print "Plugin created"
		#print "iiii ok"
		self.geditWindow = geditWindow
		self.plugin = plugin
		gobject.timeout_add(2000, self.dummy)
	
	def deactivate(self):
		print "Plugin deactivated"

	def dummy(self):
		print "hello"
		#self.geditWindow.create_tab_from_uri("file:///home/feketgab/.vimrc",
			#gedit.encoding_get_from_charset("utf-8"),
			##None,
			#12, False, True)
		tab = self.geditWindow.get_active_tab()
		print tab
		doc = tab.get_document()
		doc.load("file:///home/feketgab/.vimrc",
			gedit.encoding_get_from_charset("utf-8"), 12, False)
		return False

	def update_ui(self):
		print "Plugin updated"
	
class CeceMain(gedit.Plugin):
	def __init__(self):
		gedit.Plugin.__init__(self)
		self.instances = {}

	def activate(self, geditWindow):
		print "activate"
		self.instances[geditWindow] = Cece(self, geditWindow)

	def deactivate(self, geditWindow):
		print "main deactivate"
		self.instances[geditWindow].deactivate()
		del self.instances[geditWindow]

	def update_ui(self, geditWindow):
		self.instances[geditWindow].update_ui()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]