[Add] <resedit> Edit the bar description text.

This commit is contained in:
Allanis 2013-06-22 15:15:32 +01:00
parent 72f0a93c30
commit 1396676fcb
2 changed files with 90 additions and 2 deletions

View File

@ -531,7 +531,7 @@
</child>
<child>
<widget class="GtkButton" id="butDescription">
<property name="width_request">240</property>
<property name="width_request">110</property>
<property name="height_request">25</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -544,6 +544,21 @@
<property name="y">150</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="butBar">
<property name="width_request">110</property>
<property name="height_request">25</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Edit Bar</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="x">150</property>
<property name="y">150</property>
</packing>
</child>
</widget>
<packing>
<property name="resize">True</property>
@ -592,4 +607,43 @@
</widget>
</child>
</widget>
<widget class="GtkWindow" id="winBar">
<property name="type">GTK_WINDOW_POPUP</property>
<property name="title" translatable="yes">Edit Bar</property>
<property name="modal">True</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH</property>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<child>
<widget class="GtkTextView" id="texBar">
<property name="width_request">400</property>
<property name="height_request">400</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
</widget>
<packing>
<property name="padding">10</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="butBarDone">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Done</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -138,7 +138,8 @@ class Space:
"butComRm":["clicked", self.__commodity_rm],
"comSpace":["changed", self.__space_sel],
"comExterior":["changed", self.__exterior_sel],
"butDescription":["clicked", self.__edit_description]
"butDescription":["clicked", self.__edit_description],
"butBar":["clicked", self.__edit_bar]
}
for key, val in hooks.items():
self.__pwidget(key).connect(val[0], val[1])
@ -853,6 +854,39 @@ class Space:
del self.planets[self.cur_planet]["general"]["description"]
self.dtree.get_widget("winDescription").hide_all()
"""
Open the bar editor.
"""
def __edit_bar(self, wgt=None, event=None):
if self.cur_planet == "":
return
wtree = gtk.glade.XML(self.planet_glade, "winBar")
wtree.get_widget("winBar").show_all()
# Hooks.
wtree.get_widget("butBarDone").connect("clicked", self.__bar_done)
# Set text.
buf = gtk.TextBuffer()
try:
buf.set_text(self.planets[self.cur_planet]["general"]["bar"])
except:
buf.set_text("")
wtree.get_widget("texBar").set_buffer(buf)
self.btree = wtree
def __bar_done(self, wgt=None, event=None):
buf = self.btree.get_widget("texBar").get_buffer()
desc = buf.get_text(buf.get_start_iter(), buf.get_end_iter())
if desc != "":
self.planets[self.cur_planet]["general"]["bar"] = desc
else:
if "bar" in self.planets[self.cur_planet]["general"].keys():
del self.planets[self.cur_planet]["general"]["bar"]
self.btree.get_widget("winBar").hide_all()
"""
Create a new star system.
"""