Changeset db2d6e7f884e4ab8b10583f6a687c5423a430be4
- Timestamp:
- 09/21/08 20:20:47 (5 years ago)
- Author:
- Armin Burgmeier <armin@…>
- Parents:
- b4bda6d6932419cde8676f966ea573923e787066
- Children:
- 9c500538acd917060c6d064f3e0bf857426a16ef
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2008-09-21T20:20:47Z+0200
- Message:
-
Display version information on -v
2008-08-21 Armin Burgmeier <armin@…>
- src/main.cpp: Display version information on -v.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rb4bda6d
|
rdb2d6e7
|
|
| | 1 | 2008-08-21 Armin Burgmeier <armin@arbur.net> |
| | 2 | |
| | 3 | * src/main.cpp: Display version information on -v. |
| | 4 | |
| 1 | 5 | 2008-09-21 Armin Burgmeier <armin@arbur.net> |
| 2 | 6 | |
-
|
rcd0ff9f
|
rdb2d6e7
|
|
| 22 | 22 | #include "core/iconmanager.hpp" |
| 23 | 23 | #include "util/config.hpp" |
| | 24 | #include "util/i18n.hpp" |
| 24 | 25 | |
| 25 | 26 | #include <gtkmm/main.h> |
| … |
… |
|
| 44 | 45 | std::cerr << "Unhandled exception: " << message << std::endl; |
| 45 | 46 | } |
| | 47 | |
| | 48 | const char* _(const char* str) |
| | 49 | { |
| | 50 | return Gobby::_(str); |
| | 51 | } |
| 46 | 52 | } |
| 47 | 53 | |
| … |
… |
|
| 56 | 62 | bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
| 57 | 63 | |
| 58 | | bool new_instance = false; |
| 59 | | Glib::ustring join; |
| | 64 | bool display_version = false; |
| | 65 | |
| | 66 | Glib::OptionGroup opt_group_gobby("gobby", |
| | 67 | _("Gobby options"), _("Options related to Gobby")); |
| | 68 | Glib::OptionEntry opt_version; |
| | 69 | opt_version.set_short_name('v'); |
| | 70 | opt_version.set_long_name("version"); |
| | 71 | opt_version.set_description( |
| | 72 | _("Display version information and exit")); |
| | 73 | opt_group_gobby.add_entry(opt_version, display_version); |
| 60 | 74 | |
| 61 | 75 | Glib::OptionContext opt_ctx; |
| 62 | 76 | opt_ctx.set_help_enabled(true); |
| 63 | 77 | opt_ctx.set_ignore_unknown_options(false); |
| | 78 | opt_ctx.set_main_group(opt_group_gobby); |
| 64 | 79 | |
| 65 | 80 | // I would rather like to have Gtk::Main on the stack, but I see |
| 66 | 81 | // no other chance to catch exceptions from the command line option |
| 67 | 82 | // parsing. armin. |
| | 83 | // TODO: Maybe we should parse before initializing GTK+, using |
| | 84 | // Gtk::Main::add_gtk_option_group() with open_default_display set |
| | 85 | // to false. |
| 68 | 86 | std::auto_ptr<Gtk::Main> kit; |
| 69 | 87 | |
| … |
… |
|
| 76 | 94 | std::cerr << e.what() << std::endl; |
| 77 | 95 | return EXIT_FAILURE; |
| | 96 | } |
| | 97 | |
| | 98 | if(display_version) |
| | 99 | { |
| | 100 | std::cout << "Gobby " << PACKAGE_VERSION << std::endl; |
| | 101 | return EXIT_SUCCESS; |
| 78 | 102 | } |
| 79 | 103 | |
| … |
… |
|
| 94 | 118 | wnd.show(); |
| 95 | 119 | |
| 96 | | // Cannot use just kit.run(wnd) since this would show wnd. If we |
| 97 | | // are just sending some data to theother gobby, we do not want |
| 98 | | // the window to be shown. |
| 99 | 120 | wnd.signal_hide().connect(sigc::ptr_fun(&Gtk::Main::quit) ); |
| 100 | 121 | kit->run(); |