Merge lp:~ruben-verweij/unity/fix-677594-workspaces into lp:unity

Proposed by Ruben Verweij
Status: Merged
Merged at revision: 860
Proposed branch: lp:~ruben-verweij/unity/fix-677594-workspaces
Merge into: lp:unity
Diff against target: 137 lines (+63/-13)
4 files modified
src/LauncherController.cpp (+36/-13)
src/LauncherController.h (+4/-0)
src/unityshell.cpp (+18/-0)
src/unityshell.h (+5/-0)
To merge this branch: bzr merge lp:~ruben-verweij/unity/fix-677594-workspaces
Reviewer Review Type Date Requested Status
David Barth (community) Approve
Jason Smith (community) Approve
Ruben Verweij (community) Needs Resubmitting
Alex Launi (community) Needs Fixing
Neil J. Patel Pending
Review via email: mp+43280@code.launchpad.net

This proposal supersedes a proposal from 2010-12-08.

Description of the change

Thanks for your quick reply and feedback!
I have updated the code as you have suggested, but I can't test it.
I am running Natty, how do I compile "my version" of Unity and run it to test whether it works?
Thanks again for your help!

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Hi,

You don't need to use gconf to do this, you can just ask compiz directly for the number of workspaces with screen->vpSize ().width ();

Also if you want to be notified when this number changes you can implement a

bool
UnityScreen::setOptionForPlugin (const char *plugin, const char *name, CompOption::Value &v) and make sure that UnityScreen inherits ScreenInterface (and that we call ScreenInterface::setHandler (screen) in the UnityScreen construtor) and then check for plugin == "core" and name == "hsize" and react on that change.

See git.compiz.org/compiz/core/plugins/cube/src/cube.cpp:1622 for some ideas on this.

Remind me that this method is full of suck and I need to change it.

Revision history for this message
Neil J. Patel (njpatel) wrote : Posted in a previous version of this proposal

As per sams comment

review: Needs Fixing
Revision history for this message
Alex Launi (alexlauni) wrote :

Thanks for updating. You have conflicts in this branch though.
152 +>>>>>>> MERGE-SOURCE

That will cause the code to fail to compile.
There are instructions for building Unity from source available at https://wiki.ubuntu.com/Unity/InstallationGuideFromSource

review: Needs Fixing
Revision history for this message
Ruben Verweij (ruben-verweij) wrote :

Okay, I have resolved the conflicts and I hope it works now.

review: Needs Resubmitting
Revision history for this message
Alex Launi (alexlauni) wrote :

Looks good but before we merge it we need you to sign the Canonical contributer agreement. It's a quick, but necessary step to getting your code into the tree. Luckily you only need to sign it once and it will apply to all other Canonical project contributions you may make in the future. http://www.canonical.com/contributors Make sure to CC David Barth when you send it in.

Revision history for this message
Ruben Verweij (ruben-verweij) wrote :

Okay, it's done. Thanks for your help!

-----Original Message-----
From: Alex Launi <email address hidden>
Reply-to: <email address hidden>
To: <email address hidden>
Subject: Re: [Merge] lp:~ruben-verweij/unity/fix-677594-workspaces into
lp:unity
Date: Fri, 11 Feb 2011 19:01:24 -0000

Looks good but before we merge it we need you to sign the Canonical contributer agreement. It's a quick, but necessary step to getting your code into the tree. Luckily you only need to sign it once and it will apply to all other Canonical project contributions you may make in the future. http://www.canonical.com/contributors Make sure to CC David Barth when you send it in.

Revision history for this message
Jason Smith (jassmith) wrote :

This patch leaks the Expo Icon every time the workspaces are turned off and back on

review: Needs Fixing
Revision history for this message
Jason Smith (jassmith) wrote :

I revoke my previous comment, I was wrong. +1 to merge.

review: Approve
Revision history for this message
David Barth (dbarth) wrote :

