gi.require_version raises ValueError if it can't find a module. Catching
it allows for successful fallback to text mode in case gir1.2-vte is not
available.
The dpkg status database and the reportbug configuration file might use
character sets different from the current locale. This can be
problematic when reading and decoding the file contents: The default
decoding error handler ("strict") errors out in such cases. Picking a
different one is more robust.
If we import it globally (in the reportbug thread), we get:
sqlite3.ProgrammingError: SQLite objects created in a thread can only be
used in that same thread. The object was created in thread id
<some large number> and this is thread id <some other large number>
Subclasses of Gtk objects are part of the Gtk API and must therefore
only be touched from the GLib "default main-context".
This means we have to rearrange initialization so we start the
main thread before we construct the rest of the objects.
A main context represents a set of callbacks, sockets and other
event sources, and each main-context can be acquired (owned) by at
most one thread at a time. A main-context is normally owned by the
same thread for its entire lifetime, and that's how we use them here.
The "thread-default main context" is how GLib and GIO track the thread
in which the callback for an async operation should be called; we don't
actually use any GIO async operations at the moment, but it's a good
idea to set it correctly. This also gives us the ability to give better
diagnostics than just asserting is_owner(), because we can show both
the expected thread and the actual thread in the assertion message.
This commit is made based on the following implication:
- Reportbug *will* always use debian-swirl as its icon
- The standard icon for debian-swirl is from gnome-icon-theme
- Reportbug is suitable to provide "places/debian-swirl" icon
in fallback "hicolor" theme.
As a result, the following changes were made:
- Do not install bundled debian-swirl.svg into private dir,
as previously written in setup.py.
+ Instead, install SVG file into
$prefix/icons/hicolor/scalable/places/ using dh_install.
* On GNOME system when $prefix/icons/gnome/ dir exists, this svg
file will be overridden by the icon provided by GNOME.
* If *any* other icon theme (e.g., Numix, etc) provides the
debian-swirl icon, that will override the svg file provided by
reportbug.
* If no other icon theme exists and GNOME is not installed, the
fallback (hicolor theme) svg icon will be used.
I believe that is enough to fix Debian Bug #836253.
For more information, please refer to the Icon Theme Specification:
https://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html.