Beispiel #1
0
    def _update_view_combo_names(self):
        """Update the combo box to reflect a changed list names."""
        model_names = set(self._lvm.view_names)
        store = self._store

        kept_names = set()
        it = store.get_iter_first()
        while it is not None:
            name, = store.get(it, 0)
            if isinstance(name, bytes):
                name = name.decode("utf-8")
            # Skip over our representation of the builtin
            if name == u"":
                it = store.iter_next(it)
                continue
            # Drop or keep
            if name not in model_names:
                it_still_valid = store.remove(it)  # advances it
                if not it_still_valid:
                    it = None
            else:
                it = store.iter_next(it)
                kept_names.add(name)

        for name in model_names:
            if name not in kept_names:
                markup = C_(
                    "view controls: dropdown: item markup",
                    u"{user_chosen_view_name}",
                ).format(
                    user_chosen_view_name=escape(name),
                )
                store.append([name, markup])
Beispiel #2
0
    def _update_view_combo_names(self):
        """Update the combo box to reflect a changed list names."""
        model_names = set(self._lvm.view_names)
        store = self._store

        kept_names = set()
        it = store.get_iter_first()
        while it is not None:
            name, = store.get(it, 0)
            if isinstance(name, bytes):
                name = name.decode("utf-8")
            # Skip over our representation of the builtin
            if name == u"":
                it = store.iter_next(it)
                continue
            # Drop or keep
            if name not in model_names:
                it_still_valid = store.remove(it)  # advances it
                if not it_still_valid:
                    it = None
            else:
                it = store.iter_next(it)
                kept_names.add(name)

        for name in model_names:
            if name not in kept_names:
                markup = C_(
                    "view controls: dropdown: item markup",
                    u"{user_chosen_view_name}",
                ).format(user_chosen_view_name=escape(name), )
                store.append([name, markup])
Beispiel #3
0
def run_about_dialog(mainwin, app):
    """Runs MyPaint's about window as a transient modal dialog."""
    d = Gtk.AboutDialog()
    d.set_transient_for(mainwin)
    d.set_program_name(lib.meta.MYPAINT_PROGRAM_NAME)
    p = lib.meta.MYPAINT_PROGRAM_NAME
    v_raw = app.version or lib.meta.MYPAINT_VERSION
    v = "{mypaint_version}\n\n<small>({libs_versions})</small>".format(
        mypaint_version=escape(v_raw),
        libs_versions=escape(get_libs_version_string()),
    )
    if os.name == "nt":
        # The architecture matters more on windows, to the extent that
        # we release two separate builds with differing names.
        bits_str, linkage = platform.architecture()
        bits_str = {
            "32bit": "w32",
            "64bit": "w64",
        }.get(bits_str, bits_str)
        p = "{progname} {w_bits}".format(
            progname=lib.meta.MYPAINT_PROGRAM_NAME,
            w_bits=bits_str,
        )
    # Some strings have markup characters escaped in GTK because
    # of standard markup being applied to that info section, noted below.

    # escapes input
    d.set_program_name(p)
    # does NOT escape input
    d.set_version(v)
    # escapes input
    d.set_copyright(COPYRIGHT_STRING)
    # only url (set_website_label escapes input)
    d.set_website(WEBSITE_URI)
    d.set_logo(app.pixmaps.mypaint_logo)
    # does NOT escape input
    d.set_license(LICENSE_SUMMARY)
    d.set_wrap_license(True)
    # Credits sections use some custom undocumented simple parsing
    # to produce markup for email links, website links etc.
    # NOTE: Said parsing does not care if input is escaped or not...
    d.set_authors(_AUTHOR_CREDITS)
    d.set_artists(_ARTIST_CREDITS)
    d.set_translator_credits(_TRANSLATOR_CREDITS)
    d.run()
    d.destroy()
Beispiel #4
0
def run_about_dialog(mainwin, app):
    """Runs MyPaint's about window as a transient modal dialog."""
    d = Gtk.AboutDialog()
    d.set_transient_for(mainwin)
    d.set_program_name(lib.meta.MYPAINT_PROGRAM_NAME)
    p = escape(lib.meta.MYPAINT_PROGRAM_NAME)
    v_raw = app.version or lib.meta.MYPAINT_VERSION
    v = "{mypaint_version}\n\n<small>({libs_versions})</small>".format(
        mypaint_version=escape(v_raw),
        libs_versions=escape(get_libs_version_string()),
    )
    if os.name == "nt":
        # The architecture matters more on windows, to the extent that
        # we release two separate builds with differing names.
        bits_str, linkage = platform.architecture()
        bits_str = {
            "32bit": "w32",
            "64bit": "w64",
        }.get(bits_str, bits_str)
        p = "{progname} {w_bits}".format(
            progname=escape(lib.meta.MYPAINT_PROGRAM_NAME),
            w_bits=escape(bits_str),
        )
    d.set_program_name(p)
    d.set_version(v)
    d.set_copyright(escape(COPYRIGHT_STRING))
    d.set_website(WEBSITE_URI)
    d.set_logo(app.pixmaps.mypaint_logo)
    d.set_license(LICENSE_SUMMARY)
    d.set_wrap_license(True)
    d.set_authors(_AUTHOR_CREDITS)
    d.set_artists(_ARTIST_CREDITS)
    d.set_translator_credits(_TRANSLATOR_CREDITS)
    d.run()
    d.destroy()
