Browse Source

update struct member name

master
yggverse 2 months ago
parent
commit
c97222d68c
  1. 2
      src/app/browser.rs
  2. 14
      src/app/browser/header.rs
  3. 14
      src/app/browser/header/subject.rs
  4. 16
      src/app/browser/header/subject/description.rs
  5. 12
      src/app/browser/header/subject/title.rs
  6. 14
      src/app/browser/header/tray.rs
  7. 12
      src/app/browser/header/tray/menu.rs
  8. 12
      src/app/browser/header/tray/tab.rs

2
src/app/browser.rs

@ -98,7 +98,7 @@ impl Browser { @@ -98,7 +98,7 @@ impl Browser {
// Init widget
let widget = Arc::new(Widget::new(
profile_database_connection.clone(),
header.widget(),
header.gobject(),
window.gobject(),
));

14
src/app/browser/header.rs

@ -9,7 +9,7 @@ use gtk::{gio::SimpleAction, glib::GString, HeaderBar}; @@ -9,7 +9,7 @@ use gtk::{gio::SimpleAction, glib::GString, HeaderBar};
use std::sync::Arc;
pub struct Header {
widget: HeaderBar,
gobject: HeaderBar,
subject: Subject,
}
@ -46,12 +46,12 @@ impl Header { @@ -46,12 +46,12 @@ impl Header {
let subject = Subject::new();
// Init widget
let widget = HeaderBar::builder().build();
widget.pack_start(tray.widget());
widget.set_title_widget(Some(subject.widget()));
let gobject = HeaderBar::builder().build();
gobject.pack_start(tray.gobject());
gobject.set_title_widget(Some(subject.gobject()));
// Return new struct
Self { widget, subject }
Self { gobject, subject }
}
// Actions
@ -60,7 +60,7 @@ impl Header { @@ -60,7 +60,7 @@ impl Header {
}
// Getters
pub fn widget(&self) -> &HeaderBar {
&self.widget
pub fn gobject(&self) -> &HeaderBar {
&self.gobject
}
}

14
src/app/browser/header/subject.rs

@ -7,7 +7,7 @@ use title::Title; @@ -7,7 +7,7 @@ use title::Title;
use gtk::{glib::GString, prelude::BoxExt, Align, Box, Orientation};
pub struct Subject {
widget: Box,
gobject: Box,
title: Title,
description: Description,
}
@ -18,16 +18,16 @@ impl Subject { @@ -18,16 +18,16 @@ impl Subject {
let title = Title::new();
let description = Description::new();
let widget = Box::builder()
let gobject = Box::builder()
.orientation(Orientation::Vertical)
.valign(Align::Center)
.build();
widget.append(title.widget());
widget.append(description.widget());
gobject.append(title.gobject());
gobject.append(description.gobject());
Self {
widget,
gobject,
title,
description,
}
@ -40,7 +40,7 @@ impl Subject { @@ -40,7 +40,7 @@ impl Subject {
}
// Getters
pub fn widget(&self) -> &Box {
&self.widget
pub fn gobject(&self) -> &Box {
&self.gobject
}
}

16
src/app/browser/header/subject/description.rs

@ -3,33 +3,33 @@ use gtk::prelude::WidgetExt; @@ -3,33 +3,33 @@ use gtk::prelude::WidgetExt;
use gtk::{pango::EllipsizeMode, Label};
pub struct Description {
widget: Label,
gobject: Label,
}
impl Description {
// Construct
pub fn new() -> Self {
let widget = Label::builder()
let gobject = Label::builder()
.css_classes(["subtitle"])
.single_line_mode(true)
.ellipsize(EllipsizeMode::End)
.visible(false)
.build();
Self { widget }
Self { gobject }
}
// Actions
pub fn update(&self, text: Option<GString>) {
match text {
Some(value) => self.widget.set_text(&value),
None => self.widget.set_text(""), // @TODO
Some(value) => self.gobject.set_text(&value),
None => self.gobject.set_text(""), // @TODO
};
self.widget.set_visible(!self.widget.text().is_empty());
self.gobject.set_visible(!self.gobject.text().is_empty());
}
// Getters
pub fn widget(&self) -> &Label {
&self.widget
pub fn gobject(&self) -> &Label {
&self.gobject
}
}

12
src/app/browser/header/subject/title.rs

@ -3,20 +3,20 @@ use gtk::{glib::GString, pango::EllipsizeMode, Label}; @@ -3,20 +3,20 @@ use gtk::{glib::GString, pango::EllipsizeMode, Label};
const DEFAULT_TEXT: &str = "Yoda"; // @TODO
pub struct Title {
widget: Label,
gobject: Label,
}
impl Title {
// Construct
pub fn new() -> Self {
let widget = gtk::Label::builder()
let gobject = gtk::Label::builder()
.css_classes(["title"])
.single_line_mode(true)
.ellipsize(EllipsizeMode::End)
.label(DEFAULT_TEXT)
.build();
Self { widget }
Self { gobject }
}
// Actions
@ -31,11 +31,11 @@ impl Title { @@ -31,11 +31,11 @@ impl Title {
name.push(GString::from(DEFAULT_TEXT));
self.widget.set_text(&name.join(" - "));
self.gobject.set_text(&name.join(" - "));
}
// Getters
pub fn widget(&self) -> &Label {
&self.widget
pub fn gobject(&self) -> &Label {
&self.gobject
}
}

14
src/app/browser/header/tray.rs

@ -13,7 +13,7 @@ use gtk::{ @@ -13,7 +13,7 @@ use gtk::{
use std::sync::Arc;
pub struct Tray {
widget: Box,
gobject: Box,
}
impl Tray {
@ -48,20 +48,20 @@ impl Tray { @@ -48,20 +48,20 @@ impl Tray {
);
// Init widget
let widget = Box::builder()
let gobject = Box::builder()
.orientation(Orientation::Horizontal)
.spacing(8)
.build();
widget.append(menu.widget());
widget.append(tab.widget());
gobject.append(menu.gobject());
gobject.append(tab.gobject());
// Return new struct
Self { widget }
Self { gobject }
}
// Getters
pub fn widget(&self) -> &Box {
&self.widget
pub fn gobject(&self) -> &Box {
&self.gobject
}
}

12
src/app/browser/header/tray/menu.rs

@ -8,7 +8,7 @@ use gtk::{ @@ -8,7 +8,7 @@ use gtk::{
use std::sync::Arc;
pub struct Menu {
widget: MenuButton,
gobject: MenuButton,
}
#[rustfmt::skip] // @TODO template builder?
impl Menu {
@ -66,16 +66,16 @@ impl Menu { @@ -66,16 +66,16 @@ impl Menu {
model.append(Some("Quit"), Some(&detailed_action_name(action_quit)));
// Init widget
let widget = MenuButton::builder().tooltip_text("Menu").build();
widget.set_menu_model(Some(&model));
let gobject = MenuButton::builder().tooltip_text("Menu").build();
gobject.set_menu_model(Some(&model));
// Result
Self { widget }
Self { gobject }
}
// Getters
pub fn widget(&self) -> &MenuButton {
&self.widget
pub fn gobject(&self) -> &MenuButton {
&self.gobject
}
}

12
src/app/browser/header/tray/tab.rs

@ -2,29 +2,29 @@ use gtk::{gio::SimpleAction, prelude::ActionExt, prelude::ButtonExt, Button}; @@ -2,29 +2,29 @@ use gtk::{gio::SimpleAction, prelude::ActionExt, prelude::ButtonExt, Button};
use std::sync::Arc;
pub struct Tab {
pub widget: Button,
pub gobject: Button,
}
impl Tab {
// Construct
pub fn new(action_tab_append: Arc<SimpleAction>) -> Self {
// Init widget
let widget = Button::builder()
let gobject = Button::builder()
.icon_name("tab-new-symbolic")
.tooltip_text("New tab")
.build();
// Init events
widget.connect_clicked(move |_| {
gobject.connect_clicked(move |_| {
action_tab_append.activate(None);
});
// Return activated struct
Self { widget }
Self { gobject }
}
// Getters
pub fn widget(&self) -> &Button {
&self.widget
pub fn gobject(&self) -> &Button {
&self.gobject
}
}

Loading…
Cancel
Save