[baobab/reroot-view: 21/35] Put FolderDisplay class in its own source file
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/reroot-view: 21/35] Put FolderDisplay class in its own source file
- Date: Tue, 30 Jun 2020 14:05:32 +0000 (UTC)
commit ec3678da8d3bebb59e4a81f2414081b6e03634b4
Author: Stefano Facchini <stefano facchini gmail com>
Date: Sat Jun 20 11:21:32 2020 +0200
Put FolderDisplay class in its own source file
src/baobab-folder-display.vala | 90 ++++++++++++++++++++++++++++++++++++++++++
src/baobab-window.vala | 69 --------------------------------
src/meson.build | 1 +
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',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]