[Change] Imroved sanity somewhat.

This commit is contained in:
Allanis 2013-06-18 21:37:41 +01:00
parent a9ad3298ac
commit 741aa3b5d5
2 changed files with 25 additions and 3 deletions

View File

@ -441,9 +441,9 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkComboBox" id="comFleet"> <widget class="GtkComboBox" id="comFleets">
<property name="width_request">189</property> <property name="width_request">189</property>
<property name="height_request">20</property> <property name="height_request">25</property>
<property name="visible">True</property> <property name="visible">True</property>
</widget> </widget>
<packing> <packing>

View File

@ -21,6 +21,7 @@ class Space:
self.factions = factions self.factions = factions
if fleets==None: if fleets==None:
self.fleets = {} self.fleets = {}
else:
self.fleets = fleets self.fleets = fleets
def loadSystems(self, xmlfile): def loadSystems(self, xmlfile):
@ -92,6 +93,18 @@ class Space:
area.connect("button-press-event", self.__space_down) area.connect("button-press-event", self.__space_down)
area.connect("motion-notify-event", self.__space_drag) area.connect("motion-notify-event", self.__space_drag)
# Factions.
wgt = self.__swidget("comFleets")
combo = gtk.ListStore(str)
combo.append(["None"])
for f in self.fleets.keys():
node = combo.append([f])
cell = gtk.CellRendererText()
wgt.pack_start(cell, True)
wgt.add_attribute(cell, 'text', 0)
wgt.set_model(combo)
wgt.set_active(0)
# Display the window and such. # Display the window and such.
self.__swidget("winSystems").show_all() self.__swidget("winSystems").show_all()
self.cur_system = "" self.cur_system = ""
@ -129,6 +142,7 @@ class Space:
wgt.pack_start(cell, True) wgt.pack_start(cell, True)
wgt.add_attribute(cell, 'text', 0) wgt.add_attribute(cell, 'text', 0)
wgt.set_model(combo) wgt.set_model(combo)
wgt.set_active(0)
# Factions. # Factions.
wgt = self.__pwidget("comFaction") wgt = self.__pwidget("comFaction")
@ -140,6 +154,7 @@ class Space:
wgt.pack_start(cell, True) wgt.pack_start(cell, True)
wgt.add_attribute(cell, "text", 0) wgt.add_attribute(cell, "text", 0)
wgt.set_model(combo) wgt.set_model(combo)
wgt.set_active(0)
# --------------------------------------------- # ---------------------------------------------
@ -626,7 +641,11 @@ class Space:
return model.get_value(iter, 0) return model.get_value(iter, 0)
def __fleet_add(self, wgt=None, event=None): def __fleet_add(self, wgt=None, event=None):
return fleet = self.__swidget("comFleets").get_active_text()
value = self.__swidget("spiFleets").get_value_as_int()
if fleet != "None" and value > 0:
self.systems[self.cur_system]["fleets"][fleet] = value
self.__supdate()
def __fleet_rm(self, wgt=None, event=None): def __fleet_rm(self, wgt=None, event=None):
sel = self.__fleet_sel() sel = self.__fleet_sel()
@ -700,6 +719,9 @@ class Space:
self.__pupdate() self.__pupdate()
def __pnewFact(self, wgt=None, event=None): def __pnewFact(self, wgt=None, event=None):
if self.cur_planet == "":
return
combo = self.__pwidget("comFaction") combo = self.__pwidget("comFaction")
fact = combo.get_active_text() fact = combo.get_active_text()
planet = self.planets[self.cur_planet] planet = self.planets[self.cur_planet]