Ejemplo n.º 1
0
    def custom_handler(self, prop, widget): # TODO split out these 4 properties in their own adapters
        if prop.label in ("CSDS_distribution", "components", "probabilities", "based_on"):
            if prop.label == "CSDS_distribution":
                self.reset_csds_controller()
            elif prop.label == "components":
                self.reset_components_controller()
            elif prop.label == "probabilities":
                self.reset_probabilities_controller()
            elif prop.label == "based_on" and self.phases_treemodel is not None:
                combo = self.view["phase_based_on"]

                combo.set_model(self.phases_treemodel)
                combo.connect('changed', self.on_based_on_changed)

                def phase_renderer(celllayout, cell, model, itr, user_data=None):
                    phase = model.get_user_data(itr)
                    if phase: # FIXME an error can occur here if the phase list is cleared and the view is still open
                        cell.set_sensitive(phase.R == self.model.R and phase.G == self.model.G and phase.get_based_on_root() != self.model)
                add_combo_text_column(combo, data_func=phase_renderer, text_col=self.phases_treemodel.c_name)

                for row in self.phases_treemodel:
                    if self.phases_treemodel.get_user_data(row.iter) == self.model.based_on:
                        combo.set_active_iter (row.iter)
                        break

            return DummyAdapter(controller=self, prop=prop)
    def reset_combo_box(self, name):
        if self.model.component is not None:
            # Get store, reset combo
            store = self.model.create_prop_store(self.extra_props)
            combo = self.view[self.view.widget_format % name]
            combo.clear()
            combo.set_model(store)

            # Add text column:
            def get_name(layout, cell, model, itr, data=None):
                obj, lbl = model.get(itr, 0, 2)
                if callable(lbl): lbl = lbl(obj)
                cell.set_property("markup", lbl)
            add_combo_text_column(combo, data_func=get_name)

            # Set the selected item to active:
            prop = getattr(self.model, name)
            if prop is not None:
                prop = tuple(prop)
                for row in store:
                    if tuple(store.get(row.iter, 0, 1)) == prop:
                        combo.set_active_iter(row.iter)
                        break

            return combo, store
        else:
            return None, None
Ejemplo n.º 3
0
    def reset_combo_box(self, name):
        if self.model.component is not None:
            # Get store, reset combo
            store = self.model.create_prop_store(self.extra_props)
            combo = self.view[self.view.widget_format % name]
            combo.clear()
            combo.set_model(store)

            # Add text column:
            def get_name(layout, cell, model, itr, data=None):
                obj, lbl = model.get(itr, 0, 2)
                if callable(lbl): lbl = lbl(obj)
                cell.set_property("markup", lbl)

            add_combo_text_column(combo, data_func=get_name)

            # Set the selected item to active:
            prop = getattr(self.model, name)
            if prop is not None:
                prop = tuple(prop)
                for row in store:
                    if tuple(store.get(row.iter, 0, 1)) == prop:
                        combo.set_active_iter(row.iter)
                        break

            return combo, store
        else:
            return None, None
 def generate_combo(self):
     cmb_model = Gtk.ListStore(str, object)
     print("Adding rows from:", self.parent.obj_type_map)
     for cls, _, _ in self.parent.obj_type_map:
         print("Adding row:", cls)
         cmb_model.append([cls.Meta.store_id, cls])
     self.view.behaviour_combo_box.set_model(cmb_model)
     add_combo_text_column(self.view.behaviour_combo_box, text_col=0)
 def generate_combo(self):
     cmb_model = Gtk.ListStore(str, object)
     print("Adding rows from:", self.parent.obj_type_map)
     for cls, _, _ in self.parent.obj_type_map:
         print("Adding row:", cls)
         cmb_model.append([cls.Meta.store_id, cls])
     self.view.behaviour_combo_box.set_model(cmb_model)
     add_combo_text_column(
         self.view.behaviour_combo_box, text_col=0)
Ejemplo n.º 6
0
 def reset_combo_box(self):
     """
         Reset the `linked_with` combo box.
     """
     if self.model is not None and self.model.parent is not None:
         combo = self.view["component_linked_with"]
         combo.clear()
         combo.set_model(self.components_treemodel)
         if self.components_treemodel is not None:
             add_combo_text_column(combo, text_col=self.components_treemodel.c_name)
             for row in self.components_treemodel:
                 comp = self.components_treemodel.get_user_data(row.iter)
                 if comp == self.model.linked_with:
                     combo.set_active_iter (row.iter)
                     break
Ejemplo n.º 7
0
 def reset_combo_box(self):
     """
         Reset the `linked_with` combo box.
     """
     if self.model is not None and self.model.parent is not None:
         combo = self.view["component_linked_with"]
         combo.clear()
         combo.set_model(self.components_treemodel)
         if self.components_treemodel is not None:
             add_combo_text_column(combo, text_col=self.components_treemodel.c_name)
             for row in self.components_treemodel:
                 comp = self.components_treemodel.get_user_data(row.iter)
                 if comp == self.model.linked_with:
                     combo.set_active_iter (row.iter)
                     break
Ejemplo n.º 8
0
    def custom_handler(
            self, intel,
            widget):  # TODO split out these 4 properties in their own adapters
        if intel.name in ("CSDS_distribution", "components", "probabilities",
                          "based_on"):
            if intel.name == "CSDS_distribution":
                self.reset_csds_controller()
            elif intel.name == "components":
                self.reset_components_controller()
            elif intel.name == "probabilities":
                self.reset_probabilities_controller()
            elif intel.name == "based_on" and self.phases_treemodel is not None:
                combo = self.view["phase_based_on"]

                combo.set_model(self.phases_treemodel)
                combo.connect('changed', self.on_based_on_changed)

                def phase_renderer(celllayout,
                                   cell,
                                   model,
                                   itr,
                                   user_data=None):
                    phase = model.get_user_data(itr)
                    if phase:  # FIXME an error can occur here if the phase list is cleared and the view is still open
                        cell.set_sensitive(
                            phase.R == self.model.R and phase.G == self.model.G
                            and phase.get_based_on_root() != self.model)

                add_combo_text_column(combo,
                                      data_func=phase_renderer,
                                      text_col=self.phases_treemodel.c_name)

                for row in self.phases_treemodel:
                    if self.phases_treemodel.get_user_data(
                            row.iter) == self.model.based_on:
                        combo.set_active_iter(row.iter)
                        break

            return DummyAdapter(controller=self, prop=intel)
Ejemplo n.º 9
0
 def generate_combo(self):
     self.reload_combo_model()
     add_combo_text_column(self.view.phase_combo_box,
                           text_col=0,
                           sensitive_col=2)
Ejemplo n.º 10
0
 def generate_combo(self):
     self.reload_combo_model()
     add_combo_text_column(
         self.view.phase_combo_box, text_col=0, sensitive_col=2)