Browse Source

normalize tab items component

master
yggverse 2 months ago
parent
commit
65502c247d
  1. 138
      src/app/browser/window/tab.rs
  2. 21
      src/app/browser/window/tab/database.rs
  3. 262
      src/app/browser/window/tab/item.rs
  4. 25
      src/app/browser/window/tab/item/database.rs
  5. 0
      src/app/browser/window/tab/item/label.rs
  6. 80
      src/app/browser/window/tab/item/label/database.rs
  7. 0
      src/app/browser/window/tab/item/label/pin.rs
  8. 0
      src/app/browser/window/tab/item/label/title.rs
  9. 0
      src/app/browser/window/tab/item/label/widget.rs
  10. 0
      src/app/browser/window/tab/item/page.rs
  11. 0
      src/app/browser/window/tab/item/page/content.rs
  12. 0
      src/app/browser/window/tab/item/page/content/text.rs
  13. 0
      src/app/browser/window/tab/item/page/content/text/gemini.rs
  14. 0
      src/app/browser/window/tab/item/page/content/text/gemini/reader.rs
  15. 0
      src/app/browser/window/tab/item/page/content/text/gemini/reader/default.css
  16. 0
      src/app/browser/window/tab/item/page/content/text/gemini/reader/parser.rs
  17. 0
      src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/header.rs
  18. 0
      src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/link.rs
  19. 0
      src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/plain.rs
  20. 0
      src/app/browser/window/tab/item/page/content/text/plain/reader.rs
  21. 0
      src/app/browser/window/tab/item/page/meta.rs
  22. 0
      src/app/browser/window/tab/item/page/navigation.rs
  23. 0
      src/app/browser/window/tab/item/page/navigation/base.rs
  24. 0
      src/app/browser/window/tab/item/page/navigation/bookmark.rs
  25. 0
      src/app/browser/window/tab/item/page/navigation/history.rs
  26. 0
      src/app/browser/window/tab/item/page/navigation/history/back.rs
  27. 0
      src/app/browser/window/tab/item/page/navigation/history/forward.rs
  28. 0
      src/app/browser/window/tab/item/page/navigation/reload.rs
  29. 0
      src/app/browser/window/tab/item/page/navigation/request.rs

138
src/app/browser/window/tab.rs

