1515# You should have received a copy of the GNU General Public License
1616# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18- from gi .repository import Gio , GLib , GObject , Gtk
18+ from gi .repository import GLib , GObject , Gtk
1919
20- from . import logger
21- from . import utils
2220import json , os
2321
2422
@@ -34,11 +32,13 @@ def __init__(self):
3432 GObject .GObject .__init__ (self )
3533
3634 self .bookmarked = {}
37- self ._portfolio_config_path = os .path .join (GLib .get_user_config_dir (), "portfolio" )
35+ self ._portfolio_config_path = os .path .join (
36+ GLib .get_user_config_dir (), "portfolio"
37+ )
3838 self ._bookmark_path = os .path .join (self ._portfolio_config_path , "bookmarks" )
3939
4040 try :
41- with open (self ._bookmark_path , 'r' ) as f :
41+ with open (self ._bookmark_path , "r" ) as f :
4242 data = f .read ()
4343 if not data is None :
4444 bookmarked = json .loads (data )
@@ -55,8 +55,7 @@ def __init__(self):
5555
5656 def _add_bookmark (self , path ):
5757 if path not in self .bookmarked :
58- name = os .path .basename (path )
59- self .bookmarked [path ] = 0 # Python Hashsets are limited?
58+ self .bookmarked [path ] = 0 # Python Hashsets are limited?
6059 self .emit ("add-bookmark" , path )
6160
6261 def _delete_bookmark (self , path ):
@@ -68,8 +67,8 @@ def is_bookmarked(self, path):
6867 return path in self .bookmarked
6968
7069 def _save_bookmarks (self ):
71- os .makedirs (self ._portfolio_config_path , exist_ok = True )
72- with open (self ._bookmark_path , 'w' ) as f :
70+ os .makedirs (self ._portfolio_config_path , exist_ok = True )
71+ with open (self ._bookmark_path , "w" ) as f :
7372 paths = [bookmark for bookmark in self .bookmarked ]
7473 json .dump (paths , f )
7574
@@ -80,10 +79,10 @@ def toggle_bookmark(self, button, path):
8079 self ._add_bookmark (path )
8180 self ._save_bookmarks ()
8281
82+
8383class PortfolioBookmarkButton (Gtk .Button ):
8484 __gtype_name__ = "PortfolioBookmarkButton"
8585
86-
8786 def __init__ (self , bookmarks ):
8887 Gtk .Button .__init__ (self )
8988 self .connect ("clicked" , self ._on_bookmark_toggle )
0 commit comments