From f1e9e7677f17344f9180825a38e07cf52e0ab6c5 Mon Sep 17 00:00:00 2001 From: Salem Yaslem Date: Tue, 2 Feb 2021 07:04:15 +0300 Subject: [PATCH] define all objects and improve the UI --- src/main.rs | 41 +++++++++++++++++++++++- windows/ui.glade | 82 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 112 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5adba78..e47de02 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,10 @@ mod config_management; use gio::prelude::*; use gtk::prelude::*; -use gtk::{Builder, Window}; +use gtk::{ + Adjustment, Builder, Button, CheckButton, ComboBox, Entry, FileChooser, Label, MenuItem, + SpinButton, Window, Dialog +}; use std::path::Path; fn main() { if gtk::init().is_err() { @@ -17,7 +20,43 @@ fn main() { config_management::set("default", "frame", "30"); // get Objects from UI let main_window: Window = builder.get_object("window1").unwrap(); + let about_dialog: Dialog = builder.get_object("aboutdialog").unwrap(); + let area_chooser: Window = builder.get_object("window2").unwrap(); + let folder_chooser: FileChooser = builder.get_object("filechooser").unwrap(); + let filename_entry: Entry = builder.get_object("filename").unwrap(); + let command_entry: Entry = builder.get_object("command").unwrap(); + let format_chooser: ComboBox = builder.get_object("comboboxtext1").unwrap(); + let audio_source: ComboBox = builder.get_object("audiosource").unwrap(); + let record_button: Button = builder.get_object("recordbutton").unwrap(); + let stop_button: Button = builder.get_object("stopbutton").unwrap(); + let window_grab_button: Button = builder.get_object("button4").unwrap(); + let area_grab_button: Button = builder.get_object("button5").unwrap(); + let frame_text: Label = builder.get_object("label2").unwrap(); + let delay_text: Label = builder.get_object("label3").unwrap(); + let command_text: Label = builder.get_object("label6").unwrap(); + let frames_spin: SpinButton = builder.get_object("frames").unwrap(); + let delay_spin: SpinButton = builder.get_object("delay").unwrap(); + let audio_source_label: Label = builder.get_object("audiosourcelabel").unwrap(); + let delay_adjustment: Adjustment = builder.get_object("adjustment1").unwrap(); + let frames_adjustment: Adjustment = builder.get_object("adjustment2").unwrap(); + let delay_pref_adjustment: Adjustment = builder.get_object("adjustment3").unwrap(); + let play_button: Button = builder.get_object("playbutton").unwrap(); + let video_switch: CheckButton = builder.get_object("videoswitch").unwrap(); + let audio_switch: CheckButton = builder.get_object("audioswitch").unwrap(); + let mouse_switch: CheckButton = builder.get_object("mouseswitch").unwrap(); + let follow_mouse_switch: CheckButton = builder.get_object("followmouseswitch").unwrap(); + let about_menu_item: MenuItem = builder.get_object("item2").unwrap(); + + // --- default properties + about_menu_item.set_label("about"); + + // --- connections + // show dialog window when about button clicked then hide it after close + about_menu_item.connect_activate(move |_| { + &about_dialog.run(); + &about_dialog.hide(); + }); // close the application when main window destroy main_window.connect_destroy(|_| { std::process::exit(0); diff --git a/windows/ui.glade b/windows/ui.glade index ca2713e..cf45167 100644 --- a/windows/ui.glade +++ b/windows/ui.glade @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ True dialog blue-recorder - + @@ -55,7 +55,7 @@ True False - gtk-media-play + media-playback-start True @@ -87,14 +87,42 @@ True - gtk-media-record True True True - none - True + half True + + + True + False + 2 + True + + + True + False + media-record + + + 0 + 0 + + + + + True + False + Record + + + 1 + 0 + + + + @@ -102,9 +130,15 @@ True True True - image5 none + + + True + False + media-playback-stop + + 2 @@ -504,14 +538,42 @@ True - gtk-apply True True True - none - True + half True + + + True + False + 3 + True + + + True + False + dialog-ok + + + 0 + 0 + + + + + True + False + Apply + + + 1 + 0 + + + +