Merge lp:~unity-team/unity/unity.fix-weird-favourite-paths into lp:unity

Proposed by Gord Allott
Status: Merged
Merged at revision: 552
Proposed branch: lp:~unity-team/unity/unity.fix-weird-favourite-paths
Merge into: lp:unity
Diff against target: 137 lines (+26/-32)
2 files modified
unity-private/launcher/application-controller.vala (+25/-28)
unity-private/launcher/scroller-controller.vala (+1/-4)
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix-weird-favourite-paths
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+36544@code.launchpad.net

Description of the change

changes favourites loading so we don't care about the path, we just accept whatever the path is with no questions asked. fixes lp:645835

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

When setting fav_id please just do:

  _fav_id = "app-" + Path.get_basename (filepath);

Otherwise looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-private/launcher/application-controller.vala'
2--- unity-private/launcher/application-controller.vala 2010-09-19 15:26:13 +0000
3+++ unity-private/launcher/application-controller.vala 2010-09-24 12:50:55 +0000
4@@ -37,6 +37,20 @@
5 private Dbusmenu.Client menu_client;
6 private Dbusmenu.Menuitem cached_menu;
7 private int menu_items_realized_counter;
8+ private string _fav_id = "";
9+ public string fav_id {
10+ get
11+ {
12+ if (_fav_id == "" || _fav_id == null &&
13+ desktop_file != "" && desktop_file != null)
14+ {
15+ var filepath = desktop_file.split ("/");
16+ _fav_id = "app-" + filepath[filepath.length - 1];
17+ }
18+ return _fav_id;
19+ }
20+ set { _fav_id = value; }
21+ }
22
23 public bool is_favorite = false;
24
25@@ -90,22 +104,15 @@
26
27 var favorites = Unity.Favorites.get_default ();
28
29- string uid = favorites.find_uid_for_desktop_file (desktop_file);
30- if (uid == "" || uid == null)
31- {
32- var filepath = desktop_file.split ("/");
33- uid = "app-" + filepath[filepath.length - 1];
34- }
35-
36 if (is_sticky)
37 {
38- favorites.set_string (uid, "type", "application");
39- favorites.set_string (uid, "desktop_file", desktop_file);
40- favorites.add_favorite (uid);
41+ favorites.set_string (fav_id, "type", "application");
42+ favorites.set_string (fav_id, "desktop_file", desktop_file);
43+ favorites.add_favorite (fav_id);
44 }
45 else
46 {
47- favorites.remove_favorite (uid);
48+ favorites.remove_favorite (fav_id);
49 }
50 }
51
52@@ -115,11 +122,7 @@
53 return false;
54
55 var favorites = Unity.Favorites.get_default ();
56- string uid = favorites.find_uid_for_desktop_file (desktop_file);
57- if (uid == null || uid == "")
58- return false;
59- else
60- return true;
61+ return favorites.is_favorite (fav_id);
62 }
63
64 public void close_windows ()
65@@ -136,9 +139,8 @@
66 if (desktop_file == "" || desktop_file == null)
67 return;
68
69- string uid = "app-" + Path.get_basename (desktop_file);
70 var favorites = Unity.Favorites.get_default ();
71- favorites.set_float (uid, "priority", priority);
72+ favorites.set_float (fav_id, "priority", priority);
73 }
74
75 public float get_priority () throws AppTypeError
76@@ -146,17 +148,14 @@
77 if (desktop_file == "" || desktop_file == null)
78 throw new AppTypeError.NO_DESKTOP_FILE("There is no desktop file for this app, can't get priority");
79
80- string uid = "app-" + Path.get_basename (desktop_file);
81 var favorites = Unity.Favorites.get_default ();
82- return favorites.get_float (uid, "priority");
83+ return favorites.get_float (fav_id, "priority");
84 }
85
86 private void on_favorite_added (string uid)
87 {
88 //check to see if we are the favorite
89- var favorites = Unity.Favorites.get_default ();
90- var desktop_filename = favorites.get_string (uid, "desktop_file");
91- if (desktop_filename == desktop_file)
92+ if (uid == fav_id)
93 {
94 is_favorite = true;
95 child.pin_type = PinType.PINNED;
96@@ -165,15 +164,13 @@
97
98 private void on_favorite_removed (string uid)
99 {
100- var favorites = Unity.Favorites.get_default ();
101- var desktop_filename = favorites.get_string (uid, "desktop_file");
102- if (desktop_filename == desktop_file)
103+ if (uid == fav_id)
104 {
105 is_favorite = false;
106 child.pin_type = PinType.UNPINNED;
107 closed ();
108- if (".local" in desktop_filename)
109- FileUtils.remove (desktop_filename);
110+ if (".local" in desktop_file)
111+ FileUtils.remove (desktop_file);
112 }
113 }
114
115
116=== modified file 'unity-private/launcher/scroller-controller.vala'
117--- unity-private/launcher/scroller-controller.vala 2010-09-22 13:49:14 +0000
118+++ unity-private/launcher/scroller-controller.vala 2010-09-24 12:50:55 +0000
119@@ -218,10 +218,6 @@
120
121 foreach (string uid in favorites.get_favorites ())
122 {
123- var type = favorites.get_string (uid, "type");
124- if (type != "application")
125- continue;
126-
127 string desktop_file = favorites.get_string (uid, "desktop_file");
128 if (!FileUtils.test (desktop_file, FileTest.EXISTS))
129 {
130@@ -240,6 +236,7 @@
131 childcontrollers.add (controller);
132 controller.request_removal.connect (on_scroller_controller_closed);
133 }
134+ controller.fav_id = uid;
135 }
136
137 // need to sort the list now