mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-28 12:04:13 +00:00
give name to gobject variables
This commit is contained in:
parent
702269f1f1
commit
a1617b2b1b
47
src/app.rs
47
src/app.rs
@ -16,14 +16,14 @@ const APPLICATION_ID: &str = "io.github.yggverse.Yoda";
|
||||
|
||||
pub struct App {
|
||||
profile: Rc<Profile>,
|
||||
gobject: Application,
|
||||
application: Application,
|
||||
}
|
||||
|
||||
impl App {
|
||||
// Construct
|
||||
pub fn new(profile: Rc<Profile>) -> Self {
|
||||
// Init GTK
|
||||
let gobject = Application::builder()
|
||||
let application = Application::builder()
|
||||
.application_id(APPLICATION_ID)
|
||||
.build();
|
||||
|
||||
@ -31,12 +31,12 @@ impl App {
|
||||
let browser = Rc::new(Browser::new(profile.clone()));
|
||||
|
||||
// Init events
|
||||
gobject.connect_activate({
|
||||
application.connect_activate({
|
||||
let browser = browser.clone();
|
||||
move |_| browser.update()
|
||||
});
|
||||
|
||||
gobject.connect_startup({
|
||||
application.connect_startup({
|
||||
let browser = browser.clone();
|
||||
let profile = profile.clone();
|
||||
move |this| {
|
||||
@ -72,7 +72,7 @@ impl App {
|
||||
}
|
||||
});
|
||||
|
||||
gobject.connect_shutdown({
|
||||
application.connect_shutdown({
|
||||
let browser = browser.clone();
|
||||
let profile = profile.clone();
|
||||
move |_| {
|
||||
@ -136,7 +136,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.action.id,
|
||||
browser.action.close.gobject.name()
|
||||
browser.action.close.simple_action.name()
|
||||
),
|
||||
&["<Primary>Escape"],
|
||||
),
|
||||
@ -144,7 +144,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.action.id,
|
||||
browser.action.debug.gobject.name()
|
||||
browser.action.debug.simple_action.name()
|
||||
),
|
||||
&["<Primary>i"],
|
||||
),
|
||||
@ -152,7 +152,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.action.id,
|
||||
browser.action.update.gobject.name()
|
||||
browser.action.update.simple_action.name()
|
||||
),
|
||||
&["<Primary>u"],
|
||||
),
|
||||
@ -160,7 +160,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.action.id,
|
||||
browser.action.focus.gobject.name()
|
||||
browser.action.focus.simple_action.name()
|
||||
),
|
||||
&["Escape"],
|
||||
),
|
||||
@ -169,7 +169,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.append.gobject.name()
|
||||
browser.window.action.append.simple_action.name()
|
||||
),
|
||||
&["<Primary>t"],
|
||||
),
|
||||
@ -177,7 +177,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.bookmark.gobject.name()
|
||||
browser.window.action.bookmark.simple_action.name()
|
||||
),
|
||||
&["<Primary>b"],
|
||||
),
|
||||
@ -185,7 +185,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.pin.gobject.name()
|
||||
browser.window.action.pin.simple_action.name()
|
||||
),
|
||||
&["<Primary>p"],
|
||||
),
|
||||
@ -193,7 +193,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.reload.gobject.name()
|
||||
browser.window.action.reload.simple_action.name()
|
||||
),
|
||||
&["<Primary>r"],
|
||||
),
|
||||
@ -201,7 +201,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.save_as.gobject.name()
|
||||
browser.window.action.save_as.simple_action.name()
|
||||
),
|
||||
&["<Primary>s"],
|
||||
),
|
||||
@ -209,7 +209,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.source.gobject.name()
|
||||
browser.window.action.source.simple_action.name()
|
||||
),
|
||||
&["<Primary>u"],
|
||||
),
|
||||
@ -217,7 +217,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.home.gobject.name()
|
||||
browser.window.action.home.simple_action.name()
|
||||
),
|
||||
&["<Primary>h"],
|
||||
),
|
||||
@ -225,7 +225,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.history_back.gobject.name()
|
||||
browser.window.action.history_back.simple_action.name()
|
||||
),
|
||||
&["<Primary>Left"],
|
||||
),
|
||||
@ -233,7 +233,7 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.history_forward.gobject.name()
|
||||
browser.window.action.history_forward.simple_action.name()
|
||||
),
|
||||
&["<Primary>Right"],
|
||||
),
|
||||
@ -241,16 +241,19 @@ impl App {
|
||||
format!(
|
||||
"{}.{}",
|
||||
browser.window.action.id,
|
||||
browser.window.action.close.gobject.name()
|
||||
browser.window.action.close.simple_action.name()
|
||||
),
|
||||
&["<Primary>q"],
|
||||
),
|
||||
] {
|
||||
gobject.set_accels_for_action(detailed_action_name, &accels);
|
||||
application.set_accels_for_action(detailed_action_name, &accels);
|
||||
}
|
||||
|
||||
// Return activated App struct
|
||||
Self { profile, gobject }
|
||||
Self {
|
||||
profile,
|
||||
application,
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
@ -283,7 +286,7 @@ impl App {
|
||||
} // unlock database
|
||||
|
||||
// Start application
|
||||
self.gobject.run()
|
||||
self.application.run()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,12 @@ impl Browser {
|
||||
(
|
||||
// Browser
|
||||
&action.id,
|
||||
action.gobject.clone(),
|
||||
action.simple_action_group.clone(),
|
||||
),
|
||||
(
|
||||
// Window
|
||||
&window.action.id,
|
||||
window.action.gobject.clone(),
|
||||
window.action.simple_action_group.clone(),
|
||||
),
|
||||
],
|
||||
));
|
||||
|
@ -30,7 +30,7 @@ pub struct Action {
|
||||
pub update: Rc<Update>,
|
||||
// Group
|
||||
pub id: GString,
|
||||
pub gobject: SimpleActionGroup,
|
||||
pub simple_action_group: SimpleActionGroup,
|
||||
}
|
||||
|
||||
impl Action {
|
||||
@ -50,15 +50,15 @@ impl Action {
|
||||
let id = uuid_string_random();
|
||||
|
||||
// Init group
|
||||
let gobject = SimpleActionGroup::new();
|
||||
let simple_action_group = SimpleActionGroup::new();
|
||||
|
||||
// Add action to given group
|
||||
gobject.add_action(&about.gobject);
|
||||
gobject.add_action(&close.gobject);
|
||||
gobject.add_action(&debug.gobject);
|
||||
gobject.add_action(&focus.gobject);
|
||||
gobject.add_action(&profile.gobject);
|
||||
gobject.add_action(&update.gobject);
|
||||
simple_action_group.add_action(&about.simple_action);
|
||||
simple_action_group.add_action(&close.simple_action);
|
||||
simple_action_group.add_action(&debug.simple_action);
|
||||
simple_action_group.add_action(&focus.simple_action);
|
||||
simple_action_group.add_action(&profile.simple_action);
|
||||
simple_action_group.add_action(&update.simple_action);
|
||||
|
||||
// Done
|
||||
Self {
|
||||
@ -69,7 +69,7 @@ impl Action {
|
||||
profile,
|
||||
update,
|
||||
id,
|
||||
gobject,
|
||||
simple_action_group,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random};
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `About` action of `Browser` group
|
||||
pub struct About {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl About {
|
||||
@ -11,7 +11,7 @@ impl About {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), None),
|
||||
simple_action: SimpleAction::new(&uuid_string_random(), None),
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,6 @@ impl About {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn() + 'static) {
|
||||
self.gobject.connect_activate(move |_, _| callback());
|
||||
self.simple_action.connect_activate(move |_, _| callback());
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random};
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Browser` group
|
||||
pub struct Close {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Close {
|
||||
@ -11,7 +11,7 @@ impl Close {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), None),
|
||||
simple_action: SimpleAction::new(&uuid_string_random(), None),
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,6 @@ impl Close {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn() + 'static) {
|
||||
self.gobject.connect_activate(move |_, _| callback());
|
||||
self.simple_action.connect_activate(move |_, _| callback());
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random};
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Debug` action of `Browser` group
|
||||
pub struct Debug {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Debug {
|
||||
@ -11,7 +11,7 @@ impl Debug {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), None),
|
||||
simple_action: SimpleAction::new(&uuid_string_random(), None),
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,6 @@ impl Debug {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn() + 'static) {
|
||||
self.gobject.connect_activate(move |_, _| callback());
|
||||
self.simple_action.connect_activate(move |_, _| callback());
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random, prelude::ActionExt};
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Focus` action of `Browser` group
|
||||
pub struct Focus {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Focus {
|
||||
@ -11,7 +11,7 @@ impl Focus {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), None),
|
||||
simple_action: SimpleAction::new(&uuid_string_random(), None),
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ impl Focus {
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
/// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None); // @TODO custom value
|
||||
self.simple_action.activate(None); // @TODO custom value
|
||||
}
|
||||
|
||||
// Events
|
||||
@ -28,6 +28,6 @@ impl Focus {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn() + 'static) {
|
||||
self.gobject.connect_activate(move |_, _| callback());
|
||||
self.simple_action.connect_activate(move |_, _| callback());
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random};
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Profile` action of `Browser` group
|
||||
pub struct Profile {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Profile {
|
||||
@ -11,7 +11,7 @@ impl Profile {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), None),
|
||||
simple_action: SimpleAction::new(&uuid_string_random(), None),
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,6 @@ impl Profile {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn() + 'static) {
|
||||
self.gobject.connect_activate(move |_, _| callback());
|
||||
self.simple_action.connect_activate(move |_, _| callback());
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use gtk::{
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Update` action of `Browser` group
|
||||
pub struct Update {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Update {
|
||||
@ -15,7 +15,10 @@ impl Update {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type())),
|
||||
simple_action: SimpleAction::new(
|
||||
&uuid_string_random(),
|
||||
Some(&String::static_variant_type()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +27,7 @@ impl Update {
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
/// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value
|
||||
pub fn activate(&self, tab_item_id: Option<&str>) {
|
||||
self.gobject.activate(Some(
|
||||
self.simple_action.activate(Some(
|
||||
&match tab_item_id {
|
||||
Some(value) => String::from(value),
|
||||
None => String::new(),
|
||||
@ -38,7 +41,7 @@ impl Update {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<GString>) + 'static) {
|
||||
self.gobject.connect_activate(move |_, variant| {
|
||||
self.simple_action.connect_activate(move |_, variant| {
|
||||
let tab_item_id = variant
|
||||
.expect("Variant required to call this action")
|
||||
.get::<String>()
|
||||
|
@ -29,8 +29,8 @@ impl Window {
|
||||
|
||||
// Init components
|
||||
let tab = Rc::new(Tab::new(profile, (browser_action.clone(), action.clone())));
|
||||
let header = Header::new(browser_action, action.clone(), &tab.widget.gobject);
|
||||
let widget = Rc::new(Widget::new(&header.widget.gobject, &tab.widget.gobject));
|
||||
let header = Header::new(browser_action, action.clone(), &tab.widget.tab_view);
|
||||
let widget = Rc::new(Widget::new(&header.widget.gobject, &tab.widget.tab_view));
|
||||
|
||||
// Init events
|
||||
action.append.connect_activate({
|
||||
|
@ -47,7 +47,7 @@ pub struct Action {
|
||||
pub source: Rc<Source>,
|
||||
// Group
|
||||
pub id: GString,
|
||||
pub gobject: SimpleActionGroup,
|
||||
pub simple_action_group: SimpleActionGroup,
|
||||
}
|
||||
|
||||
impl Action {
|
||||
@ -72,20 +72,20 @@ impl Action {
|
||||
let id = uuid_string_random();
|
||||
|
||||
// Init group
|
||||
let gobject = SimpleActionGroup::new();
|
||||
let simple_action_group = SimpleActionGroup::new();
|
||||
|
||||
// Add action to given group
|
||||
gobject.add_action(&append.gobject);
|
||||
gobject.add_action(&bookmark.gobject);
|
||||
gobject.add_action(&close_all.gobject);
|
||||
gobject.add_action(&close.gobject);
|
||||
gobject.add_action(&history_back.gobject);
|
||||
gobject.add_action(&history_forward.gobject);
|
||||
gobject.add_action(&home.gobject);
|
||||
gobject.add_action(&pin.gobject);
|
||||
gobject.add_action(&reload.gobject);
|
||||
gobject.add_action(&save_as.gobject);
|
||||
gobject.add_action(&source.gobject);
|
||||
simple_action_group.add_action(&append.simple_action);
|
||||
simple_action_group.add_action(&bookmark.simple_action);
|
||||
simple_action_group.add_action(&close_all.simple_action);
|
||||
simple_action_group.add_action(&close.simple_action);
|
||||
simple_action_group.add_action(&history_back.simple_action);
|
||||
simple_action_group.add_action(&history_forward.simple_action);
|
||||
simple_action_group.add_action(&home.simple_action);
|
||||
simple_action_group.add_action(&pin.simple_action);
|
||||
simple_action_group.add_action(&reload.simple_action);
|
||||
simple_action_group.add_action(&save_as.simple_action);
|
||||
simple_action_group.add_action(&source.simple_action);
|
||||
|
||||
// Done
|
||||
Self {
|
||||
@ -101,7 +101,7 @@ impl Action {
|
||||
save_as,
|
||||
source,
|
||||
id,
|
||||
gobject,
|
||||
simple_action_group,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ const DEFAULT_IS_LOAD: bool = false;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Append` action of `Window` group
|
||||
pub struct Append {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Append {
|
||||
@ -46,7 +46,7 @@ impl Append {
|
||||
/// Create new `Self` with default action state preset
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&(
|
||||
@ -69,7 +69,7 @@ impl Append {
|
||||
pub fn activate_default_once(&self) {
|
||||
// Save current state in memory
|
||||
let (position, request, is_pinned, is_selected, is_attention, is_load) =
|
||||
state(&self.gobject);
|
||||
state(&self.simple_action);
|
||||
|
||||
// Set default state
|
||||
self.change_state(
|
||||
@ -82,7 +82,7 @@ impl Append {
|
||||
);
|
||||
|
||||
// Activate action
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
|
||||
// Return previous state
|
||||
self.change_state(
|
||||
@ -108,7 +108,7 @@ impl Append {
|
||||
) {
|
||||
// Save current state in memory
|
||||
let (_position, _request, _is_pinned, _is_selected, _is_attention, _is_load) =
|
||||
state(&self.gobject);
|
||||
state(&self.simple_action);
|
||||
|
||||
// Apply requested state
|
||||
self.change_state(
|
||||
@ -121,7 +121,7 @@ impl Append {
|
||||
);
|
||||
|
||||
// Activate action
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
|
||||
// Return previous state
|
||||
self.change_state(
|
||||
@ -144,7 +144,7 @@ impl Append {
|
||||
is_attention: bool,
|
||||
is_load: bool,
|
||||
) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&(
|
||||
// Convert Option to C-based variant value
|
||||
position,
|
||||
@ -171,7 +171,7 @@ impl Append {
|
||||
&self,
|
||||
callback: impl Fn(Position, Option<String>, bool, bool, bool, bool) + 'static,
|
||||
) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let (position, request, is_pinned, is_selected, is_attention, is_load) = state(this);
|
||||
callback(
|
||||
position,
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group
|
||||
pub struct Bookmark {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
@ -20,7 +20,7 @@ impl Bookmark {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -32,13 +32,13 @@ impl Bookmark {
|
||||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -52,7 +52,7 @@ impl Bookmark {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Window` group
|
||||
pub struct Close {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Close {
|
||||
@ -20,7 +20,7 @@ impl Close {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -33,7 +33,7 @@ impl Close {
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -47,7 +47,7 @@ impl Close {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `CloseAll` action of `Window` group
|
||||
pub struct CloseAll {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl CloseAll {
|
||||
@ -20,7 +20,7 @@ impl CloseAll {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -33,7 +33,7 @@ impl CloseAll {
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -47,7 +47,7 @@ impl CloseAll {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryBack` action of `Window` group
|
||||
pub struct HistoryBack {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl HistoryBack {
|
||||
@ -20,7 +20,7 @@ impl HistoryBack {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -32,13 +32,13 @@ impl HistoryBack {
|
||||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -52,7 +52,7 @@ impl HistoryBack {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryForward` action of `Window` group
|
||||
pub struct HistoryForward {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl HistoryForward {
|
||||
@ -20,7 +20,7 @@ impl HistoryForward {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -32,13 +32,13 @@ impl HistoryForward {
|
||||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -52,7 +52,7 @@ impl HistoryForward {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group
|
||||
pub struct Home {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Home {
|
||||
@ -20,7 +20,7 @@ impl Home {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -32,13 +32,13 @@ impl Home {
|
||||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -52,7 +52,7 @@ impl Home {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Pin` action of `Window` group
|
||||
pub struct Pin {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
@ -20,7 +20,7 @@ impl Pin {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -33,7 +33,7 @@ impl Pin {
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -47,7 +47,7 @@ impl Pin {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Reload` action of `Window` group
|
||||
pub struct Reload {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
@ -20,7 +20,7 @@ impl Reload {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -32,13 +32,13 @@ impl Reload {
|
||||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -52,7 +52,7 @@ impl Reload {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Save As` action of `Window` group
|
||||
pub struct SaveAs {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl SaveAs {
|
||||
@ -20,7 +20,7 @@ impl SaveAs {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -33,7 +33,7 @@ impl SaveAs {
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -47,7 +47,7 @@ impl SaveAs {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Source` action of `Window` group
|
||||
pub struct Source {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Source {
|
||||
@ -20,7 +20,7 @@ impl Source {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
@ -33,7 +33,7 @@ impl Source {
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
@ -47,7 +47,7 @@ impl Source {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
@ -27,7 +27,7 @@ impl Header {
|
||||
|
||||
// Return new struct
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(&bar.widget.gobject)),
|
||||
widget: Rc::new(Widget::new(&bar.widget.g_box)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,19 +27,19 @@ impl Menu {
|
||||
main_page.append(Some("New"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.append.gobject.name()
|
||||
window_action.append.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page.append(Some("Reload"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.reload.gobject.name()
|
||||
window_action.reload.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page.append(Some("Save as.."), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.save_as.gobject.name()
|
||||
window_action.save_as.simple_action.name()
|
||||
)));
|
||||
|
||||
// Main > Page > Mark
|
||||
@ -48,13 +48,13 @@ impl Menu {
|
||||
main_page_mark.append(Some("Bookmark"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.bookmark.gobject.name()
|
||||
window_action.bookmark.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page_mark.append(Some("Pin"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.pin.gobject.name()
|
||||
window_action.pin.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page.append_section(None, &main_page_mark);
|
||||
@ -65,7 +65,7 @@ impl Menu {
|
||||
main_page_tools.append(Some("Source"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.source.gobject.name()
|
||||
window_action.source.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page.append_section(None, &main_page_tools);
|
||||
@ -76,7 +76,7 @@ impl Menu {
|
||||
main_page_navigation.append(Some("Home"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.home.gobject.name()
|
||||
window_action.home.simple_action.name()
|
||||
)));
|
||||
|
||||
// Main > Page > Navigation > History
|
||||
@ -85,13 +85,13 @@ impl Menu {
|
||||
main_page_navigation_history.append(Some("Back"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.history_back.gobject.name()
|
||||
window_action.history_back.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page_navigation_history.append(Some("Forward"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.history_forward.gobject.name()
|
||||
window_action.history_forward.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page_navigation.append_submenu(Some("History"), &main_page_navigation_history);
|
||||
@ -104,13 +104,13 @@ impl Menu {
|
||||
main_page_close.append(Some("Current"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.close.gobject.name()
|
||||
window_action.close.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page_close.append(Some("All"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.close_all.gobject.name()
|
||||
window_action.close_all.simple_action.name()
|
||||
)));
|
||||
|
||||
main_page.append_submenu(Some("Close"), &main_page_close);
|
||||
@ -124,19 +124,19 @@ impl Menu {
|
||||
main_tool.append(Some("Debug"), Some(&format!(
|
||||
"{}.{}",
|
||||
browser_action.id,
|
||||
browser_action.debug.gobject.name()
|
||||
browser_action.debug.simple_action.name()
|
||||
)));
|
||||
|
||||
main_tool.append(Some("Profile"), Some(&format!(
|
||||
"{}.{}",
|
||||
browser_action.id,
|
||||
browser_action.profile.gobject.name()
|
||||
browser_action.profile.simple_action.name()
|
||||
)));
|
||||
|
||||
main_tool.append(Some("About"), Some(&format!(
|
||||
"{}.{}",
|
||||
browser_action.id,
|
||||
browser_action.about.gobject.name()
|
||||
browser_action.about.simple_action.name()
|
||||
)));
|
||||
|
||||
main.append_submenu(Some("Tool"), &main_tool);
|
||||
@ -144,7 +144,7 @@ impl Menu {
|
||||
main.append(Some("Quit"), Some(&format!(
|
||||
"{}.{}",
|
||||
browser_action.id,
|
||||
browser_action.close.gobject.name()
|
||||
browser_action.close.simple_action.name()
|
||||
)));
|
||||
|
||||
// Result
|
||||
|
@ -2,21 +2,21 @@ use adw::TabBar;
|
||||
use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls};
|
||||
|
||||
pub struct Widget {
|
||||
pub gobject: Box,
|
||||
pub g_box: Box,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Self {
|
||||
let gobject = Box::builder()
|
||||
let g_box = Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.spacing(8)
|
||||
.build();
|
||||
|
||||
gobject.append(tab);
|
||||
gobject.append(menu);
|
||||
gobject.append(control);
|
||||
g_box.append(tab);
|
||||
g_box.append(menu);
|
||||
g_box.append(control);
|
||||
|
||||
Self { gobject }
|
||||
Self { g_box }
|
||||
}
|
||||
}
|
||||
|
@ -40,11 +40,11 @@ impl Tab {
|
||||
let menu = Menu::new(action.1.clone());
|
||||
|
||||
// Init widget
|
||||
let widget = Rc::new(Widget::new(&menu.gobject));
|
||||
let widget = Rc::new(Widget::new(&menu.main));
|
||||
|
||||
// Init events
|
||||
|
||||
widget.gobject.connect_setup_menu({
|
||||
widget.tab_view.connect_setup_menu({
|
||||
let action = action.1.clone();
|
||||
move |tab_view, tab_page| {
|
||||
// Set new state for page selected on menu open
|
||||
@ -65,7 +65,7 @@ impl Tab {
|
||||
}
|
||||
});
|
||||
|
||||
widget.gobject.connect_close_page({
|
||||
widget.tab_view.connect_close_page({
|
||||
let index = index.clone();
|
||||
move |_, item| {
|
||||
// Get index ID by keyword saved
|
||||
@ -84,7 +84,7 @@ impl Tab {
|
||||
}
|
||||
});
|
||||
|
||||
widget.gobject.connect_selected_page_notify({
|
||||
widget.tab_view.connect_selected_page_notify({
|
||||
let index = index.clone();
|
||||
move |this| {
|
||||
if let Some(page) = this.selected_page() {
|
||||
@ -120,7 +120,7 @@ impl Tab {
|
||||
) -> Rc<Item> {
|
||||
// Init new tab item
|
||||
let item = Rc::new(Item::new(
|
||||
&self.widget.gobject,
|
||||
&self.widget.tab_view,
|
||||
self.profile.clone(),
|
||||
// Actions
|
||||
(self.actions.0.clone(), self.actions.1.clone()),
|
||||
@ -227,7 +227,7 @@ impl Tab {
|
||||
// Update tab title on loading indicator inactive
|
||||
if !item.page.is_loading() {
|
||||
item.widget
|
||||
.gobject
|
||||
.tab_page
|
||||
.set_title(&item.page.meta.title.borrow())
|
||||
}
|
||||
}
|
||||
@ -240,7 +240,7 @@ impl Tab {
|
||||
// Update tab title on loading indicator inactive
|
||||
if !item.page.is_loading() {
|
||||
item.widget
|
||||
.gobject
|
||||
.tab_page
|
||||
.set_title(&item.page.meta.title.borrow())
|
||||
}
|
||||
}
|
||||
@ -282,7 +282,7 @@ impl Tab {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match Item::restore(
|
||||
&self.widget.gobject,
|
||||
&self.widget.tab_view,
|
||||
transaction,
|
||||
&record.id,
|
||||
self.profile.clone(),
|
||||
@ -321,10 +321,10 @@ impl Tab {
|
||||
item.save(
|
||||
transaction,
|
||||
&id,
|
||||
&self.widget.gobject.page_position(&item.widget.gobject),
|
||||
&item.widget.gobject.is_pinned(),
|
||||
&item.widget.gobject.is_selected(),
|
||||
&item.widget.gobject.needs_attention(),
|
||||
&self.widget.tab_view.page_position(&item.widget.tab_page),
|
||||
&item.widget.tab_page.is_pinned(),
|
||||
&item.widget.tab_page.is_selected(),
|
||||
&item.widget.tab_page.needs_attention(),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ impl Item {
|
||||
let widget = Rc::new(Widget::new(
|
||||
id.as_str(),
|
||||
tab_view,
|
||||
page.widget.gobject(),
|
||||
&page.widget.g_box,
|
||||
None,
|
||||
position,
|
||||
(is_pinned, is_selected, is_attention),
|
||||
@ -118,7 +118,7 @@ impl Item {
|
||||
self.page.update();
|
||||
|
||||
// Update tab loading indicator
|
||||
self.widget.gobject.set_loading(self.page.is_loading());
|
||||
self.widget.tab_page.set_loading(self.page.is_loading());
|
||||
}
|
||||
|
||||
pub fn clean(
|
||||
|
@ -24,7 +24,7 @@ impl Back {
|
||||
|
||||
pub fn update(&self, status: bool) {
|
||||
// Update actions
|
||||
self.action.history_back.gobject.set_enabled(status);
|
||||
self.action.history_back.simple_action.set_enabled(status);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(status);
|
||||
|
@ -22,7 +22,10 @@ impl Forward {
|
||||
// Actions
|
||||
pub fn update(&self, status: bool) {
|
||||
// Update actions
|
||||
self.action.history_forward.gobject.set_enabled(status);
|
||||
self.action
|
||||
.history_forward
|
||||
.simple_action
|
||||
.set_enabled(status);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(status);
|
||||
|
@ -34,7 +34,7 @@ impl Home {
|
||||
false
|
||||
}
|
||||
};
|
||||
self.action.home.gobject.set_enabled(has_home);
|
||||
self.action.home.simple_action.set_enabled(has_home);
|
||||
self.widget.update(has_home);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ impl Reload {
|
||||
|
||||
pub fn update(&self, is_enabled: bool) {
|
||||
// Update actions
|
||||
self.action.reload.gobject.set_enabled(is_enabled);
|
||||
self.action.reload.simple_action.set_enabled(is_enabled);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(is_enabled);
|
||||
|
@ -4,7 +4,7 @@ use gtk::{
|
||||
};
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Box,
|
||||
pub g_box: Box,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
@ -17,20 +17,15 @@ impl Widget {
|
||||
input: &impl IsA<gtk::Widget>,
|
||||
) -> Self {
|
||||
// Init self
|
||||
let gobject = Box::builder()
|
||||
let g_box = Box::builder()
|
||||
.orientation(Orientation::Vertical)
|
||||
.name(name)
|
||||
.build();
|
||||
|
||||
gobject.append(navigation);
|
||||
gobject.append(content);
|
||||
gobject.append(input);
|
||||
g_box.append(navigation);
|
||||
g_box.append(content);
|
||||
g_box.append(input);
|
||||
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Box {
|
||||
&self.gobject
|
||||
Self { g_box }
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use sqlite::Transaction;
|
||||
const DEFAULT_TITLE: &str = "New page";
|
||||
|
||||
pub struct Widget {
|
||||
pub gobject: TabPage,
|
||||
pub tab_page: TabPage,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
@ -25,8 +25,8 @@ impl Widget {
|
||||
// Define state variables
|
||||
let (is_pinned, is_selected, is_attention) = state;
|
||||
|
||||
// Create new `TabPage` GObject in given `TabView`
|
||||
let gobject = match position {
|
||||
// Create new `TabPage` for given `TabView`
|
||||
let tab_page = match position {
|
||||
Position::After => match tab_view.selected_page() {
|
||||
Some(page) => add(tab_view, child, tab_view.page_position(&page) + 1),
|
||||
None => tab_view.append(child),
|
||||
@ -35,22 +35,22 @@ impl Widget {
|
||||
Position::Number(value) => add(tab_view, child, value),
|
||||
};
|
||||
|
||||
// Setup `GObject`
|
||||
gobject.set_needs_attention(is_attention);
|
||||
gobject.set_keyword(keyword);
|
||||
gobject.set_title(match title {
|
||||
// Setup
|
||||
tab_page.set_needs_attention(is_attention);
|
||||
tab_page.set_keyword(keyword);
|
||||
tab_page.set_title(match title {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_TITLE,
|
||||
});
|
||||
|
||||
tab_view.set_page_pinned(&gobject, is_pinned);
|
||||
tab_view.set_page_pinned(&tab_page, is_pinned);
|
||||
|
||||
if is_selected {
|
||||
tab_view.set_selected_page(&gobject);
|
||||
tab_view.set_selected_page(&tab_page);
|
||||
}
|
||||
|
||||
// Done
|
||||
Self { gobject }
|
||||
Self { tab_page }
|
||||
}
|
||||
|
||||
// Actions
|
||||
@ -88,7 +88,7 @@ impl Widget {
|
||||
for record in records {
|
||||
// Record value can be stored as NULL
|
||||
if let Some(title) = record.title {
|
||||
self.gobject.set_title(title.as_str());
|
||||
self.tab_page.set_title(title.as_str());
|
||||
}
|
||||
|
||||
// Delegate restore action to the item childs
|
||||
@ -107,7 +107,7 @@ impl Widget {
|
||||
app_browser_window_tab_item_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
// Keep value in memory until operation complete
|
||||
let title = self.gobject.title();
|
||||
let title = self.tab_page.title();
|
||||
|
||||
match database::insert(
|
||||
transaction,
|
||||
|
@ -6,7 +6,7 @@ use std::rc::Rc;
|
||||
///
|
||||
/// https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/method.TabView.get_menu_model.html
|
||||
pub struct Menu {
|
||||
pub gobject: gtk::gio::Menu,
|
||||
pub main: gtk::gio::Menu,
|
||||
}
|
||||
|
||||
impl Menu {
|
||||
@ -21,7 +21,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.reload.gobject.name()
|
||||
window_action.reload.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -30,7 +30,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.save_as.gobject.name()
|
||||
window_action.save_as.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -41,7 +41,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.bookmark.gobject.name()
|
||||
window_action.bookmark.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -50,7 +50,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.pin.gobject.name()
|
||||
window_action.pin.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -63,7 +63,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.source.gobject.name()
|
||||
window_action.source.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -76,7 +76,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.home.gobject.name()
|
||||
window_action.home.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -89,7 +89,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.history_back.gobject.name()
|
||||
window_action.history_back.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -98,7 +98,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.history_forward.gobject.name()
|
||||
window_action.history_forward.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -111,7 +111,7 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.close.gobject.name()
|
||||
window_action.close.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
@ -120,12 +120,12 @@ impl Menu {
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id,
|
||||
window_action.close_all.gobject.name()
|
||||
window_action.close_all.simple_action.name()
|
||||
)),
|
||||
);
|
||||
|
||||
main.append_submenu(Some("Close"), &close);
|
||||
|
||||
Self { gobject: main }
|
||||
Self { main }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ const DEFAULT_TAB_ICON: &str = "view-pin-symbolic";
|
||||
|
||||
/// Wrapper for [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) GObject
|
||||
pub struct Widget {
|
||||
pub gobject: TabView,
|
||||
pub tab_view: TabView,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
@ -18,17 +18,17 @@ impl Widget {
|
||||
/// Create new `Self`
|
||||
pub fn new(menu_model: &impl IsA<MenuModel>) -> Self {
|
||||
// Init gobject
|
||||
let gobject = TabView::builder().menu_model(menu_model).build();
|
||||
let tab_view = TabView::builder().menu_model(menu_model).build();
|
||||
|
||||
// Change default icon (if available in the system icon set)
|
||||
// * visible for pinned tabs only
|
||||
// * @TODO not default GTK behavior, make this feature optional
|
||||
if let Ok(default_icon) = Icon::for_string(DEFAULT_TAB_ICON) {
|
||||
gobject.set_default_icon(&default_icon);
|
||||
tab_view.set_default_icon(&default_icon);
|
||||
}
|
||||
|
||||
// Done
|
||||
Self { gobject }
|
||||
Self { tab_view }
|
||||
}
|
||||
|
||||
// Actions
|
||||
@ -39,8 +39,8 @@ impl Widget {
|
||||
/// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter
|
||||
pub fn close(&self, position: Option<i32>) {
|
||||
if let Some(page) = self.page(position) {
|
||||
self.gobject.set_page_pinned(&page, false);
|
||||
self.gobject.close_page(&page);
|
||||
self.tab_view.set_page_pinned(&page, false);
|
||||
self.tab_view.close_page(&page);
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,16 +49,16 @@ impl Widget {
|
||||
/// * 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
|
||||
pub fn close_all(&self) {
|
||||
while let Some(page) = self.gobject.selected_page() {
|
||||
self.gobject.set_page_pinned(&page, false);
|
||||
self.gobject.close_page(&page);
|
||||
while let Some(page) = self.tab_view.selected_page() {
|
||||
self.tab_view.set_page_pinned(&page, false);
|
||||
self.tab_view.close_page(&page);
|
||||
}
|
||||
}
|
||||
|
||||
/// 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
|
||||
self.tab_view.set_page_pinned(&page, !page.is_pinned()); // toggle
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ impl Widget {
|
||||
/// * return `None` if requested or selected page not found
|
||||
pub fn page(&self, position: Option<i32>) -> Option<TabPage> {
|
||||
match position {
|
||||
Some(value) => Some(self.gobject.nth_page(value)),
|
||||
None => self.gobject.selected_page(),
|
||||
Some(value) => Some(self.tab_view.nth_page(value)),
|
||||
None => self.tab_view.selected_page(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user