def _on_add_collection (self, widget): name = utils.InputDialog (None, _("Nome per la nuova collezione:")).run () if impostazioni.get_collection (name) != None: utils.warning (_("Esiste gia' una collezione con lo stesso nome")) return elif name == None: utils.warning (_("Devi fornire un nome per la nuova collezione")) return else: keys = ('ph', 'kh', 'gh', 'no2', 'no3', 'con', 'am', 'fe', 'ra', 'fo', 'cal', 'mag', 'den') collection = {} if self.combo.get_active () == 0: # Nessun modello di base for i in keys: collection[i] = [None, None, None] else: base = impostazioni.get_collection (self.combo.get_active_text ()) if not base: for i in keys: collection[i] = [None, None, None] else: collection = copy (base) # Aggiungiamo la nostra collection self.store.append ([name]) impostazioni.add_collection (name, collection)
def _check_iterator (self, mod, it): # TODO: implementare i valori ideali if it == None: return if type (mod) != gtk.ListStore: it = mod.convert_iter_to_child_iter (it) mod = self.store checks = impostazioni.get_collection (mod.get_value (it, 16)) if checks == None: return keys = ('ph', 'kh', 'gh', 'no2', 'no3', 'con', 'am', 'fe', 'ra', 'fo', 'cal', 'mag', 'den') x = 0 for i in keys: if checks.has_key (i): val = mod.get_value (it, x + 3) if val < checks[i][0]: mod.set_value (it, x + 14 + 3, gcolor[0]) elif val > checks[i][1]: mod.set_value (it, x + 14 + 3, gcolor[1]) #elif val == checks[i][2]: # print "Ideal value" else: mod.set_value (it, x + 14 + 3, gcolor[2]) x += 1
def _on_spin_change (self, widget): id = self.vars.index (widget) id -= 2 if id < 16: mod, it = self.view.get_selection ().get_selected () if it == None: return checks = impostazioni.get_collection (mod.get_value (it, 16)) # Nessun filtro selezionato! (colonna limiti) if checks == None: return keys = ('ph', 'kh', 'gh', 'no2', 'no3', 'con', 'am', 'fe', 'ra', 'fo', 'cal', 'mag', 'den') # Resettiamo il colore iniziale widget.modify_bg (gtk.STATE_NORMAL, gcolor[3]) if not checks.has_key (keys[id]): widget.set_sensitive (False) return else: widget.set_sensitive (True) check = checks [keys [id]] # FIXME: levami di torno :( print keys[id], check val = widget.get_value () if check[0] == None and check[1] == None: widget.set_sensitive (False) return else: widget.set_sensitive (True) if val < check[0]: widget.modify_bg (gtk.STATE_NORMAL, gcolor[0]) elif val > check[1]: widget.modify_bg (gtk.STATE_NORMAL, gcolor[1]) else: widget.modify_bg (gtk.STATE_NORMAL, gcolor[2])
def _on_change_selection (self, selection): mod, it = selection.get_selected () if it != None: collection = impostazioni.get_collection (mod.get_value (it, 0)) if not collection: return keys = ('ph', 'kh', 'gh', 'no2', 'no3', 'con', 'am', 'fe', 'ra', 'fo', 'cal', 'mag', 'den') x = 0 for i in keys: if collection.has_key (i): min, max, ideal = collection[i] self.widgets[x][0].set_text (min) self.widgets[x][1].set_text (max) self.widgets[x][2].set_text (ideal) x += 1
def _on_apply_changes (self, widget): mod, it = self.view.get_selection ().get_selected () if it != None: # Ora estrapoliamo i valori e applichiamo le modifiche collection = impostazioni.get_collection (mod.get_value (it, 0)) if collection == None: return keys = ('ph', 'kh', 'gh', 'no2', 'no3', 'con', 'am', 'fe', 'ra', 'fo', 'cal', 'mag', 'den') x = 0 for i in keys: min = self.widgets[x][0].get_text () max = self.widgets[x][1].get_text () ide = self.widgets[x][2].get_text () collection [i] = [min, max, ide] x += 1