3 public class AppSettings : Object
8 // what are we going to have as settings?
9 public string roo_html_dir { get; set; }
13 this.notify.connect(() => {
18 public static AppSettings factory()
21 var setting_file = BuilderApplication.configDirectory() + "/builder.settings";
23 if (!FileUtils.test(setting_file, FileTest.EXISTS)) {
24 return new AppSettings();
27 FileUtils.get_contents(setting_file, out data);
28 return Json.gobject_from_data (typeof (AppSettings), data) as AppSettings;
32 var dirname = GLib.Environment.get_home_dir() + "/.Builder";
33 var setting_file = dirname + "/builder.settings";
34 string data = Json.gobject_to_data (this, null);
35 print("saving application settings\n");
36 FileUtils.set_contents(setting_file, data);
43 public static BuilderApplication application = null;
45 public class BuilderApplication : Gtk.Application
48 // options - used when builder is run as a compiler
49 // we have to spawn ourself as a compiler as just running libvala
50 // as a task to check syntax causes memory leakage..
52 const OptionEntry[] options = {
55 { "project", 0, 0, OptionArg.STRING, ref opt_compile_project, "Compile a project", null },
56 { "target", 0, 0, OptionArg.STRING, ref opt_compile_target, "Target to build", null },
57 { "skip-file", 0, 0, OptionArg.STRING, ref opt_compile_skip ,"For test compiles do not add this (usually used in conjunction with add-file ", null },
58 { "add-file", 0, 0, OptionArg.STRING, ref opt_compile_add, "Add this file to compile list", null },
59 { "debug", 0, 0, OptionArg.NONE, ref opt_debug, "Show debug messages", null },
62 public static string opt_compile_project;
63 public static string opt_compile_target;
64 public static string opt_compile_skip;
65 public static string opt_compile_add;
66 public static bool opt_debug = false;
76 public const Gtk.TargetEntry[] targetList = {
77 { "INTEGER", 0, Target.INT32 },
78 { "STRING", 0, Target.STRING },
79 { "application/json", 0, Target.STRING },
80 { "text/plain", 0, Target.STRING },
81 { "application/x-rootwindow-drop", 0, Target.ROOTWIN }
83 public AppSettings settings = null;
86 public BuilderApplication ( string[] args)
89 application_id: "org.roojs.app-builder",
90 flags: ApplicationFlags.FLAGS_NONE
94 this.settings = AppSettings.factory();
95 var opt_context = new OptionContext ("Application Builder");
98 opt_context.set_help_enabled (true);
99 opt_context.add_main_entries (options, null);
100 opt_context.parse (ref args);
103 } catch (OptionError e) {
104 stdout.printf ("error: %s\n", e.message);
105 stdout.printf ("Run '%s --help' to see a full list of available command line options.\n %s",
106 args[0], opt_context.get_help(true,null));
107 GLib.Process.exit(Posix.EXIT_FAILURE);
115 public static BuilderApplication singleton( string[] args)
117 if (application==null) {
118 application = new BuilderApplication( args);
126 public static string configDirectory()
128 var dirname = GLib.Environment.get_home_dir() + "/.Builder";
130 if (!FileUtils.test(dirname,FileTest.IS_DIR)) {
131 var dir = File.new_for_path(dirname);
132 dir.make_directory();
134 if (!FileUtils.test(dirname + "/resources",FileTest.IS_DIR)) {
135 var dir = File.new_for_path(dirname + "/resources");
136 dir.make_directory();