Merge lp:~azzar1/unity/fix-830536 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Mirco Müller
Approved revision: no longer in the source branch.
Merged at revision: 1436
Proposed branch: lp:~azzar1/unity/fix-830536
Merge into: lp:unity
Diff against target: 163 lines (+40/-33)
5 files modified
plugins/unityshell/src/Launcher.cpp (+3/-25)
plugins/unityshell/src/LauncherController.cpp (+28/-8)
plugins/unityshell/src/LauncherController.h (+1/-0)
plugins/unityshell/src/LauncherModel.cpp (+6/-0)
plugins/unityshell/src/LauncherModel.h (+2/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-830536
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+72350@code.launchpad.net

Description of the change

Solves (or at least it should solve :) ) an old regression due to my mistake.

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

Code looks ok, works as described.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/Launcher.cpp'
2--- plugins/unityshell/src/Launcher.cpp 2011-08-19 15:23:50 +0000
3+++ plugins/unityshell/src/Launcher.cpp 2011-08-21 16:35:34 +0000
4@@ -35,8 +35,6 @@
5 #include "Nux/BaseWindow.h"
6 #include "Nux/WindowCompositor.h"
7
8-#include "BamfLauncherIcon.h"
9-#include "FavoriteStore.h"
10 #include "Launcher.h"
11 #include "LauncherIcon.h"
12 #include "SpacerLauncherIcon.h"
13@@ -2231,29 +2229,9 @@
14 EnsureAnimation();
15 }
16 else
17- {
18-
19- std::list<BamfLauncherIcon*> launchers;
20- std::list<BamfLauncherIcon*>::iterator it;
21- unity::FavoriteList desktop_paths;
22-
23- // Updates gsettings favorites.
24- launchers = _model->GetSublist<BamfLauncherIcon> ();
25- for (it = launchers.begin(); it != launchers.end(); it++)
26- {
27- BamfLauncherIcon* icon = *it;
28-
29- if (!icon->IsSticky())
30- continue;
31-
32- const char* desktop_file = icon->DesktopFile();
33-
34- if (desktop_file && strlen(desktop_file) > 0)
35- desktop_paths.push_back(desktop_file);
36- }
37-
38- unity::FavoriteStore::GetDefault().SetFavorites(desktop_paths);
39-
40+ {
41+ _model->Save();
42+
43 _drag_window->SetAnimationTarget((int)(_drag_icon->GetCenter().x), (int)(_drag_icon->GetCenter().y));
44 _drag_window->StartAnimation();
45
46
47=== modified file 'plugins/unityshell/src/LauncherController.cpp'
48--- plugins/unityshell/src/LauncherController.cpp 2011-08-03 03:01:46 +0000
49+++ plugins/unityshell/src/LauncherController.cpp 2011-08-21 16:35:34 +0000
50@@ -99,30 +99,49 @@
51 if (before)
52 _model->ReorderBefore(result, before, false);
53 }
54+
55+ Save();
56+}
57+
58+void LauncherController::Save()
59+{
60+ unity::FavoriteList desktop_paths;
61+
62+ // Updates gsettings favorites.
63+ std::list<BamfLauncherIcon*> launchers = _model->GetSublist<BamfLauncherIcon> ();
64+ for (auto icon : launchers)
65+ {
66+ if (!icon->IsSticky())
67+ continue;
68+
69+ const char* desktop_file = icon->DesktopFile();
70+
71+ if (desktop_file && strlen(desktop_file) > 0)
72+ desktop_paths.push_back(desktop_file);
73+ }
74+
75+ unity::FavoriteStore::GetDefault().SetFavorites(desktop_paths);
76 }
77
78 void LauncherController::SortAndUpdate()
79 {
80- std::list<BamfLauncherIcon*> launchers;
81- std::list<BamfLauncherIcon*>::iterator it;
82- FavoriteList desktop_paths;
83 gint shortcut = 1;
84 gchar* buff;
85
86- launchers = _model->GetSublist<BamfLauncherIcon> ();
87- for (it = launchers.begin(); it != launchers.end(); it++)
88+ std::list<BamfLauncherIcon*> launchers = _model->GetSublist<BamfLauncherIcon> ();
89+ for (auto it : launchers)
90 {
91- if (shortcut < 11 && (*it)->GetQuirk(LauncherIcon::QUIRK_VISIBLE))
92+ if (shortcut < 11 && it->GetQuirk(LauncherIcon::QUIRK_VISIBLE))
93 {
94 buff = g_strdup_printf("%d", shortcut % 10);
95- (*it)->SetShortcut(buff[0]);
96+ it->SetShortcut(buff[0]);
97 g_free(buff);
98 shortcut++;
99 }
100 // reset shortcut
101 else
102 {
103- (*it)->SetShortcut(0);
104+ it->SetShortcut(0);
105 }
106 }
107 }
108@@ -367,5 +386,6 @@
109 }
110
111 _model->order_changed.connect(sigc::mem_fun(this, &LauncherController::SortAndUpdate));
112+ _model->saved.connect(sigc::mem_fun(this, &LauncherController::Save));
113 }
114
115
116=== modified file 'plugins/unityshell/src/LauncherController.h'
117--- plugins/unityshell/src/LauncherController.h 2011-07-26 12:33:23 +0000
118+++ plugins/unityshell/src/LauncherController.h 2011-08-21 16:35:34 +0000
119@@ -65,6 +65,7 @@
120
121 guint32 _on_view_opened_id;
122
123+ void Save();
124 void SortAndUpdate();
125
126 void OnIconAdded(LauncherIcon* icon);
127
128=== modified file 'plugins/unityshell/src/LauncherModel.cpp'
129--- plugins/unityshell/src/LauncherModel.cpp 2011-07-21 14:59:25 +0000
130+++ plugins/unityshell/src/LauncherModel.cpp 2011-08-21 16:35:34 +0000
131@@ -142,6 +142,12 @@
132 }
133
134 void
135+LauncherModel::Save()
136+{
137+ saved.emit();
138+}
139+
140+void
141 LauncherModel::Sort()
142 {
143 _inner_shelf.sort(&LauncherModel::CompareIcons);
144
145=== modified file 'plugins/unityshell/src/LauncherModel.h'
146--- plugins/unityshell/src/LauncherModel.h 2011-07-21 14:59:25 +0000
147+++ plugins/unityshell/src/LauncherModel.h 2011-08-21 16:35:34 +0000
148@@ -37,6 +37,7 @@
149
150 void AddIcon(LauncherIcon* icon);
151 void RemoveIcon(LauncherIcon* icon);
152+ void Save();
153 void Sort();
154 int Size();
155
156@@ -67,6 +68,7 @@
157 sigc::signal<void, LauncherIcon*> icon_added;
158 sigc::signal<void, LauncherIcon*> icon_removed;
159 sigc::signal<void> order_changed;
160+ sigc::signal<void> saved;
161
162 // connected to from class Launcher
163 sigc::connection on_icon_added_connection;