Skip to content

Commit

Permalink
chore(deps): Rust 1.35 + Gtk-rs 0.7
Browse files Browse the repository at this point in the history
One of the side effects of this upgrade is that we can set the header
function for list boxes now, so separators will now be displayed between
elements in a list box.
  • Loading branch information
mmstick committed Aug 13, 2019
1 parent 79348e1 commit eb494e0
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 160 deletions.
228 changes: 114 additions & 114 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions gtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ fwupd = []
system76 = []

[dependencies]
cascade = "0.1.3"
err-derive = "0.1.5"
gio = "0.6.0"
glib = "0.7.1"
gtk = {version = "0.6.0", features = [ "v3_22" ] }
shrinkwraprs = "0.2.1"
slotmap = "0.3.0"
html2runes = "1.0.1"
cascade = "0.1"
err-derive = "0.1"
gio = "0.7"
glib = "0.8"
gtk = {version = "0.7", features = [ "v3_22" ] }
shrinkwraprs = "0.2"
slotmap = "0.3"
html2runes = "1.0"
firmware-manager = { path = "../" }

[target.'cfg(all(not(feature = "fwupd"), feature = "system76"))'.dependencies]
Expand Down
6 changes: 3 additions & 3 deletions gtk/ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ cdylib-link-lines = "0.1"

[dependencies]
firmware-manager-gtk = { path = "../" }
glib = "0.7.1"
gtk-sys = "0.8.0"
gtk = "0.6.0"
glib = "0.8"
gtk-sys = "0.9"
gtk = "0.7"

[target.'cfg(all(not(feature = "fwupd"), feature = "system76"))'.dependencies]
firmware-manager-gtk = { path = "../", features = [ "system76" ] }
Expand Down
24 changes: 11 additions & 13 deletions gtk/src/dialogs/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ impl FirmwareUpdateDialog {
changelog_entries.add(&cascade! {
gtk::Box::new(gtk::Orientation::Vertical, 12);
..add(&cascade! {
gtk::Label::new(format!("<b>{}</b>", version.as_ref()).as_str());
gtk::Label::new(Some(&*format!("<b>{}</b>", version.as_ref())));
..set_use_markup(true);
..set_xalign(0.0);
});
..add(&gtk::Separator::new(gtk::Orientation::Horizontal));
..add(&cascade! {
gtk::Label::new(&*markdown);
..set_line_wrap(true);
..set_xalign(0.0);
});
..add(&gtk::LabelBuilder::new().label(&*markdown).wrap(true).xalign(0.0).build());
});
});

