Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: branding support #930

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions branding.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Branding
#
# You are kindly asked to replace all links if you are
# distributing a build with custom branding.
#
# Support will not be provided to your users without
# prior agreement.
#
# You may not make your builds publicly available
# without modifying the app ID and all relevant files,
# as it won't be able to co-exist with Tuba.
#
# This is mostly aimed at organizations for internal
# usage, limited to their instances.
NAME=Tuba
WEBSITE=https://github.com/GeopJr/Tuba
ISSUES_WEBSITE=https://github.com/GeopJr/Tuba/issues
SUPPORT_WEBSITE=https://matrix.to/%23/%23tuba:gnome.org
DONATE_WEBSITE=https://geopjr.dev/donate
TRANSLATE_WEBSITE=https://hosted.weblate.org/engage/tuba/
WIKI_WEBSITE=https://github.com/GeopJr/Tuba/wiki
# Prefilled instance when logging in.
# This does not limit your users from
# logging in to other instances.
# e.g. faraway.town
DEFAULT_INSTANCE=
22 changes: 13 additions & 9 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,27 @@ endif
devel = get_option('devel')
distro = get_option('distro')

branding = import('keyval').load('branding.conf')
assert(branding.get('NAME') != '', 'Branding: Name cannot be empty.')

# Setup configuration file
config = configuration_data()
config.set('EXEC_NAME', meson.project_name())
config.set('GETTEXT_PACKAGE', meson.project_name())
config.set('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
config.set('DOMAIN', meson.project_name ())
config.set('G_LOG_DOMAIN', 'Tuba')
config.set('G_LOG_DOMAIN', branding.get('NAME', 'Tuba'))
config.set('RESOURCES', '/' + '/'.join(meson.project_name().split('.')) + '/')
config.set('VERSION', meson.project_version())
config.set('PREFIX', get_option('prefix'))
config.set('NAME', 'Tuba')
config.set('WEBSITE', 'https://github.com/GeopJr/Tuba')
config.set('ISSUES_WEBSITE', 'https://github.com/GeopJr/Tuba/issues')
config.set('SUPPORT_WEBSITE', 'https://matrix.to/#/#tuba:gnome.org')
config.set('DONATE_WEBSITE', 'https://geopjr.dev/donate')
config.set('TRANSLATE_WEBSITE', 'https://hosted.weblate.org/engage/tuba/')
config.set('WIKI_WEBSITE', 'https://github.com/GeopJr/Tuba/wiki')
config.set('NAME', branding.get('NAME', 'Tuba'))
config.set('WEBSITE', branding.get('WEBSITE', 'https://github.com/GeopJr/Tuba'))
config.set('ISSUES_WEBSITE', branding.get('ISSUES_WEBSITE', 'https://github.com/GeopJr/Tuba/issues'))
config.set('SUPPORT_WEBSITE', branding.get('SUPPORT_WEBSITE', 'https://matrix.to/#/#tuba:gnome.org'))
config.set('DONATE_WEBSITE', branding.get('DONATE_WEBSITE', 'https://geopjr.dev/donate'))
config.set('TRANSLATE_WEBSITE', branding.get('TRANSLATE_WEBSITE', 'https://hosted.weblate.org/engage/tuba/'))
config.set('WIKI_WEBSITE', branding.get('WIKI_WEBSITE', 'https://github.com/GeopJr/Tuba/wiki'))
config.set('DEFAULT_INSTANCE', branding.get('DEFAULT_INSTANCE', ''))
config.set('PROFILE', devel ? 'development' : 'production')

if devel
Expand Down Expand Up @@ -63,7 +67,7 @@ endif
add_project_arguments(['--vapidir=' + meson.project_source_root() / 'vapi'], language: 'vala')
add_project_arguments (
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
'-DG_LOG_DOMAIN="Tuba"',
'-DG_LOG_DOMAIN="@0@"'.format(config.get('G_LOG_DOMAIN')),
language: 'c'
)

Expand Down
10 changes: 6 additions & 4 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,12 @@ namespace Tuba {
};

// translators: Wiki pages / Guides
dialog.add_link (_("Wiki"), Build.WIKI_WEBSITE);

dialog.add_link (_("Translate"), Build.TRANSLATE_WEBSITE);
dialog.add_link (_("Donate"), Build.DONATE_WEBSITE);
if (Build.WIKI_WEBSITE != "")
dialog.add_link (_("Wiki"), Build.WIKI_WEBSITE);
if (Build.TRANSLATE_WEBSITE != "")
dialog.add_link (_("Translate"), Build.TRANSLATE_WEBSITE);
if (Build.DONATE_WEBSITE != "")
dialog.add_link (_("Donate"), Build.DONATE_WEBSITE);

// For some obscure reason, const arrays produce duplicates in the credits.
// Static functions seem to avoid this peculiar behavior.
Expand Down
1 change: 1 addition & 0 deletions src/Build.vala.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Build {
public const string DOMAIN = "@DOMAIN@";
public const string RESOURCES = "@RESOURCES@";
public const string PROFILE = "@PROFILE@";
public const string DEFAULT_INSTANCE = "@DEFAULT_INSTANCE@";

public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
public const string LOCALEDIR = "@LOCALEDIR@";
Expand Down
10 changes: 8 additions & 2 deletions src/Dialogs/NewAccount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {
reset ();
present ();
instance_entry.grab_focus ();

if (Build.DEFAULT_INSTANCE != "")
instance_entry.text = Build.DEFAULT_INSTANCE;
}

public bool on_manual_auth (string url) {
Expand Down Expand Up @@ -130,8 +133,11 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {
.with_account (account)
.with_form_data ("client_name", Build.NAME)
.with_form_data ("redirect_uris", redirect_uri = setup_redirect_uri ())
.with_form_data ("scopes", SCOPES)
.with_form_data ("website", Build.WEBSITE);
.with_form_data ("scopes", SCOPES);

if (Build.WEBSITE != "")
msg.with_form_data ("website", Build.WEBSITE);

yield msg.await ();

var parser = Network.get_parser_from_inputstream (msg.response_body);
Expand Down
Loading