Beispiel #5
0
def run_about_dialog(mainwin, app):
    """Runs MyPaint's about window as a transient modal dialog."""
    d = Gtk.AboutDialog()
    d.set_transient_for(mainwin)
    d.set_program_name(lib.meta.MYPAINT_PROGRAM_NAME)
    p = escape(lib.meta.MYPAINT_PROGRAM_NAME)
    v_raw = app.version or lib.meta.MYPAINT_VERSION
    v = "{mypaint_version}\n\n<small>({libs_versions})</small>".format(
        mypaint_version = escape(v_raw),
        libs_versions = escape(get_libs_version_string()),
    )
    if os.name == "nt":
        # The architecture matters more on windows, to the extent that
        # we release two separate builds with differing names.
        bits_str, linkage = platform.architecture()
        bits_str = {
            "32bit": "w32",
            "64bit": "w64",
        }.get(bits_str, bits_str)
        p = "{progname} {w_bits}".format(
            progname = escape(lib.meta.MYPAINT_PROGRAM_NAME),
            w_bits = escape(bits_str),
        )
    d.set_program_name(p)
    d.set_version(v)
    d.set_copyright(escape(COPYRIGHT_STRING))
    d.set_website(WEBSITE_URI)
    d.set_logo(app.pixmaps.mypaint_logo)
    d.set_license(LICENSE_SUMMARY)
    d.set_wrap_license(True)
    d.set_authors(_AUTHOR_CREDITS)
    d.set_artists(_ARTIST_CREDITS)
    d.set_translator_credits(_TRANSLATOR_CREDITS)
    d.run()
    d.destroy()
Beispiel #6
0
    def init_view(self):
        self._init_model()
        store = Gtk.ListStore(str, str)  # columns: <our_id, display_markup>
        markup = C_(
            "view controls: dropdown: item markup",
            u"<i>{builtin_view_name}</i>",
        ).format(builtin_view_name=escape(
            lib.layervis.UNSAVED_VIEW_DISPLAY_NAME), )
        # None has a special meaning for GTK combo ID columns,
        # so we substitute the empty string. Corrolory: you can't name
        # views to the empty string.
        store.append([u"", markup])
        store.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        self._store = store

        combo = self.view.current_view_combo
        combo.set_model(store)
        combo.set_id_column(0)

        cell = self.view.layer_text_cell
        combo.add_attribute(cell, "markup", 1)

        self._refresh_ui()
Beispiel #7
0
    def init_view(self):
        self._init_model()
        store = Gtk.ListStore(str, str)   # columns: <our_id, display_markup>
        markup = C_(
            "view controls: dropdown: item markup",
            u"<i>{builtin_view_name}</i>",
        ).format(
            builtin_view_name=escape(lib.layervis.UNSAVED_VIEW_DISPLAY_NAME),
        )
        # None has a special meaning for GTK combo ID columns,
        # so we substitute the empty string. Corrolory: you can't name
        # views to the empty string.
        store.append([u"", markup])
        store.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        self._store = store

        combo = self.view.current_view_combo
        combo.set_model(store)
        combo.set_id_column(0)

        cell = self.view.layer_text_cell
        combo.add_attribute(cell, "markup", 1)

        self._refresh_ui()
