diff options
author | Holger Cremer <HolgerCremer@gmail.com> | 2015-06-13 01:16:26 +0200 |
---|---|---|
committer | Holger Cremer <HolgerCremer@gmail.com> | 2015-06-13 01:16:26 +0200 |
commit | bf64a764cc5f4036baa6772733b373f44508f6af (patch) | |
tree | 44d634b71f08834f806e3c5989501fa85a364bef | |
parent | df4d78a79f480c93880f11ec72516d3ac76290c1 (diff) | |
download | serial-barcode-scanner-bf64a764cc5f4036baa6772733b373f44508f6af.tar.bz2 |
replace the popup with an overlay over the messagebox - this is much better on very small screens
-rw-r--r-- | src/curses-ui/Makefile | 2 | ||||
-rw-r--r-- | src/curses-ui/curses-ui.vala | 16 | ||||
-rw-r--r-- | src/curses-ui/main.vala | 6 | ||||
-rw-r--r-- | src/scanner-session/scannersession-interface.vala | 2 | ||||
-rw-r--r-- | src/scanner-session/scannersession.vala | 6 |
5 files changed, 23 insertions, 9 deletions
diff --git a/src/curses-ui/Makefile b/src/curses-ui/Makefile index 10778ca..1ca68cf 100644 --- a/src/curses-ui/Makefile +++ b/src/curses-ui/Makefile @@ -1,7 +1,7 @@ all: curses-ui @echo > /dev/null -curses-ui: clock.vala curses-ui.vala dialog.vala logo.vala main.vala message_box.vala numbers.vala status.vala ../audio/audio-interface.vala ../scanner-session/scannersession-interface.vala +curses-ui: *.vala ../audio/audio-interface.vala ../scanner-session/scannersession-interface.vala valac -X -w -o $@ --pkg curses -X -lncursesw --pkg posix --pkg gio-2.0 $^ clean: diff --git a/src/curses-ui/curses-ui.vala b/src/curses-ui/curses-ui.vala index b3efdd5..28fad08 100644 --- a/src/curses-ui/curses-ui.vala +++ b/src/curses-ui/curses-ui.vala @@ -19,6 +19,7 @@ public class CursesUI { Logo banner; ClockWindow clkwin; StatusPanel statuswin; + MessageBoxOverlay mbOverlay; public CursesUI() { /* unicode support */ @@ -36,7 +37,7 @@ public class CursesUI { Curses.init_pair(1, Curses.Color.GREEN, Curses.Color.BLACK); Curses.init_pair(2, Curses.Color.WHITE, Curses.Color.RED); - /* initialize widgets */ + /* initialize widgets */ banner = new Logo(); statuswin = new StatusPanel(); messages = new MessageBox(); @@ -80,6 +81,11 @@ public class CursesUI { } + public void log_overlay(string title, string message, int closeAfter) { + mbOverlay = new MessageBoxOverlay(title, message, closeAfter); + Timeout.add_seconds(closeAfter, closeMbOverlay); + } + public void dialog_open(string title, string message, int closeAfter=0) { dialog = new Dialog(message, title, closeAfter); if (closeAfter > 0) { @@ -87,6 +93,14 @@ public class CursesUI { } } + bool closeMbOverlay() { + mbOverlay = null; + messages.redraw(); + statuswin.redraw(); + // just call me once + return false; + } + bool close() { dialog_close(); // just call me once diff --git a/src/curses-ui/main.vala b/src/curses-ui/main.vala index 7487308..e57e4ee 100644 --- a/src/curses-ui/main.vala +++ b/src/curses-ui/main.vala @@ -30,8 +30,8 @@ public void msg_handler(MessageType type, string message) { ui.log(type, message); } -public void popup_handler(string title, string message) { - ui.dialog_open(title, message, 10); +public void msg_overlay_handler(string title, string message) { + ui.log_overlay(title, message, 10); } @@ -58,7 +58,7 @@ public static int main(string[] args) { Log.set_default_handler(log_handler); scanner.msg.connect(msg_handler); - scanner.popup.connect(popup_handler); + scanner.msg_overlay.connect(msg_overlay_handler); ui.log(MessageType.INFO, "KtT Shop System has been started"); play("startup.ogg"); diff --git a/src/scanner-session/scannersession-interface.vala b/src/scanner-session/scannersession-interface.vala index ec5e487..89498df 100644 --- a/src/scanner-session/scannersession-interface.vala +++ b/src/scanner-session/scannersession-interface.vala @@ -16,7 +16,7 @@ [DBus (name = "io.mainframe.shopsystem.ScannerSession")] public interface ScannerSession : Object { public abstract signal void msg(MessageType type, string message); - public abstract signal void popup(string title, string message); + public abstract signal void msg_overlay(string title, string message); } public enum MessageType { diff --git a/src/scanner-session/scannersession.vala b/src/scanner-session/scannersession.vala index 8d89593..2661179 100644 --- a/src/scanner-session/scannersession.vala +++ b/src/scanner-session/scannersession.vala @@ -28,7 +28,7 @@ public class ScannerSessionImplementation { public signal void msg(MessageType type, string message); - public signal void popup(string title, string message); + public signal void msg_overlay(string title, string message); public ScannerSessionImplementation() { try { @@ -179,7 +179,7 @@ public class ScannerSessionImplementation { audio.play_user(theme, "error"); var msg = "Error: unknown product: %llu".printf(id); send_message(MessageType.ERROR, msg); - popup("Attention", msg); + msg_overlay("Attention", msg); } else { audio.play_user(theme, "error"); send_message(MessageType.ERROR, "Error: %s", e.message); @@ -194,7 +194,7 @@ public class ScannerSessionImplementation { audio.play_system("error.ogg"); send_message(MessageType.INFO, msg); send_message(MessageType.ERROR, "Login required for purchase!"); - popup("Attention", "%s\nLogin required for purchase!".printf(msg)); + msg_overlay("Attention", "%s\nLogin required for purchase!".printf(msg)); return false; } |