diff options
author | Stefano Facchini <stefano.facchini@gmail.com> | 2020-06-28 16:22:25 +0200 |
---|---|---|
committer | Stefano Facchini <stefano.facchini@gmail.com> | 2020-06-30 16:01:23 +0200 |
commit | c33e8f8f4659b0fdca54f9eac1f7cd1721e1c899 (patch) | |
tree | 1327ca314d1da0aaee91adc55bcce846b83156f9 | |
parent | c81b4a2cdc4506ad903774ae72c79db8a5465da2 (diff) | |
download | baobab-reroot-view.tar.gz |
Add a symbolic icon to Location and use it in the pathbarreroot-view
-rw-r--r-- | data/ui/baobab-pathbutton.ui | 16 | ||||
-rw-r--r-- | src/baobab-location.vala | 6 | ||||
-rw-r--r-- | src/baobab-pathbar.vala | 14 |
3 files changed, 31 insertions, 5 deletions
diff --git a/data/ui/baobab-pathbutton.ui b/data/ui/baobab-pathbutton.ui index 98f41ef..90cf5f7 100644 --- a/data/ui/baobab-pathbutton.ui +++ b/data/ui/baobab-pathbutton.ui @@ -4,10 +4,20 @@ <template class="BaobabPathButton" parent="GtkButton"> <property name="visible">True</property> <child> - <object class="GtkLabel" id="label"> + <object class="GtkBox" id="box"> <property name="visible">True</property> - <property name="ellipsize">middle</property> - <property name="max_width_chars">15</property> + <child> + <object class="GtkImage" id="icon"> + <property name="margin-end">8</property> + </object> + </child> + <child> + <object class="GtkLabel" id="label"> + <property name="visible">True</property> + <property name="ellipsize">middle</property> + <property name="max_width_chars">15</property> + </object> + </child> </object> </child> </template> diff --git a/src/baobab-location.vala b/src/baobab-location.vala index 2c4dced..02a9f8c 100644 --- a/src/baobab-location.vala +++ b/src/baobab-location.vala @@ -35,6 +35,7 @@ namespace Baobab { public uint64? used { get; private set; } public uint64? reserved { get; private set; } public Icon? icon { get; private set; } + public Icon? symbolic_icon { get; private set; } public Volume? volume { get; private set; } public Mount? mount { get; private set; } @@ -70,6 +71,7 @@ namespace Baobab { void make_this_home_location () { name = _("Home folder"); icon = new ThemedIcon ("user-home"); + symbolic_icon = new ThemedIcon ("user-home-symbolic"); } public Location.for_home_folder () { @@ -107,6 +109,7 @@ namespace Baobab { file = File.new_for_path ("/"); icon = new ThemedIcon.with_default_fallbacks ("drive-harddisk-system"); + symbolic_icon = new ThemedIcon.with_default_fallbacks ("drive-harddisk-system-symbolic"); is_main_volume = true; scanner = new Scanner (file, ScanFlags.EXCLUDE_MOUNTS); @@ -117,6 +120,7 @@ namespace Baobab { file = File.new_for_uri (recent_info.get_uri ()); name = recent_info.get_display_name (); icon = recent_info.get_gicon (); + symbolic_icon = new ThemedIcon ("folder-symbolic"); scanner = new Scanner (file, ScanFlags.EXCLUDE_MOUNTS); } @@ -146,6 +150,7 @@ namespace Baobab { } else { name = volume.get_name (); icon = volume.get_icon (); + symbolic_icon = volume.get_symbolic_icon (); mount = null; file = null; size = null; @@ -159,6 +164,7 @@ namespace Baobab { void fill_from_mount () { name = mount.get_name (); icon = mount.get_icon (); + symbolic_icon = mount.get_symbolic_icon (); file = mount.get_root (); if (file != null && file.equal (File.new_for_path (Environment.get_home_dir ()))) { diff --git a/src/baobab-pathbar.vala b/src/baobab-pathbar.vala index fea4264..736348b 100644 --- a/src/baobab-pathbar.vala +++ b/src/baobab-pathbar.vala @@ -23,9 +23,17 @@ namespace Baobab { public class PathButton : Gtk.Button { [GtkChild] new Gtk.Label label; + [GtkChild] + Gtk.Image icon; - public PathButton (string name) { + public PathButton (string name, Icon? gicon) { label.label = name; + + icon.hide (); + if (gicon != null) { + icon.gicon = gicon; + icon.show (); + } } } @@ -79,9 +87,11 @@ namespace Baobab { PathButton make_button (Gtk.TreePath path) { string label; + Icon? gicon = null; if (path.get_depth () == 1) { label = location.name; + gicon = location.symbolic_icon; } else { Gtk.TreeIter iter; string name; @@ -93,7 +103,7 @@ namespace Baobab { label = display_name != null ? display_name : name; } - var button = new PathButton (label); + var button = new PathButton (label, gicon); button.clicked.connect (() => { item_activated (path); }); |