Skip to content

Commit a849537

Browse files
committed
add: created workspaces to convert, cli and gui to sepate interfaces and make convert as a lib
1 parent d7ed24a commit a849537

File tree

9 files changed

+191
-30
lines changed

9 files changed

+191
-30
lines changed

Cargo.lock

Lines changed: 86 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
[package]
2-
name = "rpdf"
3-
version = "0.1.0"
4-
edition = "2021"
5-
authors = ["Fabio Kleis <[email protected]>"]
6-
description = "Rust cli to convert images to pdf"
7-
readme = "README.md"
8-
repository = "https://github.com/fabiokleis/rpdf/"
9-
license = "MIT"
10-
11-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12-
13-
[dependencies]
14-
clap = "4.0.32"
15-
printpdf = { version = "0.5.3", features = ["embedded_images"] }
1+
[workspace]
2+
members = [
3+
"convert",
4+
"cli",
5+
"gui",
6+
]

cli/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "cli"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["Fabio Kleis <[email protected]>"]
6+
description = "Rust cli to convert images to pdf"
7+
readme = "README.md"
8+
repository = "https://github.com/fabiokleis/rpdf/"
9+
license = "MIT"
10+
11+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12+
13+
[dependencies]
14+
convert = { path = "../convert" }
15+
clap = "4.0.32"

src/main.rs renamed to cli/src/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
extern crate clap;
2-
extern crate printpdf;
32
use clap::{arg, Command};
43

5-
mod conf;
6-
mod convert;
7-
use conf::Conf;
8-
use convert::Convert;
4+
#[allow(dead_code)]
5+
use convert::{Convert, conf::Conf};
96

107
fn cli() -> Command {
118
Command::new("rpdf")
@@ -25,6 +22,7 @@ fn cli() -> Command {
2522
)
2623
}
2724

25+
#[allow(dead_code, unused_assignments)]
2826
fn main() -> Result<(), String> {
2927
let mut config = Conf::default();
3028
let matches = cli().get_matches();

convert/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "convert"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["Fabio Kleis <[email protected]>"]
6+
description = "Rust lib convert images to pdf"
7+
readme = "README.md"
8+
repository = "https://github.com/fabiokleis/rpdf/"
9+
license = "MIT"
10+
11+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12+
13+
[dependencies]
14+
printpdf = { version = "0.5.3", features = ["embedded_images"] }
15+
16+
File renamed without changes.

src/convert.rs renamed to convert/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
extern crate printpdf;
12
use printpdf::*;
23
use image_crate::codecs::{jpeg::JpegDecoder, png::PngDecoder};
34
use std::{path::Path, fs::File, io::BufWriter};
4-
use crate::conf;
5+
6+
#[allow(dead_code)]
7+
pub mod conf;
58

69
#[derive(Debug, Clone)]
710
pub struct Convert {

gui/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "gui"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["Fabio Kleis <[email protected]>"]
6+
description = "cross-platform gui to rpdf"
7+
readme = "README.md"
8+
repository = "https://github.com/fabiokleis/rpdf/"
9+
license = "MIT"
10+
11+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12+
13+
[dependencies]
14+
convert = { path = "../convert" }
15+
fltk = "1.3.25"

gui/src/main.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
extern crate fltk;
2+
use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window, };
3+
4+
#[derive(Copy, Clone)]
5+
enum Message {
6+
Increment,
7+
Decrement,
8+
}
9+
10+
fn main() {
11+
let app = app::App::default().with_scheme(app::Scheme::Oxy);
12+
let mut wind = Window::default()
13+
.with_size(160, 200)
14+
.center_screen()
15+
.with_label("Counter");
16+
let mut frame = Frame::default()
17+
.with_size(100, 40)
18+
.center_of(&wind)
19+
.with_label("0");
20+
let mut but_inc = Button::default()
21+
.size_of(&frame)
22+
.above_of(&frame, 0)
23+
.with_label("+");
24+
let mut but_dec = Button::default()
25+
.size_of(&frame)
26+
.below_of(&frame, 0)
27+
.with_label("-");
28+
wind.make_resizable(true);
29+
wind.end();
30+
wind.show();
31+
/* Event handling */
32+
let (s, r) = app::channel::<Message>();
33+
but_inc.emit(s, Message::Increment);
34+
but_dec.emit(s, Message::Decrement);
35+
36+
while app.wait() {
37+
let label: i32 = frame.label().parse().unwrap();
38+
if let Some(msg) = r.recv() {
39+
match msg {
40+
Message::Increment => frame.set_label(&(label + 1).to_string()),
41+
Message::Decrement => frame.set_label(&(label - 1).to_string()),
42+
}
43+
}
44+
}
45+
app.run().unwrap();
46+
}

0 commit comments

Comments
 (0)