summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@gnome.org>2014-02-16 23:08:35 +0100
committerPaolo Borelli <pborelli@gnome.org>2014-02-16 23:10:31 +0100
commitd8174c9a52ecd32454ff55d4b9e02f3f55ea76b9 (patch)
treecce508277fea22a85a7130c1d54b7db8a772673b
parente2b4ab37b7caebcddd3b15aa5eb001b4e7f5ca80 (diff)
downloadbaobab-d8174c9a52ecd32454ff55d4b9e02f3f55ea76b9.tar.gz
Use new method to deal with command line options
-rw-r--r--src/baobab-application.vala28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index a51d83d..2751d52 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -25,9 +25,8 @@ namespace Baobab {
public class Application : Gtk.Application {
static Application baobab;
- static bool print_version;
const OptionEntry[] option_entries = {
- { "version", 'v', 0, OptionArg.NONE, ref print_version, N_("Print version information and exit"), null },
+ { "version", 'v', 0, OptionArg.NONE, null, N_("Print version information and exit"), null },
{ null }
};
@@ -95,29 +94,13 @@ namespace Baobab {
add_accelerator ("<Primary>r", "win.reload", null);
}
- protected override bool local_command_line ([CCode (array_length = false, array_null_terminated = true)] ref unowned string[] arguments, out int exit_status) {
- var ctx = new OptionContext (_("- Disk Usage Analyzer"));
-
- ctx.add_main_entries (option_entries, Config.GETTEXT_PACKAGE);
- ctx.add_group (Gtk.get_option_group (true));
-
- // Workaround for bug #642885
- unowned string[] argv = arguments;
-
- try {
- ctx.parse (ref argv);
- } catch (Error e) {
- exit_status = 1;
- return true;
- }
-
- if (print_version) {
+ protected override int handle_local_options (GLib.VariantDict options) {
+ if (options.contains("version")) {
print ("%s %s\n", Environment.get_application_name (), Config.VERSION);
- exit_status = 0;
- return true;
+ return 0;
}
- return base.local_command_line (ref arguments, out exit_status);
+ return -1;
}
protected override void shutdown () {
@@ -128,6 +111,7 @@ namespace Baobab {
public Application () {
Object (application_id: "org.gnome.baobab", flags: ApplicationFlags.HANDLES_OPEN);
+ add_main_option_entries (option_entries);
add_action_entries (action_entries, this);
}