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