mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
add pin action to context menu
This commit is contained in:
parent
2aed6691b9
commit
998f51e0fc
@ -147,8 +147,8 @@ impl Browser {
|
|||||||
|
|
||||||
action_page_home.connect_activate({
|
action_page_home.connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
move |_, _| {
|
move |this, _| {
|
||||||
window.tab_page_navigation_home();
|
window.tab_page_navigation_home(page_position_from_action_state(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -173,8 +173,8 @@ impl Browser {
|
|||||||
|
|
||||||
action_page_pin.connect_activate({
|
action_page_pin.connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
move |_, _| {
|
move |this, _| {
|
||||||
window.tab_pin();
|
window.tab_pin(page_position_from_action_state(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ impl Window {
|
|||||||
action_page_home.clone(),
|
action_page_home.clone(),
|
||||||
action_page_history_back.clone(),
|
action_page_history_back.clone(),
|
||||||
action_page_history_forward.clone(),
|
action_page_history_forward.clone(),
|
||||||
|
action_page_pin.clone(),
|
||||||
action_page_reload.clone(),
|
action_page_reload.clone(),
|
||||||
action_update.clone(),
|
action_update.clone(),
|
||||||
);
|
);
|
||||||
@ -82,8 +83,8 @@ impl Window {
|
|||||||
self.tab.append(page_position);
|
self.tab.append(page_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_page_navigation_home(&self) {
|
pub fn tab_page_navigation_home(&self, page_position: Option<i32>) {
|
||||||
self.tab.page_navigation_home();
|
self.tab.page_navigation_home(page_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_page_navigation_history_back(&self) {
|
pub fn tab_page_navigation_history_back(&self) {
|
||||||
@ -108,8 +109,8 @@ impl Window {
|
|||||||
self.tab.close_all();
|
self.tab.close_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_pin(&self) {
|
pub fn tab_pin(&self, page_position: Option<i32>) {
|
||||||
self.tab.pin();
|
self.tab.pin(page_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&self, id: &str) {
|
pub fn update(&self, id: &str) {
|
||||||
|
@ -39,6 +39,7 @@ impl Tab {
|
|||||||
action_page_home: SimpleAction,
|
action_page_home: SimpleAction,
|
||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
action_page_history_forward: SimpleAction,
|
action_page_history_forward: SimpleAction,
|
||||||
|
action_page_pin: SimpleAction,
|
||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
action_update: SimpleAction,
|
action_update: SimpleAction,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
@ -55,7 +56,12 @@ impl Tab {
|
|||||||
menu.append(
|
menu.append(
|
||||||
Some("Reload"),
|
Some("Reload"),
|
||||||
Some(&gformat!("win.{}", action_page_reload.name())),
|
Some(&gformat!("win.{}", action_page_reload.name())),
|
||||||
); // @TODO resolve namespace outside
|
);
|
||||||
|
|
||||||
|
menu.append(
|
||||||
|
Some("Pin"),
|
||||||
|
Some(&gformat!("win.{}", action_page_pin.name())),
|
||||||
|
);
|
||||||
|
|
||||||
let navigation = Menu::new();
|
let navigation = Menu::new();
|
||||||
|
|
||||||
@ -89,6 +95,7 @@ impl Tab {
|
|||||||
// Clone actions to update
|
// Clone actions to update
|
||||||
let action_page_close = action_page_close.clone();
|
let action_page_close = action_page_close.clone();
|
||||||
let action_page_home = action_page_home.clone();
|
let action_page_home = action_page_home.clone();
|
||||||
|
let action_page_pin = action_page_pin.clone();
|
||||||
let action_page_reload = action_page_reload.clone();
|
let action_page_reload = action_page_reload.clone();
|
||||||
move |tab_view, tab_page| {
|
move |tab_view, tab_page| {
|
||||||
// Setup state for selected page
|
// Setup state for selected page
|
||||||
@ -102,6 +109,7 @@ impl Tab {
|
|||||||
// Update actions
|
// Update actions
|
||||||
action_page_close.change_state(&state);
|
action_page_close.change_state(&state);
|
||||||
action_page_home.change_state(&state);
|
action_page_home.change_state(&state);
|
||||||
|
action_page_pin.change_state(&state);
|
||||||
action_page_reload.change_state(&state);
|
action_page_reload.change_state(&state);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -223,16 +231,12 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Toggle pin status for active tab
|
// Toggle pin status for active tab
|
||||||
pub fn pin(&self) {
|
pub fn pin(&self, page_position: Option<i32>) {
|
||||||
if let Some(page) = self.widget.gobject().selected_page() {
|
self.widget.pin(page_position);
|
||||||
self.widget
|
|
||||||
.gobject()
|
|
||||||
.set_page_pinned(&page, !page.is_pinned()); // toggle
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn page_navigation_home(&self) {
|
pub fn page_navigation_home(&self, page_position: Option<i32>) {
|
||||||
if let Some(id) = self.widget.current_page_keyword() {
|
if let Some(id) = self.widget.page_keyword(page_position) {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
item.page_navigation_home();
|
item.page_navigation_home();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ impl Widget {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/// Close page at given `position`, `None` to close selected page
|
/// Close page at given `position`, `None` to close selected page (if available)
|
||||||
/// * this action includes `pinned` pages, to prevent that:
|
/// * this action includes `pinned` pages, to prevent that:
|
||||||
/// * deactivate [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) outside if selected page should not be closed
|
/// * deactivate [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) outside if selected page should not be closed
|
||||||
/// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter
|
/// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter
|
||||||
@ -54,6 +54,13 @@ impl Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Toggle pin for page at given `position`, `None` to pin selected page (if available)
|
||||||
|
pub fn pin(&self, position: Option<i32>) {
|
||||||
|
if let Some(page) = self.page(position) {
|
||||||
|
self.gobject.set_page_pinned(&page, !page.is_pinned()); // toggle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
pub fn current_page_keyword(&self) -> Option<GString> {
|
pub fn current_page_keyword(&self) -> Option<GString> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user