def _on_columns_changed(self, *args): """Reset the columns enumeration to match new column layout.""" count_changed = (len(self.columns) != len(self.get_columns())) self._reset_columns() field_order = [] for column in self.get_columns(): attribute = column.gaupol_id.upper() item = aeidon.EnumerationItem() setattr(self.columns, attribute, item) if hasattr(gaupol.fields, attribute): field = getattr(gaupol.fields, attribute) field_order.append(field) if not count_changed: gaupol.conf.editor.field_order = field_order
def _add_framerates(self): """Add custom framerates and corresponding UI elements.""" self.framerates = [] menu = self.application.get_menubar_section( "custom-framerates-placeholder") for value in sorted(self.conf.framerates): name = "FPS_{:.3f}".format(value).replace(".", "_") if hasattr(aeidon.framerates, name): continue setattr(aeidon.framerates, name, aeidon.EnumerationItem()) framerate = getattr(aeidon.framerates, name) framerate.label = _("{:.3f} fps").format(value) framerate.value = float(value) self.framerates.append(framerate) with aeidon.util.silent(AttributeError): # Menubar not available when running unit tests. action = "win.set-framerate::{}".format(name) menu.append(framerate.label, action)
def _add_framerates(self): """Add custom framerates and corresponding UI elements.""" self._action_group = Gtk.ActionGroup(name="custom-framerates") self.application.uim.insert_action_group(self._action_group, -1) tooltip = _("Calculate nonnative units with a framerate of {:.3f} fps") directory = os.path.abspath(os.path.dirname(__file__)) ui_file_path = os.path.join(directory, "custom-framerates.ui.xml") ui_xml_template = open(ui_file_path, "r").read() self._framerates = [] self._uim_ids = [] for value in sorted(self._conf.framerates): name = "FPS_{:.3f}".format(value).replace(".", "_") if hasattr(aeidon.framerates, name): print("Framerate {:.3f} already exists!".format(value), file=sys.stderr) continue setattr(aeidon.framerates, name, aeidon.EnumerationItem()) framerate = getattr(aeidon.framerates, name) framerate.label = _("{:.3f} fps").format(value) framerate.mpsub = "{:.2f}".format(value) framerate.value = float(value) self._framerates.append(framerate) action_name = name.replace("FPS", "show_framerate") action = Gtk.RadioAction(name=action_name, label=framerate.label, tooltip=(tooltip.format(value)), stock_id=None, value=int(framerate)) group = "show_framerate_23_976" action.join_group(self.application.get_action(group)) action.framerate = framerate self._action_group.add_action(action) ui_xml = ui_xml_template.format(name=name.replace("FPS_", ""), action=action.get_name()) uim_id = self.application.uim.add_ui_from_string(ui_xml) self._uim_ids.append(uim_id) gaupol.framerate_actions[framerate] = action.get_name() self.application.framerate_combo.append_text(action.get_label()) self.application.uim.ensure_update() self.application.set_menu_notify_events("custom-framerates")
def setup_method(self, method): self.fruits = aeidon.Enumeration() self.fruits.APPLE = aeidon.EnumerationItem() self.fruits.MANGO = aeidon.EnumerationItem() self.fruits.APPLE.size = 10 self.fruits.MANGO.size = 20
def setup_method(self, method): self.parent = object() self.item_0 = aeidon.EnumerationItem(0, "a", self.parent) self.item_1 = aeidon.EnumerationItem(1, "b", self.parent) self.item_2 = aeidon.EnumerationItem(2, "c", self.parent)