include slop

This commit is contained in:
Michael Zhang 2018-09-09 23:24:43 -05:00
parent 129ca1e221
commit cdf9f6f74f
No known key found for this signature in database
GPG key ID: A1B65B603268116B
11 changed files with 59 additions and 13 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "slop-sys/slop"]
path = slop-sys/slop
url = https://github.com/naelstrof/slop.git

17
Cargo.lock generated
View file

@ -105,6 +105,14 @@ dependencies = [
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cmake"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure"
version = "0.1.1"
@ -360,9 +368,17 @@ dependencies = [
"gdk-pixbuf 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"slop-sys 0.1.0",
"time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "slop-sys"
version = "0.1.0"
dependencies = [
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "strsim"
version = "0.7.0"
@ -470,6 +486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0ebb87d1116151416c0cf66a0e3fb6430cccd120fd6300794b4dfaa050ac40ba"
"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18"
"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536"
"checksum cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "704fbf3bb5149daab0afb255dbea24a1f08d2f4099cedb9baab6d470d4c5eefb"
"checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82"
"checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b"
"checksum gdk 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd30051ff3d908ff2fc7e5776ffe1c699821e043809f294c3a61004f11d6c3a9"

View file

@ -2,7 +2,9 @@
name = "screenshot"
version = "0.2.3"
authors = ["Michael Zhang <failed.down@gmail.com>"]
build = "src/build.rs"
[workspace]
members = [".", "slop-sys"]
[dependencies]
clap = "2.31.2"
@ -13,3 +15,4 @@ gdk-pixbuf = "0.4.0"
gio = "0.4.0"
gtk = { version = "0.4.1", features = ["v3_16"] }
time = "0.1.40"
slop-sys = { path = "slop-sys" }

4
slop-sys/Cargo.lock generated Normal file
View file

@ -0,0 +1,4 @@
[[package]]
name = "slop-sys"
version = "0.1.0"

13
slop-sys/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "slop-sys"
version = "0.1.0"
authors = ["Michael Zhang <failed.down@gmail.com>"]
build = "build.rs"
[lib]
path = "lib.rs"
[build-dependencies]
cmake = "0.1"
[dependencies]

12
slop-sys/build.rs Normal file
View file

@ -0,0 +1,12 @@
extern crate cmake;
use cmake::Config;
fn main() {
let dst = Config::new("slop").define("CMAKE_SKIP_RPATH", "ON").build();
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=slopy");
// println!("cargo:rustc-link-lib=slopy");
// println!("cargo:rustc-link-search=native=/usr/lib/usr/lib/x86_64-linux-gnu");
}

1
slop-sys/slop Submodule

@ -0,0 +1 @@
Subproject commit 2196617d8e10bb4a4a1e4a1520af4cab890f1e00

View file

@ -1,4 +0,0 @@
fn main() {
println!("cargo:rustc-link-lib=slopy");
println!("cargo:rustc-link-search=native=/usr/lib:/usr/lib/x86_64-linux-gnu");
}

View file

@ -9,13 +9,13 @@ extern crate gdk;
extern crate gdk_pixbuf;
extern crate gio;
extern crate gtk;
extern crate slop_sys;
extern crate time;
mod capture;
mod errors;
mod options;
mod selection;
mod slop;
use std::process::exit;
@ -42,22 +42,19 @@ fn run() -> Result<(), Error> {
.help("The region to be captured.")
.takes_value(false)
.required(true),
)
.arg(
).arg(
Arg::with_name("output")
.alias("o")
.long("output")
.help("Specify the output file.")
.takes_value(true)
.required(true),
)
.arg(
).arg(
Arg::with_name("clip")
.alias("c")
.long("clip")
.help("Copies the image to the clipboard if set."),
)
.get_matches();
).get_matches();
let region = match app.value_of("region").unwrap() {
"fullscreen" => Region::Fullscreen,
"active" | "window" => Region::ActiveWindow,

View file

@ -4,7 +4,7 @@ use failure::Error;
use gdk_pixbuf::{Pixbuf, PixbufExt};
use errors::ScreenshotError;
use slop::{slop_options, slop_select};
use slop_sys::{slop_options, slop_select};
pub fn select_area(pixbuf: Pixbuf) -> Result<Pixbuf, Error> {
let xdisplay = CString::new(":0")?.as_ptr();