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
=== modified file 'unity-private/launcher/application-controller.vala'
--- unity-private/launcher/application-controller.vala 2010-09-19 15:26:13 +0000
+++ unity-private/launcher/application-controller.vala 2010-09-24 12:50:55 +0000
@@ -37,6 +37,20 @@
37 private Dbusmenu.Client menu_client;37 private Dbusmenu.Client menu_client;
38 private Dbusmenu.Menuitem cached_menu;38 private Dbusmenu.Menuitem cached_menu;
39 private int menu_items_realized_counter;39 private int menu_items_realized_counter;
40 private string _fav_id = "";
41 public string fav_id {
42 get
43 {
44 if (_fav_id == "" || _fav_id == null &&
45 desktop_file != "" && desktop_file != null)
46 {
47 var filepath = desktop_file.split ("/");
48 _fav_id = "app-" + filepath[filepath.length - 1];
49 }
50 return _fav_id;
51 }
52 set { _fav_id = value; }
53 }
4054
41 public bool is_favorite = false;55 public bool is_favorite = false;
4256
@@ -90,22 +104,15 @@
90104
91 var favorites = Unity.Favorites.get_default ();105 var favorites = Unity.Favorites.get_default ();
92106
93 string uid = favorites.find_uid_for_desktop_file (desktop_file);
94 if (uid == "" || uid == null)
95 {
96 var filepath = desktop_file.split ("/");
97 uid = "app-" + filepath[filepath.length - 1];
98 }
99
100 if (is_sticky)107 if (is_sticky)
101 {108 {
102 favorites.set_string (uid, "type", "application");109 favorites.set_string (fav_id, "type", "application");
103 favorites.set_string (uid, "desktop_file", desktop_file);110 favorites.set_string (fav_id, "desktop_file", desktop_file);
104 favorites.add_favorite (uid);111 favorites.add_favorite (fav_id);
105 }112 }
106 else113 else
107 {114 {
108 favorites.remove_favorite (uid);115 favorites.remove_favorite (fav_id);
109 }116 }
110 }117 }
111118
@@ -115,11 +122,7 @@
115 return false;122 return false;
116123
117 var favorites = Unity.Favorites.get_default ();124 var favorites = Unity.Favorites.get_default ();
118 string uid = favorites.find_uid_for_desktop_file (desktop_file);125 return favorites.is_favorite (fav_id);
119 if (uid == null || uid == "")
120 return false;
121 else
122 return true;
123 }126 }
124127
125 public void close_windows ()128 public void close_windows ()
@@ -136,9 +139,8 @@
136 if (desktop_file == "" || desktop_file == null)139 if (desktop_file == "" || desktop_file == null)
137 return;140 return;
138141
139 string uid = "app-" + Path.get_basename (desktop_file);
140 var favorites = Unity.Favorites.get_default ();142 var favorites = Unity.Favorites.get_default ();
141 favorites.set_float (uid, "priority", priority);143 favorites.set_float (fav_id, "priority", priority);
142 }144 }
143145
144 public float get_priority () throws AppTypeError146 public float get_priority () throws AppTypeError
@@ -146,17 +148,14 @@
146 if (desktop_file == "" || desktop_file == null)148 if (desktop_file == "" || desktop_file == null)
147 throw new AppTypeError.NO_DESKTOP_FILE("There is no desktop file for this app, can't get priority");149 throw new AppTypeError.NO_DESKTOP_FILE("There is no desktop file for this app, can't get priority");
148150
149 string uid = "app-" + Path.get_basename (desktop_file);
150 var favorites = Unity.Favorites.get_default ();151 var favorites = Unity.Favorites.get_default ();
151 return favorites.get_float (uid, "priority");152 return favorites.get_float (fav_id, "priority");
152 }153 }
153154
154 private void on_favorite_added (string uid)155 private void on_favorite_added (string uid)
155 {156 {
156 //check to see if we are the favorite157 //check to see if we are the favorite
157 var favorites = Unity.Favorites.get_default ();158 if (uid == fav_id)
158 var desktop_filename = favorites.get_string (uid, "desktop_file");
159 if (desktop_filename == desktop_file)
160 {159 {
161 is_favorite = true;160 is_favorite = true;
162 child.pin_type = PinType.PINNED;161 child.pin_type = PinType.PINNED;
@@ -165,15 +164,13 @@
165164
166 private void on_favorite_removed (string uid)165 private void on_favorite_removed (string uid)
167 {166 {
168 var favorites = Unity.Favorites.get_default ();167 if (uid == fav_id)
169 var desktop_filename = favorites.get_string (uid, "desktop_file");
170 if (desktop_filename == desktop_file)
171 {168 {
172 is_favorite = false;169 is_favorite = false;
173 child.pin_type = PinType.UNPINNED;170 child.pin_type = PinType.UNPINNED;
174 closed ();171 closed ();
175 if (".local" in desktop_filename)172 if (".local" in desktop_file)
176 FileUtils.remove (desktop_filename);173 FileUtils.remove (desktop_file);
177 }174 }
178 }175 }
179176
180177
=== modified file 'unity-private/launcher/scroller-controller.vala'
--- unity-private/launcher/scroller-controller.vala 2010-09-22 13:49:14 +0000
+++ unity-private/launcher/scroller-controller.vala 2010-09-24 12:50:55 +0000
@@ -218,10 +218,6 @@
218218
219 foreach (string uid in favorites.get_favorites ())219 foreach (string uid in favorites.get_favorites ())
220 {220 {
221 var type = favorites.get_string (uid, "type");
222 if (type != "application")
223 continue;
224
225 string desktop_file = favorites.get_string (uid, "desktop_file");221 string desktop_file = favorites.get_string (uid, "desktop_file");
226 if (!FileUtils.test (desktop_file, FileTest.EXISTS))222 if (!FileUtils.test (desktop_file, FileTest.EXISTS))
227 {223 {
@@ -240,6 +236,7 @@
240 childcontrollers.add (controller);236 childcontrollers.add (controller);
241 controller.request_removal.connect (on_scroller_controller_closed);237 controller.request_removal.connect (on_scroller_controller_closed);
242 }238 }
239 controller.fav_id = uid;
243 }240 }
244241
245 // need to sort the list now242 // need to sort the list now