Skip to content

Commit

Permalink
Bunch of large changes
Browse files Browse the repository at this point in the history
- Basic i18n support (untested)
- Fix flatpak build
- Clarify some docs and metainfo
- Improved project structure
- Remove user-facing switch for custom definitions
- Improve some strings
- Change default width of settings window to 450
- Do not show cdef completions when cdef is disabled
  • Loading branch information
mufeedali committed Mar 25, 2022
1 parent 096013f commit 775fa2e
Show file tree
Hide file tree
Showing 26 changed files with 347 additions and 113 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
Wordbook
</h1>

<p align="center">Lookup definitions of any term</p>
<p align="center">Lookup definitions of any English term</p>

<p align="center">
<img src="images/ss2.png?raw=true" alt="Searching (Light mode)" width="290">
</p>

<p align="center">
<b>Wordbook</b> is a dictionary application built for GNOME using the <a href="https://github.com/globalwordnet/english-wordnet">Open English WordNet</a> database for definitions and the reliable eSpeak for pronunciations (both audio and phoneme).
<b>Wordbook</b> is an offline English-English dictionary application built for GNOME using the <a href="https://github.com/globalwordnet/english-wordnet">Open English WordNet</a> database for definitions and the reliable eSpeak for pronunciations (both audio and phoneme).
</p>

## Features
Expand Down
2 changes: 1 addition & 1 deletion build-aux/flatpak/com.github.fushinari.Wordbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"type": "archive",
"url": "https://github.com/espeak-ng/pcaudiolib/archive/1.2.tar.gz",
"sha256": "82bb8df1cbaee6abca6f3e8698521cc398eba2284dde1fade07d72517eb34a2f"
"sha256": "44b9d509b9eac40a0c61585f756d76a7b555f732e8b8ae4a501c8819c59c6619"
}
]
},
Expand Down
12 changes: 0 additions & 12 deletions data/com.github.fushinari.Wordbook.desktop

This file was deleted.

14 changes: 14 additions & 0 deletions data/com.github.fushinari.Wordbook.desktop.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=Wordbook
Exec=wordbook
Comment=Lookup definitions for any English term
Terminal=false
Type=Application
Icon=com.github.fushinari.Wordbook
Categories=Education;GTK;
# Translators: These are search terms to find this application. Do NOT translate or localize the semicolons. The list MUST also end with a semicolon.
Keywords=dictionary;
# Translators: Do NOT translate or transliterate this text (these are enum types)!
X-Purism-FormFactor=Workstation;Mobile;
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<project_license>GPL-3.0-or-later</project_license>

<name>Wordbook</name>
<summary>Lookup definitions for any term</summary>
<summary>Lookup definitions for any English term</summary>
<description>
<p>Wordbook is an offline dictionary application powered by WordNet and eSpeak.</p>
<p>Wordbook is an offline English-English dictionary application powered by WordNet and eSpeak.</p>
<p>Features:</p>
<ul>
<li>Fully offline after initial data download</li>
Expand Down Expand Up @@ -80,7 +80,10 @@
</description>
</release>
</releases>

<kudos>
<kudo>ModernToolkit</kudo>
<kudo>HiDpiIcon</kudo>
</kudos>
<custom>
<value key="Purism::form_factor">workstation</value>
<value key="Purism::form_factor">mobile</value>
Expand Down
4 changes: 2 additions & 2 deletions data/icons/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ message('Installing icons')
# Scalable
icondir = join_paths(get_option('datadir'), 'icons/hicolor/scalable/apps')
install_data (
app_id + '.svg',
application_id + '.svg',
install_dir: icondir
)

# Symbolic
icondir = join_paths(get_option('datadir'), 'icons/hicolor/symbolic/apps')
install_data (
app_id + '-symbolic.svg',
application_id + '-symbolic.svg',
install_dir: icondir
)

27 changes: 11 additions & 16 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
gnome = import('gnome')

gnome.compile_resources('wordbook',
'com.github.fushinari.Wordbook.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)

subdir('icons')
subdir('resources')

desktop_file = configure_file(
input: app_id + '.desktop',
output: app_id + '.desktop',
copy: true,
desktop_file = i18n.merge_file(
input: application_id + '.desktop.in',
output: application_id + '.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
)
Expand All @@ -25,10 +20,10 @@ if desktop_utils.found()
)
endif

appstream_file = configure_file(
input: app_id + '.appdata.xml',
output: app_id + '.appdata.xml',
copy: true,
appstream_file = i18n.merge_file(
input: application_id + '.metainfo.xml.in',
output: application_id + '.metainfo.xml',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'appdata')
)
Expand All @@ -40,7 +35,7 @@ if appstream_util.found()
)
endif

