Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library: Ported Menu Button in rust #552

Merged
merged 11 commits into from
Aug 30, 2023
23 changes: 23 additions & 0 deletions src/Library/demos/Menu Button/code.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use crate::workbench;
use gtk::prelude::*;
use gtk::{Button, Switch};

pub fn main() {
let circular_switch: Switch = workbench::builder()
.object("circular_switch")
.expect("Failed to get circular_switch");
let primary_button: Button = workbench::builder()
.object("primary")
.expect("Failed to get primary_button");
mbilal234 marked this conversation as resolved.
Show resolved Hide resolved
let secondary_button: Button = workbench::builder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be a MenuButton not a Button

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check now pls

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried the code?
it doesn't look like it would work. I also don't think it's formatted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to add an import, it works on my side now + did the formatting.

Pls check :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look formatted to me :)

Please run the code in Workbench, that will format it.
Then copy the result to code.rs.

See here:
#554 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I ran the code and copy-pasted it as you asked. Let me know if its correctly formatted now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good now.

you don’t have to remove your name, you should resolve the conflict in a way that all of the additions are there. You can give it a try by clicking on “Resolve conflicts” on this page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that, but I cant figure it out. Could you please help out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done it for you.
You can see how in this screencast, so you can try next time on your own :)
screencast

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I will look at the screencast. Much appreciated

.object("secondary")
.expect("Failed to get secondary_button");

circular_switch.connect_active_notify(move |switch| {
if switch.is_active() {
secondary_button.add_css_class("circular");
} else {
secondary_button.remove_css_class("circular");
}
});
}