Beispiel #8
0
    def _layer_description_markup(layer):
        """GMarkup text description of a layer, used in the list."""
        name_markup = None
        description = None

        if layer is None:
            name_markup = escape(lib.layer.PlaceholderLayer.DEFAULT_NAME)
            description = C_(
                "Layers: description: no layer (\"never happens\" condition!)",
                u"?layer",
            )
        elif layer.name is None:
            name_markup = escape(layer.DEFAULT_NAME)
        else:
            name_markup = escape(layer.name)

        if layer is not None:
            desc_parts = []
            if isinstance(layer, lib.layer.LayerStack):
                name_markup = "<i>{}</i>".format(name_markup)

            # Mode (if it's interesting)
            if layer.mode in lib.modes.MODE_STRINGS:
                if layer.mode != lib.modes.default_mode():
                    s, d = lib.modes.MODE_STRINGS[layer.mode]
                    desc_parts.append(s)
            else:
                desc_parts.append(
                    C_(
                        "Layers: description parts: unknown mode (fallback str!)",
                        u"?mode",
                    ))

            # Visibility and opacity (if interesting)
            if not layer.visible:
                desc_parts.append(
                    C_(
                        "Layers: description parts: layer hidden",
                        u"Hidden",
                    ))
            elif layer.opacity < 1.0:
                desc_parts.append(
                    C_("Layers: description parts: opacity percentage",
                       u"%d%% opaque" % (round(layer.opacity * 100), )))

            # Locked flag (locked is interesting)
            if layer.locked:
                desc_parts.append(
                    C_(
                        "Layers dockable: description parts: layer locked flag",
                        u"Locked",
                    ))

            # Description of the layer's type.
            # Currently always used, for visual rhythm reasons, but it goes
            # on the end since it's perhaps the least interesting info.
            if layer.TYPE_DESCRIPTION is not None:
                desc_parts.append(layer.TYPE_DESCRIPTION)
            else:
                desc_parts.append(
                    C_(
                        "Layers: description parts: unknown type (fallback str!)",
                        u"?type",
                    ))

            # Stitch it all together
            if desc_parts:
                description = C_(
                    "Layers dockable: description parts joiner text",
                    u", ",
                ).join(desc_parts)
            else:
                description = None

        if description is None:
            markup_template = C_(
                "Layers dockable: markup for a layer with no description",
                u"{layer_name}",
            )
        else:
            markup_template = C_(
                "Layers dockable: markup for a layer with a description",
                '<span size="smaller">{layer_name}\n'
                '<span size="smaller">{layer_description}</span>'
                '</span>')

        markup = markup_template.format(
            layer_name=name_markup,
            layer_description=escape(description),
        )
        return markup
Beispiel #9
0
    def _layer_description_markup(layer):
        """GMarkup text description of a layer, used in the list."""
        name_markup = None
        description = None

        if layer is None:
            name_markup = escape(lib.layer.PlaceholderLayer.DEFAULT_NAME)
            description = C_(
                "Layers: description: no layer (\"never happens\" condition!)",
                u"?layer",
            )
        elif layer.name is None:
            name_markup = escape(layer.DEFAULT_NAME)
        else:
            name_markup = escape(layer.name)

        if layer is not None:
            desc_parts = []
            if isinstance(layer, lib.layer.LayerStack):
                name_markup = "<i>{}</i>".format(name_markup)

            # Mode (if it's interesting)
            if layer.mode in lib.modes.MODE_STRINGS:
                if layer.mode != lib.modes.DEFAULT_MODE:
                    s, d = lib.modes.MODE_STRINGS[layer.mode]
                    desc_parts.append(s)
            else:
                desc_parts.append(C_(
                    "Layers: description parts: unknown mode (fallback str!)",
                    u"?mode",
                ))

            # Visibility and opacity (if interesting)
            if not layer.visible:
                desc_parts.append(C_(
                    "Layers: description parts: layer hidden",
                    u"Hidden",
                ))
            elif layer.opacity < 1.0:
                desc_parts.append(C_(
                    "Layers: description parts: opacity percentage",
                    u"%d%% opaque" % (round(layer.opacity * 100),)
                ))

            # Locked flag (locked is interesting)
            if layer.locked:
                desc_parts.append(C_(
                    "Layers dockable: description parts: layer locked flag",
                    u"Locked",
                ))

            # Description of the layer's type.
            # Currently always used, for visual rhythm reasons, but it goes
            # on the end since it's perhaps the least interesting info.
            if layer.TYPE_DESCRIPTION is not None:
                desc_parts.append(layer.TYPE_DESCRIPTION)
            else:
                desc_parts.append(C_(
                    "Layers: description parts: unknown type (fallback str!)",
                    u"?type",
                ))

            # Stitch it all together
            if desc_parts:
                description = C_(
                    "Layers dockable: description parts joiner text",
                    u", ",
                ).join(desc_parts)
            else:
                description = None

        if description is None:
            markup_template = C_(
                "Layers dockable: markup for a layer with no description",
                u"{layer_name}",
            )
        else:
            markup_template = C_(
                "Layers dockable: markup for a layer with a description",
                '<span size="smaller">{layer_name}\n'
                '<span size="smaller" alpha="50%">{layer_description}</span>'
                '</span>'
            )

        markup = markup_template.format(
            layer_name=name_markup,
            layer_description=escape(description),
        )
        return markup