<commit_before>;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause

;;;; This file produces two warnings due to redefinitions of
;;;; renderer-thread-p and ffi-initialize.
;;;;
;;;; This is necessary to modify the behavior of renderer-gtk to use
;;;; gobject to launch/manage the main GTK thread. When/if this
;;;; renderer will fully utilize gobject introspection (by taking the
;;;; changes made on the respectively named branch, and reapplying
;;;; them), then these errors will disappear, as there will be no
;;;; reliance on renderer-gtk (and thus, no redefinition).

(in-package :nyxt)

(setf +renderer+ "GI-GTK")
(handler-bind ((warning #'muffle-warning))
  (defun renderer-thread-p ()
    (string= "main thread" (bt:thread-name (bt:current-thread))))
  (defmethod ffi-initialize ((browser gtk-browser) urls startup-timestamp)
    (log:debug "Initializing GI-GTK Interface")
    (setf gtk-running-p t)
    (let ((main-thread (bt:make-thread
                        (lambda ()
                          (with-protect ("Error on GTK thread: ~a" :condition)
                            (glib:g-set-prgname "nyxt")
                            (gdk:gdk-set-program-class "Nyxt")
                            (gir:invoke ((gir:ffi "Gtk") 'main))))
                        :name "main thread")))
      (finalize browser urls startup-timestamp)
      (unless *run-from-repl-p*
        (bt:join-thread main-thread)))))<commit_msg>renderer-gi-gtk.lisp: do not try to set the program class in GTK4, specify GTK3<commit_after>;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause

;;;; This file produces two warnings due to redefinitions of
;;;; renderer-thread-p and ffi-initialize.
;;;;
;;;; This is necessary to modify the behavior of renderer-gtk to use
;;;; gobject to launch/manage the main GTK thread. When/if this
;;;; renderer will fully utilize gobject introspection (by taking the
;;;; changes made on the respectively named branch, and reapplying
;;;; them), then these errors will disappear, as there will be no
;;;; reliance on renderer-gtk (and thus, no redefinition).

(in-package :nyxt)

(setf +renderer+ "GI-GTK")
(handler-bind ((warning #'muffle-warning))
  (defun renderer-thread-p ()
    (string= "main thread" (bt:thread-name (bt:current-thread))))
  (defmethod ffi-initialize ((browser gtk-browser) urls startup-timestamp)
    (log:debug "Initializing GI-GTK Interface")
    (setf gtk-running-p t)
    (let ((main-thread (bt:make-thread
                        (lambda ()
                          (with-protect ("Error on GTK thread: ~a" :condition)
                            (glib:g-set-prgname "nyxt")
                            #+GTK-3-4
                            (gdk:gdk-set-program-class "Nyxt")
                            (gir:invoke ((gir:ffi "Gtk" "3.0") 'main))))
                        :name "main thread")))
      (finalize browser urls startup-timestamp)
      (unless *run-from-repl-p*
        (bt:join-thread main-thread)))))
{'fraction_non_alphanumeric': 0.13543721236028927, 'fraction_numerical': 0.0026298487836949377, 'mean_word_length': 2.6884848484848485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2616327', 'n_tokens_mistral': 941, 'n_tokens_neox': 900, 'n_words': 279}