@@ -36,6 +36,7 @@ class PortfolioPlaces(Gtk.Stack):
3636 "removed" : (GObject .SignalFlags .RUN_LAST , None , (str , bool )),
3737 "failed" : (GObject .SignalFlags .RUN_LAST , None , (str ,)),
3838 "unlock" : (GObject .SignalFlags .RUN_LAST , None , (object ,)),
39+ "toggle-bookmark" : (GObject .SignalFlags .RUN_LAST , None , (str ,)),
3940 }
4041
4142 FLATPAK_INFO = os .path .join (os .path .abspath (os .sep ), ".flatpak-info" )
@@ -66,6 +67,7 @@ def __init__(self, **kargs):
6667 self ._setup ()
6768
6869 def _setup (self ):
70+ self .connect ("toggle-bookmark" , self ._on_bookmark_toggled )
6971 self .props .visible = True
7072 self .props .transition_type = Gtk .StackTransitionType .CROSSFADE
7173
@@ -77,7 +79,6 @@ def _setup(self):
7779 self ._devices .connect ("encrypted-added" , self ._on_encrypted_added )
7880
7981 self ._bookmarks = PortfolioBookmarks ()
80- self ._bookmarks .connect ("bookmark_toggled" , self ._on_bookmark_toggled )
8182
8283 # begin UI structure
8384
@@ -102,6 +103,9 @@ def _setup(self):
102103 self ._bookmarks_group .props .title = _ ("Bookmarks" )
103104 self ._bookmarks_group .props .visible = True
104105
106+ for path in self ._bookmarks .bookmarked :
107+ self ._add_bookmark_place (path )
108+
105109 # places
106110
107111 if self ._has_permission_for (self .HOME_PERMISSION ):
@@ -405,6 +409,14 @@ def _find_place_by_path(self, listbox, path):
405409 return place
406410 return None
407411
412+ def _remove_bookmark (self , button , path ):
413+ place = self ._find_place_by_path (self ._bookmarks_listbox , path )
414+ if place is not None :
415+ self ._bookmarks_group .remove (place )
416+ self ._bookmarks .emit ("toggle-bookmark" , path )
417+ return True
418+ return False
419+
408420 def _add_bookmark_place (self , path ):
409421 name = os .path .basename (path )
410422 place = self ._add_place (
@@ -413,10 +425,13 @@ def _add_bookmark_place(self, path):
413425 name ,
414426 path
415427 )
428+ place .remove_bookmark .props .visible = True
429+ place .remove_bookmark .connect ("clicked" , self ._remove_bookmark , path )
416430
417- def _on_bookmark_toggled (self , path ):
431+ def _on_bookmark_toggled (self , places , path ):
418432 place = self ._find_place_by_path (self ._bookmarks_listbox , path )
419433 if place is None :
420434 self ._add_bookmark_place (path )
421435 else :
422436 self ._bookmarks_group .remove (place )
437+ self ._bookmarks .emit ("toggle-bookmark" , path )
0 commit comments