File: StorageView.vala

package info (click to toggle)
granite 6.2.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,768 kB
  • sloc: python: 10; makefile: 8
file content (27 lines) | stat: -rw-r--r-- 1,133 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Copyright 2011–2019 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

public class StorageView : Gtk.Grid {
    construct {
        var file_root = GLib.File.new_for_path ("/");

        try {
            var info = file_root.query_filesystem_info (GLib.FileAttribute.FILESYSTEM_SIZE, null);

            var size = info.get_attribute_uint64 (GLib.FileAttribute.FILESYSTEM_SIZE);

            var storage = new Granite.Widgets.StorageBar.with_total_usage (size, size / 2);
            storage.update_block_size (Granite.Widgets.StorageBar.ItemDescription.AUDIO, size / 40);
            storage.update_block_size (Granite.Widgets.StorageBar.ItemDescription.VIDEO, size / 30);
            storage.update_block_size (Granite.Widgets.StorageBar.ItemDescription.APP, size / 20);
            storage.update_block_size (Granite.Widgets.StorageBar.ItemDescription.PHOTO, size / 10);
            storage.update_block_size (Granite.Widgets.StorageBar.ItemDescription.FILES, size / 5);

            add (storage);
        } catch (Error e) {
            critical (e.message);
        }
    }
}