refactor: remove thin layer for Gtk.AboutDialog

This commit is contained in:
Romain Failliot 2023-04-08 15:00:46 -04:00
parent d4f2032972
commit f8f0b0618c
4 changed files with 38 additions and 39 deletions

View File

@ -21,6 +21,7 @@ from gettext import gettext as _
from typing import Final
APP_NAME: Final[str] = 'Diffuse'
APP_ID: Final[str] = 'io.github.mightycreak.Diffuse'
COPYRIGHT: Final[str] = '''{copyright} © 2006-2019 Derrick Moser
{copyright} © 2015-2023 Romain Failliot'''.format(copyright=_("Copyright"))
WEBSITE: Final[str] = 'https://mightycreak.github.io/diffuse/'

View File

@ -22,7 +22,6 @@ import os
from gettext import gettext as _
from typing import Optional
from diffuse import constants
from diffuse import utils
import gi # type: ignore
@ -31,39 +30,6 @@ gi.require_version('Gtk', '3.0')
from gi.repository import GObject, Gtk # type: ignore # noqa: E402
# the about dialog
class AboutDialog(Gtk.AboutDialog):
def __init__(self, parent: Gtk.Widget) -> None:
Gtk.AboutDialog.__init__(self)
self.set_transient_for(parent)
self.set_logo_icon_name('io.github.mightycreak.Diffuse')
self.set_program_name(constants.APP_NAME)
self.set_version(constants.VERSION)
self.set_comments(_('Diffuse is a graphical tool for merging and comparing text files.'))
self.set_copyright(constants.COPYRIGHT)
self.set_website(constants.WEBSITE)
self.set_authors(['Derrick Moser <derrick_moser@yahoo.com>',
'Romain Failliot <romain.failliot@foolstep.com>'])
self.set_translator_credits(_('translator-credits'))
license_text = [
constants.APP_NAME + ' ' + constants.VERSION + '\n\n',
constants.COPYRIGHT + '\n\n',
'''This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.''']
self.set_license(''.join(license_text))
# custom dialogue for picking files with widgets for specifying the encoding
# and revision
class FileChooserDialog(Gtk.FileChooserDialog):

View File

@ -37,7 +37,7 @@ class DiffuseApplication(Gtk.Application):
def __init__(self, sysconfigdir):
super().__init__(
application_id='io.github.mightycreak.Diffuse',
application_id=constants.APP_ID,
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.NON_UNIQUE)
self.window = None

View File

@ -28,7 +28,7 @@ from typing import List, Optional
from urllib.parse import urlparse
from diffuse import constants, utils
from diffuse.dialogs import AboutDialog, FileChooserDialog, NumericDialog, SearchDialog
from diffuse.dialogs import FileChooserDialog, NumericDialog, SearchDialog
from diffuse.preferences import Preferences
from diffuse.resources import theResources
from diffuse.utils import LineEnding
@ -1733,9 +1733,41 @@ class DiffuseWindow(Gtk.ApplicationWindow):
# callback for the about menu item
def about_cb(self, widget, data):
dialog = AboutDialog(self.get_toplevel())
dialog.run()
dialog.destroy()
authors = [
'Derrick Moser <derrick_moser@yahoo.com>',
'Romain Failliot <romain.failliot@foolstep.com>'
]
license = f'''{constants.APP_NAME} {constants.VERSION}
{constants.COPYRIGHT}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.'''
dialog = Gtk.AboutDialog(
transient_for=self.get_toplevel(),
modal=True,
program_name=constants.APP_NAME,
logo_icon_name=constants.APP_ID,
version=constants.VERSION,
comments=_('Diffuse is a graphical tool for merging and comparing text files.'),
copyright=constants.COPYRIGHT,
website=constants.WEBSITE,
authors=authors,
translator_credits=_('translator-credits'),
license=license)
dialog.present()
def _append_buttons(box, size, specs):