<commit_before>const EosKnowledge = imports.gi.EosKnowledge;
const EvinceDocument = imports.gi.EvinceDocument;
const EvinceView = imports.gi.EvinceView;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;

/**
 * Class: PDFView
 *
 * The view used to display PDFs in the article page.
 *
 * Makes all the Evince calls necessary to load a PDF. Only exposes one
 * <load_uri> function.
 *
 * Parent class:
 *     Gtk.ScrolledWindow
 */
const PDFView = new Lang.Class({
    Name: 'PDFView',
    GTypeName: 'EknPDFView',
    Extends: Gtk.ScrolledWindow,

    _init: function (props) {
        this.parent(props);

        this.get_style_context().add_class(EosKnowledge.STYLE_CLASS_PDF_VIEW);
    },

    /**
     *  Method: load_uri
     *
     *  Loads the given uri of a PDF in the view.
     */
    load_uri: function (uri) {
        let evince_document = EvinceDocument.Document.factory_get_document(
            uri, EvinceDocument.DocumentLoadFlags.NONE, null);
        let document_model = new EvinceView.DocumentModel({
            document: evince_document,
        });
        let view = new EvinceView.View();
        view.set_model(document_model);

        let child = this.get_child();
        if (child !== null)
            this.remove(child);
        this.add(view);
    },
});<commit_msg>Give PDF view a maximum width<commit_after>const EosKnowledge = imports.gi.EosKnowledge;
const EvinceDocument = imports.gi.EvinceDocument;
const EvinceView = imports.gi.EvinceView;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;

const _MAX_PDF_VIEW_WIDTH = 1300;

/**
 * Class: PDFView
 *
 * The view used to display PDFs in the article page.
 *
 * Makes all the Evince calls necessary to load a PDF. Only exposes one
 * <load_uri> function.
 *
 * Parent class:
 *     Gtk.ScrolledWindow
 */
const PDFView = new Lang.Class({
    Name: 'PDFView',
    GTypeName: 'EknPDFView',
    Extends: Gtk.ScrolledWindow,

    _init: function (props) {
        props = props || {};
        props.halign = Gtk.Align.CENTER;
        this.parent(props);

        this.get_style_context().add_class(EosKnowledge.STYLE_CLASS_PDF_VIEW);
    },

    /**
     *  Method: load_uri
     *
     *  Loads the given uri of a PDF in the view.
     */
    load_uri: function (uri) {
        let evince_document = EvinceDocument.Document.factory_get_document(
            uri, EvinceDocument.DocumentLoadFlags.NONE, null);
        let document_model = new EvinceView.DocumentModel({
            document: evince_document,
        });
        let view = new EvinceView.View();
        view.set_model(document_model);

        let child = this.get_child();
        if (child !== null)
            this.remove(child);
        this.add(view);
    },

    vfunc_get_preferred_width: function () {
        let [minimal, natural] = this.parent();
        return [Math.min(minimal, _MAX_PDF_VIEW_WIDTH), _MAX_PDF_VIEW_WIDTH];
    }
});
{'fraction_non_alphanumeric': 0.10924081071796633, 'fraction_numerical': 0.0013740982480247338, 'mean_word_length': 2.6907477820025347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6470752', 'n_tokens_mistral': 939, 'n_tokens_neox': 910, 'n_words': 222}