2020 * Authors : Jeremy Wootten <[email protected] > 2121 */
2222
23- public class Sidebar.BookmarkListBox : Gtk .ListBox , Sidebar .SidebarListInterface {
23+ public class Sidebar.BookmarkListBox : Gtk .Box , Sidebar .SidebarListInterface {
24+ public Files . SidebarInterface sidebar { get ; construct; }
25+ public Gtk . ListBox list_box { get ; internal set ; }
26+
2427 private Files . BookmarkList bookmark_list;
2528 private unowned Files . TrashMonitor trash_monitor;
2629
27- public Files . SidebarInterface sidebar {get ; construct;}
28-
2930 public BookmarkListBox (Files .SidebarInterface sidebar ) {
30- Object (
31- sidebar: sidebar
32- );
31+ Object (sidebar: sidebar);
3332 }
3433
3534 construct {
36- hexpand = true ;
37- selection_mode = Gtk . SelectionMode . SINGLE ;
35+ list_box = new Gtk .ListBox () {
36+ hexpand = true ,
37+ selection_mode = Gtk . SelectionMode . SINGLE
38+ };
39+
40+ add (list_box);
41+
3842 trash_monitor = Files . TrashMonitor . get_default ();
3943 bookmark_list = Files . BookmarkList . get_instance ();
4044 bookmark_list. loaded. connect (() = > {
4145 refresh ();
4246 });
43- row_activated. connect ((row) = > {
44- if (row is SidebarItemInterface ) {
45- ((SidebarItemInterface ) row). activated ();
47+
48+ list_box. row_activated. connect ((row) = > {
49+ if (row is BookmarkRow ) {
50+ ((BookmarkRow ) row). activated ();
4651 }
4752 });
48- row_selected. connect ((row) = > {
49- if (row is SidebarItemInterface ) {
50- select_item ((SidebarItemInterface ) row);
53+
54+ list_box. row_selected. connect ((row) = > {
55+ if (row is BookmarkRow ) {
56+ select_item (row);
5157 }
5258 });
5359 }
5460
55- public SidebarItemInterface ? add_bookmark (string label ,
61+ public BookmarkRow ? add_bookmark (string label ,
5662 string uri ,
5763 Icon gicon ,
5864 bool pinned = false ,
@@ -61,7 +67,7 @@ public class Sidebar.BookmarkListBox : Gtk.ListBox, Sidebar.SidebarListInterface
6167 return insert_bookmark (label, uri, gicon, - 1 , pinned, permanent);
6268 }
6369
64- private SidebarItemInterface ? insert_bookmark (string label ,
70+ private BookmarkRow ? insert_bookmark (string label ,
6571 string uri ,
6672 Icon gicon ,
6773 int index ,
@@ -74,9 +80,9 @@ public class Sidebar.BookmarkListBox : Gtk.ListBox, Sidebar.SidebarListInterface
7480
7581 var row = new BookmarkRow (label, uri, gicon, this , pinned, permanent);
7682 if (index >= 0 ) {
77- insert (row, index);
83+ list_box . insert (row, index);
7884 } else {
79- add (row);
85+ list_box . add (row);
8086 }
8187
8288 return row;
@@ -94,22 +100,22 @@ public class Sidebar.BookmarkListBox : Gtk.ListBox, Sidebar.SidebarListInterface
94100 }
95101
96102
97- public void select_item (SidebarItemInterface ? item ) {
103+ public void select_item (Gtk . ListBoxRow ? item ) {
98104 if (item != null && item is BookmarkRow ) {
99- select_row (( BookmarkRow ) item);
105+ list_box . select_row (item);
100106 } else {
101107 unselect_all_items ();
102108 }
103109 }
104110
105111 public void unselect_all_items () {
106- unselect_all ();
112+ list_box . unselect_all ();
107113 }
108114
109115 public void refresh () {
110116 clear ();
111117
112- SidebarItemInterface ? row;
118+ BookmarkRow ? row;
113119 var home_uri = " " ;
114120 try {
115121 home_uri = GLib . Filename . to_uri (PF . UserUtils . get_real_user_home (), null );
@@ -189,8 +195,8 @@ public class Sidebar.BookmarkListBox : Gtk.ListBox, Sidebar.SidebarListInterface
189195 int pos = 0 ) {
190196
191197 int pinned = 0 ; // Assume pinned items only at start and end of list
192- foreach (unowned Gtk . Widget child in get_children ()) {
193- if (((SidebarItemInterface )child). pinned) {
198+ foreach (unowned var child in list_box . get_children ()) {
199+ if (((BookmarkRow )child). pinned) {
194200 pinned++ ;
195201 } else {
196202 break ;
@@ -212,11 +218,11 @@ public class Sidebar.BookmarkListBox : Gtk.ListBox, Sidebar.SidebarListInterface
212218
213219 public override bool remove_item_by_id (uint32 id ) {
214220 bool removed = false ;
215- this . @foreach ((child) = > {
216- if (child is SidebarItemInterface ) {
217- unowned var row = (SidebarItemInterface )child;
221+ list_box . @foreach ((child) = > {
222+ if (child is BookmarkRow ) {
223+ unowned var row = (BookmarkRow )child;
218224 if (! row. permanent && row. id == id) {
219- remove (row);
225+ list_box . remove (row);
220226 bookmark_list. delete_items_with_uri (row. uri); // Assumes no duplicates
221227 removed = true ;
222228 }
@@ -227,11 +233,11 @@ public class Sidebar.BookmarkListBox : Gtk.ListBox, Sidebar.SidebarListInterface
227233 }
228234
229235 public SidebarItemInterface ? get_item_at_index (int index ) {
230- if (index < 0 || index > get_children (). length ()) {
236+ if (index < 0 || index > list_box . get_children (). length ()) {
231237 return null ;
232238 }
233239
234- return (SidebarItemInterface ? )( get_row_at_index (index) );
240+ return (SidebarItemInterface ? ) list_box . get_row_at_index (index);
235241 }
236242
237243 public override bool move_item_after (SidebarItemInterface item , int target_index ) {
@@ -244,12 +250,12 @@ public class Sidebar.BookmarkListBox : Gtk.ListBox, Sidebar.SidebarListInterface
244250 return false ;
245251 }
246252
247- remove (item);
253+ list_box . remove (( Gtk . ListBoxRow ) item);
248254
249255 if (old_index > target_index) {
250- insert (item, ++ target_index);
256+ list_box . insert (( Gtk . ListBoxRow ) item, ++ target_index);
251257 } else {
252- insert (item, target_index);
258+ list_box . insert (( Gtk . ListBoxRow ) item, target_index);
253259 }
254260
255261 bookmark_list. move_item_uri (item. uri, target_index - old_index);
0 commit comments