Merge lp:~dobey/ubuntuone-client/bookmark-fixins into lp:ubuntuone-client

Proposed by dobey on 2009-10-02
Status: Merged
Approved by: Mark G. Saye on 2009-10-05
Approved revision: 233
Merged at revision: not available
Proposed branch: lp:~dobey/ubuntuone-client/bookmark-fixins
Merge into: lp:ubuntuone-client
Diff against target: 59 lines
1 file modified
bin/ubuntuone-client-applet (+10/-18)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/bookmark-fixins
Reviewer Review Type Date Requested Status
Mark G. Saye (community) Approve on 2009-10-05
John O'Brien (community) 2009-10-02 Approve on 2009-10-05
Review via email: mp+12799@code.launchpad.net

Commit message

Remove the remove_from_places code
Add a config option to only create the bookmark on first authorization
Only set the bookmark on first authorization

To post a comment you must log in.
John O'Brien (jdobrien) wrote :

Looks good.

When reviewing this I noticed I had the following bookmark:
file:///home/john/Ubuntu%20One/My%20Files Ubuntu One

I am guessing it's an old one and that it was overridden by the correct one that came after it.

review: Approve
Mark G. Saye (markgsaye) wrote :

Bookmark appears when first expected, but not after deleting it. Code looks good, tests pass (apart from one unrelated failure)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-client-applet'
2--- bin/ubuntuone-client-applet 2009-09-30 14:31:41 +0000
3+++ bin/ubuntuone-client-applet 2009-10-02 18:00:27 +0000
4@@ -121,6 +121,9 @@
5 if not self.config.has_option("ubuntuone", "connected"):
6 self.config.set("ubuntuone", "connected", "False")
7
8+ if not self.config.has_option("ubuntuone", "bookmarked"):
9+ self.config.set("ubuntuone", "bookmarked", "False")
10+
11 self.show_applet = self.config.getint("ubuntuone", "show_applet")
12 self.connect = self.config.getint("ubuntuone", "connect")
13 self.connected = self.config.getboolean("ubuntuone", "connected")
14@@ -756,8 +759,6 @@
15 iface = dbus.Interface(client, DBUS_IFACE_SYNC_NAME)
16 def got_root(root):
17 """We got the root dir."""
18- if self.__managed_dir:
19- self.__remove_from_places(self.__managed_dir)
20 self.__managed_dir = root
21 if os.path.isdir(self.__managed_dir) and \
22 os.access(self.__managed_dir,
23@@ -961,9 +962,10 @@
24
25 def __add_to_places(self):
26 """Add the managed directory to the .gtk-bookmarks file."""
27- # migrate from the old places bookmark
28- if os.path.basename(self.__managed_dir) != BOOKMARK_NAME:
29- self.__remove_from_places(os.path.dirname(self.__managed_dir))
30+ # Only add once
31+ if self.__config.getboolean("ubuntuone", "bookmarked"):
32+ return
33+
34 path = os.path.join(os.path.expanduser("~"), ".gtk-bookmarks")
35 with open(path, "a+") as f:
36 bookmarks_entry = "file://%s %s\n" % (
37@@ -975,19 +977,9 @@
38 if not in_file:
39 f.write(bookmarks_entry)
40
41- def __remove_from_places(self, dir):
42- """Remove the old path from the .gtk-bookmarks file."""
43- path = os.path.join(os.path.expanduser("~"), ".gtk-bookmarks")
44- with open(path, "a+") as f:
45- entry = "file://%s %s\n" % (quote(dir), os.path.basename(dir))
46- lines = []
47- for line in f:
48- if line != entry:
49- lines.append(line)
50- f.truncate(0)
51- f.seek(0)
52- output = "".join(lines)
53- f.write(output)
54+ self.__config.set("ubuntuone", "bookmarked", "True")
55+ with open(CONF_FILE, "w+b") as f:
56+ self.__config.write(f)
57
58 def sd_dbus_error(self, error):
59 """

Subscribers

People subscribed via source and target branches