Commit 8a3f2983 authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

Initial boilerplate

parent b9ceede2
[default]
name=Default
runtime=flatpak:org.gnome.Platform/x86_64/master
config-opts=
run-opts=
prefix=/app
app-id=
postbuild=
prebuild=
default=true
[package]
name = "automata"
version = "0.0.1"
authors = ["Eisha Chen-yen-su <chenyensu0@gmail.com>"]
[dependencies]
foundry = "0.2.1"
gdk = "0.9.0"
gdk-pixbuf = "0.5.0"
gio = "0.5.0"
glib = "0.6.0"
[dependencies.gtk]
features = ["v3_22"]
version = "0.5.0"
# Automata
### A cellular automata application for GNOME.
use std::process::Command;
fn main() {
Command::new("glib-compile-resources")
.args(&["--generate", "resources.xml"])
.current_dir("resources")
.status()
.unwrap();
}
# Adatped from:
# https://gitlab.gnome.org/danigm/fractal/blob/6e2911f9d2353c99a18a6c19fab7f903c4bbb431/meson.build
project(
'Automata', 'rust',
version: '0.0.1',
license: 'GPLv3',
)
Automata_version = meson.project_version()
version_array = Automata_version.split('.')
Automata_major_version = version_array[0].to_int()
Automata_minor_version = version_array[1].to_int()
Automata_version_micro = version_array[2].to_int()
Automata_prefix = get_option('prefix')
Automata_bindir = join_paths(Automata_prefix, get_option('bindir'))
datadir = get_option('datadir')
icondir = join_paths(datadir, 'icons')
subdir('resources')
cargo = find_program('cargo', required: false)
gresource = find_program('glib-compile-resources', required: false)
cargo_vendor = find_program('cargo-vendor', required: false)
cargo_script = find_program('scripts/cargo.sh')
cargo_release = custom_target('cargo-build',
build_by_default: true,
build_always: true,
output: ['automata'],
install: true,
install_dir: Automata_bindir,
command: [cargo_script, '@CURRENT_SOURCE_DIR@', '@OUTPUT@'])
run_target('release', command: ['scripts/release.sh',
meson.project_name() + '-' + Automata_version
])
{
"app-id" : "org.gnome.Automata",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"sdk-extensions" : [
"org.freedesktop.Sdk.Extension.rust-stable"
],
"command" : "automata",
"tags" : [
"nightly"
],
"desktop-file-name-prefix" : "(Nightly) ",
"finish-args" : [
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf",
"--share=network",
"--share=ipc",
"--socket=x11",
"--socket=wayland",
"--talk-name=org.freedesktop.Desktop"
],
"build-options" : {
"append-path" : "/usr/lib/sdk/rust-stable/bin",
"build-args" : [
"--share=network"
],
"env" : {
"CARGO_HOME" : "/run/build/Automata/cargo",
"RUST_BACKTRACE" : "1",
"DEBUG" : "true"
}
},
"modules" : [
{
"name" : "automata",
"buildsystem" : "meson",
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/Kagamihime/automata",
"branch" : "master"
}
]
}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkAboutDialog" id="about_dialog">
<property name="can_focus">False</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<property name="program_name">Glade</property>
<property name="copyright" translatable="yes">2018 Eisha Chen-yen-su</property>
<property name="authors">Developer 1
Developer 2</property>
<property name="artists">Artist 1
Artist 2</property>
<property name="logo_icon_name">image-missing</property>
<property name="license_type">gplv3</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="titlebar">
<placeholder/>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkMenu" id="app_menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="about_menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Show About Dialog</property>
<property name="label" translatable="yes">About</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
<object class="GtkApplicationWindow" id="app_window">
<property name="can_focus">False</property>
<property name="default_width">600</property>
<property name="default_height">300</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">Hello, World!</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/>
</attributes>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="header_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">Automata</property>
<property name="subtitle">A cellular automata application for GNOME</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="action_button">
<property name="label">Action</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkMenuButton" id="menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popup">app_menu</property>
<property name="direction">none</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
# subdir('icons')
install_data('org.gnome.Automata.desktop', install_dir : datadir + '/applications')
install_data('org.gnome.Automata.appdata.xml', install_dir : datadir + '/appdata')
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gnome.Automata</id>
<name>Automata</name>
<project_license>GPLv3</project_license>
<metadata_license>CC0-1.0</metadata_license>
<developer_name>Eisha Chen-yen-su</developer_name>
<summary>A cellular automata application for GNOME</summary>
<description xml:lang="en">
<p>
A cellular automata application
for GNOME written in Rust and
using Vulkan.
</p>
</description>
<url type="homepage">https://gitlab.gnome.org/Kagamihime/automata</url>
<releases>
<release version="0.0.1" date="2018-10-19"/>
</releases>
<url type="homepage">https://gitlab.gnome.org/Kagamihime/automata</url>
<update_contact>chenyensu0@gmail.com</update_contact>
<developer_name>Eisha Chen-yen-su</developer_name>
</component>
[Desktop Entry]
Name=Automata
GenericName=Automata
Comment=Cellular Automata Application For GNOME
Exec=automata
Terminal=false
Type=Application
StartupNotify=true
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/Automata/">
<file>gtk/window.ui</file>
<file>gtk/about.ui</file>
</gresource>
</gresources>
#!/bin/sh
export CARGO_HOME=$1/target/cargo-home
if [[ $DEBUG = true ]]
then
echo "DEBUG MODE"
cargo build && cp $1/target/debug/automata $2
else
echo "RELEASE MODE"
cargo build --release && cp $1/target/release/automata $2
fi
#!/bin/sh
VERSION=$1
DEST=${MESON_BUILD_ROOT}
DIST=$DEST/dist/$VERSION
cd "${MESON_SOURCE_ROOT}"
mkdir -p $DIST
# copying files
cp *.rs $DIST
cp Cargo.toml $DIST
cp Cargo.lock $DIST
cp configure $DIST
cp meson.build $DIST
cp LICENSE $DIST
cp README.md $DIST
cp -rf scripts $DIST
cp -rf resources $DIST
# cargo vendor
mkdir $DIST/.cargo
cargo vendor > $DIST/.cargo/config
cp -rf vendor $DIST/
# packaging
cd $DEST/dist
tar -cJvf $VERSION.tar.xz $VERSION
extern crate gio;
extern crate glib;
extern crate gtk;
use gio::prelude::*;
use gio::ApplicationFlags;
use gtk::prelude::*;
use gtk::{Application, ApplicationWindow};
mod static_resource;
mod window;
fn main() {
gtk::init().expect("Error initialising gtk");
static_resource::init().expect("Error loading static resource");
let app: Application = Application::new("org.gnome.Automata", ApplicationFlags::empty())
.expect("Could not create application");
app.connect_startup(setup_window);
app.run(&std::env::args().collect::<Vec<_>>());
}
fn setup_window(app: &Application) {
let w: ApplicationWindow = window::new_window();
w.set_application(app);
w.show_all();
}
use gio::{resources_register, Error, Resource};
use glib::Bytes;
pub fn init() -> Result<(), Error> {
// load the gresource binary at build time and include/link it into the final
// binary.
let res_bytes = include_bytes!("../resources/resources.gresource");
// Create Resource it will live as long the value lives.
let gbytes = Bytes::from_static(res_bytes.as_ref());
let resource = Resource::new_from_data(&gbytes)?;
// Register the resource so It wont be dropped and will continue to live in
// memory.
resources_register(&resource);
Ok(())
}
extern crate gio;
extern crate glib;
extern crate gtk;
use gtk::prelude::*;
pub fn new_window() -> gtk::ApplicationWindow {
let builder: gtk::Builder =
gtk::Builder::new_from_resource("/org/gnome/Automata/gtk/window.ui");
let window: gtk::ApplicationWindow = builder
.get_object("app_window")
.expect("Application window could not be loaded");
window.connect_delete_event(|_, _| {
gtk::main_quit();
gtk::Inhibit(false)
});
let hello_label: gtk::Label = builder.get_object("label").expect("label not found");
let btn_action: gtk::Button = builder
.get_object("action_button")
.expect("action_button not found");
btn_action.connect_clicked(move |_| hello_label.set_text("Action button clicked"));
let mnu_about: gtk::MenuItem = builder
.get_object("about_menu")
.expect("about_menu not found");
{
let window = window.clone();
mnu_about.connect_activate(move |_| {
show_about(&window);
});
}
return window;
}
fn show_about(window: &gtk::ApplicationWindow) {
let builder: gtk::Builder =
gtk::Builder::new_from_resource("/org/gnome/Automata/gtk/about.ui");
let about_dialog: gtk::AboutDialog = builder
.get_object("about_dialog")
.expect("about_dialog not found");
about_dialog.set_modal(true);
about_dialog.set_transient_for(window);
about_dialog.show();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment