mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
use shared reference for tab item id
This commit is contained in:
parent
e66b065fc3
commit
ea3aab4d68
@ -25,7 +25,7 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc};
|
|||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
profile: Rc<Profile>,
|
profile: Rc<Profile>,
|
||||||
actions: (Rc<BrowserAction>, Rc<WindowAction>),
|
actions: (Rc<BrowserAction>, Rc<WindowAction>),
|
||||||
index: Rc<RefCell<HashMap<GString, Rc<Item>>>>,
|
index: Rc<RefCell<HashMap<Rc<GString>, Rc<Item>>>>,
|
||||||
pub widget: Rc<Widget>,
|
pub widget: Rc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,8 @@ impl Tab {
|
|||||||
// Construct
|
// Construct
|
||||||
pub fn new(profile: Rc<Profile>, action: (Rc<BrowserAction>, Rc<WindowAction>)) -> Self {
|
pub fn new(profile: Rc<Profile>, action: (Rc<BrowserAction>, Rc<WindowAction>)) -> Self {
|
||||||
// Init empty HashMap index
|
// Init empty HashMap index
|
||||||
let index: Rc<RefCell<HashMap<GString, Rc<Item>>>> = Rc::new(RefCell::new(HashMap::new()));
|
let index: Rc<RefCell<HashMap<Rc<GString>, Rc<Item>>>> =
|
||||||
|
Rc::new(RefCell::new(HashMap::new()));
|
||||||
|
|
||||||
// Init context menu
|
// Init context menu
|
||||||
let menu = Menu::new(action.1.clone());
|
let menu = Menu::new(action.1.clone());
|
||||||
|
@ -24,7 +24,7 @@ use std::rc::Rc;
|
|||||||
pub struct Item {
|
pub struct Item {
|
||||||
// Auto-generated unique item ID
|
// Auto-generated unique item ID
|
||||||
// useful as widget name in GTK actions callback
|
// useful as widget name in GTK actions callback
|
||||||
pub id: GString,
|
pub id: Rc<GString>,
|
||||||
// Components
|
// Components
|
||||||
pub page: Rc<Page>,
|
pub page: Rc<Page>,
|
||||||
pub widget: Rc<Widget>,
|
pub widget: Rc<Widget>,
|
||||||
@ -42,7 +42,7 @@ impl Item {
|
|||||||
let (position, request, is_pinned, is_selected, is_attention, is_load) = options;
|
let (position, request, is_pinned, is_selected, is_attention, is_load) = options;
|
||||||
|
|
||||||
// Generate unique ID for new page components
|
// Generate unique ID for new page components
|
||||||
let id = uuid_string_random();
|
let id = Rc::new(uuid_string_random());
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ use sqlite::Transaction;
|
|||||||
use std::{rc::Rc, time::Duration};
|
use std::{rc::Rc, time::Duration};
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
id: GString,
|
id: Rc<GString>,
|
||||||
profile: Rc<Profile>,
|
profile: Rc<Profile>,
|
||||||
// Actions
|
// Actions
|
||||||
browser_action: Rc<BrowserAction>,
|
browser_action: Rc<BrowserAction>,
|
||||||
@ -54,7 +54,7 @@ impl Page {
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
id: GString,
|
id: Rc<GString>,
|
||||||
profile: Rc<Profile>,
|
profile: Rc<Profile>,
|
||||||
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>),
|
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>),
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user