1280
  C   ˆl–Ým_Jµ2Ž¥2 Z¸ Ül*bÑ¿�þBÇ*ÍÊ&ŠÈrÏÂ„qÇßÁ_ŠI|¥�+Wé3ž¯ÁÀ ?÷     # a graphical (GTK+) user interface
#   Written by Luca Bruno <lethalman88@gmail.com>
#   Based on gnome-reportbug work done by Philipp Kern <pkern@debian.org>
#   Copyright (C) 2006 Philipp Kern
#   Copyright (C) 2008-2009 Luca Bruno
#   Copyright (C) 2021-2022 Takahide Nojima
#
# This program is freely distributable per the following license:
#
#  Permission to use, copy, modify, and distribute this software and its
#  documentation for any purpose and without fee is hereby granted,
#  provided that the above copyright notice appears in all copies and that
#  both that copyright notice and this permission notice appear in
#  supporting documentation.
#
#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
#  SOFTWARE.

from reportbug.exceptions import UINotImportable

import os
if not ('DISPLAY' in os.environ or 'WAYLAND_DISPLAY' in os.environ):
    raise UINotImportable('No graphical display detected, falling back to text UI.')

try:
    import gi

    gi.require_version('GLib', '2.0')
    from gi.repository import GLib

    gi.require_version('Pango', '1.0')
    from gi.repository import Pango

    gi.require_version('Gdk', '3.0')
    from gi.repository import Gdk

    gi.require_version('GdkPixbuf', '2.0')
    from gi.repository import GdkPixbuf

    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk

    gi.require_version('GtkSource', '4')
    from gi.repository import GtkSource

    gi.require_foreign('cairo')
except ImportError:
    raise UINotImportable('Please install the reportbug-gtk package to use this interface.')

import sys
import re
import traceback
from queue import Queue
import threading
import textwrap
import signal

from reportbug.exceptions import NoPackage, NoBugs, QuertBTSError
from reportbug import debbugs
from reportbug.urlutils import launch_browser

ISATTY = True
DEBIAN_LOGO = "/usr/share/pixmaps/debian-logo.png"

global application, assistant, report_message, reportbug_context, ui_context
global Vte

gtkspellcheck = None


# Utilities


def _describe_context(context):
    if context == ui_context:
        return '<MainContext of UI thread>'
    elif context == reportbug_context:
        return '<MainContext of reportbug thread>'
    else:
        return repr(context)


def _assert_context(expected):
    really = GLib.MainContext.ref_thread_default()

    # This compares by pointer value of the underlying GMainContext
    if really != expected:
        raise AssertionError('Function should be called in %s but was called in %s' %
                             (_describe_context(expected), _describe_context(really)))

    if not really.is_owner():
        raise AssertionError('Function should be called with %s acquired')


def _exit():
    os.kill(os.getpid(), signal.SIGINT)


def highlight(s):
    return '<b>%s</b>' % s


re_markup_free = re.compile("<.*?>")


def markup_free(s):
    return re_markup_free.sub("", s)


def ask_free(s):
    s = s.strip()
    if s[-1] in ('?', ':'):
        return s[:-1]
    return s


def create_scrollable(widget, with_viewport=False):
    _assert_context(ui_context)
    scrolled = Gtk.ScrolledWindow()
    scrolled.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
    scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    if with_viewport:
        scrolled.add_with_viewport(widget)
    else:
        scrolled.add(widget)
    return scrolled


def info_dialog(message):
    _assert_context(ui_context)
    dialog = Gtk.MessageDialog(assistant, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                               Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, mes