Example #1
0
    def _populate_inputs(self, ui_xml):
        # Grid repacking magic for the templated stuff

        # XXX FRAGILE
        # It would be nice to use the template's own left-attach, top-attach,
        # width and height child properties to replicate its layout as
        # specified, but unfortunately the current versions of PyGI are all
        # broken in one way or another with respect to getting container child
        # properties. So we fudge it until upstream fix
        # https://bugzilla.gnome.org/show_bug.cgi?id=685076
        group_start_row = 4
        tmpl_layouts = [
            ("by{name}_label", 0, 0, 1, 1),
            ("by{name}_expander_button", 1, 0, 1, 1),
            ("by{name}_scale", 2, 0, 1, 1),
            ("by{name}_reset_button", 3, 0, 1, 1),
            ("by{name}_curve_grid", 2, 2, 2, 1),
        ]
        grid_pos = {}
        grid = self._builder.get_object("setting_editor_grid")
        # Extract the relative layout and pattern of by-input widgets
        group_step = 0
        tmpl_objs = []
        for tmpl_id, x, y, w, h in tmpl_layouts:
            tmpl_obj = self._builder.get_object(tmpl_id)
            group_step = max(group_step, y + h)
            tmpl_objs.append(tmpl_obj)
        # Remove the "originals": they're not useful in themselves
        for tmpl_obj in tmpl_objs:
            grid.remove(tmpl_obj)
        # Generate lots of clones, one group per brush input
        for i in brushsettings.inputs:
            params = dict(dname=i.dname, name=i.name, tooltip=i.tooltip)
            object_ids = [layout[0] for layout in tmpl_layouts]
            widgets = add_objects_from_template_string(self._builder, ui_xml,
                                                       object_ids, params)
            for layout, widget in zip(tmpl_layouts, widgets):
                tmpl_id, x, y, w, h = layout
                y += group_start_row
                grid.attach(widget, x, y, w, h)
                if tmpl_id == "by{name}_curve_grid":
                    widget.hide()
            group_start_row += group_step
            label = self._builder.get_object("by%s_label" % i.name)
            label.set_tooltip_text(i.tooltip)
            btn = self._builder.get_object("by%s_expander_button" % i.name)
            btn.__input = i
            # Hook up curve max and min adjustments
            cb = self._update_axis_label
            fmt = "%+.2f"
            # Y axis
            scale = self._builder.get_object("by%s_scale" % i.name)
            scale_adj = self._input_y_adj[i.name]
            scale_lbl = self._builder.get_object("by%s_ymax_label" % i.name)
            scale_adj.connect("value-changed", cb, scale_lbl, fmt, False)
            cb(scale_adj, scale_lbl, fmt, False)
            scale_lbl = self._builder.get_object("by%s_ymin_label" % i.name)
            scale_adj.connect("value-changed", cb, scale_lbl, fmt, True)
            cb(scale_adj, scale_lbl, fmt, True)
            scale.set_adjustment(scale_adj)
            # X axis: min
            sbut = self._builder.get_object("by%s_xmin_scalebutton" % i.name)
            sbut_lbl = self._builder.get_object("by%s_xmin_label" % i.name)
            sbut_adj = self._input_xmin_adj[i.name]
            sbut_adj.connect("value-changed", cb, sbut_lbl, fmt, False)
            cb(sbut_adj, sbut_lbl, fmt, False)
            sbut.set_adjustment(sbut_adj)
            # X axis: max
            sbut = self._builder.get_object("by%s_xmax_scalebutton" % i.name)
            sbut_lbl = self._builder.get_object("by%s_xmax_label" % i.name)
            sbut_adj = self._input_xmax_adj[i.name]
            sbut_adj.connect("value-changed", cb, sbut_lbl, fmt, False)
            cb(sbut_adj, sbut_lbl, fmt, False)
            sbut.set_adjustment(sbut_adj)
Example #2
0
    def _populate_inputs(self, ui_xml):
        # Grid repacking magic for the templated stuff

        # XXX FRAGILE
        # It would be nice to use the template's own left-attach, top-attach,
        # width and height child properties to replicate its layout as
        # specified, but unfortunately the current versions of PyGI are all
        # broken in one way or another with respect to getting container child
        # properties. So we fudge it until upstream fix
        # https://bugzilla.gnome.org/show_bug.cgi?id=685076
        group_start_row = 4
        tmpl_layouts = [
            ("by{name}_label",           0, 0, 1, 1),
            ("by{name}_expander_button", 1, 0, 1, 1),
            ("by{name}_scale",           2, 0, 1, 1),
            ("by{name}_reset_button",    3, 0, 1, 1),
            ("by{name}_curve_grid",      2, 2, 2, 1),
        ]
        grid = self._builder.get_object("setting_editor_grid")
        # Extract the relative layout and pattern of by-input widgets
        group_step = 0
        tmpl_objs = []
        for tmpl_id, x, y, w, h in tmpl_layouts:
            tmpl_obj = self._builder.get_object(tmpl_id)
            group_step = max(group_step, y+h)
            tmpl_objs.append(tmpl_obj)
        # Remove the "originals": they're not useful in themselves
        for tmpl_obj in tmpl_objs:
            grid.remove(tmpl_obj)
        # Generate lots of clones, one group per brush input
        for i in brushsettings.inputs:
            params = dict(dname=i.dname, name=i.name, tooltip=i.tooltip)
            object_ids = [layout[0] for layout in tmpl_layouts]
            widgets = add_objects_from_template_string(self._builder, ui_xml,
                                                       object_ids, params)
            for layout, widget in zip(tmpl_layouts, widgets):
                tmpl_id, x, y, w, h = layout
                y += group_start_row
                grid.attach(widget, x, y, w, h)
                if tmpl_id == "by{name}_curve_grid":
                    widget.hide()
            group_start_row += group_step
            label = self._builder.get_object("by%s_label" % i.name)
            label.set_tooltip_text(i.tooltip)
            btn = self._builder.get_object("by%s_expander_button" % i.name)
            btn.__input = i
            # Hook up curve max and min adjustments
            cb = self._update_axis_label
            fmt = "%+.2f"
            # Y axis
            scale = self._builder.get_object("by%s_scale" % i.name)
            scale_adj = self._input_y_adj[i.name]
            scale_lbl = self._builder.get_object("by%s_ymax_label" % i.name)
            scale_adj.connect("value-changed", cb, scale_lbl, fmt, False)
            cb(scale_adj, scale_lbl, fmt, False)
            scale_lbl = self._builder.get_object("by%s_ymin_label" % i.name)
            scale_adj.connect("value-changed", cb, scale_lbl, fmt, True)
            cb(scale_adj, scale_lbl, fmt, True)
            scale.set_adjustment(scale_adj)
            # X axis: min
            sbut = self._builder.get_object("by%s_xmin_scalebutton" % i.name)
            sbut_lbl = self._builder.get_object("by%s_xmin_label" % i.name)
            sbut_adj = self._input_xmin_adj[i.name]
            sbut_adj.connect("value-changed", cb, sbut_lbl, fmt, False)
            cb(sbut_adj, sbut_lbl, fmt, False)
            sbut.set_adjustment(sbut_adj)
            # X axis: max
            sbut = self._builder.get_object("by%s_xmax_scalebutton" % i.name)
            sbut_lbl = self._builder.get_object("by%s_xmax_label" % i.name)
            sbut_adj = self._input_xmax_adj[i.name]
            sbut_adj.connect("value-changed", cb, sbut_lbl, fmt, False)
            cb(sbut_adj, sbut_lbl, fmt, False)
            sbut.set_adjustment(sbut_adj)