Don't swap menus while you're navigating on the same traitbox
[crapvine.git] / text_box.py
blob8dbc31cd6de065e8aa3c6b8f0d67a76b9408ebaa
1 ## This file is part of Crapvine.
2 ##
3 ## Copyright (C) 2007 Andrew Sayman <lorien420@myrealbox.com>
4 ##
5 ## Crapvine is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## Crapvine is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import gtk
19 import gtk.glade
20 import gobject
21 import configuration
23 class TextBox:
24 __text_box_xml_file = configuration.get_textbox_xml_file_path()
25 def __init__(self, trait_display_name, overlord, character):
26 self.xml = gtk.glade.XML(self.__text_box_xml_file, 'textbox')
27 self.vbox = self.xml.get_widget('textbox')
28 self.title = self.xml.get_widget('lblTextBoxTitle')
29 self.textview = self.xml.get_widget('textview')
30 self.trait_display_name = trait_display_name
31 self.overlord = overlord
32 self.character = character
34 buffer = self.textview.get_buffer()
35 iter = buffer.get_start_iter()
36 buffer.insert(iter, character[trait_display_name])
37 buffer.connect('changed', self.on_text_changed)
39 self.title.set_label(self.trait_display_name.capitalize())
41 def on_text_changed(self, textbuffer):
42 self.character[self.trait_display_name] = textbuffer.get_text(textbuffer.get_start_iter(), textbuffer.get_end_iter(), False)
44 def get_vbox(self):
45 return self.vbox