diff options
Diffstat (limited to 'src/pdf-stock')
-rw-r--r-- | src/pdf-stock/.gitignore | 3 | ||||
-rw-r--r-- | src/pdf-stock/Makefile | 20 | ||||
-rw-r--r-- | src/pdf-stock/main.vala | 11 | ||||
-rw-r--r-- | src/pdf-stock/pdf-stock-interface.vala | 3 | ||||
-rw-r--r-- | src/pdf-stock/pdf-stock.vala | 10 | ||||
-rw-r--r-- | src/pdf-stock/test.vala | 8 |
6 files changed, 18 insertions, 37 deletions
diff --git a/src/pdf-stock/.gitignore b/src/pdf-stock/.gitignore deleted file mode 100644 index 58a1e54..0000000 --- a/src/pdf-stock/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -pdf-stock -test -test.pdf diff --git a/src/pdf-stock/Makefile b/src/pdf-stock/Makefile deleted file mode 100644 index a9ad1a6..0000000 --- a/src/pdf-stock/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -include ../../config.mk - -LIBCAIROBARCODE=-X -I../../libcairobarcode -X -L../../libcairobarcode -X -lcairobarcode - -all: pdf-stock - @echo > /dev/null - -pdf-stock: main.vala pdf-stock.vala ../database/db-interface.vala ../price.vapi ../../libcairobarcode/libcairobarcode.vapi - valac -X -w ${LIBCAIROBARCODE} -o $@ --pkg cairo --pkg pangocairo --pkg gio-2.0 --pkg posix $^ - -test: test.vala pdf-stock-interface.vala - valac -X -w -o $@ --pkg gio-2.0 $^ - -run: pdf-stock - LD_LIBRARY_PATH=../../libcairobarcode ./pdf-stock - -clean: - rm -rf pdf-stock test - -.PHONY: all clean run diff --git a/src/pdf-stock/main.vala b/src/pdf-stock/main.vala index 49613f4..10aef60 100644 --- a/src/pdf-stock/main.vala +++ b/src/pdf-stock/main.vala @@ -14,23 +14,26 @@ */ public static int main(string[] args) { + Intl.setlocale(LocaleCategory.ALL, ""); + Intl.textdomain("shopsystem"); + Bus.own_name( BusType.SYSTEM, "io.mainframe.shopsystem.StockPDF", BusNameOwnerFlags.NONE, - on_bus_aquired, + on_bus_acquired, () => {}, - () => stderr.printf("Could not aquire name\n")); + () => stderr.printf(_("Could not acquire name\n"))); new MainLoop().run(); return 0; } -void on_bus_aquired(DBusConnection conn) { +void on_bus_acquired(DBusConnection conn) { try { conn.register_object("/io/mainframe/shopsystem/stockpdf", new StockPDF()); } catch(IOError e) { - stderr.printf("Could not register service\n"); + stderr.printf(_("Could not register service\n")); } } diff --git a/src/pdf-stock/pdf-stock-interface.vala b/src/pdf-stock/pdf-stock-interface.vala index be49a20..87d9f61 100644 --- a/src/pdf-stock/pdf-stock-interface.vala +++ b/src/pdf-stock/pdf-stock-interface.vala @@ -15,6 +15,5 @@ [DBus (name = "io.mainframe.shopsystem.StockPDF")] public interface PDFStock : Object { - // if false, only products with an amount > 0 are selected - public abstract uint8[] generate(bool allProducts) throws IOError; + public abstract uint8[] generate(bool allProducts) throws DBusError, IOError; } diff --git a/src/pdf-stock/pdf-stock.vala b/src/pdf-stock/pdf-stock.vala index ac51c23..6270c43 100644 --- a/src/pdf-stock/pdf-stock.vala +++ b/src/pdf-stock/pdf-stock.vala @@ -40,7 +40,7 @@ public class StockPDF { EAN ean; Cairo.Context ctx; Pango.Layout layout; - StockEntry[] stock; + DetailedProduct[] stock; /* pdf data */ private uint8[] data; @@ -99,7 +99,7 @@ public class StockPDF { ctx.restore(); } - private void render_table_row(StockEntry product) throws BarcodeError { + private void render_table_row(DetailedProduct product) throws BarcodeError { ctx.set_line_width(0.8); /* borders */ @@ -117,7 +117,7 @@ public class StockPDF { /* EAN */ ctx.move_to(col1 + padding, y + padding); - ean.draw(product.id); + ean.draw(@"$(product.ean)"); /* Product Name */ ctx.move_to(col2 + padding, y); @@ -125,7 +125,7 @@ public class StockPDF { layout.set_wrap(Pango.WrapMode.WORD_CHAR); layout.set_spacing((int) (-padding * Pango.SCALE)); layout.set_width((int) (col3-col2) * Pango.SCALE); - var text = @"$(product.id)\n$(product.name)"; + var text = @"$(product.ean)\n$(product.name)"; layout.set_text(text, text.length); Pango.cairo_update_layout(ctx, layout); Pango.cairo_show_layout(ctx, layout); @@ -154,7 +154,7 @@ public class StockPDF { return Cairo.Status.SUCCESS; } - public uint8[] generate(bool allProducts) { + public uint8[] generate(bool allProducts) throws DBusError, IOError { data = null; var surface = new Cairo.PdfSurface.for_stream(pdf_write, a4w, a4h); diff --git a/src/pdf-stock/test.vala b/src/pdf-stock/test.vala index cc3da4f..92b6232 100644 --- a/src/pdf-stock/test.vala +++ b/src/pdf-stock/test.vala @@ -16,12 +16,14 @@ public static int main(string args[]) { try { PDFStock stock = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.StockPDF", "/io/mainframe/shopsystem/stockpdf"); - var pdfdata = stock.generate(); + var pdfdata = stock.generate(true); FileUtils.set_contents("test.pdf", (string) pdfdata, pdfdata.length); } catch(IOError e) { - error("IOError: %s", e.message); + error(_("IO Error: %s"), e.message); } catch(FileError e) { - error("FileError: %s", e.message); + error(_("File Error: %s"), e.message); + } catch(DBusError e) { + error(_("DBus Error: %s"), e.message); } return 0; |