From fae1d00b86d4209dd156fce0f5eda1e695af4080 Mon Sep 17 00:00:00 2001 From: Piyush Mishra Date: Thu, 18 Mar 2021 17:22:22 +0530 Subject: [PATCH] fixes --- src/main.rs | 11 ++++++++++- ui.glade | 2 +- ui.glade~ | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index b782520..0204643 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,7 @@ fn main() { } fn display(app: &Application) { - let builder = gtk::Builder::from_file("ui.glade"); + let builder = gtk::Builder::from_file(find_ui_file()); let win = builder.get_object::("win").expect("Resource file missing!"); win.set_application(Some(app)); @@ -57,3 +57,12 @@ fn display(app: &Application) { } }); } + +fn find_ui_file() -> String{ + let ui_file = std::env::var("RANG_UI_FILE"); + match ui_file { + Ok(val) => val, + Err(_) => std::env::current_exe().unwrap().parent().unwrap() + .join("ui.glade").to_str().unwrap().to_owned() + } +} diff --git a/ui.glade b/ui.glade index 2fc8b47..5e19b25 100644 --- a/ui.glade +++ b/ui.glade @@ -7,7 +7,7 @@ dialog Rang Color Chooser - PiyushXCoder (https://gitlab.com/PiyushXCoder) + https://gitlab.com/PiyushXCoder gtk-select-color gpl-3-0 diff --git a/ui.glade~ b/ui.glade~ index 2fc8b47..5e19b25 100644 --- a/ui.glade~ +++ b/ui.glade~ @@ -7,7 +7,7 @@ dialog Rang Color Chooser - PiyushXCoder (https://gitlab.com/PiyushXCoder) + https://gitlab.com/PiyushXCoder gtk-select-color gpl-3-0