Skip to content

Commit

Permalink
Create about dialog from appstream metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmardojai committed Jul 31, 2024
1 parent 0562b4d commit 450ac13
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 29 deletions.
1 change: 1 addition & 0 deletions data/app.drey.Dialect.metainfo.xml.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<url type="homepage">https://dialectapp.org/</url>
<url type="donation">https://opencollective.com/dialect/</url>
<url type="bugtracker">https://github.com/dialect-app/dialect/issues/</url>
<url type="help">https://github.com/dialect-app/dialect/discussions/</url>
<url type="translate">https://hosted.weblate.org/engage/dialect/</url>
<url type="vcs-browser">https://github.com/dialect-app/dialect/</url>
<!-- developer_name tag deprecated with Appstream 1.0 -->
Expand Down
17 changes: 0 additions & 17 deletions dialect/about.blp

This file was deleted.

3 changes: 2 additions & 1 deletion dialect/dialect.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<file compressed="true">style.css</file>
<file compressed="true">style-dark.css</file>

<file compressed="true" preprocess="xml-stripblanks">about.ui</file>
<file compressed="true" preprocess="xml-stripblanks">preferences.ui</file>
<file compressed="true" preprocess="xml-stripblanks">shortcuts.ui</file>
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">widgets/lang_row.ui</file>
<file compressed="true" preprocess="xml-stripblanks">widgets/lang_selector.ui</file>
<file compressed="true" preprocess="xml-stripblanks">widgets/provider_preferences.ui</file>
<file compressed="true" preprocess="xml-stripblanks">widgets/theme_switcher.ui</file>

<file compressed="true" preprocess="xml-stripblanks" alias="appdata.xml">@appstream-path@</file>
</gresource>

<gresource prefix="/app/drey/Dialect/icons/scalable/emblems/">
Expand Down
13 changes: 6 additions & 7 deletions dialect/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
gi.require_version("Secret", "1")
gi.require_version("Soup", "3.0")

from gi.repository import Adw, Gio, GLib, Gst, Gtk
from gi.repository import Adw, Gio, GLib, Gst
except ImportError or ValueError:
logging.error("Error: GObject dependencies not met.")

Expand Down Expand Up @@ -181,13 +181,12 @@ def _on_preferences(self, _action, _param):

def _on_about(self, _action, _param):
"""Show about dialog"""
builder = Gtk.Builder.new_from_resource(f"{RES_PATH}/about.ui")
about: Adw.AboutDialog = builder.get_object("about") # type: ignore

about.props.application_icon = APP_ID
about.props.version = VERSION
about = Adw.AboutDialog.new_from_appdata(f"{RES_PATH}/appdata.xml", VERSION)
about.props.version = VERSION # For development version
about.props.comments = _("A translation app for GNOME.")
about.props.copyright = _("Copyright 2020–⁠2024 The Dialect Authors")
about.props.developers = ["Mufeed Ali", "Rafael Mardojai CM http://rafaelmardojai.com", "Libretto"]

about.props.translator_credits = _("translator-credits")
about.add_link(_("Donate"), "https://opencollective.com/dialect")

about.present(self.window)
Expand Down
12 changes: 8 additions & 4 deletions dialect/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.proje
# Resources
blueprints = custom_target('blueprints',
input: files(
'about.blp',
'shortcuts.blp',
'window.blp',
'widgets/lang_selector.blp',
Expand All @@ -17,15 +16,20 @@ blueprints = custom_target('blueprints',
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
)

gresource_conf = configuration_data()
gresource_conf.set('appstream-path', appstream_file.full_path())
gnome.compile_resources('dialect',
'dialect.gresource.xml',
dependencies: blueprints,
configure_file(
input: 'dialect.gresource.xml',
output: 'dialect.gresource.xml',
configuration: gresource_conf,
),
dependencies: [blueprints, appstream_file],
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)


# Generate dialect bin
configure_file(
input: 'dialect.in',
Expand Down

0 comments on commit 450ac13

Please sign in to comment.