-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into blueprint-formatter
- Loading branch information
Showing
23 changed files
with
131 additions
and
6 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,2 @@ | ||
pub fn main() {} | ||
|
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,3 @@ | ||
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
||
public void main () {} |
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,2 @@ | ||
pub fn main() {} | ||
|
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,3 @@ | ||
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
||
public void main () {} |
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,24 @@ | ||
use crate::workbench; | ||
|
||
pub fn main() { | ||
let calendar: gtk::Calendar = workbench::builder().object("calendar").unwrap(); | ||
|
||
calendar.connect_day_notify(|calendar| { | ||
println!("{}", calendar.date().format("%e").unwrap()); | ||
}); | ||
|
||
calendar.connect_month_notify(|calendar| { | ||
println!("{}", calendar.date().format("%B").unwrap()); | ||
}); | ||
|
||
calendar.connect_year_notify(|calendar| { | ||
println!("{}", calendar.date().format("%Y").unwrap()); | ||
}); | ||
|
||
calendar.connect_day_selected(|calendar| { | ||
println!("{}", calendar.date().format_iso8601().unwrap()); | ||
}); | ||
|
||
calendar.mark_day(15); | ||
} | ||
|
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,2 @@ | ||
pub fn main() {} | ||
|
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,3 @@ | ||
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
||
public void main () {} |
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,2 @@ | ||
pub fn main() {} | ||
|
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,2 @@ | ||
pub fn main() {} | ||
|
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,3 @@ | ||
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
||
public void main () {} |
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,2 @@ | ||
pub fn main() {} | ||
|
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,3 @@ | ||
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
||
public void main () {} |
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,2 @@ | ||
pub fn main() {} | ||
|
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,3 @@ | ||
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
||
public void main () {} |
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,2 @@ | ||
pub fn main() {} | ||
|
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,3 @@ | ||
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
||
public void main () {} |
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,8 @@ | ||
use crate::workbench; | ||
use gtk::prelude::*; | ||
|
||
pub fn main() { | ||
let basic_label: gtk::Label = workbench::builder().object("basic_label").unwrap(); | ||
basic_label.add_css_class("css_text"); | ||
} | ||
|
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,50 @@ | ||
use crate::workbench; | ||
use gtk::pango; | ||
|
||
// Pango is a text layout library. It can e.g. be used for formatting text | ||
// https://docs.rs/pango/0.18.0/pango/index.html | ||
|
||
pub fn main() { | ||
let label: gtk::Label = workbench::builder().object("label").unwrap(); | ||
label.connect_label_notify(update_attributes); | ||
update_attributes(&label); | ||
} | ||
|
||
/// A Pango Attribute List is used to style the label | ||
fn update_attributes(label: >k::Label) { | ||
label.set_attributes(Some(&rainbow_attributes(label.label().as_str()))); | ||
} | ||
|
||
/// Generates an Attribute List that styles the label in rainbow colors. | ||
/// The `str` parameter is needed to detect string length + position of spaces | ||
fn rainbow_attributes(input_str: &str) -> pango::AttrList { | ||
let rainbow_colors = ["#D00", "#C50", "#E90", "#090", "#24E", "#55E", "#C3C"]; | ||
|
||
// Create a color array with the length needed to color all the letters | ||
let mut color_array = Vec::new(); | ||
let mut i = 0; | ||
while i < input_str.chars().count() { | ||
color_array.extend_from_slice(&rainbow_colors); | ||
i = color_array.len(); | ||
} | ||
|
||
// Independent variable from `i` in the following loop to avoid spaces "consuming" a color | ||
let mut color_idx = 0; | ||
let mut attr_list_string = String::new(); | ||
for (i, character) in input_str.chars().enumerate() { | ||
// Skip space characters | ||
if !character.is_whitespace() { | ||
let start_idx = i; | ||
let end_idx = i + 1; | ||
|
||
let color = color_array[color_idx]; | ||
color_idx += 1; | ||
// See comment below | ||
attr_list_string.push_str(&format!("{start_idx} {end_idx} foreground {color},")); | ||
} | ||
} | ||
// For more info about the syntax for this function, see: | ||
// https://docs.rs/pango/0.18.0/pango/struct.AttrList.html#method.from_string | ||
pango::AttrList::from_string(&attr_list_string).unwrap() | ||
} | ||
|
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,2 @@ | ||
pub fn main() {} | ||
|
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,3 @@ | ||
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
||
public void main () {} |
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