From bd637cb97da79bad44a0b6daee6d102c086f58ed Mon Sep 17 00:00:00 2001 From: Franz Dietrich Date: Sun, 21 Jan 2024 22:26:03 +0100 Subject: [PATCH] Sliding details --- gui/main_window.blp | 106 +++++++++++++++++++++++-------------- src/bin/gui/main_window.rs | 15 +++--- 2 files changed, 73 insertions(+), 48 deletions(-) diff --git a/gui/main_window.blp b/gui/main_window.blp index 1e891bb..05e352c 100644 --- a/gui/main_window.blp +++ b/gui/main_window.blp @@ -2,53 +2,77 @@ using Gtk 4.0; using Adw 1; Adw.ApplicationWindow window { - default-width: 900; - default-height: 500; + default-width: 900; + default-height: 500; - content: Gtk.Box { - orientation: vertical; + content: Gtk.Box { + orientation: vertical; - Adw.HeaderBar{ - title-widget: Adw.WindowTitle { - title: "Sieverman"; - }; + Adw.HeaderBar { + title-widget: Adw.WindowTitle { + title: "Sieverman"; + }; - Gtk.Button { label: "Neu";} - } - Gtk.Box { - orientation: horizontal; - - vexpand: true; - halign: fill; + [start] + Gtk.Button { + label: "Neu"; + } - Gtk.Label{ - label: "Log information"; - hexpand: true; + [end] + Gtk.ToggleButton settings_button { + icon-name: "open-menu-symbolic"; + active: true; + } + } + + Gtk.Box { + orientation: horizontal; + vexpand: true; + halign: fill; + + Gtk.Label { + label: "Log information"; + hexpand: true; + } + + Gtk.Revealer settings_pane { + reveal-child: bind settings_button.active bidirectional; + transition-type: slide_left; + + Gtk.ScrolledWindow server_info { + width-request: 100; + + Adw.PreferencesPage { + Adw.PreferencesGroup server_settings { + vexpand: true; + valign: center; + title: "Server Information"; + description: "The information the server published on connection"; } - Gtk.ScrolledWindow server_info { - width-request: 100; - Adw.PreferencesPage { - Adw.PreferencesGroup server_settings{ - vexpand: true; - valign: center; - title: "Server Information"; - description: "The information the server published on connection"; - } - Adw.PreferencesGroup credentials { - vexpand: true; - valign: center; - title: "Login Information"; - description: "The credentials that will be used to log in."; - Adw.EntryRow{title: "Username:";} - Adw.PasswordEntryRow{title: "Password:";} - }} - + Adw.PreferencesGroup credentials { + vexpand: true; + valign: center; + title: "Login Information"; + description: "The credentials that will be used to log in."; + + Adw.EntryRow { + title: "Username:"; + } + + Adw.PasswordEntryRow { + title: "Password:"; + } } + } } - Gtk.Statusbar{Gtk.Label{ - label: "Status"; - }} + } + } - }; -} \ No newline at end of file + Gtk.Statusbar { + Gtk.Label { + label: "Status"; + } + } + }; +} diff --git a/src/bin/gui/main_window.rs b/src/bin/gui/main_window.rs index 16f175f..1cd794c 100644 --- a/src/bin/gui/main_window.rs +++ b/src/bin/gui/main_window.rs @@ -1,11 +1,11 @@ use std::{cell::RefCell, rc::Rc}; use crate::__COMPILED_BLUEPRINT_MAP__; -use gtk4::{ - glib, +use gtk::{ prelude::{ApplicationExt, GtkWindowExt}, Application, }; +use gtk4 as gtk; use gtk_blueprint::get_blp; use libadwaita::prelude::{PreferencesGroupExt, PreferencesRowExt}; use tracing::trace; @@ -25,16 +25,17 @@ pub(crate) fn get_app( } fn build_ui( - app: >k4::Application, + app: >k::Application, from_backend_rx: Rc>>>, ) { - let builder = gtk4::Builder::new(); + let builder = gtk::Builder::new(); builder .add_from_string(get_blp!("gui/main_window.blp")) .expect("Failed to parse blueprint"); let main_window = builder .object::("window") .unwrap(); + let prefrences_group = builder .object::("server_settings") .unwrap(); @@ -58,14 +59,14 @@ fn build_ui( } }; - let c = glib::MainContext::default(); + let c = gtk::glib::MainContext::default(); c.spawn_local(future); main_window.present(); trace!("Window is visible"); } fn row_in_settings(name: &str, value: &str) -> libadwaita::ActionRow { - let builder = gtk4::Builder::new(); + let builder = gtk::Builder::new(); builder .add_from_string(get_blp!("gui/server_info_row.blp")) .expect("Failed to parse blueprint"); @@ -75,7 +76,7 @@ fn row_in_settings(name: &str, value: &str) -> libadwaita::ActionRow { .unwrap(); row.set_title(name); let label = builder - .object::("server_info_row_value") + .object::("server_info_row_value") .unwrap(); label.set_label(value); row