summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefano Facchini <stefano.facchini@gmail.com>2020-06-20 11:21:32 +0200
committerStefano Facchini <stefano.facchini@gmail.com>2020-06-30 16:01:22 +0200
commitec3678da8d3bebb59e4a81f2414081b6e03634b4 (patch)
treee4a90553643fd2144531ba58cdd1fbab4f884268 /src
parent7f9ab0b389c13c36dd38448dc88ce5512f7ee7d6 (diff)
downloadbaobab-ec3678da8d3bebb59e4a81f2414081b6e03634b4.tar.gz
Put FolderDisplay class in its own source file
Diffstat (limited to 'src')
-rw-r--r--src/baobab-folder-display.vala90
-rw-r--r--src/baobab-window.vala69
-rw-r--r--src/meson.build1
3 files changed, 91 insertions, 69 deletions
diff --git a/src/baobab-folder-display.vala b/src/baobab-folder-display.vala
new file mode 100644
index 0000000..1e3c6a1
--- /dev/null
+++ b/src/baobab-folder-display.vala
@@ -0,0 +1,90 @@
+/* Baobab - disk usage analyzer
+ *
+ * Copyright (C) 2020 Stefano Facchini <stefano.facchini@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+namespace Baobab {
+
+ [GtkTemplate (ui = "/org/gnome/baobab/ui/baobab-folder-display.ui")]
+ public class FolderDisplay : Gtk.Grid {
+ static construct {
+ set_css_name ("folder-display");
+ }
+
+ [GtkChild]
+ private Gtk.Label folder_name_primary;
+ [GtkChild]
+ private Gtk.Label folder_name_secondary;
+ [GtkChild]
+ private Gtk.Label folder_size;
+ [GtkChild]
+ private Gtk.Label folder_elements;
+ [GtkChild]
+ private Gtk.Label folder_time;
+
+ Location location_;
+ public Location location {
+ set {
+ location_ = value;
+
+ set_name_from_location ();
+ folder_size.label = "";
+ folder_elements.label = "";
+ folder_time.label = "";
+ }
+
+ get {
+ return location_;
+ }
+ }
+
+ public new Gtk.TreePath path {
+ set {
+ Gtk.TreeIter iter;
+ location.scanner.get_iter (out iter, value);
+
+ string name;
+ string display_name;
+ uint64 size;
+ int elements;
+ uint64 time;
+
+ location.scanner.get (iter,
+ Scanner.Columns.NAME, out name,
+ Scanner.Columns.DISPLAY_NAME, out display_name,
+ Scanner.Columns.SIZE, out size,
+ Scanner.Columns.ELEMENTS, out elements,
+ Scanner.Columns.TIME_MODIFIED, out time);
+
+ if (value.get_depth () == 1) {
+ set_name_from_location ();
+ } else {
+ folder_name_primary.label = format_name (display_name, name);
+ folder_name_secondary.label = "";
+ }
+ folder_size.label = format_size (size);
+ folder_elements.label = format_items (elements);
+ folder_time.label = format_time_approximate (time);
+ }
+ }
+
+ void set_name_from_location () {
+ folder_name_primary.label = location.name;
+ folder_name_secondary.label = location.file.get_parse_name ();
+ }
+ }
+}
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 3b20ff0..1c87492 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -22,75 +22,6 @@
namespace Baobab {
- [GtkTemplate (ui = "/org/gnome/baobab/ui/baobab-folder-display.ui")]
- public class FolderDisplay : Gtk.Grid {
- static construct {
- set_css_name ("folder-display");
- }
-
- [GtkChild]
- private Gtk.Label folder_name_primary;
- [GtkChild]
- private Gtk.Label folder_name_secondary;
- [GtkChild]
- private Gtk.Label folder_size;
- [GtkChild]
- private Gtk.Label folder_elements;
- [GtkChild]
- private Gtk.Label folder_time;
-
- Location location_;
- public Location location {
- set {
- location_ = value;
-
- set_name_from_location ();
- folder_size.label = "";
- folder_elements.label = "";
- folder_time.label = "";
- }
-
- get {
- return location_;
- }
- }
-
- public new Gtk.TreePath path {
- set {
- Gtk.TreeIter iter;
- location.scanner.get_iter (out iter, value);
-
- string name;
- string display_name;
- uint64 size;
- int elements;
- uint64 time;
-
- location.scanner.get (iter,
- Scanner.Columns.NAME, out name,
- Scanner.Columns.DISPLAY_NAME, out display_name,
- Scanner.Columns.SIZE, out size,
- Scanner.Columns.ELEMENTS, out elements,
- Scanner.Columns.TIME_MODIFIED, out time);
-
- if (value.get_depth () == 1) {
- set_name_from_location ();
- } else {
- folder_name_primary.label = format_name (display_name, name);
- folder_name_secondary.label = "";
- }
- folder_size.label = format_size (size);
- folder_elements.label = format_items (elements);
- folder_time.label = format_time_approximate (time);
- }
- }
-
- void set_name_from_location () {
- folder_name_primary.label = location.name;
- folder_name_secondary.label = location.file.get_parse_name ();
- }
- }
-
[GtkTemplate (ui = "/org/gnome/baobab/ui/baobab-main-window.ui")]
public class Window : Gtk.ApplicationWindow {
[GtkChild]
diff --git a/src/meson.build b/src/meson.build
index 0e265f0..95dc593 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -6,6 +6,7 @@ baobab_vala_sources = [
'baobab-application.vala',
'baobab-cellrenderers.vala',
'baobab-chart.vala',
+ 'baobab-folder-display.vala',
'baobab-location-list.vala',
'baobab-location.vala',
'baobab-pathbar.vala',