Stato full in stato finestra

master
Pietro Brenna 2020-03-21 12:55:03 +01:00
parent a0425f01f5
commit 0626fab9d4
3 changed files with 27 additions and 40 deletions

View File

@ -8,14 +8,13 @@ use gtk::prelude::*;
use glib::clone;
use gtk::SettingsExt;
use std::env::args;
use std::sync::{Arc, RwLock};
use std::thread;
mod menu;
mod stato_finestra;
mod tabs;
mod wake_listener;
use stato_finestra::OperazStato;
use stato_finestra::{OperazStato, PosizFinestra, StatoFinestra, StatoFull};
fn build_ui(application: &gtk::Application) {
let window = gtk::ApplicationWindow::new(application);
@ -70,8 +69,7 @@ fn build_ui(application: &gtk::Application) {
}),
);
let (key, modifier) = gtk::accelerator_parse("F11");
let full_screen = Arc::new(RwLock::new(false));
let stato = Arc::new(RwLock::new(stato_finestra::StatoFinestra::new(stato_finestra::PosizFinestra::Su)));
let stato = StatoFinestra::new_arc(PosizFinestra::Su, StatoFull::NonFull);
let stato0 = stato.clone();
let stato1 = stato.clone();
let stato2 = stato.clone();
@ -83,15 +81,16 @@ fn build_ui(application: &gtk::Application) {
modifier,
gtk::AccelFlags::VISIBLE,
clone!(@weak window => @default-return true, move |_accel_g, _win, _key, _modif| {
if let Ok(mut lock) = full_screen.write(){
if *lock {
match stato5.get_full() {
StatoFull::Full => {
window.unfullscreen();
stato5.set_full(stato_finestra::StatoFull::NonFull);
} else {
window.fullscreen();
stato5.set_full(stato_finestra::StatoFull::Full);
stato5.set_full(StatoFull::NonFull);
}
*lock = !*lock;
StatoFull::NonFull => {
window.fullscreen();
stato5.set_full(StatoFull::Full);
}
_ => {}
}
true
}),
@ -133,23 +132,21 @@ fn build_ui(application: &gtk::Application) {
window.connect_focus_in_event(clone!(@weak window => @default-return gtk::Inhibit(false),
move |_widget, _b| stato_finestra::focus_in(&window, &stato2)));
nb.connect_destroy(move |_nb| {
stato.set_pos(stato_finestra::PosizFinestra::Chiudendo);
stato.set_pos(PosizFinestra::Chiudendo);
});
nb.connect_page_removed(
clone!(@weak window => move |notebook, _vte, _index| {
if notebook.get_n_pages() == 0 {
if stato0.get_pos() != stato_finestra::PosizFinestra::Chiudendo {
crate::tabs::apri_tab(&window, &notebook, false,None, None, None);
stato_finestra::butta_giu(&window, &stato0);
}
} else {
tabs::set_titles(&notebook);
if notebook.get_n_pages() == 1 {
notebook.set_show_tabs(false);
}
nb.connect_page_removed(clone!(@weak window => move |notebook, _vte, _index| {
if notebook.get_n_pages() == 0 {
if stato0.get_pos() != PosizFinestra::Chiudendo {
crate::tabs::apri_tab(&window, &notebook, false,None, None, None);
stato_finestra::butta_giu(&window, &stato0);
}
}),
);
} else {
tabs::set_titles(&notebook);
if notebook.get_n_pages() == 1 {
notebook.set_show_tabs(false);
}
}
}));
nb.connect_page_added(move |notebook, _vte, _index| {
if notebook.get_n_pages() > 1 {
notebook.set_show_tabs(true);
@ -185,14 +182,7 @@ fn build_ui(application: &gtk::Application) {
command,
} => {
tira_su();
tabs::apri_tab(
&window,
&nb,
true,
cwd,
Some(shell),
Some(command),
);
tabs::apri_tab(&window, &nb, true, cwd, Some(shell), Some(command));
}
}
glib::Continue(true)

View File

@ -21,11 +21,8 @@ pub struct StatoFinestra {
full: StatoFull,
}
impl StatoFinestra {
pub fn new(p: PosizFinestra) -> Self {
StatoFinestra {
full: NonFull,
posiz: p,
}
pub fn new_arc(p: PosizFinestra, f: StatoFull) -> Arc<RwLock<Self>> {
Arc::new(RwLock::new(StatoFinestra { full: f, posiz: p }))
}
}
pub trait OperazStato {

View File

@ -31,7 +31,7 @@ pub fn build_tab(
let shell = shell.unwrap_or(vec![var("SHELL").unwrap_or("/bin/sh".to_string())]);
let shell: Vec<_> = shell.iter().map(Path::new).collect();
let stringa: String;
let cwd = if cwd.is_some() {
let cwd = if cwd.is_some() {
stringa = cwd.unwrap();
Some(stringa.as_str())
} else {