-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for changing card profiles
- Loading branch information
Showing
12 changed files
with
704 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- SPDX-License-Identifier: GPL-3.0-or-later --> | ||
<interface> | ||
<requires lib="gtk" version="4.0" /> | ||
<requires lib="Adw" version="1.0" /> | ||
<template class="PwDeviceBox" parent="GtkListBoxRow"> | ||
<child> | ||
<object class="GtkBox"> | ||
<property name="orientation">horizontal</property> | ||
<property name="spacing">6</property> | ||
<child> | ||
<object class="GtkLabel" id="label"> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="PwProfileDropDown" id="profile_dropdown"> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</template> | ||
</interface> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- SPDX-License-Identifier: GPL-3.0-or-later --> | ||
<interface> | ||
<requires lib="gtk" version="4.0" /> | ||
<requires lib="Adw" version="1.0" /> | ||
<template class="PwProfileDropDown" parent="GtkWidget"> | ||
<property name="layout-manager"> | ||
<object class="GtkBinLayout" /> | ||
</property> | ||
<child> | ||
<object class="GtkDropDown" id="profile_dropdown"> | ||
<property name="hexpand">0</property> | ||
<property name="valign">center</property> | ||
<style> | ||
<class name="suffixes" /> | ||
</style> | ||
</object> | ||
</child> | ||
</template> | ||
</interface> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use crate::{profile_dropdown::PwProfileDropDown, pwdeviceobject::PwDeviceObject}; | ||
use gtk::{prelude::*, subclass::prelude::*}; | ||
use std::cell::RefCell; | ||
|
||
mod imp { | ||
use super::*; | ||
|
||
#[derive(Default, gtk::CompositeTemplate, glib::Properties)] | ||
#[template(resource = "/com/saivert/pwvucontrol/gtk/devicebox.ui")] | ||
#[properties(wrapper_type = super::PwDeviceBox)] | ||
pub struct PwDeviceBox { | ||
#[template_child] | ||
pub label: TemplateChild<gtk::Label>, | ||
#[template_child] | ||
pub profile_dropdown: TemplateChild<PwProfileDropDown>, | ||
|
||
#[property(get, set, construct_only)] | ||
pub deviceobject: RefCell<Option<PwDeviceObject>>, | ||
} | ||
|
||
#[glib::object_subclass] | ||
impl ObjectSubclass for PwDeviceBox { | ||
const NAME: &'static str = "PwDeviceBox"; | ||
type Type = super::PwDeviceBox; | ||
type ParentType = gtk::ListBoxRow; | ||
|
||
fn class_init(klass: &mut Self::Class) { | ||
klass.bind_template(); | ||
klass.bind_template_callbacks(); | ||
} | ||
|
||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) { | ||
obj.init_template(); | ||
} | ||
} | ||
|
||
#[glib::derived_properties] | ||
impl ObjectImpl for PwDeviceBox { | ||
fn constructed(&self) { | ||
self.parent_constructed(); | ||
|
||
let obj = self.obj(); | ||
|
||
let deviceobject = obj.deviceobject().expect("Device object"); | ||
|
||
deviceobject | ||
.bind_property("name", &self.label.get(), "label") | ||
.sync_create() | ||
.build(); | ||
|
||
self.profile_dropdown.set_deviceobject(obj.deviceobject()); | ||
} | ||
} | ||
impl WidgetImpl for PwDeviceBox {} | ||
impl ListBoxRowImpl for PwDeviceBox {} | ||
|
||
#[gtk::template_callbacks] | ||
impl PwDeviceBox {} | ||
} | ||
|
||
glib::wrapper! { | ||
pub struct PwDeviceBox(ObjectSubclass<imp::PwDeviceBox>) | ||
@extends gtk::Widget, gtk::ListBoxRow, | ||
@implements gtk::Actionable; | ||
} | ||
|
||
impl PwDeviceBox { | ||
pub(crate) fn new(deviceobject: &PwDeviceObject) -> Self { | ||
glib::Object::builder() | ||
.property("deviceobject", deviceobject) | ||
.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.