Skip to content

Commit 9c49338

Browse files
committed
chore: Rename DaemonBoard to Board
1 parent 50853a3 commit 9c49338

File tree

10 files changed

+42
-46
lines changed

10 files changed

+42
-46
lines changed

backend/src/board.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ use std::{cell::Cell, collections::HashMap, rc::Rc};
77

88
use crate::{BoardId, Daemon, DerefCell, Key, KeyMap, Layer, Layout};
99

10-
// GObject
11-
// Add changed signal
12-
// Want DerefCell, I guess... Or use OnceCell
13-
1410
#[derive(Default)]
15-
pub struct DaemonBoardInner {
11+
pub struct BoardInner {
1612
daemon: DerefCell<Rc<dyn Daemon>>,
1713
board: DerefCell<BoardId>,
1814
model: DerefCell<String>,
@@ -26,13 +22,13 @@ pub struct DaemonBoardInner {
2622
}
2723

2824
#[glib::object_subclass]
29-
impl ObjectSubclass for DaemonBoardInner {
25+
impl ObjectSubclass for BoardInner {
3026
const NAME: &'static str = "S76DaemonBoard";
3127
type ParentType = glib::Object;
32-
type Type = DaemonBoard;
28+
type Type = Board;
3329
}
3430

35-
impl ObjectImpl for DaemonBoardInner {
31+
impl ObjectImpl for BoardInner {
3632
fn signals() -> &'static [Signal] {
3733
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
3834
vec![
@@ -45,10 +41,10 @@ impl ObjectImpl for DaemonBoardInner {
4541
}
4642

4743
glib::wrapper! {
48-
pub struct DaemonBoard(ObjectSubclass<DaemonBoardInner>);
44+
pub struct Board(ObjectSubclass<BoardInner>);
4945
}
5046

51-
impl DaemonBoard {
47+
impl Board {
5248
pub fn new(daemon: Rc<dyn Daemon>, board: BoardId) -> Result<Self, String> {
5349
let model = match daemon.model(board) {
5450
Ok(model) => model,
@@ -73,7 +69,7 @@ impl DaemonBoard {
7369
let has_led_save = daemon.led_save(board).is_ok();
7470
let has_matrix = daemon.matrix_get(board).is_ok();
7571

76-
let self_ = glib::Object::new::<DaemonBoard>(&[]).unwrap();
72+
let self_ = glib::Object::new::<Board>(&[]).unwrap();
7773
self_.inner().daemon.set(daemon);
7874
self_.inner().board.set(board);
7975
self_.inner().model.set(model);
@@ -99,8 +95,8 @@ impl DaemonBoard {
9995
Ok(self_)
10096
}
10197

102-
fn inner(&self) -> &DaemonBoardInner {
103-
DaemonBoardInner::from_instance(self)
98+
fn inner(&self) -> &BoardInner {
99+
BoardInner::from_instance(self)
104100
}
105101

106102
pub(crate) fn set_leds_changed(&self) {

backend/src/key.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use glib::clone::Downgrade;
22
use std::{cell::Cell, char};
33

4-
use crate::{DaemonBoard, Hs, PhysicalLayoutKey, Rect, Rgb};
4+
use crate::{Board, Hs, PhysicalLayoutKey, Rect, Rgb};
55

66
#[derive(Debug)]
77
pub struct Key {
8-
pub(crate) board: glib::WeakRef<DaemonBoard>,
8+
pub(crate) board: glib::WeakRef<Board>,
99
// Logical position (row, column)
1010
pub logical: (u8, u8),
1111
// Logical name (something like K01, where 0 is the row and 1 is the column)
@@ -32,7 +32,7 @@ pub struct Key {
3232
}
3333

3434
impl Key {
35-
pub(crate) fn new(board: &DaemonBoard, physical_key: &PhysicalLayoutKey) -> Self {
35+
pub(crate) fn new(board: &Board, physical_key: &PhysicalLayoutKey) -> Self {
3636
let logical = physical_key.logical;
3737
let physical = physical_key.physical;
3838
let physical_name = physical_key.physical_name.clone();
@@ -121,7 +121,7 @@ impl Key {
121121
}
122122
}
123123

124-
fn board(&self) -> DaemonBoard {
124+
fn board(&self) -> Board {
125125
self.board.upgrade().unwrap()
126126
}
127127

backend/src/layer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use glib::clone::Downgrade;
22
use std::cell::Cell;
33

4-
use crate::{DaemonBoard, Hs, Mode, Rgb};
4+
use crate::{Board, Hs, Mode, Rgb};
55

66
#[derive(Debug)]
77
pub struct Layer {
88
layer: u8,
99
index: u8,
10-
board: glib::WeakRef<DaemonBoard>,
10+
board: glib::WeakRef<Board>,
1111
mode: Cell<Option<(u8, u8)>>,
1212
brightness: Cell<i32>,
1313
color: Cell<Hs>,
1414
}
1515

1616
impl Layer {
17-
pub(crate) fn new(board: &DaemonBoard, layer: u8) -> Self {
17+
pub(crate) fn new(board: &Board, layer: u8) -> Self {
1818
let index = if board.layout().meta.has_per_layer {
1919
0xf0 + layer
2020
} else {
@@ -63,7 +63,7 @@ impl Layer {
6363
}
6464
}
6565

66-
fn board(&self) -> DaemonBoard {
66+
fn board(&self) -> Board {
6767
self.board.upgrade().unwrap()
6868
}
6969

src/application/backlight.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use once_cell::sync::Lazy;
66
use std::cell::{Cell, RefCell};
77

88
use crate::{DerefCell, KeyboardColor, KeyboardColorIndex, SelectedKeys};
9-
use backend::{DaemonBoard, Hs, Mode};
9+
use backend::{Board, Hs, Mode};
1010

1111
#[derive(Default)]
1212
pub struct BacklightInner {
13-
board: DerefCell<DaemonBoard>,
13+
board: DerefCell<Board>,
1414
disable_color_button: DerefCell<gtk::Button>,
1515
keyboard_color: DerefCell<KeyboardColor>,
1616
color_row: DerefCell<gtk::ListBoxRow>,
@@ -208,7 +208,7 @@ glib::wrapper! {
208208
}
209209

210210
impl Backlight {
211-
pub fn new(board: DaemonBoard) -> Self {
211+
pub fn new(board: Board) -> Self {
212212
let max_brightness = board.max_brightness() as f64;
213213
let has_led_save = board.has_led_save();
214214

@@ -242,7 +242,7 @@ impl Backlight {
242242
BacklightInner::from_instance(self)
243243
}
244244

245-
fn board(&self) -> &DaemonBoard {
245+
fn board(&self) -> &Board {
246246
&self.inner().board
247247
}
248248

src/application/keyboard.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ use std::{
1212

1313
use super::{show_error_dialog, Backlight, KeyboardLayer, Page, Picker};
1414
use crate::{DerefCell, SelectedKeys};
15-
use backend::{DaemonBoard, KeyMap, Layout};
15+
use backend::{Board, KeyMap, Layout};
1616

1717
#[derive(Default)]
1818
pub struct KeyboardInner {
1919
action_group: DerefCell<gio::SimpleActionGroup>,
20-
board: DerefCell<DaemonBoard>,
20+
board: DerefCell<Board>,
2121
page: Cell<Page>,
2222
picker: RefCell<WeakRef<Picker>>,
2323
selected: RefCell<SelectedKeys>,
@@ -164,7 +164,7 @@ glib::wrapper! {
164164
}
165165

166166
impl Keyboard {
167-
pub fn new(board: DaemonBoard, debug_layers: bool) -> Self {
167+
pub fn new(board: Board, debug_layers: bool) -> Self {
168168
let keyboard: Self = glib::Object::new(&[]).unwrap();
169169

170170
let backlight = cascade! {
@@ -202,7 +202,7 @@ impl Keyboard {
202202
self.inner().action_group.upcast_ref()
203203
}
204204

205-
pub fn board(&self) -> &DaemonBoard {
205+
pub fn board(&self) -> &Board {
206206
&self.inner().board
207207
}
208208

src/application/keyboard_layer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99

1010
use super::Page;
1111
use crate::{DerefCell, SelectedKeys};
12-
use backend::{DaemonBoard, Key, Layer, Rect, Rgb};
12+
use backend::{Board, Key, Layer, Rect, Rgb};
1313

1414
const SCALE: f64 = 64.0;
1515
const MARGIN: f64 = 2.;
@@ -18,7 +18,7 @@ const RADIUS: f64 = 4.;
1818
#[derive(Default)]
1919
pub struct KeyboardLayerInner {
2020
page: Cell<Page>,
21-
board: DerefCell<DaemonBoard>,
21+
board: DerefCell<Board>,
2222
selected: RefCell<SelectedKeys>,
2323
selectable: Cell<bool>,
2424
multiple: Cell<bool>,
@@ -204,7 +204,7 @@ glib::wrapper! {
204204
}
205205

206206
impl KeyboardLayer {
207-
pub fn new(page: Page, board: DaemonBoard) -> Self {
207+
pub fn new(page: Page, board: Board) -> Self {
208208
let (width, height) = board
209209
.keys()
210210
.iter()

src/application/main_window.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
77

88
use super::{shortcuts_window, ConfiguratorApp, Keyboard, KeyboardLayer, Page, Picker};
99
use crate::DerefCell;
10-
use backend::{Daemon, DaemonBoard, DaemonClient, DaemonDummy, DaemonServer};
10+
use backend::{Board, Daemon, DaemonClient, DaemonDummy, DaemonServer};
1111

1212
#[derive(Default)]
1313
pub struct MainWindowInner {
@@ -164,7 +164,7 @@ impl MainWindow {
164164
let daemon = daemon();
165165

166166
for i in daemon.boards().expect("Failed to load boards") {
167-
match DaemonBoard::new(daemon.clone(), i) {
167+
match Board::new(daemon.clone(), i) {
168168
Ok(board) => window.add_keyboard(board),
169169
Err(err) => error!("{}", err),
170170
}
@@ -175,7 +175,7 @@ impl MainWindow {
175175
let daemon = Rc::new(DaemonDummy::new(phony_board_names));
176176

177177
for i in daemon.boards().unwrap() {
178-
match DaemonBoard::new(daemon.clone(), i) {
178+
match Board::new(daemon.clone(), i) {
179179
Ok(board) => window.add_keyboard(board),
180180
Err(err) => error!("{}", err),
181181
}
@@ -216,7 +216,7 @@ impl MainWindow {
216216
inner.picker.set_keyboard(Some(keyboard.clone()));
217217
}
218218

219-
fn add_keyboard(&self, board: DaemonBoard) {
219+
fn add_keyboard(&self, board: Board) {
220220
let app: ConfiguratorApp = self.get_application().unwrap().downcast().unwrap();
221221

222222
let keyboard = cascade! {

src/choose_color.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use glib::clone;
33
use gtk::prelude::*;
44

55
use crate::ColorWheel;
6-
use backend::{DaemonBoard, Hs, Mode};
6+
use backend::{Board, Hs, Mode};
77

88
pub fn choose_color<W: IsA<gtk::Widget>, F: Fn(Option<Hs>) + 'static>(
9-
board: DaemonBoard,
9+
board: Board,
1010
w: &W,
1111
title: &'static str,
1212
color: Option<Hs>,

src/keyboard_backlight_widget.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use gtk::prelude::*;
66
use std::rc::Rc;
77

88
use crate::{KeyboardColor, KeyboardColorIndex};
9-
use backend::{Daemon, DaemonBoard, DaemonS76Power};
9+
use backend::{Board, Daemon, DaemonS76Power};
1010

1111
pub fn keyboard_backlight_widget() -> gtk::Widget {
1212
let stack = cascade! {
@@ -37,7 +37,7 @@ fn add_boards(stack: &gtk::Stack) -> Result<(), String> {
3737
let daemon = Rc::new(DaemonS76Power::new()?);
3838

3939
for i in daemon.boards()? {
40-
match DaemonBoard::new(daemon.clone(), i) {
40+
match Board::new(daemon.clone(), i) {
4141
Ok(board) => {
4242
let name = board.model().to_owned();
4343
stack.add_titled(&page(board), &name, &name);
@@ -49,7 +49,7 @@ fn add_boards(stack: &gtk::Stack) -> Result<(), String> {
4949
Ok(())
5050
}
5151

52-
fn page(board: DaemonBoard) -> gtk::Widget {
52+
fn page(board: Board) -> gtk::Widget {
5353
let max_brightness = board.max_brightness() as f64;
5454
let brightness = board.layers()[0].brightness() as f64;
5555
let brightness_scale = cascade! {

src/keyboard_color.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
};
99

1010
use crate::{choose_color, ColorCircle, DerefCell, SelectedKeys};
11-
use backend::{DaemonBoard, Hs};
11+
use backend::{Board, Hs};
1212

1313
#[derive(Clone)]
1414
pub enum KeyboardColorIndex {
@@ -25,7 +25,7 @@ impl Default for KeyboardColorIndex {
2525
#[derive(Default)]
2626
pub struct KeyboardColorInner {
2727
circle: DerefCell<ColorCircle>,
28-
board: RefCell<Option<DaemonBoard>>,
28+
board: RefCell<Option<Board>>,
2929
hs: Cell<Hs>,
3030
index: RefCell<KeyboardColorIndex>,
3131
}
@@ -105,7 +105,7 @@ glib::wrapper! {
105105
}
106106

107107
impl KeyboardColor {
108-
pub fn new(board: Option<DaemonBoard>, index: KeyboardColorIndex) -> Self {
108+
pub fn new(board: Option<Board>, index: KeyboardColorIndex) -> Self {
109109
cascade! {
110110
glib::Object::new::<Self>(&[]).unwrap();
111111
..set_board(board);
@@ -133,7 +133,7 @@ impl KeyboardColor {
133133
);
134134
}
135135

136-
fn board(&self) -> Option<Ref<DaemonBoard>> {
136+
fn board(&self) -> Option<Ref<Board>> {
137137
let board = self.inner().board.borrow();
138138
if board.is_some() {
139139
Some(Ref::map(board, |x| x.as_ref().unwrap()))
@@ -142,7 +142,7 @@ impl KeyboardColor {
142142
}
143143
}
144144

145-
pub fn set_board(&self, board: Option<DaemonBoard>) {
145+
pub fn set_board(&self, board: Option<Board>) {
146146
self.inner().circle.set_sensitive(board.is_some());
147147
*self.inner().board.borrow_mut() = board;
148148
self.read_color();

0 commit comments

Comments
 (0)