Merge lp:~fabiozaramella/audience/fix-1044329 into lp:~audience-members/audience/trunk

Proposed by Fabio Zaramella
Status: Work in progress
Proposed branch: lp:~fabiozaramella/audience/fix-1044329
Merge into: lp:~audience-members/audience/trunk
Diff against target: 95 lines (+43/-18)
1 file modified
src/Audience.vala (+43/-18)
To merge this branch: bzr merge lp:~fabiozaramella/audience/fix-1044329
Reviewer Review Type Date Requested Status
Audience Members Pending
Review via email: mp+248200@code.launchpad.net

Description of the change

add --version command

To post a comment you must log in.
Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

Hello fabio,
It would be better if its added into Granite.Applications,
we'll have --version for all apps

Unmerged revisions

486. By Fabio Zaramella

--version command

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Audience.vala'
2--- src/Audience.vala 2015-01-07 10:29:27 +0000
3+++ src/Audience.vala 2015-02-01 14:57:21 +0000
4@@ -1,6 +1,6 @@
5 // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
6 /*-
7- * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat)
8+ * Copyright (c) 2013-2015 Audience Developers (http://launchpad.net/pantheon-chat)
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12@@ -30,6 +30,47 @@
13
14 public Audience.Settings settings; //global space for easier access...
15
16+ namespace Options {
17+ private static bool PRINT_VERSION = false;
18+ }
19+
20+ public static const OptionEntry[] app_options = {
21+ { "version", 'v', 0, OptionArg.NONE, out Options.PRINT_VERSION, N_("Print version info and exit"), null },
22+ { null }
23+ };
24+
25+ public static void main (string [] args) {
26+ X.init_threads ();
27+
28+ var context = new OptionContext ("Audience");
29+ context.add_main_entries (app_options, null);
30+ context.add_group (Gtk.get_option_group (false));
31+
32+ try {
33+ context.parse (ref args);
34+ } catch (Error e) {
35+ warning (e.message);
36+ }
37+
38+ if (Options.PRINT_VERSION) {
39+ stdout.printf ("Audience %s\n", Constants.VERSION);
40+ stdout.printf ("Copyright 2011-2015 Audience Developers.\n");
41+
42+ return;
43+ }
44+
45+ var err = GtkClutter.init (ref args);
46+ if (err != Clutter.InitError.SUCCESS) {
47+ error ("Could not initalize clutter! "+err.to_string ());
48+ }
49+
50+ Gst.init (ref args);
51+ Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;
52+
53+ var app = Audience.App.get_instance ();
54+ app.run (args);
55+ }
56+
57 public class App : Granite.Application {
58
59 /**
60@@ -60,7 +101,7 @@
61 build_version = Constants.VERSION;
62 build_version_info = Constants.VERSION_INFO;
63
64- app_years = "2011-2014";
65+ app_years = "2011-2015";
66 app_icon = "audience";
67 app_launcher = "audience.desktop";
68 application_id = "net.launchpad.audience";
69@@ -111,7 +152,6 @@
70 public App () {
71 Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG;
72
73- Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;
74 this.flags |= GLib.ApplicationFlags.HANDLES_OPEN;
75
76 repeat = false;
77@@ -835,18 +875,3 @@
78 }
79 }
80 }
81-
82-public static void main (string [] args) {
83- X.init_threads ();
84-
85- var err = GtkClutter.init (ref args);
86- if (err != Clutter.InitError.SUCCESS) {
87- error ("Could not initalize clutter! "+err.to_string ());
88- }
89-
90- Gst.init (ref args);
91-
92- var app = Audience.App.get_instance ();
93-
94- app.run (args);
95-}

Subscribers

People subscribed via source and target branches