Traduz inglese
parent
efb473c6fc
commit
93d44a0c99
58
src/main.rs
58
src/main.rs
|
|
@ -11,11 +11,11 @@ use std::env::args;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
mod menu;
|
mod menu;
|
||||||
mod stato_finestra;
|
|
||||||
mod tabs;
|
mod tabs;
|
||||||
mod wake_listener;
|
mod wake_listener;
|
||||||
|
mod window_state;
|
||||||
use crate::vte::TerminalExt;
|
use crate::vte::TerminalExt;
|
||||||
use stato_finestra::{OperazStato, PosizFinestra, StatoFinestra, StatoFull};
|
use window_state::{FullScreenState, StateOperations, WindowPos, WindowState};
|
||||||
|
|
||||||
fn build_ui(application: >k::Application) {
|
fn build_ui(application: >k::Application) {
|
||||||
let window = gtk::ApplicationWindow::new(application);
|
let window = gtk::ApplicationWindow::new(application);
|
||||||
|
|
@ -45,7 +45,7 @@ fn build_ui(application: >k::Application) {
|
||||||
modifier,
|
modifier,
|
||||||
gtk::AccelFlags::VISIBLE,
|
gtk::AccelFlags::VISIBLE,
|
||||||
clone!(@weak window, @weak nb => @default-return true, move |_accel_g, _window, _key, _modif| {
|
clone!(@weak window, @weak nb => @default-return true, move |_accel_g, _window, _key, _modif| {
|
||||||
tabs::apri_tab(&window, &nb, true, None, None, None);
|
tabs::open_tab(&window, &nb, true, None, None, None);
|
||||||
true
|
true
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -86,26 +86,26 @@ fn build_ui(application: >k::Application) {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
let (key, modifier) = gtk::accelerator_parse("F11");
|
let (key, modifier) = gtk::accelerator_parse("F11");
|
||||||
let stato = StatoFinestra::new_arc(PosizFinestra::Su, StatoFull::NonFull);
|
let w_state = WindowState::new_arc(WindowPos::Up, FullScreenState::NotFull);
|
||||||
let stato0 = stato.clone();
|
let w_state0 = w_state.clone();
|
||||||
let stato1 = stato.clone();
|
let w_state1 = w_state.clone();
|
||||||
let stato2 = stato.clone();
|
let w_state2 = w_state.clone();
|
||||||
let stato3 = stato.clone();
|
let w_state3 = w_state.clone();
|
||||||
let stato4 = stato.clone();
|
let w_state4 = w_state.clone();
|
||||||
let stato5 = stato.clone();
|
let w_state5 = w_state.clone();
|
||||||
accel_group.connect_accel_group(
|
accel_group.connect_accel_group(
|
||||||
key,
|
key,
|
||||||
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| {
|
||||||
match stato5.get_full() {
|
match w_state5.get_full() {
|
||||||
StatoFull::Full => {
|
FullScreenState::Full => {
|
||||||
window.unfullscreen();
|
window.unfullscreen();
|
||||||
stato5.set_full(StatoFull::NonFull);
|
w_state5.set_full(FullScreenState::NotFull);
|
||||||
}
|
}
|
||||||
StatoFull::NonFull => {
|
FullScreenState::NotFull => {
|
||||||
window.fullscreen();
|
window.fullscreen();
|
||||||
stato5.set_full(StatoFull::Full);
|
w_state5.set_full(FullScreenState::Full);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
@ -128,8 +128,8 @@ fn build_ui(application: >k::Application) {
|
||||||
window.add_accel_group(&accel_group);
|
window.add_accel_group(&accel_group);
|
||||||
|
|
||||||
window.add(&nb);
|
window.add(&nb);
|
||||||
if let Ok(first_tab) = tabs::build_tab(&window, &nb, None, None) {
|
if let Ok(first_tab) = tabs::build_tab(&nb, None, None) {
|
||||||
tabs::passa_a_tab(&window, &nb, &first_tab);
|
tabs::go_to_tab(&window, &nb, &first_tab);
|
||||||
}
|
}
|
||||||
window.set_skip_taskbar_hint(true);
|
window.set_skip_taskbar_hint(true);
|
||||||
window.set_skip_pager_hint(true);
|
window.set_skip_pager_hint(true);
|
||||||
|
|
@ -145,17 +145,17 @@ fn build_ui(application: >k::Application) {
|
||||||
);
|
);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
window.connect_focus_out_event(move |_widget, _b| stato_finestra::focus_out(&stato1));
|
window.connect_focus_out_event(move |_widget, _b| window_state::focus_out(&w_state1));
|
||||||
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| window_state::focus_in(&window, &w_state2)));
|
||||||
nb.connect_destroy(move |_nb| {
|
nb.connect_destroy(move |_nb| {
|
||||||
stato.set_pos(PosizFinestra::Chiudendo);
|
w_state.set_pos(WindowPos::Closing);
|
||||||
});
|
});
|
||||||
nb.connect_page_removed(clone!(@weak window => move |notebook, _vte, _index| {
|
nb.connect_page_removed(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 w_state0.get_pos() != WindowPos::Closing {
|
||||||
crate::tabs::apri_tab(&window, ¬ebook, false,None, None, None);
|
crate::tabs::open_tab(&window, ¬ebook, false,None, None, None);
|
||||||
stato_finestra::butta_giu(&window, &stato0);
|
window_state::hide(&window, &w_state0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tabs::set_titles(¬ebook);
|
tabs::set_titles(¬ebook);
|
||||||
|
|
@ -174,24 +174,24 @@ fn build_ui(application: >k::Application) {
|
||||||
});
|
});
|
||||||
|
|
||||||
let (tx, rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
|
let (tx, rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
|
||||||
stato_finestra::tira_su(&window, &stato4, gtk::get_current_event_time());
|
window_state::bring_up(&window, &w_state4, gtk::get_current_event_time());
|
||||||
//tabs::focus_tab_corrente(&nb);
|
//tabs::focus_tab_corrente(&nb);
|
||||||
rx.attach(None, move |cmd| {
|
rx.attach(None, move |cmd| {
|
||||||
let tira_su = || {
|
let tira_su = || {
|
||||||
stato_finestra::tira_su(&window, &stato3, gtk::get_current_event_time());
|
window_state::bring_up(&window, &w_state3, gtk::get_current_event_time());
|
||||||
};
|
};
|
||||||
use wake_listener::RpcCommand::*;
|
use wake_listener::RpcCommand::*;
|
||||||
match cmd {
|
match cmd {
|
||||||
Toggle => {
|
Toggle => {
|
||||||
stato_finestra::esegui_toggle(&window, &nb, &stato3);
|
window_state::esegui_toggle(&window, &nb, &w_state3);
|
||||||
}
|
}
|
||||||
RunShell { cwd, shell } => {
|
RunShell { cwd, shell } => {
|
||||||
tira_su();
|
tira_su();
|
||||||
tabs::apri_tab(&window, &nb, true, cwd, Some(shell), None);
|
tabs::open_tab(&window, &nb, true, cwd, Some(shell), None);
|
||||||
}
|
}
|
||||||
RunInDefaultShell { cwd, command } => {
|
RunInDefaultShell { cwd, command } => {
|
||||||
tira_su();
|
tira_su();
|
||||||
tabs::apri_tab(&window, &nb, true, cwd, None, Some(command));
|
tabs::open_tab(&window, &nb, true, cwd, None, Some(command));
|
||||||
}
|
}
|
||||||
RunInCustomShell {
|
RunInCustomShell {
|
||||||
cwd,
|
cwd,
|
||||||
|
|
@ -199,7 +199,7 @@ fn build_ui(application: >k::Application) {
|
||||||
command,
|
command,
|
||||||
} => {
|
} => {
|
||||||
tira_su();
|
tira_su();
|
||||||
tabs::apri_tab(&window, &nb, true, cwd, Some(shell), Some(command));
|
tabs::open_tab(&window, &nb, true, cwd, Some(shell), Some(command));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glib::Continue(true)
|
glib::Continue(true)
|
||||||
|
|
|
||||||
21
src/tabs.rs
21
src/tabs.rs
|
|
@ -4,26 +4,16 @@ use std::{env::var, path::Path};
|
||||||
use vte::TerminalExt;
|
use vte::TerminalExt;
|
||||||
|
|
||||||
pub fn build_tab(
|
pub fn build_tab(
|
||||||
window: >k::ApplicationWindow,
|
|
||||||
nb: >k::Notebook,
|
nb: >k::Notebook,
|
||||||
cwd: Option<String>,
|
cwd: Option<String>,
|
||||||
shell: Option<Vec<String>>,
|
shell: Option<Vec<String>>,
|
||||||
) -> Result<vte::Terminal, glib::Error> {
|
) -> Result<vte::Terminal, glib::Error> {
|
||||||
let new_accel_g = gtk::AccelGroup::new();
|
|
||||||
let l = gtk::Label::new(Some("~"));
|
let l = gtk::Label::new(Some("~"));
|
||||||
l.set_width_chars(14);
|
l.set_width_chars(14);
|
||||||
l.set_ellipsize(pango::EllipsizeMode::Middle);
|
l.set_ellipsize(pango::EllipsizeMode::Middle);
|
||||||
//gtk::Window::set_interactive_debugging(true);
|
//gtk::Window::set_interactive_debugging(true);
|
||||||
let vte = vte::Terminal::new();
|
let vte = vte::Terminal::new();
|
||||||
vte.set_scrollback_lines(-1);
|
vte.set_scrollback_lines(-1);
|
||||||
// let (key, modifier) = gtk::accelerator_parse("<Control><Shift>c");
|
|
||||||
// vte.add_accelerator(
|
|
||||||
// "copy-clipboard",
|
|
||||||
// &new_accel_g,
|
|
||||||
// key,
|
|
||||||
// modifier,
|
|
||||||
// gtk::AccelFlags::VISIBLE,
|
|
||||||
// );
|
|
||||||
|
|
||||||
let font = pango::FontDescription::from_string("Iosevka Regular 13");
|
let font = pango::FontDescription::from_string("Iosevka Regular 13");
|
||||||
vte.set_font(Some(&font));
|
vte.set_font(Some(&font));
|
||||||
|
|
@ -66,7 +56,6 @@ pub fn build_tab(
|
||||||
vte.connect_window_title_changed(clone!(@weak nb => move |term| {
|
vte.connect_window_title_changed(clone!(@weak nb => move |term| {
|
||||||
set_title(term, &nb);
|
set_title(term, &nb);
|
||||||
}));
|
}));
|
||||||
window.add_accel_group(&new_accel_g);
|
|
||||||
// Setto colori terminale
|
// Setto colori terminale
|
||||||
use glib::translate::ToGlibPtr;
|
use glib::translate::ToGlibPtr;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
@ -130,12 +119,12 @@ pub fn set_titles(nb: >k::Notebook) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn passa_a_tab(win: >k::ApplicationWindow, nb: >k::Notebook, vte: &vte::Terminal) {
|
pub fn go_to_tab(win: >k::ApplicationWindow, nb: >k::Notebook, vte: &vte::Terminal) {
|
||||||
let p_num = nb.page_num(vte);
|
let p_num = nb.page_num(vte);
|
||||||
nb.set_current_page(p_num);
|
nb.set_current_page(p_num);
|
||||||
win.set_focus(Some(vte));
|
win.set_focus(Some(vte));
|
||||||
}
|
}
|
||||||
pub fn focus_tab_corrente(nb: >k::Notebook) {
|
pub fn focus_current_tab(nb: >k::Notebook) {
|
||||||
let n_p = nb.get_current_page();
|
let n_p = nb.get_current_page();
|
||||||
let vte = nb.get_nth_page(n_p);
|
let vte = nb.get_nth_page(n_p);
|
||||||
if let Some(vte) = vte {
|
if let Some(vte) = vte {
|
||||||
|
|
@ -149,7 +138,7 @@ pub fn focus_tab_corrente(nb: >k::Notebook) {
|
||||||
fn inject(term: &vte::Terminal, command: String) {
|
fn inject(term: &vte::Terminal, command: String) {
|
||||||
term.feed_child_binary(format!("{}\n", command.trim()).as_bytes());
|
term.feed_child_binary(format!("{}\n", command.trim()).as_bytes());
|
||||||
}
|
}
|
||||||
pub fn apri_tab(
|
pub fn open_tab(
|
||||||
window: >k::ApplicationWindow,
|
window: >k::ApplicationWindow,
|
||||||
nb: >k::Notebook,
|
nb: >k::Notebook,
|
||||||
focus: bool,
|
focus: bool,
|
||||||
|
|
@ -157,11 +146,11 @@ pub fn apri_tab(
|
||||||
shell: Option<Vec<String>>,
|
shell: Option<Vec<String>>,
|
||||||
inject_command: Option<String>,
|
inject_command: Option<String>,
|
||||||
) {
|
) {
|
||||||
let new_tab = build_tab(window, nb, cwd, shell);
|
let new_tab = build_tab(nb, cwd, shell);
|
||||||
if let Ok(new_tab) = new_tab {
|
if let Ok(new_tab) = new_tab {
|
||||||
window.show_all();
|
window.show_all();
|
||||||
if focus {
|
if focus {
|
||||||
crate::tabs::passa_a_tab(&window, &nb, &new_tab);
|
crate::tabs::go_to_tab(&window, &nb, &new_tab);
|
||||||
}
|
}
|
||||||
if let Some(command) = inject_command {
|
if let Some(command) = inject_command {
|
||||||
inject(&new_tab, command);
|
inject(&new_tab, command);
|
||||||
|
|
|
||||||
|
|
@ -5,68 +5,68 @@ use std::sync::RwLock;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
|
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
|
||||||
pub enum PosizFinestra {
|
pub enum WindowPos {
|
||||||
Su,
|
Up,
|
||||||
TirandoSu,
|
BringingUp,
|
||||||
Nascondendo,
|
Hiding,
|
||||||
Nascosta,
|
Hidden,
|
||||||
SuNonFocusata,
|
UpWithoutFocus,
|
||||||
Chiudendo,
|
Closing,
|
||||||
Sconosciuta,
|
Unknown,
|
||||||
}
|
}
|
||||||
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
|
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
|
||||||
pub enum StatoFull {
|
pub enum FullScreenState {
|
||||||
Full,
|
Full,
|
||||||
NonFull,
|
NotFull,
|
||||||
Sconosciuto,
|
Unknown,
|
||||||
}
|
}
|
||||||
pub use PosizFinestra::*;
|
pub use FullScreenState::*;
|
||||||
pub use StatoFull::*;
|
pub use WindowPos::*;
|
||||||
pub struct StatoFinestra {
|
pub struct WindowState {
|
||||||
posiz: PosizFinestra,
|
position: WindowPos,
|
||||||
full: StatoFull,
|
full: FullScreenState,
|
||||||
last_toggle: Option<Instant>,
|
last_toggle: Option<Instant>,
|
||||||
}
|
}
|
||||||
impl StatoFinestra {
|
impl WindowState {
|
||||||
pub fn new_arc(p: PosizFinestra, f: StatoFull) -> Rc<RwLock<Self>> {
|
pub fn new_arc(p: WindowPos, f: FullScreenState) -> Rc<RwLock<Self>> {
|
||||||
Rc::new(RwLock::new(StatoFinestra {
|
Rc::new(RwLock::new(WindowState {
|
||||||
full: f,
|
full: f,
|
||||||
posiz: p,
|
position: p,
|
||||||
last_toggle: None,
|
last_toggle: None,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub trait OperazStato {
|
pub trait StateOperations {
|
||||||
fn set_pos(&self, p: PosizFinestra);
|
fn set_pos(&self, p: WindowPos);
|
||||||
fn get_pos(&self) -> PosizFinestra;
|
fn get_pos(&self) -> WindowPos;
|
||||||
fn set_full(&self, f: StatoFull);
|
fn set_full(&self, f: FullScreenState);
|
||||||
fn get_full(&self) -> StatoFull;
|
fn get_full(&self) -> FullScreenState;
|
||||||
fn set_last_toggle(&self, instant: Option<Instant>);
|
fn set_last_toggle(&self, instant: Option<Instant>);
|
||||||
fn get_last_toggle(&self) -> Option<Instant>;
|
fn get_last_toggle(&self) -> Option<Instant>;
|
||||||
}
|
}
|
||||||
impl OperazStato for Rc<RwLock<StatoFinestra>> {
|
impl StateOperations for Rc<RwLock<WindowState>> {
|
||||||
fn set_pos(&self, p: PosizFinestra) {
|
fn set_pos(&self, p: WindowPos) {
|
||||||
if let Ok(mut w_lock) = self.write() {
|
if let Ok(mut w_lock) = self.write() {
|
||||||
w_lock.posiz = p;
|
w_lock.position = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn get_pos(&self) -> PosizFinestra {
|
fn get_pos(&self) -> WindowPos {
|
||||||
if let Ok(r_lock) = self.read() {
|
if let Ok(r_lock) = self.read() {
|
||||||
r_lock.posiz
|
r_lock.position
|
||||||
} else {
|
} else {
|
||||||
Sconosciuta
|
WindowPos::Unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn set_full(&self, full: StatoFull) {
|
fn set_full(&self, full: FullScreenState) {
|
||||||
if let Ok(mut w_lock) = self.write() {
|
if let Ok(mut w_lock) = self.write() {
|
||||||
w_lock.full = full;
|
w_lock.full = full;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn get_full(&self) -> StatoFull {
|
fn get_full(&self) -> FullScreenState {
|
||||||
if let Ok(r_lock) = self.read() {
|
if let Ok(r_lock) = self.read() {
|
||||||
r_lock.full
|
r_lock.full
|
||||||
} else {
|
} else {
|
||||||
Sconosciuto
|
FullScreenState::Unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn get_last_toggle(&self) -> Option<Instant> {
|
fn get_last_toggle(&self) -> Option<Instant> {
|
||||||
|
|
@ -83,15 +83,15 @@ impl OperazStato for Rc<RwLock<StatoFinestra>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tira_su(window: >k::ApplicationWindow, stato: &Rc<RwLock<StatoFinestra>>, ts: u32) {
|
pub fn bring_up(window: >k::ApplicationWindow, w_state: &Rc<RwLock<WindowState>>, ts: u32) {
|
||||||
if let Some(instant) = stato.get_last_toggle() {
|
if let Some(instant) = w_state.get_last_toggle() {
|
||||||
if instant.elapsed() < Duration::from_millis(300) {
|
if instant.elapsed() < Duration::from_millis(300) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stato.set_last_toggle(Some(Instant::now()));
|
w_state.set_last_toggle(Some(Instant::now()));
|
||||||
let new_pos = match stato.get_pos() {
|
let new_pos = match w_state.get_pos() {
|
||||||
Nascosta | Nascondendo => {
|
Hidden | Hiding => {
|
||||||
// Shameless copy from guake
|
// Shameless copy from guake
|
||||||
/*window.hide();
|
/*window.hide();
|
||||||
window.present();
|
window.present();
|
||||||
|
|
@ -105,9 +105,9 @@ pub fn tira_su(window: >k::ApplicationWindow, stato: &Rc<RwLock<StatoFinestra>
|
||||||
/*if let Some(ref gdk_window) = gdk_window {
|
/*if let Some(ref gdk_window) = gdk_window {
|
||||||
gdk_window.focus(0);
|
gdk_window.focus(0);
|
||||||
}*/
|
}*/
|
||||||
Some(TirandoSu)
|
Some(BringingUp)
|
||||||
}
|
}
|
||||||
SuNonFocusata => {
|
UpWithoutFocus => {
|
||||||
window.hide();
|
window.hide();
|
||||||
window.show();
|
window.show();
|
||||||
let gdk_window = window.get_window();
|
let gdk_window = window.get_window();
|
||||||
|
|
@ -117,43 +117,43 @@ pub fn tira_su(window: >k::ApplicationWindow, stato: &Rc<RwLock<StatoFinestra>
|
||||||
}
|
}
|
||||||
let s = calc_w_h(window);
|
let s = calc_w_h(window);
|
||||||
window.get_window().map(|w| w.resize(s.0, s.1));
|
window.get_window().map(|w| w.resize(s.0, s.1));
|
||||||
Some(Su)
|
Some(Up)
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
if let Some(new_pos) = new_pos {
|
if let Some(new_pos) = new_pos {
|
||||||
stato.set_pos(new_pos);
|
w_state.set_pos(new_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn butta_giu(window: >k::ApplicationWindow, stato: &Rc<RwLock<StatoFinestra>>) {
|
pub fn hide(window: >k::ApplicationWindow, stato: &Rc<RwLock<WindowState>>) {
|
||||||
stato.set_pos(Nascondendo);
|
stato.set_pos(Hiding);
|
||||||
window.hide();
|
window.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn esegui_toggle(
|
pub fn esegui_toggle(
|
||||||
window: >k::ApplicationWindow,
|
window: >k::ApplicationWindow,
|
||||||
nb: >k::Notebook,
|
nb: >k::Notebook,
|
||||||
stato: &Rc<RwLock<StatoFinestra>>,
|
w_state: &Rc<RwLock<WindowState>>,
|
||||||
) {
|
) {
|
||||||
let ts = gtk::get_current_event_time();
|
let ts = gtk::get_current_event_time();
|
||||||
match stato.get_pos() {
|
match w_state.get_pos() {
|
||||||
Nascosta | Nascondendo | SuNonFocusata => {
|
Hidden | Hiding | UpWithoutFocus => {
|
||||||
tira_su(window, stato, ts);
|
bring_up(window, w_state, ts);
|
||||||
crate::tabs::focus_tab_corrente(&nb);
|
crate::tabs::focus_current_tab(&nb);
|
||||||
}
|
}
|
||||||
Su => butta_giu(window, &stato),
|
Up => hide(window, &w_state),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focus_out(stato: &Rc<RwLock<StatoFinestra>>) -> gtk::Inhibit {
|
pub fn focus_out(w_state: &Rc<RwLock<WindowState>>) -> gtk::Inhibit {
|
||||||
match stato.get_pos() {
|
match w_state.get_pos() {
|
||||||
Nascondendo => {
|
Hiding => {
|
||||||
stato.set_pos(Nascosta);
|
w_state.set_pos(Hidden);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
stato.set_pos(SuNonFocusata);
|
w_state.set_pos(UpWithoutFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
|
|
@ -161,14 +161,14 @@ pub fn focus_out(stato: &Rc<RwLock<StatoFinestra>>) -> gtk::Inhibit {
|
||||||
|
|
||||||
pub fn focus_in(
|
pub fn focus_in(
|
||||||
window: >k::ApplicationWindow,
|
window: >k::ApplicationWindow,
|
||||||
stato: &Rc<RwLock<StatoFinestra>>,
|
w_state: &Rc<RwLock<WindowState>>,
|
||||||
) -> gtk::Inhibit {
|
) -> gtk::Inhibit {
|
||||||
stato.set_pos(Su);
|
w_state.set_pos(Up);
|
||||||
let s = calc_w_h(window);
|
let s = calc_w_h(window);
|
||||||
window.set_type_hint(gdk::WindowTypeHint::Dock);
|
window.set_type_hint(gdk::WindowTypeHint::Dock);
|
||||||
if let Some((_x, _y, width, height)) = window.get_window().and_then(|x| Some(x.get_geometry()))
|
if let Some((_x, _y, width, height)) = window.get_window().and_then(|x| Some(x.get_geometry()))
|
||||||
{
|
{
|
||||||
if (height != s.1 || width != s.0) && stato.get_full() != Full {
|
if (height != s.1 || width != s.0) && w_state.get_full() != Full {
|
||||||
window.hide();
|
window.hide();
|
||||||
window.resize(s.0, s.1);
|
window.resize(s.0, s.1);
|
||||||
window.show();
|
window.show();
|
||||||
Loading…
Reference in New Issue