Changeset db2d6e7f884e4ab8b10583f6a687c5423a430be4

Show
Ignore:
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:
2 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rb4bda6d rdb2d6e7  
     12008-08-21  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * src/main.cpp: Display version information on -v. 
     4 
    152008-09-21  Armin Burgmeier  <armin@arbur.net> 
    26 
  • src/main.cpp

    rcd0ff9f rdb2d6e7  
    2222#include "core/iconmanager.hpp" 
    2323#include "util/config.hpp" 
     24#include "util/i18n.hpp" 
    2425 
    2526#include <gtkmm/main.h> 
     
    4445                std::cerr << "Unhandled exception: " << message << std::endl; 
    4546        } 
     47 
     48        const char* _(const char* str) 
     49        { 
     50                return Gobby::_(str); 
     51        } 
    4652} 
    4753 
     
    5662        bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); 
    5763 
    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); 
    6074 
    6175        Glib::OptionContext opt_ctx; 
    6276        opt_ctx.set_help_enabled(true); 
    6377        opt_ctx.set_ignore_unknown_options(false); 
     78        opt_ctx.set_main_group(opt_group_gobby); 
    6479 
    6580        // I would rather like to have Gtk::Main on the stack, but I see 
    6681        // no other chance to catch exceptions from the command line option 
    6782        // 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. 
    6886        std::auto_ptr<Gtk::Main> kit; 
    6987 
     
    7694                std::cerr << e.what() << std::endl; 
    7795                return EXIT_FAILURE; 
     96        } 
     97 
     98        if(display_version) 
     99        { 
     100                std::cout << "Gobby " << PACKAGE_VERSION << std::endl; 
     101                return EXIT_SUCCESS; 
    78102        } 
    79103 
     
    94118        wnd.show(); 
    95119 
    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. 
    99120        wnd.signal_hide().connect(sigc::ptr_fun(&Gtk::Main::quit) ); 
    100121        kit->run();