mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2025-03-31 23:04:55 +03:00
add area_chooser_size_label
This commit is contained in:
parent
67b5e17b7d
commit
c2405c5540
1629
Cargo.lock
generated
1629
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -6,13 +6,16 @@ edition = "2021"
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
async-std = {version = "1.12.0", features = ["attributes"]}
|
||||
blue-recorder-core = { git = "https://github.com/ochibani/blue-recorder-core.git", rev = "85c9d8f" }
|
||||
blue-recorder-core = { git = "https://github.com/ochibani/blue-recorder-core.git", rev = "ae9fa71" }
|
||||
cpal = "0.15.3"
|
||||
dark-light = "1.0.0"
|
||||
dirs = "4.0.0"
|
||||
display-info = "0.5.1"
|
||||
fluent-bundle = "0.15.3"
|
||||
glib = "0.10.3"
|
||||
libadwaita = { version = "0.1.1" }
|
||||
rdev = "0.5"
|
||||
regex = "1.4.3"
|
||||
rust-ini = "0.16"
|
||||
secfmt = "0.1.1"
|
||||
x-win = "2.0.2"
|
||||
|
@ -20,28 +20,83 @@
|
||||
<child>
|
||||
<object class="GtkWindowHandle">
|
||||
<child>
|
||||
<object class="GtkButton" id="area_set_button">
|
||||
<property name="name">area_set_button</property>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="halign">fill</property>
|
||||
<property name="valign">filr</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="column-spacing">3</property>
|
||||
<property name="row-homogeneous">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="halign">fill</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-start">5</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<object class="GtkLabel" id="area_size_top">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="icon-name">object-select-symbolic</property>
|
||||
<property name="label" translatable="yes">label</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="vexpand">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="area_apply">
|
||||
<object class="GtkButton" id="area_set_button">
|
||||
<property name="name">area_set_button</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="column-spacing">3</property>
|
||||
<property name="row-homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="icon-name">object-select-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="area_apply">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="label" translatable="yes">label</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<property name="margin-end">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="area_size_bottom">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="label" translatable="yes">label</property>
|
||||
|
12
interfaces/select_window.ui
Normal file
12
interfaces/select_window.ui
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkMessageDialog" id="select_window">
|
||||
<property name="name">select_window</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="destroy-with-parent">True</property>
|
||||
<property name="deletable">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="modal">True</property>
|
||||
</object>
|
||||
</interface>
|
@ -60,6 +60,9 @@ wmv-format = WMV (Windows Media Video)
|
||||
# Name
|
||||
blue-recorder = المسجّل الأزرق
|
||||
|
||||
# Click to select window
|
||||
click-window = Left click to select a window
|
||||
|
||||
# Close error dialog
|
||||
close = Close
|
||||
|
||||
|
@ -60,6 +60,9 @@ wmv-format = WMV (Windows Media Video)
|
||||
# Name
|
||||
blue-recorder = المسجّل الأزرق
|
||||
|
||||
# Click to select window
|
||||
click-window = Left click to select a window
|
||||
|
||||
# Close error dialog
|
||||
close = Close
|
||||
|
||||
|
@ -60,6 +60,9 @@ wmv-format = WMV (Windows Media Video)
|
||||
# Name
|
||||
blue-recorder = Blue Recorder
|
||||
|
||||
# Click to select window
|
||||
click-window = Left click to select a window
|
||||
|
||||
# Close error dialog
|
||||
close = Close
|
||||
|
||||
|
@ -60,12 +60,18 @@ wmv-format = WMV (Windows Media Video)
|
||||
# Name
|
||||
blue-recorder = Blue Recorder
|
||||
|
||||
# Click to select window
|
||||
click-window = Left click to select a window
|
||||
|
||||
# Close error dialog
|
||||
close = Close
|
||||
|
||||
# Copy right
|
||||
copy-right = © 2021 Salem Yaslem
|
||||
|
||||
# Close error dialog
|
||||
close-error-dialog = Close
|
||||
|
||||
# Run command label
|
||||
default-command = Default command:
|
||||
|
||||
@ -81,12 +87,12 @@ delay-title = Start Recording in…
|
||||
# Stop delay timer
|
||||
delay-window-stop = Stop
|
||||
|
||||
# About message
|
||||
dialog-comment = A simple screen recorder for Linux desktop. Supports Wayland & Xorg.
|
||||
|
||||
# Details button
|
||||
details-button = Details
|
||||
|
||||
# About message
|
||||
dialog-comment = A simple screen recorder for Linux desktop. Supports Wayland & Xorg.
|
||||
|
||||
# Run command input
|
||||
enter-command = Enter your command here..
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
extern crate regex;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use display_info::DisplayInfo;
|
||||
use regex::Regex;
|
||||
use std::process::Command;
|
||||
#[cfg(target_os = "windows")]
|
||||
use x_win::get_active_window;
|
||||
|
||||
// This struct use "xwininfo" in linux & freebsd to get area x, y, width and height
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
@ -13,22 +16,46 @@ pub struct AreaCapture {
|
||||
pub height: u16,
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
impl AreaCapture {
|
||||
pub fn new() -> Result<AreaCapture> {
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
let coordinate = xwininfo_to_coordinate(
|
||||
String::from_utf8(Command::new("xwininfo").arg("-root").output()?.stdout)?
|
||||
)?;
|
||||
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
let area_capture = AreaCapture {
|
||||
x: coordinate.0,
|
||||
y: coordinate.1,
|
||||
width: coordinate.2,
|
||||
height: coordinate.3,
|
||||
};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
let coordinate = DisplayInfo::all()?;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
let area_capture = AreaCapture {
|
||||
x: coordinate[0].x as u16,
|
||||
y: coordinate[0].y as u16,
|
||||
width: coordinate[0].width as u16,
|
||||
height: coordinate[0].height as u16,
|
||||
};
|
||||
Ok(area_capture)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn get_active_window(&mut self) -> Result<Self> {
|
||||
let coordinate = get_active_window()?.position;
|
||||
|
||||
self.x = coordinate.x as u16;
|
||||
self.y = coordinate.y as u16;
|
||||
self.width = coordinate.width as u16;
|
||||
self.height = coordinate.height as u16;
|
||||
Ok(*self)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
pub fn get_area(&mut self) -> Result<Self> {
|
||||
let coordinate = xwininfo_to_coordinate(
|
||||
String::from_utf8(Command::new("xwininfo").output()?.stdout)?
|
||||
@ -40,9 +67,16 @@ impl AreaCapture {
|
||||
Ok(*self)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn get_title(&mut self) -> Result<String> {
|
||||
let title = get_active_window()?.title;
|
||||
Ok(title)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
pub fn get_window_by_name(&mut self, name: &str) -> Result<Self> {
|
||||
let coordinate = xwininfo_to_coordinate(
|
||||
String::from_utf8(Command::new("xwininfo").arg("-name").arg(name).output().unwrap().stdout).unwrap(),
|
||||
String::from_utf8(Command::new("xwininfo").arg("-name").arg(name).output()?.stdout)?,
|
||||
)?;
|
||||
self.x = coordinate.0;
|
||||
self.y = coordinate.1;
|
||||
@ -52,17 +86,27 @@ impl AreaCapture {
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) -> Result<Self> {
|
||||
let coordinate = xwininfo_to_coordinate(
|
||||
String::from_utf8(Command::new("xwininfo").arg("-root").output().unwrap().stdout).unwrap()
|
||||
)?;
|
||||
self.x = coordinate.0;
|
||||
self.y = coordinate.1;
|
||||
self.width = coordinate.2;
|
||||
self.height = coordinate.3;
|
||||
if cfg!(target_os = "windows") {
|
||||
let coordinate = DisplayInfo::all()?;
|
||||
self.x = coordinate[0].x as u16;
|
||||
self.y = coordinate[0].y as u16;
|
||||
self.width = coordinate[0].width as u16;
|
||||
self.height = coordinate[0].height as u16;
|
||||
} else {
|
||||
let coordinate = xwininfo_to_coordinate(
|
||||
String::from_utf8(Command::new("xwininfo").arg("-root").output()?.stdout)?
|
||||
)?;
|
||||
self.x = coordinate.0;
|
||||
self.y = coordinate.1;
|
||||
self.width = coordinate.2;
|
||||
self.height = coordinate.3;
|
||||
}
|
||||
|
||||
Ok(*self)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
fn xwininfo_to_coordinate(xwininfo_output: String) -> Result<(u16, u16, u16, u16)> {
|
||||
let x: u16 = Regex::new(r"A.*X:\s+(\d+)\n")?
|
||||
.captures(xwininfo_output.as_str())
|
||||
|
@ -91,6 +91,10 @@
|
||||
color: @theme_selected_bg_color;
|
||||
}
|
||||
|
||||
#select_window {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#stop_button {
|
||||
background: #ed333b;
|
||||
border: 1px solid #ed333b;
|
||||
|
10
src/ui.rs
10
src/ui.rs
@ -62,11 +62,13 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
let area_selection_ui_src = include_str!("../interfaces/area_selection.ui").to_string();
|
||||
let delay_ui_src = include_str!("../interfaces/delay.ui").to_string();
|
||||
let main_ui_src = include_str!("../interfaces/main.ui").to_string();
|
||||
let select_window_ui_src = include_str!("../interfaces/select_window.ui").to_string();
|
||||
|
||||
let builder: Builder = Builder::from_string(main_ui_src.as_str());
|
||||
builder.add_from_string(about_dialog_ui_src.as_str()).unwrap();
|
||||
builder.add_from_string(area_selection_ui_src.as_str()).unwrap();
|
||||
builder.add_from_string(delay_ui_src.as_str()).unwrap();
|
||||
builder.add_from_string(select_window_ui_src.as_str()).unwrap();
|
||||
|
||||
// Get Objects from UI
|
||||
let area_apply_label: Label = builder.object("area_apply").unwrap();
|
||||
@ -75,6 +77,8 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
let area_grab_icon: Image = builder.object("area_grab_icon").unwrap();
|
||||
let area_grab_label: Label = builder.object("area_grab_label").unwrap();
|
||||
let area_set_button: Button = builder.object("area_set_button").unwrap();
|
||||
let area_size_bottom_label: Label = builder.object("area_size_bottom").unwrap();
|
||||
let area_size_top_label: Label = builder.object("area_size_top").unwrap();
|
||||
let area_switch: CheckButton = builder.object("areaswitch").unwrap();
|
||||
let about_button: Button = builder.object("aboutbutton").unwrap();
|
||||
let about_dialog: AboutDialog = builder.object("about_dialog").unwrap();
|
||||
@ -110,6 +114,7 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
let screen_grab_button: ToggleButton = builder.object("screen_grab_button").unwrap();
|
||||
let screen_grab_icon: Image = builder.object("screen_grab_icon").unwrap();
|
||||
let screen_grab_label: Label = builder.object("screen_grab_label").unwrap();
|
||||
let select_window: MessageDialog = builder.object("select_window").unwrap();
|
||||
let speaker_switch: CheckButton = builder.object("speakerswitch").unwrap();
|
||||
let stop_button: Button = builder.object("stopbutton").unwrap();
|
||||
let stop_label: Label = builder.object("stop_label").unwrap();
|
||||
@ -124,6 +129,9 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
// Windows
|
||||
area_chooser_window.set_title(Some(&get_bundle("area-chooser", None))); // Title is hidden
|
||||
error_dialog.set_transient_for(Some(&main_window));
|
||||
select_window.set_transient_for(Some(&main_window));
|
||||
select_window.set_message_type(libadwaita::gtk::MessageType::Info);
|
||||
select_window.set_text(Some(&get_bundle("click-window", None)));
|
||||
main_window.set_application(Some(application));
|
||||
main_window.set_title(Some(&get_bundle("blue-recorder", None)));
|
||||
|
||||
@ -602,6 +610,8 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
window_grab_button.set_tooltip_text(Some(&get_bundle("window-tooltip", None)));
|
||||
window_grab_label.set_label(&get_bundle("select-window", None));
|
||||
window_grab_button.connect_clicked(move |_| {
|
||||
select_window.show();
|
||||
select_window.set_hide_on_close(true);
|
||||
let text_buffer = TextBuffer::new(None);
|
||||
config_management::set_bool("default", "areacheck", _area_switch.is_active());
|
||||
_area_switch.set_active(false);
|
||||
|
Loading…
Reference in New Issue
Block a user