~muelnet/heybuddy/pulltimes

91 by jezra
copyright notices
1
'''
2
this is a part of the heybuddy project
3
copyright 2010 jezra lickter http://www.jezra.net
4
'''
1 by jezra
init
5
import gtk
162 by jezra
parse color for older gtks
6
import PlatformSpecific	
41 by jezra
mentions and shit
7
#what is the max number of dents we want to keep track of?
119 by jezra
copy user selected text from dents
8
#MAX_DENTS=50
69 by jezra
fuck you NOKIA! If you want developers, write better documentation for your APIs
9
class DentScroller(gtk.EventBox):
162 by jezra
parse color for older gtks
10
	def __init__(self):
11
		gtk.EventBox.__init__(self)
12
		#keep track of this dentscroller's ids
13
		self.ids = []
14
		main_child= PlatformSpecific.ScrollThingy()
15
		self.add(main_child)	
16
		self.dent_scroll_vbox=gtk.VBox(spacing=1)
17
		self.viewport = gtk.Viewport()
18
		self.viewport.add(self.dent_scroll_vbox)
19
		try:
20
			the_color = gtk.gdk.color_parse('#666')
21
			self.viewport.modify_bg(gtk.STATE_NORMAL,the_color )
22
		except:
23
			#what the hell version of python-gtk is this?
24
			pass
25
		main_child.add(self.viewport)
26
		# add an empty "something" to the vbox
27
		self.dent_scroll_vbox.pack_end(gtk.Label(),True,True,0)
28
		
29
	def add_dent(self,dent,is_conv=False,conv_backwards=False):
30
		#is this id already in this scroller?
31
		dent_id = dent.id
32
		if not dent_id in self.ids:
33
			self.ids.append(dent_id)
34
			if is_conv and not conv_backwards:
35
				self.dent_scroll_vbox.pack_start(dent,False,False,0)
36
			else:
37
				self.dent_scroll_vbox.pack_end(dent,False,False,0)
38
39
			#it would be nice to see this dent
40
			dent.show_all()
203 by jezra
some brutal shit
41
			return True
42
		else:
211 by jezra
garbage test
43
			del dent_id
44
			del dent
203 by jezra
some brutal shit
45
			return False
162 by jezra
parse color for older gtks
46
47
	def prune(self, number):
48
		#hey! how many children does the self.dent_scroll_vbox have?
49
		children=self.dent_scroll_vbox.get_children()
50
		while len(children)>number:
51
			self.dent_scroll_vbox.remove( children[-1] )
52
			d = children.pop()
53
			try:
54
				self.ids.remove(d.id)
55
			except:
56
				pass
210 by jezra
working on the mem leak, fuckers
57
			d.unrealize()
208 by jezra
destroy that shit
58
			d.destroy()
211 by jezra
garbage test
59
			del d
162 by jezra
parse color for older gtks
60
61
	def clear(self):
62
		children=self.dent_scroll_vbox.get_children()
208 by jezra
destroy that shit
63
		#clear the ids
64
		self.ids = []
162 by jezra
parse color for older gtks
65
		for child in children:
210 by jezra
working on the mem leak, fuckers
66
			child.unrealize()
208 by jezra
destroy that shit
67
			child.destroy()
68