install_data(app_id + '.gschema.xml',
install_data(application_id + '.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)

Expand Down
7 changes: 7 additions & 0 deletions data/resources/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources = gnome.compile_resources(
'resources',
'resources.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/github/fushinari/Wordbook">
<file compressed="true">ui/css/style.css</file>
<gresource prefix="/com/github/fushinari/Wordbook/">
<file compressed="true">style.css</file>

<file compressed="true" preprocess="xml-stripblanks">ui/menu.xml</file>
<file compressed="true" preprocess="xml-stripblanks">ui/menu.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/settings_window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/shortcuts_window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/window.ui</file>
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions data/ui/menu.xml → data/resources/ui/menu.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
<attribute name="action">app.search-selected</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Random Word</attribute>
<attribute name="label" translatable="yes">_Random Word</attribute>
<attribute name="action">app.random-word</attribute>
</item>
</section>
<section>
<attribute name="id">edit-section</attribute>
<item>
<attribute name="label" translatable="yes">Preferences</attribute>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<attribute name="id">help-section</attribute>
<item>
<attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
</item>
<item>
<attribute name="label" translatable="yes">About Wordbook</attribute>
<attribute name="label" translatable="yes">_About Wordbook</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<template class="SettingsWindow" parent="HdyPreferencesWindow">
<property name="can-focus">False</property>
<property name="modal">True</property>
<property name="default-width">380</property>
<property name="default-width">450</property>
<property name="default-height">350</property>
<property name="destroy-with-parent">True</property>
<property name="window-position">center-on-parent</property>
Expand All @@ -20,22 +20,6 @@
<object class="HdyPreferencesGroup">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="HdyActionRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="title" translatable="yes">Custom Definitions</property>
<property name="activatable-widget">cdef_switch</property>
<child>
<object class="GtkSwitch" id="cdef_switch">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="HdyActionRow">
<property name="visible">True</property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">True</property>
<property name="title" translatable="yes" context="shortcut window">Show Shortcuts</property>
<property name="accelerator">&lt;Primary&gt;question</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Preferences</property>
<property name="accelerator">&lt;Primary&gt;comma</property>
</object>
Expand Down
8 changes: 4 additions & 4 deletions data/ui/window.ui → data/resources/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
<object class="GtkLabel" id="loading_label">
<property name="visible">True</property>
<property name="margin-bottom">4</property>
<property name="label" translatable="yes">Loading...</property>
<property name="label" translatable="yes">Loading</property>
<style>
<class name="dim-label"/>
</style>
Expand Down Expand Up @@ -253,7 +253,7 @@
<property name="visible">True</property>
<property name="icon-name">com.github.fushinari.Wordbook-symbolic</property>
<property name="title" translatable="yes">Wordbook</property>
<property name="description" translatable="yes">Lookup definitions of any term</property>
<property name="description" translatable="yes">Lookup definitions of any English term</property>
</object>
<packing>
<property name="name">welcome_page</property>
Expand Down Expand Up @@ -295,7 +295,7 @@
<child>
<object class="GtkLabel" id="term_view">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;span size=&quot;large&quot; weight=&quot;bold&quot;&gt;Term&lt;/span&gt;</property>
<property name="label" translatable="no">&lt;span size=&quot;large&quot; weight=&quot;bold&quot;&gt;Term&lt;/span&gt;</property>
<property name="use-markup">True</property>
<property name="single-line-mode">True</property>
<property name="xalign">0</property>
Expand Down Expand Up @@ -396,7 +396,7 @@
</object>
<packing>
<property name="name">spinner_page</property>
<property name="title" translatable="yes">Loading</property>
<property name="title" translatable="yes">Loading</property>
<property name="position">4</property>
</packing>
</child>
Expand Down
53 changes: 44 additions & 9 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
project('wordbook',
version: '0.3.1',
project(
'wordbook',
version: '0.3.1',
meson_version: '>= 0.50.0',
default_options: [ 'warning_level=2',
],
default_options: [ 'warning_level=2',
],
)

app_id = 'com.github.fushinari.Wordbook'

i18n = import('i18n')
gnome = import('gnome')
python = import('python')

pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
profile = get_option('profile')
moduledir = join_paths(pkgdatadir, meson.project_name())
base_id = 'com.github.fushinari.Wordbook'

message('Looking for dependencies')
py_installation = python.find_installation('python3')
Expand All @@ -25,8 +24,44 @@ dependency('gobject-introspection-1.0', version: '>= 1.35.0')
dependency('gtk+-3.0', version: '>= 3.22')
dependency('glib-2.0')
dependency('pygobject-3.0', version: '>= 3.29.1')
dependency('libhandy-1')

glib_compile_resources = find_program('glib-compile-resources', required: true)
glib_compile_schemas = find_program('glib-compile-schemas', required: true)
desktop_file_validate = find_program('desktop-file-validate', required: false)
appstream_util = find_program('appstream-util', required: false)

version = meson.project_version()
version_array = version.split('.')
major_version = version_array[0].to_int()
minor_version = version_array[1].to_int()
version_micro = version_array[2].to_int()

prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
localedir = prefix / get_option('localedir')

pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
profile = get_option('profile')
moduledir = join_paths(pkgdatadir, meson.project_name())

if get_option('profile') == 'development'
profile = 'Devel'
vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
if vcs_tag == ''
version_suffix = '-devel'
else
version_suffix = '-@0@'.format(vcs_tag)
endif
application_id = '@0@.@1@'.format(base_id, profile)
else
profile = ''
version_suffix = ''
application_id = base_id
endif

subdir('data')
subdir('wordbook')
subdir('po')

meson.add_install_script('build-aux/meson/postinstall.py')
3 changes: 2 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ option(
'default',
'development'
],
value: 'default'
value: 'default',
description: 'The build profile for Wordbook. One of "default" or "development".'
)
Empty file added po/LINGUAS
Empty file.
7 changes: 7 additions & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data/resources/ui/menu.ui
data/resources/ui/settings_window.ui
data/resources/ui/shortcuts_window.ui
data/resources/ui/window.ui
wordbook/main.py
wordbook/settings_window.py
wordbook/window.py
1 change: 1 addition & 0 deletions po/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
i18n.gettext('wordbook', preset: 'glib')
Loading

0 comments on commit 775fa2e

Please sign in to comment.