Expand Down Expand Up @@ -58,10 +54,12 @@ impl FirmwareUpdateDialog {

cascade! {
&headerbar;
..set_custom_title(&cascade! {
gtk::Label::new("<b>Firmware Update</b>");
..set_use_markup(true);
});
..set_custom_title(
Some(&gtk::LabelBuilder::new()
.label("<b>Firmware Update</b>")
.use_markup(true)
.build())
);
..set_show_close_button(false);
..pack_start(&cancel);
..pack_end(&reboot);
Expand All @@ -73,13 +71,13 @@ impl FirmwareUpdateDialog {
..set_border_width(12);
..set_spacing(12);
..add(&cascade! {
gtk::Image::new_from_icon_name("application-x-firmware", gtk::IconSize::Dialog.into());
gtk::Image::new_from_icon_name("application-x-firmware".into(), gtk::IconSize::Dialog.into());
..set_valign(gtk::Align::Start);
});
..add(&cascade! {
gtk::Box::new(gtk::Orientation::Vertical, 12);
..add(&cascade! {
gtk::Label::new(&*header_text);
gtk::Label::new(Some(&*header_text));
..set_line_wrap(true);
..set_use_markup(true);
..set_xalign(0.0);
Expand All @@ -91,7 +89,7 @@ impl FirmwareUpdateDialog {
..add(changelog_entries);
});
..add(&cascade! {
gtk::Label::new("If you're on a laptop, <b>plug into power</b> before you begin.");
gtk::Label::new("If you're on a laptop, <b>plug into power</b> before you begin.".into());
..set_use_markup(true);
..set_xalign(0.0);
});
Expand Down
6 changes: 2 additions & 4 deletions gtk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ impl FirmwareWidget {
};

eprintln!("received response");
let expected: i32 = gtk::ResponseType::Accept.into();
if expected == response {
if gtk::ResponseType::Accept == response {
// Exchange the button for a progress bar.
if let (Some(stack), Some(progress)) =
(stack.upgrade(), progress.upgrade())
Expand Down Expand Up @@ -300,8 +299,7 @@ impl FirmwareWidget {
let dialog = FirmwareUpdateDialog::new(latest, log_entries);
dialog.show_all();

let expected: i32 = gtk::ResponseType::Accept.into();
if expected == dialog.run() {
if gtk::ResponseType::Accept == dialog.run() {
// Exchange the button for a progress bar.
if let (Some(stack), Some(progress)) =
(stack.upgrade(), progress.upgrade())
Expand Down
10 changes: 5 additions & 5 deletions gtk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub const APP_ID: &str = "com.system76.FirmwareManager";
fn main() {
glib::set_program_name(APP_ID.into());

let application =
Application::new(APP_ID, ApplicationFlags::empty()).expect("GTK initialization failed");
let application = Application::new(APP_ID.into(), ApplicationFlags::empty())
.expect("GTK initialization failed");

application.connect_activate(|app| {
if let Some(window) = app.get_window_by_id(0) {
Expand All @@ -27,12 +27,12 @@ fn main() {
let weak_widget = Rc::downgrade(&widget);
let headerbar = cascade! {
gtk::HeaderBar::new();
..set_title("System76 Firmware Manager");
..set_title("System76 Firmware Manager".into());
..set_show_close_button(true);
..show();
..pack_end(&cascade! {
gtk::Button::new_from_icon_name(
"view-refresh-symbolic",
"view-refresh-symbolic".into(),
gtk::IconSize::SmallToolbar
);
..connect_clicked(move |_| {
Expand All @@ -47,7 +47,7 @@ fn main() {
let _window = cascade! {
gtk::ApplicationWindow::new(app);
..set_titlebar(Some(&headerbar));
..set_icon_name("firmware-manager");
..set_icon_name("firmware-manager".into());
..set_keep_above(true);
..set_property_window_position(gtk::WindowPosition::Center);
..set_default_size(768, 576);
Expand Down
21 changes: 11 additions & 10 deletions gtk/src/views/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ impl DevicesView {
..set_halign(gtk::Align::Center);
..set_margin_top(24);
..add(&cascade! {
gtk::Label::new("<b>System Firmware</b>");
gtk::Label::new("<b>System Firmware</b>".into());
..set_use_markup(true);
..set_xalign(0.0);
});
..add(&system_firmware);
..add(&cascade! {
gtk::Label::new("<b>Device Firmware</b>");
gtk::Label::new("<b>Device Firmware</b>".into());
..set_use_markup(true);
..set_xalign(0.0);
});
Expand All @@ -48,9 +48,8 @@ impl DevicesView {
..add_widget(&device_firmware);
};

// Enable w/ Rust 1.34.0 and gtk-rs 0.8
// device_firmware.set_header_func(Some(Box::new(separator_header)));
// system_firmware.set_header_func(Some(Box::new(separator_header)));
device_firmware.set_header_func(Some(Box::new(separator_header)));
system_firmware.set_header_func(Some(Box::new(separator_header)));

let container = cascade! {
gtk::ScrolledWindow::new(None::<&gtk::Adjustment>, None::<&gtk::Adjustment>);
Expand All @@ -77,12 +76,12 @@ impl DevicesView {

fn append(container: &impl gtk::ContainerExt, info: &FirmwareInfo) -> DeviceWidget {
let device = cascade! {
gtk::Label::new(info.name.as_ref());
gtk::Label::new(Some(info.name.as_ref()));
..set_xalign(0.0);
};

let label = cascade! {
gtk::Label::new(info.current.as_ref());
gtk::Label::new(Some(info.current.as_ref()));
..set_xalign(0.0);
..get_style_context().add_class(&gtk::STYLE_CLASS_DIM_LABEL);
};
Expand Down Expand Up @@ -131,6 +130,8 @@ pub struct DeviceWidget {
pub stack: gtk::Stack,
}

// fn separator_header(current: &gtk::ListBoxRow, before: Option<&gtk::ListBoxRow>) {
// current.set_header(Some(&gtk::Separator::new(gtk::Orientation::Horizontal)));
// }
fn separator_header(current: &gtk::ListBoxRow, before: Option<&gtk::ListBoxRow>) {
if before.is_some() {
current.set_header(Some(&gtk::Separator::new(gtk::Orientation::Horizontal)));
}
}
4 changes: 2 additions & 2 deletions gtk/src/views/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ impl EmptyView {
..set_valign(gtk::Align::Center);
..add(&cascade! {
gtk::Image::new_from_icon_name(
"firmware-manager-symbolic",
"firmware-manager-symbolic".into(),
gtk::IconSize::Dialog
);
..set_pixel_size(64);
});
..add(&cascade! {
gtk::Label::new("Managed Firmware Unavailable\n\nNo devices supporting \
automatic firmware updates detected");
automatic firmware updates detected".into());
..set_line_wrap(true);
..set_xalign(0.0);
..set_yalign(0.0);
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.32.0
1.35.0

0 comments on commit eb494e0

Please sign in to comment.