Created
April 17, 2024 19:19
-
-
Save pmartinez8241/041b4e45937cc6e15d384507f1fe75cd to your computer and use it in GitHub Desktop.
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
use gtk::{prelude::*, Orientation}; | |
use gtk::{glib, Application, ApplicationWindow, Widget}; | |
use std::fs; | |
const APP_ID: &str = "org.gtk_rs.HelloWorld2"; | |
fn main() -> glib::ExitCode { | |
// Create a new application | |
let app = Application::builder().application_id(APP_ID).build(); | |
// Connect to "activate" signal of `app` | |
app.connect_activate(build_ui); | |
// Run the application | |
app.run() | |
} | |
fn build_ui(app: &Application) { | |
let path_text = gtk::Entry::builder() | |
.placeholder_text("Path to Folder") | |
.margin_bottom(12) | |
.margin_top(12) | |
.margin_start(12) | |
.margin_end(12) | |
.build(); | |
let find_path_button = gtk::Button::builder() | |
.label("Find Path Files") | |
.margin_top(12) | |
.margin_bottom(12) | |
.margin_start(12) | |
.margin_end(12) | |
.build(); | |
let gtk_box = gtk::Box::builder() | |
.orientation(Orientation::Vertical).build(); | |
gtk_box.append(&path_text); | |
gtk_box.append(&find_path_button); | |
find_path_button.connect_clicked(move | _button|{ | |
for file in fs::read_dir(path_text.text().as_str()).unwrap() | |
{ | |
let x= file.unwrap().file_name(); | |
println!("{:?}",x); | |
} | |
}); | |
// Create a window and set the title | |
let window = ApplicationWindow::builder() | |
.application(app) | |
.title("File Renaming Application") | |
.child(>k_box) | |
.default_height(400) | |
.default_width(800) | |
.build(); | |
// Present window | |
window.present(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment