1 ## This file is part of Crapvine.
3 ## Copyright (C) 2007 Andrew Sayman <lorien420@myrealbox.com>
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.
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/>.
23 class TextAttributeBox
:
24 __glade_xml_file
= configuration
.get_text_attribute_box_xml_file_path()
25 def __init__(self
, menu_name
, display_name
, overlord
, character
):
26 self
.xml
= gtk
.glade
.XML(self
.__glade
_xml
_file
, 'textattribute')
27 self
.vbox
= self
.xml
.get_widget('textattribute')
28 self
.entry
= self
.xml
.get_widget('textAttributeEntry')
29 self
.label
= self
.xml
.get_widget('lblTextAttributeName')
30 self
.menu_name
= menu_name
31 self
.display_name
= display_name
32 self
.overlord
= overlord
33 self
.character
= character
35 self
.label
.set_label(self
.display_name
.capitalize())
36 self
.entry
.set_text(self
.character
[self
.display_name
])
38 self
.xml
.signal_autoconnect({
39 'on_textAttributeEntry_changed': self
.on_text_changed
,
40 'demand_menu' : self
.demand_menu
43 def on_text_changed(self
, entry
):
44 self
.character
[self
.display_name
] = entry
.get_text()
46 def demand_menu(self
, unused
=None, unused2
=None, unused3
=None):
47 print 'Demanding menu for text %s' % (self
.menu_name
)
48 self
.overlord
.target
= self
49 translated_menu_name
= self
.menu_name
50 if self
.menu_name
in self
.character
.attr_menu_map
.keys():
51 translated_menu_name
= self
.character
.attr_menu_map
[self
.menu_name
]
52 self
.overlord
.show_menu(translated_menu_name
)
54 def add_menu_item(self
, menu_item
):
55 self
.entry
.set_text(menu_item
.name
)