|
|
|
@ -137,99 +137,61 @@ impl Tab {
@@ -137,99 +137,61 @@ impl Tab {
|
|
|
|
|
|
|
|
|
|
// Close active tab
|
|
|
|
|
pub fn close(&self) { |
|
|
|
|
self.widget |
|
|
|
|
.gobject() |
|
|
|
|
.remove_page(self.widget.gobject().current_page()); |
|
|
|
|
self.widget.close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Close all tabs
|
|
|
|
|
pub fn close_all(&self) { |
|
|
|
|
// @TODO skip pinned or make confirmation alert (GTK>=4.10)
|
|
|
|
|
while let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
self.widget.gobject().remove_page(Some(page_number)); |
|
|
|
|
} |
|
|
|
|
self.widget.close_all(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Toggle pin status for active tab
|
|
|
|
|
pub fn pin(&self) { |
|
|
|
|
// Get current page
|
|
|
|
|
if let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
// Get default widget to extract it name as the ID for childs
|
|
|
|
|
if let Some(widget) = self.widget.gobject().nth_page(Some(page_number)) { |
|
|
|
|
// Get label by ID
|
|
|
|
|
if let Some(label) = self.labels.borrow().get(&widget.widget_name()) { |
|
|
|
|
if let Some(id) = self.widget.current_name() { |
|
|
|
|
if let Some(label) = self.labels.borrow().get(&id) { |
|
|
|
|
label.pin(!label.is_pinned()); // toggle
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn page_navigation_base(&self) { |
|
|
|
|
// Get current page
|
|
|
|
|
if let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
// Get default widget to extract it name as the ID for childs
|
|
|
|
|
if let Some(widget) = self.widget.gobject().nth_page(Some(page_number)) { |
|
|
|
|
// Get page by widget ID
|
|
|
|
|
if let Some(page) = self.pages.borrow().get(&widget.widget_name()) { |
|
|
|
|
if let Some(id) = self.widget.current_name() { |
|
|
|
|
if let Some(page) = self.pages.borrow().get(&id) { |
|
|
|
|
page.navigation_base(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn page_navigation_history_back(&self) { |
|
|
|
|
// Get current page
|
|
|
|
|
if let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
// Get default widget to extract it name as the ID for childs
|
|
|
|
|
if let Some(widget) = self.widget.gobject().nth_page(Some(page_number)) { |
|
|
|
|
// Get page by widget ID
|
|
|
|
|
if let Some(page) = self.pages.borrow().get(&widget.widget_name()) { |
|
|
|
|
if let Some(id) = self.widget.current_name() { |
|
|
|
|
if let Some(page) = self.pages.borrow().get(&id) { |
|
|
|
|
page.navigation_history_back(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn page_navigation_history_forward(&self) { |
|
|
|
|
// Get current page
|
|
|
|
|
if let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
// Get default widget to extract it name as the ID for childs
|
|
|
|
|
if let Some(widget) = self.widget.gobject().nth_page(Some(page_number)) { |
|
|
|
|
// Get page by widget ID
|
|
|
|
|
if let Some(page) = self.pages.borrow().get(&widget.widget_name()) { |
|
|
|
|
if let Some(id) = self.widget.current_name() { |
|
|
|
|
if let Some(page) = self.pages.borrow().get(&id) { |
|
|
|
|
page.navigation_history_forward(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn page_navigation_reload(&self) { |
|
|
|
|
// Get current page
|
|
|
|
|
if let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
// Get default widget to extract it name as the ID for childs
|
|
|
|
|
if let Some(widget) = self.widget.gobject().nth_page(Some(page_number)) { |
|
|
|
|
// Get page by widget ID
|
|
|
|
|
if let Some(page) = self.pages.borrow().get(&widget.widget_name()) { |
|
|
|
|
if let Some(id) = self.widget.current_name() { |
|
|
|
|
if let Some(page) = self.pages.borrow().get(&id) { |
|
|
|
|
page.navigation_reload(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn update(&self) { |
|
|
|
|
// Get current page
|
|
|
|
|
if let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
// Get default widget to extract it name as the ID for childs
|
|
|
|
|
if let Some(widget) = self.widget.gobject().nth_page(Some(page_number)) { |
|
|
|
|
// Get widget ID
|
|
|
|
|
let id = &widget.widget_name(); |
|
|
|
|
|
|
|
|
|
// Get page by widget ID
|
|
|
|
|
if let Some(page) = self.pages.borrow().get(id) { |
|
|
|
|
if let Some(id) = self.widget.current_name() { |
|
|
|
|
if let Some(page) = self.pages.borrow().get(&id) { |
|
|
|
|
page.update(); |
|
|
|
|
|
|
|
|
|
// Get label by widget ID
|
|
|
|
|
if let Some(label) = self.labels.borrow().get(id) { |
|
|
|
|
if let Some(label) = self.labels.borrow().get(&id) { |
|
|
|
|
if let Some(title) = page.title() { |
|
|
|
|
label.update(Some(&title)); |
|
|
|
|
} else { |
|
|
|
@ -239,39 +201,25 @@ impl Tab {
@@ -239,39 +201,25 @@ impl Tab {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Getters
|
|
|
|
|
pub fn page_title(&self) -> Option<GString> { |
|
|
|
|
// Get current page
|
|
|
|
|
if let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
// Get default widget to extract it name as the ID for childs
|
|
|
|
|
if let Some(widget) = self.widget.gobject().nth_page(Some(page_number)) { |
|
|
|
|
// Get widget ID
|
|
|
|
|
let id = &widget.widget_name(); |
|
|
|
|
// Get page by widget ID
|
|
|
|
|
if let Some(page) = self.pages.borrow().get(id) { |
|
|
|
|
if let Some(id) = self.widget.current_name() { |
|
|
|
|
if let Some(page) = self.pages.borrow().get(&id) { |
|
|
|
|
return page.title(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
None |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn page_description(&self) -> Option<GString> { |
|
|
|
|
// Get current page
|
|
|
|
|
if let Some(page_number) = self.widget.gobject().current_page() { |
|
|
|
|
// Get default widget to extract it name as the ID for childs
|
|
|
|
|
if let Some(widget) = self.widget.gobject().nth_page(Some(page_number)) { |
|
|
|
|
// Get widget ID
|
|
|
|
|
let id = &widget.widget_name(); |
|
|
|
|
if let Some(id) = self.widget.current_name() { |
|
|
|
|
// Get page by widget ID
|
|
|
|
|
if let Some(page) = self.pages.borrow().get(id) { |
|
|
|
|
if let Some(page) = self.pages.borrow().get(&id) { |
|
|
|
|
return page.description(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
None |
|
|
|
|
} |
|
|
|
|