@ -1,29 +1,21 @@
mod database; mod database;
mod label; mod item;
mod page;
mod widget; mod widget;
use database::Database; use database::Database;
use label::Label; use item::Item;
use page::Page;
use sqlite::Transaction; use sqlite::Transaction;
use widget::Widget; use widget::Widget;
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::GString,
prelude::{ActionExt, WidgetExt}, prelude::{ActionExt, WidgetExt},
GestureClick, Notebook, Notebook,
}; };
use std::{cell::RefCell, collections::HashMap, sync::Arc}; use std::{cell::RefCell, collections::HashMap, sync::Arc};
// Common struct for HashMap index
pub struct TabItem {
label: Arc<Label>,
page: Arc<Page>,
}
// Main // Main
pub struct Tab { pub struct Tab {
// Actions // Actions
@ -33,7 +25,7 @@ pub struct Tab {
action_tab_page_navigation_reload: Arc<SimpleAction>, action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>, action_update: Arc<SimpleAction>,
// Dynamically allocated reference index // Dynamically allocated reference index
index: RefCell<HashMap<GString, Arc<TabItem>>>, index: RefCell<HashMap<GString, Arc<Item>>>,
// GTK // GTK
widget: Arc<Widget>, widget: Arc<Widget>,
} }
@ -96,17 +88,13 @@ impl Tab {
pub fn append( pub fn append(
&self, &self,
page_navigation_request_text: Option<GString>, page_navigation_request_text: Option<GString>,
is_current_page: bool, is_initially_current: bool,
) -> Arc<TabItem> { ) -> Arc<Item> {
// Generate unique ID for new page components // Init new tab item
let id = uuid_string_random(); let item = Arc::new(Item::new(
// Init new tab components
let label = Arc::new(Label::new(id.clone(), false));
let page = Arc::new(Page::new(
id.clone(),
page_navigation_request_text.clone(), page_navigation_request_text.clone(),
is_initially_current,
// Actions
self.action_tab_page_navigation_base.clone(), self.action_tab_page_navigation_base.clone(),
self.action_tab_page_navigation_history_back.clone(), self.action_tab_page_navigation_history_back.clone(),
self.action_tab_page_navigation_history_forward.clone(), self.action_tab_page_navigation_history_forward.clone(),
@ -114,36 +102,15 @@ impl Tab {
self.action_update.clone(), self.action_update.clone(),
)); ));
// Init new tab item
let item = Arc::new(TabItem {
label: label.clone(),
page: page.clone(),
});
// Register dynamically created tab components in the HashMap index // Register dynamically created tab components in the HashMap index
self.index.borrow_mut().insert(id.clone(), item.clone()); self.index.borrow_mut().insert(item.id(), item.clone());
// Init additional label actions
let controller = GestureClick::new();
controller.connect_pressed({
let label = label.clone();
move |_, count, _, _| {
// double click
if count == 2 {
label.pin(!label.is_pinned()); // toggle
}
}
});
label.gobject().add_controller(controller);
// Append new Notebook page // Append new Notebook page
self.widget self.widget
.append(label.gobject(), page.widget(), is_current_page, true); .append(item.label(), item.page(), is_initially_current, true);
if page_navigation_request_text.is_none() { if page_navigation_request_text.is_none() {
page.navigation_request_grab_focus(); item.page_navigation_request_grab_focus(); // @TODO
} }
item item
@ -163,7 +130,7 @@ impl Tab {
pub fn pin(&self) { pub fn pin(&self) {
if let Some(id) = self.widget.current_name() { if let Some(id) = self.widget.current_name() {
if let Some(item) = self.index.borrow().get(&id) { if let Some(item) = self.index.borrow().get(&id) {
item.label.pin(!item.label.is_pinned()); // toggle item.pin(); // toggle
} }
} }
} }
@ -171,7 +138,7 @@ impl Tab {
pub fn page_navigation_base(&self) { pub fn page_navigation_base(&self) {
if let Some(id) = self.widget.current_name() { if let Some(id) = self.widget.current_name() {
if let Some(item) = self.index.borrow().get(&id) { if let Some(item) = self.index.borrow().get(&id) {
item.page.navigation_base(); item.page_navigation_base();
} }
} }
} }
@ -179,7 +146,7 @@ impl Tab {
pub fn page_navigation_history_back(&self) { pub fn page_navigation_history_back(&self) {
if let Some(id) = self.widget.current_name() { if let Some(id) = self.widget.current_name() {
if let Some(item) = self.index.borrow().get(&id) { if let Some(item) = self.index.borrow().get(&id) {
item.page.navigation_history_back(); item.page_navigation_history_back();
} }
} }
} }
@ -187,7 +154,7 @@ impl Tab {
pub fn page_navigation_history_forward(&self) { pub fn page_navigation_history_forward(&self) {
if let Some(id) = self.widget.current_name() { if let Some(id) = self.widget.current_name() {
if let Some(item) = self.index.borrow().get(&id) { if let Some(item) = self.index.borrow().get(&id) {
item.page.navigation_history_forward(); item.page_navigation_history_forward();
} }
} }
} }
@ -195,7 +162,7 @@ impl Tab {
pub fn page_navigation_reload(&self) { pub fn page_navigation_reload(&self) {
if let Some(id) = self.widget.current_name() { if let Some(id) = self.widget.current_name() {
if let Some(item) = self.index.borrow().get(&id) { if let Some(item) = self.index.borrow().get(&id) {
item.page.navigation_reload(); item.page_navigation_reload();
} }
} }
} }
@ -203,12 +170,7 @@ impl Tab {
pub fn update(&self) { pub fn update(&self) {
if let Some(id) = self.widget.current_name() { if let Some(id) = self.widget.current_name() {
if let Some(item) = self.index.borrow().get(&id) { if let Some(item) = self.index.borrow().get(&id) {
item.page.update(); item.update();
if let Some(title) = item.page.title() {
item.label.update(Some(&title));
} else {
item.label.update(None);
}
} }
} }
} }
@ -225,10 +187,9 @@ impl Tab {
Ok(_) => { Ok(_) => {
// Delegate clean action to childs // Delegate clean action to childs
for (_, item) in self.index.borrow().iter() { for (_, item) in self.index.borrow().iter() {
if let Err(e) = item.label.clean(transaction, &record.id) { if let Err(e) = item.clean(transaction, &record.id) {
return Err(e.to_string()); return Err(e.to_string());
} }
// @TODO item.page.clean(transaction, &record.id);
} }
} }
Err(e) => return Err(e.to_string()), Err(e) => return Err(e.to_string()),
@ -249,12 +210,31 @@ impl Tab {
match Database::records(transaction, app_browser_window_id) { match Database::records(transaction, app_browser_window_id) {
Ok(records) => { Ok(records) => {
for record in records { for record in records {
let item = self.append(None, record.is_current); match Item::restore(
// Delegate restore action to childs transaction,
if let Err(e) = item.label.restore(transaction, &record.id) { &record.id,
return Err(e.to_string()); self.action_tab_page_navigation_base.clone(),
self.action_tab_page_navigation_history_back.clone(),
self.action_tab_page_navigation_history_forward.clone(),
self.action_tab_page_navigation_reload.clone(),
self.action_update.clone(),
) {
Ok(items) => {
for item in items {
// Register dynamically created tab item in the HashMap index
self.index.borrow_mut().insert(item.id(), item.clone());
// Append new Notebook page
self.widget.append(
item.label(),
item.page(),
item.is_initially_current(),
true,
);
}
}
Err(e) => return Err(e.to_string()),
} }
// item.page.restore(transaction, record.id);
} }
} }
Err(e) => return Err(e.to_string()), Err(e) => return Err(e.to_string()),
@ -268,32 +248,30 @@ impl Tab {
transaction: &Transaction, transaction: &Transaction,
app_browser_window_id: &i64, app_browser_window_id: &i64,
) -> Result<(), String> { ) -> Result<(), String> {
match Database::add(transaction, app_browser_window_id) {
Ok(_) => {
// Delegate save action to childs
let id = Database::last_insert_id(transaction);
// Read HashMap index collected
let mut page_number = 0; let mut page_number = 0;
for (_, item) in self.index.borrow().iter() { for (_, item) in self.index.borrow().iter() {
match Database::add( if let Err(e) = item.save(
transaction, transaction,
app_browser_window_id, &id,
&match self.widget.gobject().current_page() { &match self.widget.gobject().current_page() {
Some(number) => number == page_number, Some(number) => number == page_number,
None => false, None => false,
}, },
) { ) {
Ok(_) => {
// Delegate save action to childs
let id = Database::last_insert_id(transaction);
if let Err(e) = item.label.save(transaction, &id) {
return Err(e.to_string()); return Err(e.to_string());
} }
// @TODO page_number += 1;
// item.page.save()
} }
Err(e) => return Err(e.to_string()),
} }
Err(e) => return Err(e.to_string()),
page_number += 1;
} }
Ok(()) Ok(())
@ -303,7 +281,7 @@ impl Tab {
pub fn page_title(&self) -> Option<GString> { pub fn page_title(&self) -> Option<GString> {
if let Some(id) = self.widget.current_name() { if let Some(id) = self.widget.current_name() {
if let Some(item) = self.index.borrow().get(&id) { if let Some(item) = self.index.borrow().get(&id) {
return item.page.title(); return item.page_title();
} }
} }
None None
@ -313,7 +291,7 @@ impl Tab {
if let Some(id) = self.widget.current_name() { if let Some(id) = self.widget.current_name() {
// Get page by widget ID // Get page by widget ID
if let Some(item) = self.index.borrow().get(&id) { if let Some(item) = self.index.borrow().get(&id) {
return item.page.description(); return item.page_description();
} }
} }
None None
@ -331,7 +309,7 @@ impl Tab {
} }
// Delegate migration to childs // Delegate migration to childs
if let Err(e) = Label::migrate(&tx) { if let Err(e) = Item::migrate(&tx) {
return Err(e.to_string()); return Err(e.to_string());
} }

21
src/app/browser/window/tab/database.rs

@ -3,7 +3,6 @@ use sqlite::{Error, Transaction};
pub struct Table { pub struct Table {
pub id: i64, pub id: i64,
// pub app_browser_window_id: i64, not in use // pub app_browser_window_id: i64, not in use
pub is_current: bool,
} }
pub struct Database { pub struct Database {
@ -16,32 +15,25 @@ impl Database {
"CREATE TABLE IF NOT EXISTS `app_browser_window_tab` "CREATE TABLE IF NOT EXISTS `app_browser_window_tab`
( (
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`app_browser_window_id` INTEGER NOT NULL, `app_browser_window_id` INTEGER NOT NULL
`is_current` INTEGER NOT NULL
)", )",
[], [],
) )
} }
pub fn add( pub fn add(tx: &Transaction, app_browser_window_id: &i64) -> Result<usize, Error> {
tx: &Transaction,
app_browser_window_id: &i64,
is_current: &bool,
) -> Result<usize, Error> {
tx.execute( tx.execute(
"INSERT INTO `app_browser_window_tab` ( "INSERT INTO `app_browser_window_tab` (
`app_browser_window_id`, `app_browser_window_id`
`is_current` ) VALUES (?)",
) VALUES (?,?)", [app_browser_window_id],
[app_browser_window_id, &(*is_current as i64)],
) )
} }
pub fn records(tx: &Transaction, app_browser_window_id: &i64) -> Result<Vec<Table>, Error> { pub fn records(tx: &Transaction, app_browser_window_id: &i64) -> Result<Vec<Table>, Error> {
let mut stmt = tx.prepare( let mut stmt = tx.prepare(
"SELECT `id`, "SELECT `id`,
`app_browser_window_id`, `app_browser_window_id` FROM `app_browser_window_tab`
`is_current` FROM `app_browser_window_tab`
WHERE `app_browser_window_id` = ?", WHERE `app_browser_window_id` = ?",
)?; )?;
@ -49,7 +41,6 @@ impl Database {
Ok(Table { Ok(Table {
id: row.get(0)?, id: row.get(0)?,
// app_browser_window_id: row.get(1)?, not in use // app_browser_window_id: row.get(1)?, not in use
is_current: row.get(2)?,
}) })
})?; })?;

262
src/app/browser/window/tab/item.rs

@ -0,0 +1,262 @@
mod database;
mod label;
mod page;
use database::Database;
use label::Label;
use page::Page;
use sqlite::Transaction;
use gtk::{
gio::SimpleAction,
glib::{uuid_string_random, GString},
prelude::WidgetExt,
Box, GestureClick,
};
use std::sync::Arc;
pub struct Item {
// Auto-generated unique item ID
// useful as widget name in GTK actions callback
id: GString,
// Components
label: Arc<Label>,
page: Arc<Page>,
// Extras, useful for session restore
is_initially_current: bool,
}
impl Item {
// Construct
pub fn new(
page_navigation_request_text: Option<GString>,
is_initially_current: bool,
// Actions
action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
) -> Self {
// Generate unique ID for new page components
let id = uuid_string_random();
// Init components
let label = Arc::new(Label::new(id.clone(), false));
let page = Arc::new(Page::new(
id.clone(),
page_navigation_request_text.clone(),
action_tab_page_navigation_base.clone(),
action_tab_page_navigation_history_back.clone(),
action_tab_page_navigation_history_forward.clone(),
action_tab_page_navigation_reload.clone(),
action_update.clone(),
));
// Init additional label actions @TODO move to Label?
let controller = GestureClick::new();
controller.connect_pressed({
let label = label.clone();
move |_, count, _, _| {
// double click
if count == 2 {
label.pin(!label.is_pinned()); // toggle
}
}
});
label.gobject().add_controller(controller);
// Return struct
Self {
id,
is_initially_current,
label,
page,
}
}
// Actions
pub fn pin(&self) {
self.label.pin(!self.label.is_pinned()) // toggle
}
pub fn page_navigation_base(&self) {
self.page.navigation_base()
}
pub fn page_navigation_history_back(&self) {
self.page.navigation_history_back()
}
pub fn page_navigation_history_forward(&self) {
self.page.navigation_history_forward()
}
pub fn page_navigation_reload(&self) {
self.page.navigation_reload()
}
pub fn page_navigation_request_grab_focus(&self) {
self.page.navigation_request_grab_focus()
}
pub fn update(&self) {
self.page.update();
if let Some(title) = self.page.title() {
self.label.update(Some(&title));
} else {
self.label.update(None);
}
}
pub fn clean(
&self,
transaction: &Transaction,
app_browser_window_tab_id: &i64,
) -> Result<(), String> {
match Database::records(transaction, app_browser_window_tab_id) {
Ok(records) => {
for record in records {
match Database::delete(transaction, &record.id) {
Ok(_) => {
// Delegate clean action to the item childs
if let Err(e) = self.label.clean(transaction, &record.id) {
return Err(e.to_string());
}
/* @TODO
if let Err(e) = self.page.clean(transaction, &record.id) {
return Err(e.to_string());
} */
}
Err(e) => return Err(e.to_string()),
}
}
}
Err(e) => return Err(e.to_string()),
}
Ok(())
}
// This method does not contain Self context,
// because child items creating in the runtime (by parent component)
pub fn restore(
transaction: &Transaction,
app_browser_window_tab_id: &i64,
// Actions
action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
) -> Result<Vec<Arc<Item>>, String> {
let mut items = Vec::new();
match Database::records(transaction, app_browser_window_tab_id) {
Ok(records) => {
for record in records {
// Construct new item object
let item = Arc::new(Item::new(
None,
record.is_initially_current,
// Actions
action_tab_page_navigation_base.clone(),
action_tab_page_navigation_history_back.clone(),
action_tab_page_navigation_history_forward.clone(),
action_tab_page_navigation_reload.clone(),
action_update.clone(),
));
// Delegate restore action to the item childs
if let Err(e) = item.label.restore(transaction, &record.id) {
return Err(e.to_string());
}
// Result
items.push(item);
}
}
Err(e) => return Err(e.to_string()),
}
Ok(items)
}
pub fn save(
&self,
transaction: &Transaction,
app_browser_window_tab_id: &i64,
is_initially_current: &bool,
) -> Result<(), String> {
match Database::add(transaction, app_browser_window_tab_id, is_initially_current) {
Ok(_) => {
let id = Database::last_insert_id(transaction);
// Delegate save action to childs
if let Err(e) = self.label.save(transaction, &id) {
return Err(e.to_string());
}
/* @TODO
if let Err(e) = self.page.save(transaction, &id) {
return Err(e.to_string());
} */
}
Err(e) => return Err(e.to_string()),
}
Ok(())
}
// Getters
pub fn id(&self) -> GString {
self.id.clone()
}
pub fn is_initially_current(&self) -> bool {
self.is_initially_current
}
pub fn label(&self) -> &Box {
&self.label.gobject()
}
pub fn page(&self) -> &Box {
&self.page.widget() // @TODO
}
pub fn page_title(&self) -> Option<GString> {
self.page.title()
}
pub fn page_description(&self) -> Option<GString> {
self.page.description()
}
// Tools
pub fn migrate(tx: &Transaction) -> Result<(), String> {
// Migrate self components
if let Err(e) = Database::init(&tx) {
return Err(e.to_string());
}
// Delegate migration to childs
if let Err(e) = Label::migrate(&tx) {
return Err(e.to_string());
}
/* @TODO
if let Err(e) = Page::migrate(&tx) {
return Err(e.to_string());
} */
// Success
Ok(())
}
}

25
src/app/browser/window/tab/label/database.rs → src/app/browser/window/tab/item/database.rs

@ -3,7 +3,7 @@ use sqlite::{Error, Transaction};
pub struct Table { pub struct Table {
pub id: i64, pub id: i64,
// pub app_browser_window_tab_id: i64, not in use // pub app_browser_window_tab_id: i64, not in use
pub is_pinned: bool, pub is_initially_current: bool,
} }
pub struct Database { pub struct Database {
@ -13,11 +13,11 @@ pub struct Database {
impl Database { impl Database {
pub fn init(tx: &Transaction) -> Result<usize, Error> { pub fn init(tx: &Transaction) -> Result<usize, Error> {
tx.execute( tx.execute(
"CREATE TABLE IF NOT EXISTS `app_browser_window_tab_label` "CREATE TABLE IF NOT EXISTS `app_browser_window_tab_item`
( (
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`app_browser_window_tab_id` INTEGER NOT NULL, `app_browser_window_tab_id` INTEGER NOT NULL,
`is_pinned` INTEGER NOT NULL `is_initially_current` INTEGER NOT NULL
)", )",
[], [],
) )
@ -26,14 +26,14 @@ impl Database {
pub fn add( pub fn add(
tx: &Transaction, tx: &Transaction,
app_browser_window_tab_id: &i64, app_browser_window_tab_id: &i64,
is_pinned: &bool, is_initially_current: &bool,
) -> Result<usize, Error> { ) -> Result<usize, Error> {
tx.execute( tx.execute(
"INSERT INTO `app_browser_window_tab_label` ( "INSERT INTO `app_browser_window_tab_item` (
`app_browser_window_tab_id`, `app_browser_window_tab_id`,
`is_pinned` `is_initially_current`
) VALUES (?,?)", ) VALUES (?, ?)",
[app_browser_window_tab_id, &(*is_pinned as i64)], [app_browser_window_tab_id, &(*is_initially_current as i64)],
) )
} }
@ -41,7 +41,7 @@ impl Database {
let mut stmt = tx.prepare( let mut stmt = tx.prepare(
"SELECT `id`, "SELECT `id`,
`app_browser_window_tab_id`, `app_browser_window_tab_id`,
`is_pinned` FROM `app_browser_window_tab_label` `is_initially_current` FROM `app_browser_window_tab_item`
WHERE `app_browser_window_tab_id` = ?", WHERE `app_browser_window_tab_id` = ?",
)?; )?;
@ -49,7 +49,7 @@ impl Database {
Ok(Table { Ok(Table {
id: row.get(0)?, id: row.get(0)?,
// app_browser_window_tab_id: row.get(1)?, not in use // app_browser_window_tab_id: row.get(1)?, not in use
is_pinned: row.get(2)?, is_initially_current: row.get(2)?,
}) })
})?; })?;
@ -65,13 +65,12 @@ impl Database {
pub fn delete(tx: &Transaction, id: &i64) -> Result<usize, Error> { pub fn delete(tx: &Transaction, id: &i64) -> Result<usize, Error> {
tx.execute( tx.execute(
"DELETE FROM `app_browser_window_tab_label` WHERE `id` = ?", "DELETE FROM `app_browser_window_tab_item` WHERE `id` = ?",
[id], [id],
) )
} }
/* not in use
pub fn last_insert_id(tx: &Transaction) -> i64 { pub fn last_insert_id(tx: &Transaction) -> i64 {
tx.last_insert_rowid() tx.last_insert_rowid()
} */ }
} }

0
src/app/browser/window/tab/label.rs → src/app/browser/window/tab/item/label.rs

80
src/app/browser/window/tab/item/label/database.rs

@ -0,0 +1,80 @@
use sqlite::{Error, Transaction};
pub struct Table {
pub id: i64,
// pub app_browser_window_tab_item_id: i64, not in use
pub is_pinned: bool,
}
pub struct Database {
// nothing yet..
}
impl Database {
pub fn init(tx: &Transaction) -> Result<usize, Error> {
tx.execute(
"CREATE TABLE IF NOT EXISTS `app_browser_window_tab_item_label`
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`app_browser_window_tab_item_id` INTEGER NOT NULL,
`is_pinned` INTEGER NOT NULL
)",
[],
)
}
pub fn add(
tx: &Transaction,
app_browser_window_tab_item_id: &i64,
is_pinned: &bool,
) -> Result<usize, Error> {
tx.execute(
"INSERT INTO `app_browser_window_tab_item_label` (
`app_browser_window_tab_item_id`,
`is_pinned`
) VALUES (?,?)",
[app_browser_window_tab_item_id, &(*is_pinned as i64)],
)
}
pub fn records(
tx: &Transaction,
app_browser_window_tab_item_id: &i64,
) -> Result<Vec<Table>, Error> {
let mut stmt = tx.prepare(
"SELECT `id`,
`app_browser_window_tab_item_id`,
`is_pinned` FROM `app_browser_window_tab_item_label`
WHERE `app_browser_window_tab_item_id` = ?",
)?;
let result = stmt.query_map([app_browser_window_tab_item_id], |row| {
Ok(Table {
id: row.get(0)?,
// app_browser_window_tab_item_id: row.get(1)?, not in use
is_pinned: row.get(2)?,
})
})?;
let mut records = Vec::new();
for record in result {
let table = record?;
records.push(table);
}
Ok(records)
}
pub fn delete(tx: &Transaction, id: &i64) -> Result<usize, Error> {
tx.execute(
"DELETE FROM `app_browser_window_tab_item_label` WHERE `id` = ?",
[id],
)
}
/* not in use
pub fn last_insert_id(tx: &Transaction) -> i64 {
tx.last_insert_rowid()
} */
}

0
src/app/browser/window/tab/label/pin.rs → src/app/browser/window/tab/item/label/pin.rs

0
src/app/browser/window/tab/label/title.rs → src/app/browser/window/tab/item/label/title.rs

0
src/app/browser/window/tab/label/widget.rs → src/app/browser/window/tab/item/label/widget.rs

0
src/app/browser/window/tab/page.rs → src/app/browser/window/tab/item/page.rs

0
src/app/browser/window/tab/page/content.rs → src/app/browser/window/tab/item/page/content.rs

0
src/app/browser/window/tab/page/content/text.rs → src/app/browser/window/tab/item/page/content/text.rs

0
src/app/browser/window/tab/page/content/text/gemini.rs → src/app/browser/window/tab/item/page/content/text/gemini.rs

0
src/app/browser/window/tab/page/content/text/gemini/reader.rs → src/app/browser/window/tab/item/page/content/text/gemini/reader.rs

0
src/app/browser/window/tab/page/content/text/gemini/reader/default.css → src/app/browser/window/tab/item/page/content/text/gemini/reader/default.css

0
src/app/browser/window/tab/page/content/text/gemini/reader/parser.rs → src/app/browser/window/tab/item/page/content/text/gemini/reader/parser.rs

0
src/app/browser/window/tab/page/content/text/gemini/reader/parser/header.rs → src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/header.rs

0
src/app/browser/window/tab/page/content/text/gemini/reader/parser/link.rs → src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/link.rs

0
src/app/browser/window/tab/page/content/text/gemini/reader/parser/plain.rs → src/app/browser/window/tab/item/page/content/text/gemini/reader/parser/plain.rs

0
src/app/browser/window/tab/page/content/text/plain/reader.rs → src/app/browser/window/tab/item/page/content/text/plain/reader.rs

0
src/app/browser/window/tab/page/meta.rs → src/app/browser/window/tab/item/page/meta.rs

0
src/app/browser/window/tab/page/navigation.rs → src/app/browser/window/tab/item/page/navigation.rs

0
src/app/browser/window/tab/page/navigation/base.rs → src/app/browser/window/tab/item/page/navigation/base.rs

0
src/app/browser/window/tab/page/navigation/bookmark.rs → src/app/browser/window/tab/item/page/navigation/bookmark.rs

0
src/app/browser/window/tab/page/navigation/history.rs → src/app/browser/window/tab/item/page/navigation/history.rs

0
src/app/browser/window/tab/page/navigation/history/back.rs → src/app/browser/window/tab/item/page/navigation/history/back.rs

0
src/app/browser/window/tab/page/navigation/history/forward.rs → src/app/browser/window/tab/item/page/navigation/history/forward.rs

0
src/app/browser/window/tab/page/navigation/reload.rs → src/app/browser/window/tab/item/page/navigation/reload.rs

0
src/app/browser/window/tab/page/navigation/request.rs → src/app/browser/window/tab/item/page/navigation/request.rs

Loading…
Cancel
Save