Use autotools and intltools, translate user interface, add German translation
[led-pattern-ed] / src / led-pattern-editor.vala
1 /* This file is part of LED Pattern Editor.
2  *
3  * Copyright (C) 2010 Philipp Zabel
4  *
5  * LED Pattern Editor is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * LED Pattern Editor is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with LED Pattern Editor. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 public static Osso.Status execute (Osso.Context osso, void* data, bool user_activated) {
20         var window = data as Gtk.Window;
21
22         // Gettext hook-up
23         Intl.setlocale (LocaleCategory.ALL, "");
24         Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
25         Intl.textdomain (Config.GETTEXT_PACKAGE);
26
27         var list = mce_ini_parse ();
28
29         var dialog = new LedPatternDialog (list, osso);
30         dialog.set_transient_for (window);
31
32         int response = dialog.run ();
33         dialog.destroy ();
34         string command = null;
35         if (response == Gtk.ResponseType.OK) {
36                 mce_ini_store (list);
37                 Hildon.Banner.show_information (window, null, _("Applying changes and restarting MCE ..."));
38                 command = "sudo /usr/bin/led-pattern-helper save %s".printf ("/tmp/mce.ini");
39         } else if (response == LedPatternDialog.Response.RESTORE) {
40                 Hildon.Banner.show_information (window, null, _("Restoring defaults and restarting MCE ..."));
41                 command = "sudo /usr/bin/led-pattern-helper save %s".printf ("/etc/mce/mce.ini.orig");
42         }
43         if (command != null) {
44                 try {
45                         int exit_status;
46                         string error;
47                         Process.spawn_command_line_sync (command, null, out error, out exit_status);
48                         if (exit_status != 0) {
49                                 var information = "Exit status: %d\n%s".printf (exit_status, error);
50                                 var note = new Hildon.Note.information (window, information);
51                                 note.run ();
52                         }
53                 } catch (SpawnError e) {
54                         Hildon.Banner.show_information (null, null, e.message);
55                 }
56         }
57
58         return Osso.Status.OK;
59 }
60
61 public static Osso.Status save_state (Osso.Context osso, void* data) {
62         return Osso.Status.OK;
63 }