Skip to content

Commit

Permalink
pickup embedded icon
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshew committed Dec 4, 2020
1 parent 262c5f8 commit 08b92f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
report.txt
samples-*.log
timeouts-*.log
**/samples-*.log
**/timeouts-*.log
13 changes: 9 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ pub struct BasicApp {
#[nwg_events( OnTimerTick: [BasicApp::on_timer_tick] )]
timer: nwg::Timer,

#[nwg_resource(source_file: Some("./resources/cog.ico"))]
#[nwg_resource]
embed: nwg::EmbedResource,

//#[nwg_resource(source_file: Some("./resources/cog.ico"))]
#[nwg_resource(source_embed: Some(&data.embed), source_embed_str: Some("MAINICON"))]
icon: nwg::Icon,

#[nwg_control(icon: Some(&data.icon), tip: Some("Connection Tracker"))]
Expand Down Expand Up @@ -170,6 +174,8 @@ pub struct BasicApp {

impl BasicApp {
fn on_window_init(&self) {
// let em = &self.embed;

self.slider.set_range_min(0);
self.slider.set_range_max(100);
self.graph.init(30, 0, 20);
Expand Down Expand Up @@ -348,8 +354,8 @@ impl BasicApp {
.expect("Could not parse IP Address");
let handle = thread::spawn(move || {
let pinger = Pinger::new().unwrap();
let mut buffer = Buffer::new();
loop {
let mut buffer = Buffer::new();
let ping_response;
let timestamp = SystemTime::now()
.duration_since(UNIX_EPOCH)
Expand All @@ -374,13 +380,12 @@ impl BasicApp {
}
}

fn main() -> std::io::Result<()> {
fn main() {
nwg::init().expect("Failed to init Native Windows GUI");
nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font");
let app = BasicApp::build_ui(Default::default()).expect("Failed to build UI");
app.spawn_pinger("1.1.1.2", 600);
app.spawn_pinger("8.8.8.8", 600);
app.spawn_pinger("208.67.222.222", 600);
nwg::dispatch_thread_events();
Ok(())
}

0 comments on commit 08b92f0

Please sign in to comment.