diff options
author | Mike Crute <mike@crute.us> | 2019-12-12 17:21:17 -0800 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2019-12-12 17:21:17 -0800 |
commit | b3cff1bf5ad4a3dbdb244b9ec4a815bf9c244da2 (patch) | |
tree | 745cea0d2392cdcfbd348cbf2419b683727f3257 | |
download | doxie-scanner-b3cff1bf5ad4a3dbdb244b9ec4a815bf9c244da2.tar.bz2 doxie-scanner-b3cff1bf5ad4a3dbdb244b9ec4a815bf9c244da2.tar.xz doxie-scanner-b3cff1bf5ad4a3dbdb244b9ec4a815bf9c244da2.zip |
-rw-r--r-- | README.txt | 3 | ||||
-rwxr-xr-x | main.py | 109 | ||||
-rw-r--r-- | process.txt | 4 |
3 files changed, 116 insertions, 0 deletions
diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..71b5cc9 --- /dev/null +++ b/README.txt | |||
@@ -0,0 +1,3 @@ | |||
1 | This repository is the start of an experiment to replace the Doxie software with | ||
2 | an open-source GTK-based scanner software that works on Linux as well as Mac OS. | ||
3 | It's not yet even remotely functional. | ||
@@ -0,0 +1,109 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | |||
3 | """ | ||
4 | import gi | ||
5 | gi.require_version('Gtk', '3.0') | ||
6 | from gi.repository import Gtk, Gdk, GdkPixbuf | ||
7 | |||
8 | import os | ||
9 | |||
10 | class MyWindow(Gtk.Window): | ||
11 | |||
12 | def __init__(self): | ||
13 | super().__init__() | ||
14 | |||
15 | self.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(6400, 6400, 6440)) | ||
16 | |||
17 | |||
18 | fixed = Gtk.Fixed() | ||
19 | |||
20 | fixed.put(image1, 10, 10) | ||
21 | fixed.put(image2, 430, 10) | ||
22 | fixed.put(image3, 560, 10) | ||
23 | |||
24 | self.add(fixed) | ||
25 | |||
26 | self.set_border_width(20) | ||
27 | self.set_title("Fixed") | ||
28 | |||
29 | self.connect("destroy", Gtk.main_quit) | ||
30 | |||
31 | win = MyWindow() | ||
32 | win.show_all() | ||
33 | Gtk.main() | ||
34 | """ | ||
35 | |||
36 | import gi, os | ||
37 | gi.require_version('Gtk', '3.0') | ||
38 | from gi.repository import Gtk, Gdk, GdkPixbuf | ||
39 | |||
40 | class FlowBoxWindow(Gtk.Window): | ||
41 | |||
42 | def __init__(self): | ||
43 | Gtk.Window.__init__(self, title="FlowBox Demo") | ||
44 | self.set_border_width(10) | ||
45 | self.set_default_size(300, 250) | ||
46 | |||
47 | #header = Gtk.HeaderBar(title="Flow Box") | ||
48 | #header.set_subtitle("Sample FlowBox app") | ||
49 | #header.props.show_close_button = True | ||
50 | |||
51 | #self.set_titlebar(header) | ||
52 | |||
53 | scrolled = Gtk.ScrolledWindow() | ||
54 | scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) | ||
55 | |||
56 | flowbox = Gtk.FlowBox() | ||
57 | flowbox.set_valign(Gtk.Align.START) | ||
58 | flowbox.set_max_children_per_line(30) | ||
59 | flowbox.set_selection_mode(Gtk.SelectionMode.NONE) | ||
60 | |||
61 | self.create_flowbox(flowbox) | ||
62 | |||
63 | scrolled.add(flowbox) | ||
64 | |||
65 | self.add(scrolled) | ||
66 | self.show_all() | ||
67 | |||
68 | def on_draw(self, widget, cr, data): | ||
69 | context = widget.get_style_context() | ||
70 | |||
71 | width = widget.get_allocated_width() | ||
72 | height = widget.get_allocated_height() | ||
73 | Gtk.render_background(context, cr, 0, 0, width, height) | ||
74 | |||
75 | r,g,b,a = data['color'] | ||
76 | cr.set_source_rgba(r,g,b,a) | ||
77 | cr.rectangle(0, 0, width, height) | ||
78 | cr.fill() | ||
79 | |||
80 | def color_swatch_new(self, str_color): | ||
81 | color = Gdk.color_parse(str_color) | ||
82 | |||
83 | rgba = Gdk.RGBA.from_color(color) | ||
84 | button = Gtk.Button() | ||
85 | |||
86 | area = Gtk.DrawingArea() | ||
87 | area.set_size_request(24, 24) | ||
88 | area.connect("draw", self.on_draw, {'color': rgba}) | ||
89 | |||
90 | button.add(area) | ||
91 | |||
92 | return button | ||
93 | |||
94 | def create_flowbox(self, flowbox): | ||
95 | base_path = os.path.expanduser("~/doxie") | ||
96 | |||
97 | for fn in os.listdir(base_path): | ||
98 | pb = GdkPixbuf.Pixbuf.new_from_file(os.path.join(base_path, fn)) | ||
99 | img = Gtk.Image() | ||
100 | img.set_from_pixbuf(pb.scale_simple(300, 400, GdkPixbuf.InterpType.BILINEAR)) | ||
101 | flowbox.add(img) | ||
102 | |||
103 | |||
104 | |||
105 | |||
106 | win = FlowBoxWindow() | ||
107 | win.connect("destroy", Gtk.main_quit) | ||
108 | win.show_all() | ||
109 | Gtk.main() | ||
diff --git a/process.txt b/process.txt new file mode 100644 index 0000000..ca75d86 --- /dev/null +++ b/process.txt | |||
@@ -0,0 +1,4 @@ | |||
1 | mount /mnt/doxie | ||
2 | cp -r /mnt/doxie/DOXIE/JPEG ~/doxie | ||
3 | rm /mnt/doxie/DOXIE/JPEG/* | ||
4 | umount /mnt/doxie | ||