From 26793eb8018df7c07c74049986282ca647555388 Mon Sep 17 00:00:00 2001 From: Alecaddd Date: Wed, 18 Sep 2024 21:34:48 -0700 Subject: [PATCH] Setup gsettings and load a few initial settings --- data/launcher.desktop.in.in | 11 ++ data/meson.build | 51 ++++++++ data/metadata.appdata.xml.in.in | 198 ++++++++++++++++++++++++++++++++ data/settings.gschema.xml.in | 197 +++++++++++++++++++++++++++++++ meson.build | 3 +- src/meson.build | 7 +- src/window.rs | 52 ++++++++- 7 files changed, 516 insertions(+), 3 deletions(-) create mode 100644 data/launcher.desktop.in.in create mode 100644 data/meson.build create mode 100644 data/metadata.appdata.xml.in.in create mode 100644 data/settings.gschema.xml.in diff --git a/data/launcher.desktop.in.in b/data/launcher.desktop.in.in new file mode 100644 index 00000000..18e7d78c --- /dev/null +++ b/data/launcher.desktop.in.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=Akira +GenericName=Akira UX App +Comment=The Linux Design Tool +Exec=@EXEC_NAME@ +Icon=@APP_ID_UNQUOTED@ +Terminal=false +Type=Application +Categories=Utility;Graphics; +StartupNotify=true +MimeType=application/x-akira; diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 00000000..fcef85b9 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,51 @@ +desktop_file = i18n.merge_file( + input: configure_file( + input: 'launcher.desktop.in.in', + output: 'launcher.desktop.in', + configuration: conf + ), + output: meson.project_name() + '.desktop', + type: 'desktop', + po_dir: '../po/extra', + install: true, + install_dir: join_paths(get_option('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 + +appstream_file = i18n.merge_file( + input: configure_file( + input: 'metadata.appdata.xml.in.in', + output: 'metadata.appdata.xml.in', + configuration: conf, + ), + output: meson.project_name() + '.appdata.xml', + po_dir: '../po/extra', + install: true, + install_dir: join_paths(get_option('datadir'), 'metainfo') +) + +appstream_util = find_program('appstreamcli', required: false) +if appstream_util.found() + test('Validate appstream file', appstream_util, args: ['validate', appstream_file]) +endif + +install_data( + configure_file( + input: 'settings.gschema.xml.in', + output: 'settings.gschema.xml', + configuration: conf + ), + install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas'), + rename: meson.project_name() + '.gschema.xml', +) + +compile_schemas = find_program('glib-compile-schemas', required: false) +if compile_schemas.found() + test('Validate schema file', + compile_schemas, + args: ['--strict', '--dry-run', meson.current_source_dir()]) +endif diff --git a/data/metadata.appdata.xml.in.in b/data/metadata.appdata.xml.in.in new file mode 100644 index 00000000..58394f50 --- /dev/null +++ b/data/metadata.appdata.xml.in.in @@ -0,0 +1,198 @@ + + + @APP_ID_UNQUOTED@ + Akira + The Linux Design Tool + CC0-1.0 + GPL-3.0+ + +

+ A modern UX Design Application for UI and UX Designers +

+

+ ⚠ WARNING! Akira is still under development and not ready for production. Missing features, random bugs, and black holes opening in your kitchen are to be expected.

+

+ Akira is a native Linux Design application built in Rust and Gtk. Akira focuses on offering a modern and fast approach to UI and UX Design, mainly targeting web and graphic designers. The main goal is to offer a valid and professional solution for designers who want to use Linux as their main OS. +

+

+ Features Include: +

+
    +
  • Fully vector canvas for infinite resizing without quality loss
  • +
  • Smart option panel that shows the editable features of a selected item
  • +
  • Layers panel with easy Drag and Drop and smart ordering
  • +
  • Create Artboards to better organize your design iterations and views
  • +
  • Control the size and quality of exported images
  • +
  • Customizable icon set
  • +
  • And so much more…
  • +
+
+ + @APP_ID@ + + + + +

Performance improvements and Global colors library

+
    +
  • Improved "Modes" detection (insert, select, transform).
  • +
  • Fixed Artboard label issues on zoom.
  • +
  • Improved Pixel Grid detection and z-index stack with other items.
  • +
  • Implemented editable zoom value.
  • +
  • Fix application activation when opening a new file.
  • +
  • Fix sizing issue when dropping images into the Canvas.
  • +
  • Implemented Global colors library.
  • +
  • Italian translation.
  • +
+
+
+ + +

New Features and Bug Fixes

+
    +
  • Complete rebuild of the Canvas library architecture.
  • +
  • Implemented Pixel Grid.
  • +
  • Customize color of Pixel Grid.
  • +
  • Implemented smart Snapping Guides.
  • +
  • Customize color and magnetic threshold of Snapping Guides.
  • +
  • Allow items resizing in all directions.
  • +
  • Add images via click and drag with the Image Tool.
  • +
  • Handle multiple Fills and Border colors for each item.
  • +
  • Allow scaling items from the center.
  • +
  • Enable dropping images on the canvas.
  • +
  • A lot of code improvements and optimization.
  • +
+
+
+ + +

New Features and Bug Fixes

+
    +
  • New color picker for Fills and Borders.
  • +
  • Zooming with mouse wheel follows the position of the cursor.
  • +
  • Fix loading Artboards background color when opening a file.
  • +
  • Fix numbering of newly created items.
  • +
  • Fix Gtk-CRITICAL warning when opening the Export Dialog.
  • +
  • Fix flipping items inside Artboards.
  • +
  • Fix crash when dropping flipped items inside Artboards.
  • +
  • General code improvements and optimization.
  • +
+
+
+ + +

Bug fixes and Artboards improvements

+
    +
  • Control Artboards background color.
  • +
  • Hide and Lock Artboards from the Layers panel.
  • +
  • Items inside Artboards are masked when extending outside the edges of the Artboard.
  • +
  • Fix items reordering with the layers panel drag and drop.
  • +
  • Fix random segfault at startup while setting accelerators.
  • +
  • Updated goocanvas vapi.
  • +
+
+
+ + +

🚀 Experimental Alpha Release, say Hi to Akira!

+
    +
  • Create Artboards and basic shapes
  • +
  • Manage the fill and border properties of shapes
  • +
  • Import images
  • +
  • Export custom areas, selections, and artboards
  • +
  • So many crashes and missing features you wouldn't believe, but hey, this is an experimental alpha…
  • +
+
+
+ + +

🚀 Experimental Alpha Release, say Hi to Akira!

+
    +
  • Create Artboards and basic shapes
  • +
  • Manage the fill and border properties of shapes
  • +
  • Import images
  • +
  • Export custom areas, selections, and artboards
  • +
  • So many crashes and missing features you wouldn't believe, but hey, this is an experimental alpha…
  • +
+
+
+ + +

🚀 Experimental Alpha Release, say Hi to Akira!

+
    +
  • Create Artboards and basic shapes
  • +
  • Manage the fill and border properties of shapes
  • +
  • Import images
  • +
  • Export custom areas, selections, and artboards
  • +
  • So many crashes and missing features you wouldn't believe, but hey, this is an experimental alpha…
  • +
+
+
+
+ + + https://raw.githubusercontent.com/akiraux/akira/master/data/screenshots/screenshot-1.png + + + https://raw.githubusercontent.com/akiraux/akira/master/data/screenshots/screenshot-2.png + + + https://raw.githubusercontent.com/akiraux/akira/master/data/screenshots/screenshot-3.png + + + https://raw.githubusercontent.com/akiraux/akira/master/data/screenshots/screenshot-4.png + + + @APP_ID@.desktop + Alessandro Castellani + https://github.com/akiraux/akira + https://github.com/akiraux/akira/issues + https://github.com/akiraux/akira/issues + https://www.paypal.me/alecaddd + castellani.ale@gmail.com + @GETTEXT_PACKAGE@ + + + ModernToolkit + HighContrast + HiDpiIcon + + + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + + + #3f3f3f + #ffffff + 15 + pk_live_515yF9YDvXGakAYGJ74PQwmIwxs6xQrm0q0ULEAYO6vZyzsTIaOI40ZtDYj6qUGq6sjzCgwd25VQ4REbJob6pkB9r00tU1lgu6W + +
diff --git a/data/settings.gschema.xml.in b/data/settings.gschema.xml.in new file mode 100644 index 00000000..ced647da --- /dev/null +++ b/data/settings.gschema.xml.in @@ -0,0 +1,197 @@ + + + + + '0.0.0' + The currently installed version. + The currently installed version of Akira, updated only after the user launched the app. This is used to know when to trigger the Release Dialog. + + + + 360 + The saved horizontal position of the window. + The saved horizontal position of the window. + + + + 360 + The vertical position width of the window. + The saved vertical position of the window. + + + + -1 + Default window width + + + -1 + Default window height + + + false + Default window maximized behaviour + + + + 804 + The saved width of the right panel. + The saved width of the right panel containing the MainCanvas and RightSidebar. + + + + 220 + The saved width of the left panel. + The saved width of the left panel. Must be greater than 220, or it will not take effect. + + + + false + Use dark theme + Switch between Light and Dark theme. + + + + true + Follow system theme variation + Follow system theme dark/light variation + + + + true + Show button labels + Show or Hide the button labels to slim the UI. + + + + false + Use Symbolic Icons + Allow user to choose between normal and symbolic icons in HeaderBar. + + + + false + Invert Panels Order + Allow user to choose between default and inverted panels order. + + + + '#888888' + Default Grid Color. + The default color of the pixel grid. + + + + true + Enable Snapping Guides + Allow user to enable or disable the snapping guides when moving items. + + + + '#ff0000' + Default Snaps Color. + The default color of the snapping guides. + + + + 4 + Default Snaps Sensitivity. + The default sensitivity of the snapping threshold. + + + + '#CCCCCC' + Default Shape Color. + The default color of a newly created shape. + + + + true + Add Border on Shape Creation + Enable the addition of the border style when creating a new shape. + + + + 1 + Default Border Width. + The default width of the border for a newly created shape. + + + + '#AAAAAA' + Default Border Color. + The default color of the border for a newly created shape. + + + + false + Auto Reopen latest file + Automatically reopen the latest file on startup. + + + + [] + Recently opened files + Keep track of the 10 most recently opened files. + + + + '' + Default export folder. + The default folder where exported images will be saved. + + + + 1000 + The saved width of the export dialog. + The saved width of the export dialog. + + + + 600 + The saved height of the export dialog. + The saved height of the export dialog. + + + + 300 + The saved position of the export left panel. + The saved position of the left panel in the export dialog. + + + + 100 + The quality value for exporting JPG images. + The quality value for exporting JPG images in the export dialog. + + + + 0 + The compression value for exporting PNG images. + The compression value for exporting PNG images in the export dialog. + + + + 'png' + The format type for exporting images. + The format type for exporting images in the export dialog. + + + + 1 + The scaled resolution for exporting images. + The scaled resolution for exporting images in the export dialog. + + + + true + The alpha setting for exporting PNG images. + The alpha setting for exporting PNG images in the export dialog. + + + + [] + The list of global colors + Keep track of the colors saved by the user and available in every document file. + + + diff --git a/meson.build b/meson.build index 3adc4ecf..39aad355 100644 --- a/meson.build +++ b/meson.build @@ -20,10 +20,11 @@ conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) conf.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir'))) conf.set_quoted('PKGDATADIR', pkgdatadir) +subdir('data') subdir('src') gnome.post_install( glib_compile_schemas: true, - gtk_update_icon_cache: true, + # gtk_update_icon_cache: true, update_desktop_database: true, ) diff --git a/src/meson.build b/src/meson.build index 9fbff997..d07f1292 100644 --- a/src/meson.build +++ b/src/meson.build @@ -6,7 +6,6 @@ configure_file( configuration: conf ) - # Copy the config.rs output to the source directory. run_command( 'cp', @@ -46,3 +45,9 @@ cargo_build = custom_target( cargo_opt, '&&', 'cp', 'src' / rust_target / exec_name, '@OUTPUT@', ] ) + +test( + 'Run cargo test', + cargo_bin, args: ['test'], + timeout: 600 +) diff --git a/src/window.rs b/src/window.rs index e36acd5f..15930589 100644 --- a/src/window.rs +++ b/src/window.rs @@ -19,6 +19,8 @@ use gtk::subclass::prelude::*; use gtk::{gio, gio::Settings, glib, prelude::*, ApplicationWindow}; use once_cell::sync::OnceCell; +use crate::config::APP_ID; + mod imp { use super::*; @@ -40,6 +42,9 @@ mod imp { let obj = self.obj(); + obj.setup_settings(); + obj.load_window_size(); + let mode_switch = granite::ModeSwitch::builder() .primary_icon_name("display-brightness-symbolic") .secondary_icon_name("weather-clear-night-symbolic") @@ -64,7 +69,15 @@ mod imp { } impl WidgetImpl for AppWindow {} - impl WindowImpl for AppWindow {} + impl WindowImpl for AppWindow { + fn close_request(&self) -> glib::Propagation { + self.obj() + .save_window_size() + .expect("Failed to save window state"); + + glib::Propagation::Proceed + } + } impl ApplicationWindowImpl for AppWindow {} } @@ -82,4 +95,41 @@ impl AppWindow { .property("title", "Akira") .build() } + + fn setup_settings(&self) { + let settings = Settings::new(APP_ID); + self.imp() + .settings + .set(settings) + .expect("`settings` should not be set before calling `setup_settings`."); + } + + fn settings(&self) -> &Settings { + self.imp() + .settings + .get() + .expect("`settings` should be set in `setup_settings`.") + } + + fn save_window_size(&self) -> Result<(), glib::BoolError> { + let size = self.default_size(); + + self.settings().set_int("window-width", size.0)?; + self.settings().set_int("window-height", size.1)?; + self.settings() + .set_boolean("is-maximized", self.is_maximized())?; + + Ok(()) + } + + fn load_window_size(&self) { + let width = self.settings().int("window-width"); + let height = self.settings().int("window-height"); + let is_maximized = self.settings().boolean("is-maximized"); + + self.set_default_size(width, height); + if is_maximized { + self.maximize(); + } + } }