Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300045 from Aleksanaa/ascii-draw
ascii-draw: init at 0.3.0
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
diff --git a/src/window.py b/src/window.py | ||
index adc6d6d..1cb6bec 100644 | ||
--- a/src/window.py | ||
+++ b/src/window.py | ||
@@ -34,6 +34,15 @@ import unicodedata | ||
import emoji | ||
import os | ||
|
||
+def get_data_dir(): | ||
+ xdg_data_home = os.environ.get('XDG_DATA_HOME') | ||
+ if xdg_data_home and xdg_data_home.strip(): | ||
+ data_dir = os.path.join(xdg_data_home, 'ascii-draw', 'data') | ||
+ else: | ||
+ home = os.path.expanduser("~") | ||
+ data_dir = os.path.join(home, '.local', 'share', 'ascii-draw', 'data') | ||
+ return data_dir | ||
+ | ||
@Gtk.Template(resource_path='/io/github/nokse22/asciidraw/ui/window.ui') | ||
class AsciiDrawWindow(Adw.ApplicationWindow): | ||
__gtype_name__ = 'AsciiDrawWindow' | ||
@@ -266,7 +275,7 @@ class AsciiDrawWindow(Adw.ApplicationWindow): | ||
|
||
self.palettes = [] | ||
|
||
- directory_path = "/var/data/palettes" | ||
+ directory_path = f"{get_data_dir()}/palettes" | ||
os.makedirs(directory_path, exist_ok=True) | ||
|
||
for filename in os.listdir(directory_path): | ||
@@ -316,7 +325,7 @@ class AsciiDrawWindow(Adw.ApplicationWindow): | ||
self.char_carousel_go_next.set_sensitive(True) | ||
|
||
def save_new_palette(self, palette): | ||
- with open(f"/var/data/palettes/{palette.name}.txt", 'w') as file: | ||
+ with open(f"{get_data_dir()}/palettes/{palette.name}.txt", 'w') as file: | ||
file.write(palette.chars) | ||
|
||
@Gtk.Template.Callback("char_pages_go_back") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ lib | ||
, python3Packages | ||
, fetchFromGitHub | ||
, meson | ||
, ninja | ||
, pkg-config | ||
, gobject-introspection | ||
, wrapGAppsHook4 | ||
, desktop-file-utils | ||
, libadwaita | ||
}: | ||
|
||
python3Packages.buildPythonApplication rec { | ||
pname = "ascii-draw"; | ||
version = "0.3.0"; | ||
pyproject = false; | ||
|
||
src = fetchFromGitHub { | ||
owner = "Nokse22"; | ||
repo = "ascii-draw"; | ||
rev = "v${version}"; | ||
hash = "sha256-vI+j8OuQ3b6La0+7wWeoUtBal24dazlN/T0Bng5TgMo="; | ||
}; | ||
|
||
# Temporary fix for autosaving to flatpak directory | ||
# https://github.com/Nokse22/ascii-draw/issues/31 | ||
patches = [ ./fix_palette_data_dir.patch ]; | ||
|
||
nativeBuildInputs = [ | ||
meson | ||
ninja | ||
pkg-config | ||
gobject-introspection | ||
wrapGAppsHook4 | ||
desktop-file-utils | ||
]; | ||
|
||
buildInputs = [ | ||
libadwaita | ||
]; | ||
|
||
propagatedBuildInputs = with python3Packages; [ | ||
pygobject3 | ||
pyfiglet | ||
emoji | ||
]; | ||
|
||
dontWrapGApps = true; | ||
|
||
preFixup = '' | ||
makeWrapperArgs+=("''${gappsWrapperArgs[@]}") | ||
''; | ||
|
||
meta = { | ||
description = "An app to draw diagrams or anything using only ASCII"; | ||
homepage = "https://github.com/Nokse22/ascii-draw"; | ||
license = lib.licenses.gpl3Plus; | ||
mainProgram = "ascii-draw"; | ||
maintainers = with lib.maintainers; [ aleksana ]; | ||
# gnulib bindtextdomain is missing on various other unix platforms | ||
platforms = lib.platforms.linux; | ||
}; | ||
} |