mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
unpin pinned tab before close on middle button click
This commit is contained in:
parent
5c8c55539b
commit
4ae34e863f
@ -9,7 +9,7 @@ use sqlite::Transaction;
|
|||||||
use title::Title;
|
use title::Title;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use gtk::{glib::GString, prelude::WidgetExt, Box, GestureClick};
|
use gtk::{gdk, glib::GString, prelude::WidgetExt, Box, GestureClick};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
pub struct Label {
|
pub struct Label {
|
||||||
@ -45,11 +45,11 @@ impl Label {
|
|||||||
let widget = widget.clone();
|
let widget = widget.clone();
|
||||||
let label = label.clone();
|
let label = label.clone();
|
||||||
move |_| {
|
move |_| {
|
||||||
// Init GestureClick listener
|
// Init primary button listener
|
||||||
let controller = GestureClick::new();
|
let primary_button_controller = GestureClick::new();
|
||||||
|
|
||||||
// Listen for double click
|
// Listen for double primary button click
|
||||||
controller.connect_pressed({
|
primary_button_controller.connect_pressed({
|
||||||
let label = label.clone();
|
let label = label.clone();
|
||||||
move |_, count, _, _| {
|
move |_, count, _, _| {
|
||||||
if count == 2 {
|
if count == 2 {
|
||||||
@ -58,16 +58,34 @@ impl Label {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Init middle button listener
|
||||||
|
let middle_button_controller =
|
||||||
|
GestureClick::builder().button(gdk::BUTTON_MIDDLE).build();
|
||||||
|
|
||||||
|
// Listen for single middle button click
|
||||||
|
middle_button_controller.connect_pressed({
|
||||||
|
let label = label.clone();
|
||||||
|
move |_, _, _, _| {
|
||||||
|
if label.is_pinned() {
|
||||||
|
label.pin(false); // unpin
|
||||||
|
} else {
|
||||||
|
// @TODO close
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Label's parent contain native GTK paddings, that makes click event ignored
|
// Label's parent contain native GTK paddings, that makes click event ignored
|
||||||
// try assign the controller to parent as the solution
|
// try assign the controller to parent as the solution
|
||||||
match widget.gobject().parent() {
|
match widget.gobject().parent() {
|
||||||
// @TODO check for GtkGizmo type?
|
// @TODO check for GtkGizmo type?
|
||||||
Some(parent) => {
|
Some(parent) => {
|
||||||
parent.add_controller(controller);
|
parent.add_controller(primary_button_controller);
|
||||||
|
parent.add_controller(middle_button_controller);
|
||||||
}
|
}
|
||||||
// Assign controller to the current widget, drop notice
|
// Assign controller to the current widget, drop notice
|
||||||
None => {
|
None => {
|
||||||
widget.gobject().add_controller(controller);
|
widget.gobject().add_controller(primary_button_controller);
|
||||||
|
widget.gobject().add_controller(middle_button_controller);
|
||||||
println!("Could not assign action to destination, please report");
|
println!("Could not assign action to destination, please report");
|
||||||
// @TODO
|
// @TODO
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user