Skip to content

Commit

Permalink
Fix i18n in AppImage
Browse files Browse the repository at this point in the history
  • Loading branch information
coslyk committed Jul 19, 2020
1 parent eb4f34c commit 2b691ec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 3 additions & 1 deletion appimage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
app: bingle
binpatch: true

ingredients:
dist: xenial
Expand All @@ -16,6 +15,9 @@ script:
- cp -rf ../../build/usr/* usr/
- cp usr/share/icons/io.github.coslyk.bingle.png .
- cp usr/share/applications/io.github.coslyk.bingle.desktop .
- cd usr/share/locale
- ln -s zh-CN zh_CN
- cd ../../..
- rm -rf usr/share/man
- rm -rf usr/share/doc

3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ executable(
dependencies: [
dependency('gtk+-3.0'),
dependency('libsoup-2.4'),
dependency('json-glib-1.0')
dependency('json-glib-1.0'),
meson.get_compiler('vala').find_library('posix')
],
install: true
)
Expand Down
10 changes: 8 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ namespace Bingle {
if (_about_dialog == null) {
try {
_about_dialog = new Gtk.AboutDialog () {
authors = new string[] { "coslyk", null },
authors = {"coslyk"},
comments = _("A simple wallpaper downloader"),
copyright = "2020 coslyk",
copyright = "Copyright © 2020 coslyk",
license_type = Gtk.License.MIT_X11,
logo = new Gdk.Pixbuf.from_resource ("/io/github/coslyk/bingle/logo.png"),
program_name = "Bingle",
Expand Down Expand Up @@ -79,6 +79,12 @@ namespace Bingle {
}

public static int main (string[] args) {

// Fix i18n in AppImage
string dirname = DesktopService.get_program_path ().replace ("/bin/io.github.coslyk.bingle", "/share/locale");
Intl.bindtextdomain ("io.github.coslyk.bingle", dirname);

// Run App
var app = new Application ();
return app.run (args);
}
Expand Down
9 changes: 9 additions & 0 deletions src/DesktopService.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Bingle.DesktopService {
DEEPIN
}

// Get desktop environment type
public DEType get_de_type () {

unowned string session_name = Environment.get_variable ("DESKTOP_SESSION");
Expand All @@ -25,6 +26,7 @@ namespace Bingle.DesktopService {
}
}

// Set wallpaper
public void set_wallpaper (string filepath) {
DEType de = get_de_type ();

Expand Down Expand Up @@ -52,4 +54,11 @@ namespace Bingle.DesktopService {
warning ("%s\n", e.message);
}
}

// Get program path
private char _program_path[500];
public unowned string get_program_path () {
Posix.readlink ("/proc/self/exe", _program_path);
return (string) _program_path;
}
}

0 comments on commit 2b691ec

Please sign in to comment.