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

Proposed by Andrea Azzarone on 2011-11-30
Status: Merged
Approved by: Mirco Müller on 2011-11-30
Approved revision: 1742
Merged at revision: 1743
Proposed branch: lp:~azzar1/unity/fix-681348
Merge into: lp:unity
Diff against target: 193 lines (+61/-1)
7 files modified
plugins/unityshell/src/AbstractLauncherIcon.h (+1/-0)
plugins/unityshell/src/DesktopLauncherIcon.cpp (+1/-0)
plugins/unityshell/src/DesktopLauncherIcon.h (+9/-1)
plugins/unityshell/src/LauncherController.cpp (+38/-0)
plugins/unityshell/src/LauncherController.h (+2/-0)
plugins/unityshell/src/unityshell.cpp (+4/-0)
plugins/unityshell/unityshell.xml.in (+6/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-681348
Reviewer Review Type Date Requested Status
Mirco Müller (community) 2011-11-30 Approve on 2011-11-30
Review via email: mp+83890@code.launchpad.net

Description of the change

Add a ccsm option to display a "Show Desktop" icon in the launcher.

To post a comment you must log in.
Mirco Müller (macslow) wrote :

Code looks good and works as advertised. The used icon came from the Design-team, but isn't approved yet.

review: Approve
Mirco Müller (macslow) wrote :

Nevermind the remark about the icon. It was a mixup. The icon used here is just fine.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/AbstractLauncherIcon.h'
2--- plugins/unityshell/src/AbstractLauncherIcon.h 2011-10-26 05:41:45 +0000
3+++ plugins/unityshell/src/AbstractLauncherIcon.h 2011-11-30 03:10:29 +0000
4@@ -81,6 +81,7 @@
5 TYPE_FAVORITE,
6 TYPE_APPLICATION,
7 TYPE_EXPO,
8+ TYPE_DESKTOP,
9 TYPE_PLACE,
10 TYPE_DEVICE,
11 TYPE_TRASH,
12
13=== modified file 'plugins/unityshell/src/DesktopLauncherIcon.cpp'
14--- plugins/unityshell/src/DesktopLauncherIcon.cpp 2011-10-06 04:18:36 +0000
15+++ plugins/unityshell/src/DesktopLauncherIcon.cpp 2011-11-30 03:10:29 +0000
16@@ -29,6 +29,7 @@
17
18 DesktopLauncherIcon::DesktopLauncherIcon(Launcher* IconManager)
19 : SimpleLauncherIcon(IconManager)
20+ , show_in_switcher_(true)
21 {
22 tooltip_text = _("Show Desktop");
23 SetIconName("desktop");
24
25=== modified file 'plugins/unityshell/src/DesktopLauncherIcon.h'
26--- plugins/unityshell/src/DesktopLauncherIcon.h 2011-10-26 05:41:45 +0000
27+++ plugins/unityshell/src/DesktopLauncherIcon.h 2011-11-30 03:10:29 +0000
28@@ -37,6 +37,11 @@
29 virtual nux::Color BackgroundColor();
30 virtual nux::Color GlowColor();
31
32+ void SetShowInSwitcher(bool show_in_switcher)
33+ {
34+ show_in_switcher_ = show_in_switcher;
35+ }
36+
37 const bool HasWindowOnViewport()
38 {
39 return true;
40@@ -44,11 +49,14 @@
41
42 bool ShowInSwitcher()
43 {
44- return true;
45+ return show_in_switcher_;
46 }
47
48 protected:
49 void ActivateLauncherIcon(ActionArg arg);
50+
51+private:
52+ bool show_in_switcher_;
53 };
54
55 }
56
57=== modified file 'plugins/unityshell/src/LauncherController.cpp'
58--- plugins/unityshell/src/LauncherController.cpp 2011-10-26 05:41:45 +0000
59+++ plugins/unityshell/src/LauncherController.cpp 2011-11-30 03:10:29 +0000
60@@ -75,6 +75,9 @@
61 void InsertExpoAction();
62 void RemoveExpoAction();
63
64+ void InsertDesktopIcon();
65+ void RemoveDesktopIcon();
66+
67 void InsertTrash();
68
69 void RegisterIcon(LauncherIcon* icon);
70@@ -97,8 +100,10 @@
71 DeviceLauncherSection* device_section_;
72 LauncherEntryRemoteModel remote_model_;
73 SimpleLauncherIcon* expo_icon_;
74+ DesktopLauncherIcon* desktop_launcher_icon_;
75 nux::ObjectPtr<AbstractLauncherIcon> desktop_icon_;
76 int num_workspaces_;
77+ bool show_desktop_icon_;
78
79 guint bamf_timer_handler_id_;
80
81@@ -112,6 +117,7 @@
82 : matcher_(nullptr)
83 , model_(new LauncherModel())
84 , sort_priority_(0)
85+ , show_desktop_icon_(false)
86 {
87 // NOTE: should the launcher itself hold the base window?
88 // seems like it probably should...
89@@ -151,6 +157,11 @@
90 {
91 InsertExpoAction();
92 }
93+
94+ // Insert the "Show Desktop" launcher icon in the launcher...
95+ if (show_desktop_icon_)
96+ InsertDesktopIcon();
97+
98 InsertTrash();
99
100 auto setup_bamf = [](gpointer user_data) -> gboolean
101@@ -350,6 +361,20 @@
102 model_->RemoveIcon(expo_icon_);
103 }
104
105+void Controller::Impl::InsertDesktopIcon()
106+{
107+ desktop_launcher_icon_ = new DesktopLauncherIcon(launcher_.GetPointer());
108+ desktop_launcher_icon_->SetIconType(LauncherIcon::TYPE_DESKTOP);
109+ desktop_launcher_icon_->SetShowInSwitcher(false);
110+
111+ RegisterIcon(desktop_launcher_icon_);
112+}
113+
114+void Controller::Impl::RemoveDesktopIcon()
115+{
116+ model_->RemoveIcon(desktop_launcher_icon_);
117+}
118+
119 void Controller::Impl::RegisterIcon(LauncherIcon* icon)
120 {
121 model_->AddIcon(icon);
122@@ -542,6 +567,19 @@
123 pimpl->launcher_window_->PushToFront();
124 }
125
126+void Controller::SetShowDesktopIcon(bool show_desktop_icon)
127+{
128+ if (pimpl->show_desktop_icon_ == show_desktop_icon)
129+ return;
130+
131+ pimpl->show_desktop_icon_ = show_desktop_icon;
132+
133+ if (pimpl->show_desktop_icon_)
134+ pimpl->InsertDesktopIcon();
135+ else
136+ pimpl->RemoveDesktopIcon();
137+}
138+
139
140 } // namespace launcher
141 } // namespace unity
142
143=== modified file 'plugins/unityshell/src/LauncherController.h'
144--- plugins/unityshell/src/LauncherController.h 2011-10-25 16:04:01 +0000
145+++ plugins/unityshell/src/LauncherController.h 2011-11-30 03:10:29 +0000
146@@ -52,6 +52,8 @@
147 void PrimaryMonitorGeometryChanged(nux::Geometry const& geo);
148 void PushToFront();
149
150+ void SetShowDesktopIcon(bool show_desktop_icon);
151+
152 private:
153 class Impl;
154 Impl* pimpl;
155
156=== modified file 'plugins/unityshell/src/unityshell.cpp'
157--- plugins/unityshell/src/unityshell.cpp 2011-11-22 11:58:34 +0000
158+++ plugins/unityshell/src/unityshell.cpp 2011-11-30 03:10:29 +0000
159@@ -244,6 +244,7 @@
160 optionSetAutohideAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
161 optionSetDashBlurExperimentalNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
162 optionSetDevicesOptionNotify(boost::bind (&UnityScreen::optionChanged, this, _1, _2));
163+ optionSetShowDesktopIconNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
164 optionSetShowLauncherInitiate(boost::bind(&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3));
165 optionSetShowLauncherTerminate(boost::bind(&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3));
166 optionSetKeyboardFocusInitiate(boost::bind(&UnityScreen::setKeyboardFocusKeyInitiate, this, _1, _2, _3));
167@@ -2073,6 +2074,9 @@
168 screen->enterShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ());
169 screen->leaveShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ());
170 break;
171+ case UnityshellOptions::ShowDesktopIcon:
172+ launcher_controller_->SetShowDesktopIcon(optionGetShowDesktopIcon());
173+ break;
174 default:
175 break;
176 }
177
178=== modified file 'plugins/unityshell/unityshell.xml.in'
179--- plugins/unityshell/unityshell.xml.in 2011-10-26 05:41:45 +0000
180+++ plugins/unityshell/unityshell.xml.in 2011-11-30 03:10:29 +0000
181@@ -337,6 +337,12 @@
182 </desc>
183 </option>
184
185+ <option name="show_desktop_icon" type="bool">
186+ <_short>Show "Desktop Icon" in the launcher</_short>
187+ <_long>Enable/Disable "Show Dekstop icon" in the launcher.</_long>
188+ <default>false</default>
189+ </option>
190+
191 </group>
192 </options>
193 </plugin>