Browse Source

fix localization on macos and rtaudio device name crash, explicitly set font scaling on macos

cairo_optimizations
Alexandros Theodotou 3 years ago
parent
commit
d4cb12f649
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 7
      .travis.yml
  2. 37
      data/meson.build
  3. 24
      data/org.zrythm.Zrythm.gschema.xml
  4. 3
      meson.build
  5. 6
      meson_options.txt
  6. 7
      resources/gen-gtk-gresources-xml.py
  7. 250
      scripts/package_osx.sh.in
  8. 69
      src/utils/localization.c
  9. 10
      src/zrythm.c

7
.travis.yml

@ -12,7 +12,6 @@ language: c @@ -12,7 +12,6 @@ language: c
before_install:
- |-
set -e
case $TRAVIS_OS_NAME in
windows)
[[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
@ -31,7 +30,9 @@ before_install: @@ -31,7 +30,9 @@ before_install:
;;
osx)
brew update
brew install fftw meson libsamplerate sdl2 chromaprint libgtop lilv librsvg gtk+3
# use || true because it returns 1
brew install fftw meson libsamplerate sdl2 chromaprint libgtop lilv librsvg gtk+3 || true
brew link --overwrite python
;;
esac
@ -54,7 +55,7 @@ script: @@ -54,7 +55,7 @@ script:
if [ $TRAVIS_OS_NAME = 'osx' ]; then
meson build -Denable_sdl=true -Denable_rtaudio=true -Denable_rtmidi=true
ninja -C build
ninja -C build install
ninja -C build test
else
# hack to enable tests
$mingw64 sed -i -e '27s/false/true/' meson_options.txt

37
data/meson.build

@ -37,16 +37,25 @@ install_data ( @@ -37,16 +37,25 @@ install_data (
install_dir: samplesdir)
# Desktop launcher and description file.
desktop_file = i18n.merge_file (
input: 'zrythm.desktop.in',
output: 'zrythm.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths (
datadir,
'applications'),
)
if os_linux or os_freebsd
desktop_file = i18n.merge_file (
input: 'zrythm.desktop.in',
output: 'zrythm.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths (
datadir,
'applications'),
)
desktop_utils = find_program (
'desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils,
args: [desktop_file]
)
endif
endif
# Zrythm project MIME type
install_data (
@ -55,12 +64,4 @@ install_data ( @@ -55,12 +64,4 @@ install_data (
join_paths (
[datadir, 'mime/packages']))
desktop_utils = find_program (
'desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils,
args: [desktop_file]
)
endif
subdir('windows')

24
data/org.zrythm.Zrythm.gschema.xml

@ -42,17 +42,17 @@ @@ -42,17 +42,17 @@
<value nick="rtmidi" value="4"/>
</enum>
<enum id="org.zrythm.Zrythm.preferences.language-enum">
<value nick="english" value="0"/>
<value nick="english_uk" value="1"/>
<value nick="german" value="2"/>
<value nick="french" value="3"/>
<value nick="italian" value="4"/>
<value nick="norwegian" value="5"/>
<value nick="spanish" value="6"/>
<value nick="japanese" value="7"/>
<value nick="portuguese" value="8"/>
<value nick="russian" value="9"/>
<value nick="chinese" value="10"/>
<value nick="en" value="0"/>
<value nick="en_GB" value="1"/>
<value nick="de" value="2"/>
<value nick="fr" value="3"/>
<value nick="it" value="4"/>
<value nick="no_NB" value="5"/>
<value nick="es" value="6"/>
<value nick="ja" value="7"/>
<value nick="pt" value="8"/>
<value nick="ru" value="9"/>
<value nick="zh" value="10"/>
</enum>
<enum id="org.zrythm.Zrythm.preferences.export-time-range-enum">
<value nick="song" value="0"/>
@ -271,7 +271,7 @@ @@ -271,7 +271,7 @@
<!-- Selected language -->
<key name="language"
enum="org.zrythm.Zrythm.preferences.language-enum">
<default>"english"</default>
<default>"en"</default>
<summary>UI interface language</summary>
<description>
The interface language.

3
meson.build

@ -74,6 +74,9 @@ endif @@ -74,6 +74,9 @@ endif
if get_option ('windows_release')
cdata.set ('WINDOWS_RELEASE', 1)
endif
if get_option ('mac_release')
cdata.set ('MAC_RELEASE', 1)
endif
cdata.set_quoted('SAMPLES_DIR', samplesdir)
cdata.set (
'MESON_SOURCE_ROOT',

6
meson_options.txt

@ -113,6 +113,12 @@ option ( @@ -113,6 +113,12 @@ option (
value: false,
description: 'Turn this on when creating the installer')
option (
'mac_release',
type: 'boolean',
value: false,
description: 'Turn this on when creating the installer')
option (
'trial_ver',
type: 'boolean',

7
resources/gen-gtk-gresources-xml.py

@ -118,6 +118,7 @@ _breeze_icons = [ @@ -118,6 +118,7 @@ _breeze_icons = [
'document-save-as',
'document-send',
'draw-eraser',
'edit-find',
'edit-select',
'emblem-symbolic-link',
'edit-undo',
@ -132,6 +133,7 @@ _breeze_icons = [ @@ -132,6 +133,7 @@ _breeze_icons = [
'folder-favorites',
'format-justify-fill',
'list-add',
'list-remove',
'help-about',
'input-keyboard',
'kdenlive-show-markers',
@ -188,8 +190,9 @@ for cat in ['actions', 'animations', 'applets', 'apps', 'categories', 'devices', @@ -188,8 +190,9 @@ for cat in ['actions', 'animations', 'applets', 'apps', 'categories', 'devices',
for f in get_files(full_src_dir, '.svg'):
if (f == (icon_name + '.svg')):
icon_path = os.path.join(full_src_dir,f)
alias = os.path.join(full_alias_dir,'z-' + f)
xml += ' <file alias=\"{0}\">{1}</file>\n'.format(alias,remove_prefix(icon_path, srcdir + os.sep))
for pref in ['z-', '']:
alias = os.path.join(full_alias_dir, pref + f)
xml += ' <file alias=\"{0}\">{1}</file>\n'.format(alias,remove_prefix(icon_path, srcdir + os.sep))
xml += '''
<file>theme.css</file>

250
scripts/package_osx.sh.in

@ -1,250 +0,0 @@ @@ -1,250 +0,0 @@
#! /bin/bash
# Copyright (C) 2019 Alexandros Theodotou <alex at zrythm dot org>
#
# This file is part of Zrythm
#
# Zrythm is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Zrythm 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
#
# Notes:
# 1. This script assumes you have all the dependencies
# installed using HomeBrew.
# 2. Meant to be run from the parent dir
# 3. Uses appdmg (brew install npm, npm -g appdmg)
# 4. need to install librsvg and then reinstall gdk-pixbuf
# in brew to get svgs upport
set -e
# script for pulling together a MacOSX app bundle.
GTKSTACK_ROOT=/usr/local
BUILD_ROOT=build
SAE=
STRIP=1
PRINT_SYSDEPS=
WITH_NLS=
PROGRAM_VERSION="@PACKAGE_VERSION@"
major_version=${PROGRAM_VERSION:0:1}
APPNAME=Zrythm
BUNDLENAME=Zrythm
lower_case_appname=zrythm;
echo "Version is $major_version"
if [ "x$commit" != "x" ] ; then
info_string="$major_version ($commit) built on `hostname` by `whoami` on `date`"
else
info_string="$major_version built on `hostname` by `whoami` on `date`"
fi
echo "Info string is $info_string"
if [ x$DEBUG = xT ]; then
STRIP=
echo "Debug build, strip disabled"
else
if test x$STRIP != x ; then
echo "No debug build, strip enabled"
else
echo "No debug build, but strip disabled."
fi
fi
# setup directory structure
DATA_OSX_DIR=data/osx
OSXDIR=$BUILD_ROOT/osx
APPDIR=$OSXDIR/${BUNDLENAME}.app
TMPDIR=$OSXDIR/tmp
mkdir -p $TMPDIR
APPROOT=$APPDIR/Contents
Resources=$APPROOT/Resources
PRODUCT_PKG_DIR=$OSXDIR/Zrythm
#
# Since this is OS X, don't try to distinguish between etc and shared
# (machine dependent and independent data) - just put everything
# into Resources.
#
Bin=$Resources/bin
Share=$Resources/share
Etc=$Resources/etc
Locale=$Resources/share/locale
Lib=$Resources/lib
if [ x$PRINT_SYSDEPS != x ] ; then
#
# print system dependencies
#
echo "system dependencies:"
for file in $BUILD_ROOT/zrythm ; do
if ! file $file | grep -qs Mach-O ; then
continue
fi
otool -L $file | awk '{print $1}' | egrep -v "(^$BUILD_ROOT*)"
done | sort | uniq
fi
echo "Removing old $APPDIR tree ..."
rm -rf $APPDIR
echo "Building new app directory structure ..."
# only bother to make the longest paths
mkdir -p $APPROOT/MacOS
mkdir -p $Etc
mkdir -p $Locale
mkdir -p $Lib
mkdir -p $Bin
EXECUTABLE=${BUNDLENAME}
# copy static files
echo "copying plists"
cp $DATA_OSX_DIR/Info.plist $APPROOT
# ..and clean up
rm -f $TMPDIR/Info.plist
rm -f $TMPDIR/Resources/InfoPlist.strings
#
# if we build a bundle without jack, then
# make the Ardour executable a helper
# script that checks to see if JACK is
# installed.
#
cp $DATA_OSX_DIR/osx_startup_script.sh $APPROOT/MacOS/$EXECUTABLE
chmod 775 $APPROOT/MacOS/$EXECUTABLE
MAIN_EXECUTABLE=zrythm ## used in startup_script
echo "Copying zrythm executable ...."
cp $BUILD_ROOT/zrythm $Bin/
cp $DATA_OSX_DIR/zrythm.icns $Resources/
set +e # things below are not error-free (optional files etc) :(
#
# Copy stuff that may be dynamically loaded
#
# etc gtk
cp -RL $GTKSTACK_ROOT/etc/gtk-3.0 $Etc/
# charset alias
cp -RL $GTKSTACK_ROOT/lib/charset.alias $Lib/
# GDK Pixbuf
echo "copying gdk pixbuf loaders"
GDK_PIXBUF_DIR=gdk-pixbuf-2.0/2.10.0
mkdir -p $Lib/$GDK_PIXBUF_DIR
cp -RL $GTKSTACK_ROOT/lib/$GDK_PIXBUF_DIR/* $Lib/$GDK_PIXBUF_DIR/
# localization
echo "copying languages"
languages="fr de it es ja"
for lang in $languages; do
CUR_DIR="$Locale/$lang/LC_MESSAGES"
mkdir -p $CUR_DIR
cp po/$lang/zrythm.mo "$CUR_DIR/"
cp $GTKSTACK_ROOT/share/locale/$lang/LC_MESSAGES/gtk30.mo \
$GTKSTACK_ROOT/share/locale/$lang/LC_MESSAGES/gtk30-properties.mo \
$CUR_DIR/
done
echo "copying Adwaita icons"
ICONS_DIR="$Share/icons"
mkdir -p "$ICONS_DIR"
cp -RL "$GTKSTACK_ROOT/share/icons/Adwaita" "$ICONS_DIR/"
echo "copying existing hicolor icons"
cp -RL "$GTKSTACK_ROOT/share/icons/hicolor" "$ICONS_DIR/"
echo "copying app icon"
APPICON_DIR1=$ICONS_DIR/hicolor/scalable/apps
APPICON_DIR2=$ICONS_DIR/hicolor/48x48/apps
mkdir -p $APPICON_DIR1
mkdir -p $APPICON_DIR2
cp resources/icons/zrythm/zrythm.svg $APPICON_DIR1/
cp resources/icons/zrythm/zrythm.svg $APPICON_DIR2/
echo "copying themes"
#rsync -a --copy-links /usr/local/share/ $Share/
cp -RL "$GTKSTACK_ROOT/share/themes" "$Share/"
echo "copying fonts"
cp -R resources/fonts "$Share/"
SCHEMAS_DIR="glib-2.0/schemas"
mkdir -p $Share/$SCHEMAS_DIR
mkdir -p $BUILD_ROOT/schemas
cp data/org.zrythm.gschema.xml $BUILD_ROOT/schemas/
cp $GTKSTACK_ROOT/share/$SCHEMAS_DIR/org.gtk.*.xml $BUILD_ROOT/schemas/
echo "building schemas"
glib-compile-schemas $BUILD_ROOT/schemas/
echo "copying schemas"
cp "$BUILD_ROOT/schemas/gschemas.compiled" \
"$Share/$SCHEMAS_DIR/"
# copy libs
STDCPP='|libstdc\+\+'
while [ true ] ; do
missing=false
for file in $Bin/* $Lib/* ; do
if ! file $file | grep -qs Mach-O ; then
continue
fi
# libffi contains "S" (other section symbols) that should not be stripped.
if [[ $file == *"libffi"* ]] ; then
continue
fi
if test x$STRIP != x ; then
strip -u -r -arch all $file &>/dev/null
fi
deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|libs/$STDCPP)" | grep -v "$(basename $file)"`
echo "deps=$deps"
# echo -n "."
for dep in $deps ; do
echo "dependency $dep"
base=`basename $dep`
if ! test -f $Lib/$base; then
if echo $dep | grep -sq '^libs' ; then
cp $BUILD_ROOT/$dep $Lib
else
cp -L $dep $Lib
fi
missing=true
fi
done
done
if test x$missing = xfalse ; then
# everything has been found
break
fi
done
# make dmg
rm -f Zrythm.dmg
appdmg $DATA_OSX_DIR/appdmg.json Zrythm.dmg
echo "Done."
exit

69
src/utils/localization.c

@ -35,6 +35,39 @@ @@ -35,6 +35,39 @@
#include <glib/gi18n.h>
#ifdef _WOE32
#define CODESET "1252"
#else
#define CODESET "UTF-8"
#endif
#ifdef MAC_RELEASE
#include "CoreFoundation/CoreFoundation.h"
#include <unistd.h>
#include <libgen.h>
#endif
static char *
get_match (
char ** installed_locales,
int num_installed_locales,
const char * prefix,
const char * suffix)
{
for (int i = 0; i < num_installed_locales; i++)
{
if (
g_str_match_string (
prefix, installed_locales[i], 0) &&
g_str_match_string (
suffix, installed_locales[i], 0))
{
return installed_locales[i];
}
}
return NULL;
}
/**
* Returns the first locale found matching the given
* language, or NULL if a locale for the given
@ -55,7 +88,7 @@ localization_locale_exists ( @@ -55,7 +88,7 @@ localization_locale_exists (
/* get available locales on the system */
FILE *fp;
char path[1035];
char * installed_locales[3000];
char * installed_locales[8000];
int num_installed_locales = 0;
/* Open the command for reading. */
@ -78,10 +111,10 @@ localization_locale_exists ( @@ -78,10 +111,10 @@ localization_locale_exists (
#define IS_MATCH(caps,code) \
case LL_##caps: \
match = string_array_contains_substr ( \
installed_locales, \
num_installed_locales, \
code); \
match = \
get_match ( \
installed_locales, num_installed_locales, \
code, CODESET); \
break;
char * match = NULL;
@ -145,7 +178,7 @@ localization_init () @@ -145,7 +178,7 @@ localization_init ()
g_message (
"setting locale to %s (found %s)",
code, match);
#ifdef _WOE32
#if defined(_WOE32) || defined(__APPLE__)
char buf[120];
sprintf (buf, "LANG=%s", code);
putenv (buf);
@ -160,19 +193,31 @@ localization_init () @@ -160,19 +193,31 @@ localization_init ()
}
/* bind text domain */
#ifdef WINDOWS_RELEASE
#if defined(WINDOWS_RELEASE)
bindtextdomain (GETTEXT_PACKAGE, "share/locale");
#elif defined(MAC_RELEASE)
CFBundleRef bundle =
CFBundleGetMainBundle ();
CFURLRef bundleURL =
CFBundleCopyBundleURL (bundle);
char path[PATH_MAX];
Boolean success =
CFURLGetFileSystemRepresentation (
bundleURL, TRUE, (UInt8 *)path, PATH_MAX);
g_return_val_if_fail (success, 0);
CFRelease (bundleURL);
g_message ("bundle path: %s", path);
char localedir[PATH_MAX];
sprintf (localedir, "%s/../share/locale", path);
bindtextdomain (
GETTEXT_PACKAGE, localedir);
#else
bindtextdomain (
GETTEXT_PACKAGE, CONFIGURE_DATADIR "/locale");
#endif
/* set domain codeset */
#ifdef _WOE32
bind_textdomain_codeset (GETTEXT_PACKAGE, "1252");
#else
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
bind_textdomain_codeset (GETTEXT_PACKAGE, CODESET);
/* set domain */
textdomain (GETTEXT_PACKAGE);

10
src/zrythm.c

@ -722,7 +722,7 @@ zrythm_app_startup ( @@ -722,7 +722,7 @@ zrythm_app_startup (
gdk_monitor_get_scale_factor (monitor);
g_message (
"Monitor scale factor: %d", scale_factor);
#ifdef _WOE32
#if defined(_WOE32)
g_object_set (
gtk_settings_get_default (),
"gtk-font-name", "Segoe UI Normal 10", NULL);
@ -736,6 +736,14 @@ zrythm_app_startup ( @@ -736,6 +736,14 @@ zrythm_app_startup (
g_object_set (
gtk_settings_get_default (),
"gtk-font-name", "Regular 10", NULL);
/* explicitly set font scaling to 1.00 (for some
* reason, a different value is used by default).
* this was taken from the GtkInspector visual.c
* code */
/* TODO add an option to change the font scaling */
g_object_set (
gtk_settings_get_default (),
"gtk-xft-dpi", (int) (1.00 * 96 * 1024), NULL);
#else
g_object_set (
gtk_settings_get_default (),

Loading…
Cancel
Save