Ruben completed the (c) assignment process.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/LauncherController.cpp'
--- src/LauncherController.cpp 2011-02-10 01:18:16 +0000
+++ src/LauncherController.cpp 2011-02-10 21:57:02 +0000
@@ -47,7 +47,11 @@
47 _device_section = new DeviceLauncherSection (_launcher);47 _device_section = new DeviceLauncherSection (_launcher);
48 _device_section->IconAdded.connect (sigc::mem_fun (this, &LauncherController::OnIconAdded));48 _device_section->IconAdded.connect (sigc::mem_fun (this, &LauncherController::OnIconAdded));
4949
50 InsertExpoAction ();50 _num_workspaces = _screen->vpSize ().width ();
51 if(_num_workspaces > 1)
52 {
53 InsertExpoAction ();
54 }
51 InsertTrash ();55 InsertTrash ();
5256
53 g_timeout_add (500, (GSourceFunc) &LauncherController::BamfTimerCallback, this);57 g_timeout_add (500, (GSourceFunc) &LauncherController::BamfTimerCallback, this);
@@ -159,21 +163,40 @@
159 RegisterIcon (icon);163 RegisterIcon (icon);
160}164}
161165
166LauncherController::UpdateNumWorkspaces (int workspaces)
167{
168 if ((_num_workspaces == 0) && (workspaces > 0))
169 {
170 InsertExpoAction ();
171 }
172 else if((_num_workspaces > 0) && (workspaces == 0))
173 {
174 RemoveExpoAction ();
175 }
176
177 _num_workspaces = workspaces;
178}
179
162void180void
163LauncherController::InsertExpoAction ()181LauncherController::InsertExpoAction ()
164{182{
165 SimpleLauncherIcon *expoIcon;183 _expoIcon = new SimpleLauncherIcon (_launcher);
166 expoIcon = new SimpleLauncherIcon (_launcher);184
167 185 _expoIcon->SetTooltipText (_("Workspace Switcher"));
168 expoIcon->SetTooltipText (_("Workspace Switcher"));186 _expoIcon->SetIconName ("workspace-switcher");
169 expoIcon->SetIconName ("workspace-switcher");187 _expoIcon->SetQuirk (LauncherIcon::QUIRK_VISIBLE, true);
170 expoIcon->SetQuirk (LauncherIcon::QUIRK_VISIBLE, true);188 _expoIcon->SetQuirk (LauncherIcon::QUIRK_RUNNING, false);
171 expoIcon->SetQuirk (LauncherIcon::QUIRK_RUNNING, false);189 _expoIcon->SetIconType (LauncherIcon::TYPE_EXPO);
172 expoIcon->SetIconType (LauncherIcon::TYPE_EXPO);190
173 191 _expoIcon->MouseClick.connect (sigc::mem_fun (this, &LauncherController::OnExpoClicked));
174 expoIcon->MouseClick.connect (sigc::mem_fun (this, &LauncherController::OnExpoClicked));192
175 193 RegisterIcon (_expoIcon);
176 RegisterIcon (expoIcon);194}
195
196void
197LauncherController::RemoveExpoAction ()
198{
199 _model->RemoveIcon (__expoIcon);
177}200}
178201
179void202void
180203
=== modified file 'src/LauncherController.h'
--- src/LauncherController.h 2011-02-09 07:58:39 +0000
+++ src/LauncherController.h 2011-02-10 21:57:02 +0000
@@ -61,6 +61,8 @@
61 PlaceLauncherSection* _place_section;61 PlaceLauncherSection* _place_section;
62 DeviceLauncherSection* _device_section;62 DeviceLauncherSection* _device_section;
63 LauncherEntryRemoteModel* _remote_model;63 LauncherEntryRemoteModel* _remote_model;
64 SimpleLauncherIcon* _expoIcon;
65 int _num_workspaces;
6466
65 void SortAndSave ();67 void SortAndSave ();
6668
@@ -71,7 +73,9 @@
71 void OnLauncerEntryRemoteAdded (LauncherEntryRemote *entry);73 void OnLauncerEntryRemoteAdded (LauncherEntryRemote *entry);
72 void OnLauncerEntryRemoteRemoved (LauncherEntryRemote *entry);74 void OnLauncerEntryRemoteRemoved (LauncherEntryRemote *entry);
7375
76 void UpdateNumWorkspaces (int workspaces);
74 void InsertExpoAction ();77 void InsertExpoAction ();
78 void RemoveExpoAction ();
75 79
76 void InsertTrash ();80 void InsertTrash ();
7781
7882
=== modified file 'src/unityshell.cpp'
--- src/unityshell.cpp 2011-02-09 21:00:00 +0000
+++ src/unityshell.cpp 2011-02-10 21:57:02 +0000
@@ -478,6 +478,24 @@
478 }478 }
479}479}
480480
481/* Handle changes in the number of workspaces by showing the switcher
482 * or not showing the switcher */
483bool
484UnityScreen::setOptionForPlugin(const char *plugin, const char *name,
485 CompOption::Value &v)
486{
487 bool status;
488 status = screen->setOptionForPlugin (plugin, name, v);
489 if (status)
490 {
491 if (strcmp (plugin, "core") == 0 && strcmp (name, "hsize") == 0)
492 {
493 controller->UpdateNumWorkspaces(screen->vpSize ().width ());
494 }
495 }
496 return status;
497}
498
481static gboolean499static gboolean
482write_logger_data_to_disk (gpointer data)500write_logger_data_to_disk (gpointer data)
483{501{
484502
=== modified file 'src/unityshell.h'
--- src/unityshell.h 2011-02-03 16:14:23 +0000
+++ src/unityshell.h 2011-02-10 21:57:02 +0000
@@ -111,6 +111,11 @@
111 /* handle option changes and change settings inside of the111 /* handle option changes and change settings inside of the
112 * panel and dock views */112 * panel and dock views */
113 void optionChanged (CompOption *, Options num);113 void optionChanged (CompOption *, Options num);
114
115 /* Handle changes in the number of workspaces by showing the switcher
116 * or not showing the switcher */
117 bool setOptionForPlugin(const char *plugin, const char *name,
118 CompOption::Value &v);
114119
115 /* init plugin actions for screen */120 /* init plugin actions for screen */
116 bool initPluginForScreen (CompPlugin *p);121 bool initPluginForScreen (CompPlugin *p);