commit 78a64d22dad8f37694818152eba49319d89b1ba6
parent c6a86cfdea95e67daed2ea801f9243ff96fd785a
Author: Dan Callaghan <djc@djc.id.au>
Date: Thu, 25 Dec 2008 17:01:01 +1000
proper arg handling; avoid SIGABRT on exiv2 errors
Diffstat:
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/xmpedit.cpp b/xmpedit.cpp
@@ -1,11 +1,29 @@
#include <gtkmm/main.h>
+#include <glibmm/optioncontext.h>
#include "MainWindow.h"
int main(int argc, char *argv[]) {
- Gtk::Main kit(argc, argv);
- MainWindow window("/home/dan/Photos/indro3.jpg");
- Gtk::Main::run(window);
+ Glib::OptionContext options("PHOTO_FILENAME");
+ try {
+ Gtk::Main kit(argc, argv, options);
+ } catch (Glib::OptionError e) {
+ std::cerr << argv[0] << ": option error: " << e.what() << std::endl;
+ exit(1);
+ }
+
+ if (argc < 2) {
+ std::cerr << argv[0] << ": no photo filename supplied" << std::endl;
+ exit(2);
+ }
+
+ try {
+ MainWindow window(argv[1]);
+ Gtk::Main::run(window);
+ } catch (Exiv2::Error e) {
+ std::cerr << argv[0] << ": exiv2 error: " << e.what() << std::endl;
+ exit(3);
+ }
return 0;
}