diff --git a/.gitignore b/.gitignore index 1de5659..1702b48 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -target \ No newline at end of file +target +.flatpak +src/config.rs \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..eb33094 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,18 @@ +{ + "files.watcherExclude": { + "**/.git/objects/**": true, + "**/.git/subtree-cache/**": true, + "**/node_modules/*/**": true, + "**/.hg/store/**": true, + ".flatpak/**": true, + "_build/**": true + }, + "mesonbuild.configureOnOpen": false, + "mesonbuild.buildFolder": "_build", + "mesonbuild.mesonPath": "${workspaceFolder}/.flatpak/meson.sh", + "rust-analyzer.server.path": "${workspaceFolder}/.flatpak/rust-analyzer.sh", + "rust-analyzer.runnables.command": "${workspaceFolder}/.flatpak/cargo.sh", + "rust-analyzer.files.excludeDirs": [ + ".flatpak" + ] +} \ No newline at end of file diff --git a/dev.mnts.ModManager.json b/dev.mnts.ModManager.json index 3ed306f..6f4943b 100644 --- a/dev.mnts.ModManager.json +++ b/dev.mnts.ModManager.json @@ -1,51 +1,59 @@ { - "app-id" : "dev.mnts.ModManager", - "runtime" : "org.gnome.Platform", - "runtime-version" : "master", - "sdk" : "org.gnome.Sdk", - "sdk-extensions" : [ - "org.freedesktop.Sdk.Extension.rust-stable" - ], - "command" : "mod-manager", - "finish-args" : [ - "--share=network", - "--share=ipc", - "--socket=fallback-x11", - "--device=dri", - "--socket=wayland" - ], - "build-options" : { - "append-path" : "/usr/lib/sdk/rust-stable/bin", - "build-args" : [ - "--share=network" - ], - "env" : { - "RUST_BACKTRACE" : "1", - "RUST_LOG" : "mod-manager=debug" - } - }, - "cleanup" : [ - "/include", - "/lib/pkgconfig", - "/man", - "/share/doc", - "/share/gtk-doc", - "/share/man", - "/share/pkgconfig", - "*.la", - "*.a" - ], - "modules" : [ + "app-id": "dev.mnts.ModManager", + "runtime": "org.gnome.Platform", + "runtime-version": "master", + "sdk": "org.gnome.Sdk", + "sdk-extensions": ["org.freedesktop.Sdk.Extension.rust-stable"], + "command": "mod-manager", + "finish-args": [ + "--share=network", + "--share=ipc", + "--socket=fallback-x11", + "--device=dri", + "--socket=wayland" + ], + "build-options": { + "append-path": "/usr/lib/sdk/rust-stable/bin", + "build-args": ["--share=network"], + "env": { + "RUST_BACKTRACE": "1", + "RUST_LOG": "mod-manager=debug" + } + }, + "cleanup": [ + "/include", + "/lib/pkgconfig", + "/man", + "/share/doc", + "/share/gtk-doc", + "/share/man", + "/share/pkgconfig", + "*.la", + "*.a" + ], + "modules": [ + { + "name": "blueprint-compiler", + "buildsystem": "meson", + "cleanup": ["*"], + "sources": [ { - "name" : "mod-manager", - "builddir" : true, - "buildsystem" : "meson", - "sources" : [ - { - "type" : "git", - "url" : "file:///home/tine/projects" - } - ] + "type": "git", + "url": "https://gitlab.gnome.org/jwestman/blueprint-compiler", + "tag": "v0.10.0" } - ] + ] + }, + { + "name": "mod-manager", + "builddir": true, + "buildsystem": "meson", + "sources": [ + { + "type": "git", + "url": "file:///home/tine/projects" + } + ] + } + ] } diff --git a/src/application.rs b/src/application.rs index 4a9ef85..0b22a57 100644 --- a/src/application.rs +++ b/src/application.rs @@ -24,6 +24,7 @@ use gtk::{gio, glib}; use crate::config::VERSION; use crate::ModManagerWindow; +use crate::pages::welcome::ModManagerWelcome; mod imp { use super::*; @@ -59,6 +60,10 @@ mod imp { window } else { let window = ModManagerWindow::new(&*application); + + let welcome = &ModManagerWelcome::new().upcast::(); + window.set_page(welcome); + window.upcast() }; diff --git a/src/gtk/help-overlay.blp b/src/gtk/help-overlay.blp new file mode 100644 index 0000000..90ee78f --- /dev/null +++ b/src/gtk/help-overlay.blp @@ -0,0 +1,24 @@ +using Gtk 4.0; + +ShortcutsWindow help_overlay { + modal: true; + + ShortcutsSection { + section-name: "shortcuts"; + max-height: 10; + + ShortcutsGroup { + title: C_("shortcut window", "General"); + + ShortcutsShortcut { + title: C_("shortcut window", "Show Shortcuts"); + action-name: "win.show-help-overlay"; + } + + ShortcutsShortcut { + title: C_("shortcut window", "Quit"); + action-name: "app.quit"; + } + } + } +} diff --git a/src/gtk/help-overlay.ui b/src/gtk/help-overlay.ui deleted file mode 100644 index ef12f02..0000000 --- a/src/gtk/help-overlay.ui +++ /dev/null @@ -1,29 +0,0 @@ - - - - True - - - shortcuts - 10 - - - General - - - Show Shortcuts - win.show-help-overlay - - - - - Quit - app.quit - - - - - - - - diff --git a/src/main.rs b/src/main.rs index 9818dc5..6154a16 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,26 +1,24 @@ -/* main.rs - * - * Copyright 2023 Tine - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: GPL-3.0-or-later +/* + Copyright (c) 2023 Tine Jozelj + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ mod application; mod config; mod window; +mod pages; use self::application::ModManagerApplication; use self::window::ModManagerWindow; diff --git a/src/meson.build b/src/meson.build index 9be8000..00e4bd1 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,8 +1,21 @@ pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name() gnome = import('gnome') +blueprints = custom_target('blueprints', + input: files( + 'window.blp', + 'gtk/help-overlay.blp', + 'pages/chose-game-location.blp', + 'pages/main.blp', + 'pages/welcome.blp', + ), + output: '.', + command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], +) + gnome.compile_resources('mod-manager', 'mod-manager.gresource.xml', + dependencies: blueprints, gresource_bundle: true, install: true, install_dir: pkgdatadir, diff --git a/src/mod-manager.gresource.xml b/src/mod-manager.gresource.xml index ce8dcf9..0e9b2d2 100644 --- a/src/mod-manager.gresource.xml +++ b/src/mod-manager.gresource.xml @@ -1,7 +1,11 @@ - window.ui - gtk/help-overlay.ui + pages/welcome.ui + pages/main.ui + pages/chose-game-location.blp + gtk/help-overlay.ui + window.ui + diff --git a/src/pages/chose-game-location.blp b/src/pages/chose-game-location.blp new file mode 100644 index 0000000..f97b733 --- /dev/null +++ b/src/pages/chose-game-location.blp @@ -0,0 +1,123 @@ +using Gtk 4.0; + +Box welcome { + orientation: vertical; + valign: center; + halign: center; + + Image { + name: "logo"; + icon-name: "re.sonny.Workbench"; + pixel-size: 196; + margin-bottom: 30; + + styles [ + "icon-dropshadow" + ] + } + + Label { + label: _("Welcome to Mod Manager"); + margin-bottom: 30; + + styles [ + "title-1" + ] + } + + Box subtitle { + orientation: vertical; + halign: center; + margin-bottom: 30; + + Label { + label: "Learn and prototype with\nGNOME technologies"; + justify: center; + } + } + + Box { + orientation: vertical; + homogeneous: true; + halign: center; + + Box { + margin-bottom: 6; + + Image { + icon-name: "update-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Edit Style or UI to update the Preview"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "media-playback-start-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Hit"); + } + + ShortcutsShortcut { + accelerator: "Return"; + margin-start: 12; + } + + Label { + label: _("to format and run Code"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "media-floppy-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Changes are automatically saved and restored"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "library-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Browse the Library for demos and examples"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "user-bookmarks-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Checkout the Bookmarks menu to learn and get help"); + } + } + } +} \ No newline at end of file diff --git a/src/pages/main.blp b/src/pages/main.blp new file mode 100644 index 0000000..f97b733 --- /dev/null +++ b/src/pages/main.blp @@ -0,0 +1,123 @@ +using Gtk 4.0; + +Box welcome { + orientation: vertical; + valign: center; + halign: center; + + Image { + name: "logo"; + icon-name: "re.sonny.Workbench"; + pixel-size: 196; + margin-bottom: 30; + + styles [ + "icon-dropshadow" + ] + } + + Label { + label: _("Welcome to Mod Manager"); + margin-bottom: 30; + + styles [ + "title-1" + ] + } + + Box subtitle { + orientation: vertical; + halign: center; + margin-bottom: 30; + + Label { + label: "Learn and prototype with\nGNOME technologies"; + justify: center; + } + } + + Box { + orientation: vertical; + homogeneous: true; + halign: center; + + Box { + margin-bottom: 6; + + Image { + icon-name: "update-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Edit Style or UI to update the Preview"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "media-playback-start-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Hit"); + } + + ShortcutsShortcut { + accelerator: "Return"; + margin-start: 12; + } + + Label { + label: _("to format and run Code"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "media-floppy-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Changes are automatically saved and restored"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "library-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Browse the Library for demos and examples"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "user-bookmarks-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Checkout the Bookmarks menu to learn and get help"); + } + } + } +} \ No newline at end of file diff --git a/src/pages/mod.rs b/src/pages/mod.rs new file mode 100644 index 0000000..dc04f27 --- /dev/null +++ b/src/pages/mod.rs @@ -0,0 +1,2 @@ +pub mod welcome; +pub use welcome::*; \ No newline at end of file diff --git a/src/pages/welcome.blp b/src/pages/welcome.blp new file mode 100644 index 0000000..a174920 --- /dev/null +++ b/src/pages/welcome.blp @@ -0,0 +1,111 @@ +using Gtk 4.0; +using Adw 1; + +template $ModManagerWelcome : Adw.NavigationPage { + + + Label { + label: _("Welcome to Mod Manager"); + margin-bottom: 30; + + styles [ + "title-1" + ] + } + + Box subtitle { + orientation: vertical; + halign: center; + margin-bottom: 30; + + Label { + label: "Learn and prototype with\nGNOME technologies"; + justify: center; + } + } + + Box { + orientation: vertical; + homogeneous: true; + halign: center; + + Box { + margin-bottom: 6; + + Image { + icon-name: "update-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Edit Style or UI to update the Preview"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "media-playback-start-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Hit"); + } + + ShortcutsShortcut { + accelerator: "Return"; + margin-start: 12; + } + + Label { + label: _("to format and run Code"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "media-floppy-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Changes are automatically saved and restored"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "library-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Browse the Library for demos and examples"); + } + } + + Box { + margin-bottom: 6; + + Image { + icon-name: "user-bookmarks-symbolic"; + margin-end: 12; + icon-size: normal; + } + + Label { + label: _("Checkout the Bookmarks menu to learn and get help"); + } + } + } +} \ No newline at end of file diff --git a/src/pages/welcome.rs b/src/pages/welcome.rs new file mode 100644 index 0000000..dd91b55 --- /dev/null +++ b/src/pages/welcome.rs @@ -0,0 +1,66 @@ +/* welcome.rs + * + * Copyright 2023 Tine + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +use gtk::prelude::*; +use adw::subclass::prelude::*; +use gtk::{gio, glib}; + +mod imp { + use super::*; + + #[derive(Debug, Default, gtk::CompositeTemplate)] + #[template(resource = "/dev/mnts/ModManager/pages/welcome.ui")] + pub struct ModManagerWelcome { + } + + #[glib::object_subclass] + impl ObjectSubclass for ModManagerWelcome { + const NAME: &'static str = "ModManagerWelcome"; + type Type = super::ModManagerWelcome; + type ParentType = adw::NavigationPage; + + fn class_init(klass: &mut Self::Class) { + klass.bind_template(); + } + + fn instance_init(obj: &glib::subclass::InitializingObject) { + obj.init_template(); + } + } + + impl ObjectImpl for ModManagerWelcome {} + impl WidgetImpl for ModManagerWelcome {} + impl NavigationPageImpl for ModManagerWelcome {} + +} + +glib::wrapper! { + pub struct ModManagerWelcome(ObjectSubclass) + @extends gtk::Widget, gtk::Buildable, adw::NavigationPage, + @implements gio::ActionGroup, gio::ActionMap; +} + +impl ModManagerWelcome { + pub fn new() -> Self { + glib::Object::builder() + .build() + } +} + diff --git a/src/window.blp b/src/window.blp new file mode 100644 index 0000000..a977cdf --- /dev/null +++ b/src/window.blp @@ -0,0 +1,57 @@ +/* + Copyright (c) 2023 Tine Jozelj + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +using Gtk 4.0; +using Adw 1; + +template $ModManagerWindow : Adw.ApplicationWindow { + default-width: 600; + default-height: 300; + + content: Adw.ToolbarView { + [top] + Adw.HeaderBar header_bar { + [end] + MenuButton { + primary: true; + icon-name: "open-menu-symbolic"; + tooltip-text: _("Menu"); + menu-model: primary_menu; + } + } + content: Adw.NavigationView navigation_view {}; + }; +} + +menu primary_menu { + section { + item { + label: _("_Preferences"); + action: "app.preferences"; + } + + item { + label: _("_Keyboard Shortcuts"); + action: "win.show-help-overlay"; + } + + item { + label: _("_About Mod-manager"); + action: "app.about"; + } + } +} diff --git a/src/window.rs b/src/window.rs index f6155ae..b6961f8 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,21 +1,18 @@ -/* window.rs - * - * Copyright 2023 Tine - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: GPL-3.0-or-later +/* + Copyright (c) 2023 Tine Jozelj + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ use gtk::prelude::*; @@ -32,7 +29,7 @@ mod imp { #[template_child] pub header_bar: TemplateChild, #[template_child] - pub label: TemplateChild, + pub navigation_view: TemplateChild, } #[glib::object_subclass] @@ -59,7 +56,8 @@ mod imp { glib::wrapper! { pub struct ModManagerWindow(ObjectSubclass) - @extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, @implements gio::ActionGroup, gio::ActionMap; + @extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, + @implements gio::ActionGroup, gio::ActionMap; } impl ModManagerWindow { @@ -68,4 +66,9 @@ impl ModManagerWindow { .property("application", application) .build() } + + pub fn set_page(&self, page: &adw::NavigationPage) { + imp::ModManagerWindow::from_obj(self) + .navigation_view.push(page); + } } diff --git a/src/window.ui b/src/window.ui deleted file mode 100644 index 67e41d5..0000000 --- a/src/window.ui +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - -
- - _Preferences - app.preferences - - - _Keyboard Shortcuts - win.show-help-overlay - - - _About Mod-manager - app.about - -
-
-