25
25
public class Application : Gtk.Application {
26
static Application baobab;
28
static bool print_version;
29
27
const OptionEntry[] option_entries = {
30
{ "version", 'v', 0, OptionArg.NONE, ref print_version, N_("Print version information and exit"), null },
28
{ "version", 'v', 0, OptionArg.NONE, null, N_("Print version information and exit"), null },
35
33
{ "quit", on_quit_activate }
38
Settings prefs_settings;
36
public Settings prefs_settings { get; private set; }
37
public Settings ui_settings { get; private set; }
41
39
protected override void activate () {
45
43
protected override void open (File[] files, string hint) {
46
44
foreach (var file in files) {
47
45
var window = new Window (this);
48
window.scan_directory (file);
46
window.scan_directory (file, ScanFlags.EXCLUDE_MOUNTS);
52
public static HashTable<File, unowned File> get_excluded_locations () {
50
public static new Application get_default () {
51
return (Application) GLib.Application.get_default ();
54
public HashTable<File, unowned File> get_excluded_locations () {
55
55
var excluded_locations = new HashTable<File, unowned File> (File.hash, File.equal);
56
56
excluded_locations.add (File.new_for_path ("/proc"));
57
57
excluded_locations.add (File.new_for_path ("/sys"));
61
61
excluded_locations.add (home.get_child (".gvfs"));
63
63
var root = File.new_for_path ("/");
64
foreach (var uri in app.prefs_settings.get_value ("excluded-uris")) {
64
foreach (var uri in prefs_settings.get_value ("excluded-uris")) {
65
65
var file = File.new_for_uri ((string) uri);
66
66
if (!file.equal (root)) {
67
67
excluded_locations.add (file);
74
74
protected override void startup () {
78
var css_provider = new Gtk.CssProvider ();
79
var css_file = File.new_for_uri ("resource:///org/gnome/baobab/baobab.css");
81
css_provider.load_from_file (css_file);
83
warning ("loading css: %s", e.message);
85
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
80
88
ui_settings = new Settings ("org.gnome.baobab.ui");
83
91
ui_settings.delay ();
85
// Menus: in gnome shell we just use the app menu, since the remaining
86
// items are too few to look ok in a menubar and they are not essential
87
var gtk_settings = Gtk.Settings.get_default ();
88
var builder = new Gtk.Builder ();
90
builder.add_from_resource ("/org/gnome/baobab/ui/baobab-menu.ui");
92
error ("loading menu builder file: %s", e.message);
94
if (gtk_settings.gtk_shell_shows_app_menu && !gtk_settings.gtk_shell_shows_menubar) {
95
var app_menu = builder.get_object ("appmenu") as MenuModel;
96
set_app_menu (app_menu);
98
var menubar = builder.get_object ("menubar") as MenuModel;
99
set_menubar (menubar);
102
add_accelerator ("F10", "win.gear-menu", null);
93
set_accels_for_action ("win.gear-menu", { "F10" });
94
set_accels_for_action ("win.reload", { "<Primary>r" });
105
protected override bool local_command_line ([CCode (array_length = false, array_null_terminated = true)] ref unowned string[] arguments, out int exit_status) {
106
var ctx = new OptionContext (_("- Disk Usage Analyzer"));
108
ctx.add_main_entries (option_entries, Config.GETTEXT_PACKAGE);
109
ctx.add_group (Gtk.get_option_group (true));
111
// Workaround for bug #642885
112
unowned string[] argv = arguments;
115
ctx.parse (ref argv);
97
protected override int handle_local_options (GLib.VariantDict options) {
98
if (options.contains("version")) {
122
99
print ("%s %s\n", Environment.get_application_name (), Config.VERSION);
127
return base.local_command_line (ref arguments, out exit_status);
130
106
protected override void shutdown () {
135
111
public Application () {
136
112
Object (application_id: "org.gnome.baobab", flags: ApplicationFlags.HANDLES_OPEN);
114
add_main_option_entries (option_entries);
140
115
add_action_entries (action_entries, this);
143
public static Settings get_prefs_settings () {
145
return app.prefs_settings;
148
public static Settings get_ui_settings () {
150
return app.ui_settings;
153
118
void on_quit_activate () {