mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-24 08:04:44 +00:00
Fix bookmark menu entries in GUI.
This commit is contained in:
parent
67b751f1c7
commit
f9290932b8
6 changed files with 57 additions and 45 deletions
|
|
@ -50,11 +50,14 @@ def find_bookmark_file (profile="Default"):
|
|||
Returns absolute filename if found, or empty string if no bookmark file
|
||||
could be found.
|
||||
"""
|
||||
dirname = os.path.join(get_profile_dir(), profile)
|
||||
if os.path.isdir(dirname):
|
||||
fname = os.path.join(dirname, "Bookmarks")
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
try:
|
||||
dirname = os.path.join(get_profile_dir(), profile)
|
||||
if os.path.isdir(dirname):
|
||||
fname = os.path.join(dirname, "Bookmarks")
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
except Exception:
|
||||
pass
|
||||
return u""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,11 +52,14 @@ def find_bookmark_file (profile="Default"):
|
|||
Returns absolute filename if found, or empty string if no bookmark file
|
||||
could be found.
|
||||
"""
|
||||
dirname = os.path.join(get_profile_dir(), profile)
|
||||
if os.path.isdir(dirname):
|
||||
fname = os.path.join(dirname, "Bookmarks")
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
try:
|
||||
dirname = os.path.join(get_profile_dir(), profile)
|
||||
if os.path.isdir(dirname):
|
||||
fname = os.path.join(dirname, "Bookmarks")
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
except Exception:
|
||||
pass
|
||||
return u""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,11 +48,14 @@ def find_bookmark_file (profile="*.default"):
|
|||
Returns absolute filename if found, or empty string if no bookmark file
|
||||
could be found.
|
||||
"""
|
||||
for dirname in glob.glob(u"%s/%s" % (get_profile_dir(), profile)):
|
||||
if os.path.isdir(dirname):
|
||||
fname = os.path.join(dirname, "places.sqlite")
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
try:
|
||||
for dirname in glob.glob(u"%s/%s" % (get_profile_dir(), profile)):
|
||||
if os.path.isdir(dirname):
|
||||
fname = os.path.join(dirname, "places.sqlite")
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
except Exception:
|
||||
pass
|
||||
return u""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,15 @@ def find_bookmark_file ():
|
|||
Returns absolute filename if found, or empty string if no bookmark file
|
||||
could be found.
|
||||
"""
|
||||
dirname = get_profile_dir()
|
||||
if os.path.isdir(dirname):
|
||||
for name in OperaBookmarkFiles:
|
||||
fname = os.path.join(dirname, name)
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
try:
|
||||
dirname = get_profile_dir()
|
||||
if os.path.isdir(dirname):
|
||||
for name in OperaBookmarkFiles:
|
||||
fname = os.path.join(dirname, name)
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
except Exception:
|
||||
pass
|
||||
return u""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,11 +38,14 @@ def find_bookmark_file ():
|
|||
"""
|
||||
if sys.platform != 'darwin':
|
||||
return u""
|
||||
dirname = get_profile_dir()
|
||||
if os.path.isdir(dirname):
|
||||
fname = os.path.join(dirname, u"Bookmarks.plist")
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
try:
|
||||
dirname = get_profile_dir()
|
||||
if os.path.isdir(dirname):
|
||||
fname = os.path.join(dirname, u"Bookmarks.plist")
|
||||
if os.path.isfile(fname):
|
||||
return fname
|
||||
except Exception:
|
||||
pass
|
||||
return u""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -172,17 +172,22 @@ class LineEdit (QtGui.QLineEdit):
|
|||
|
||||
def addMenuEntries (self, menu):
|
||||
"""Add browser bookmark actions to menu."""
|
||||
msg = _("Insert %(browser)s bookmark file")
|
||||
for name, find_func in BROWSERS:
|
||||
try:
|
||||
res = find_func()
|
||||
if res:
|
||||
callback = lambda: self.setText(find_func())
|
||||
action = menu.addAction(name % {"browser": name})
|
||||
action.triggered.connect(callback)
|
||||
except Exception, msg:
|
||||
# XXX log msg
|
||||
pass
|
||||
name = _("Insert %(browser)s bookmark file")
|
||||
if find_firefox():
|
||||
action = menu.addAction(name % {"browser": u"Firefox"})
|
||||
action.triggered.connect(lambda: self.setText(find_firefox()))
|
||||
if find_chrome():
|
||||
action = menu.addAction(name % {"browser": u"Google Chrome"})
|
||||
action.triggered.connect(lambda: self.setText(find_chrome()))
|
||||
if find_chromium():
|
||||
action = menu.addAction(name % {"browser": u"Chromium"})
|
||||
action.triggered.connect(lambda: self.setText(find_chromium()))
|
||||
if find_opera():
|
||||
action = menu.addAction(name % {"browser": u"Opera"})
|
||||
action.triggered.connect(lambda: self.setText(find_opera()))
|
||||
if find_safari():
|
||||
action = menu.addAction(name % {"browser": u"Safari"})
|
||||
action.triggered.connect(lambda: self.setText(find_safari()))
|
||||
|
||||
def contextMenuEvent (self, event):
|
||||
"""Handle context menu event."""
|
||||
|
|
@ -219,11 +224,3 @@ def find_safari ():
|
|||
"""Return Safari bookmark filename or empty string if not found."""
|
||||
from ..bookmarks.safari import find_bookmark_file
|
||||
return find_bookmark_file()
|
||||
|
||||
BROWSERS = (
|
||||
(u"Firefox", find_firefox),
|
||||
(u"Google Chrome", find_chrome),
|
||||
(u"Chromium", find_chromium),
|
||||
(u"Opera", find_opera),
|
||||
(u"Safari", find_safari),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue