Merge lp://staging/~3v1n0/unity/indicators-p into lp://staging/unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2132
Proposed branch: lp://staging/~3v1n0/unity/indicators-p
Merge into: lp://staging/unity
Diff against target: 2730 lines (+1212/-342)
31 files modified
CMakeLists.txt (+1/-1)
UnityCore/AppmenuIndicator.cpp (+37/-0)
UnityCore/AppmenuIndicator.h (+45/-0)
UnityCore/CMakeLists.txt (+2/-0)
UnityCore/DBusIndicators.cpp (+87/-38)
UnityCore/DBusIndicators.h (+5/-2)
UnityCore/Indicator.cpp (+31/-11)
UnityCore/Indicator.h (+11/-7)
UnityCore/IndicatorEntry.cpp (+29/-24)
UnityCore/IndicatorEntry.h (+12/-7)
UnityCore/Indicators.cpp (+28/-7)
UnityCore/Indicators.h (+31/-10)
plugins/unityshell/src/PanelIndicatorEntryView.cpp (+21/-7)
plugins/unityshell/src/PanelIndicatorEntryView.h (+1/-0)
plugins/unityshell/src/PanelIndicatorsView.cpp (+1/-1)
plugins/unityshell/src/PanelIndicatorsView.h (+1/-1)
plugins/unityshell/src/PanelView.cpp (+6/-5)
plugins/unityshell/src/PanelView.h (+3/-3)
services/CMakeLists.txt (+1/-1)
services/panel-indicator-entry-accessible.c (+2/-1)
services/panel-main.c (+33/-10)
services/panel-marshal.list (+1/-0)
services/panel-root-accessible.c (+5/-5)
services/panel-service.c (+410/-165)
services/panel-service.h (+11/-4)
tests/CMakeLists.txt (+15/-2)
tests/test_indicator.cpp (+207/-0)
tests/test_indicator_appmenu.cpp (+66/-0)
tests/test_indicator_entry.cpp (+99/-22)
tests/unit/TestMain.cpp (+4/-4)
tests/unit/TestPanelService.cpp (+6/-4)
To merge this branch: bzr merge lp://staging/~3v1n0/unity/indicators-p
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Tim Penhey (community) Approve
Andrea Azzarone (community) Approve
Michal Hruby (community) Approve
Review via email: mp+96862@code.staging.launchpad.net

Commit message

Updated unity-panel-service and libunity-core against the libindicator API changes

Description of the change

Updated unity-panel-service and libunity-core against the libindicator API changes

Supporting the new libindicator API into unity-panel-service and exposing them in the higher level wrapper library for future usage.
Doing this, I've performed some cleanup of the code, and in particular I've:
 - Introduced the new AppmenuIndicator class to handle the appmenu indicator
   (typing it differently allows us to remove the type-checking based only on the
   indicator name, this is something we should keep at lower level).
 - Fixed an issue in Indicator class, that didn't disconnect from signals of the removed
   entries
 - Removed the IsUnused / MarkUnused methods from IndicatorEntry, since they were
   already deprecated since last cycle and actually useless. The visible() method can
   now be used to perform a similar check.
 - Removed the sscanf based matching from the panel-service.

On the unity-panel-service side I've also fixed two issues:
 - When the menus are open now they are moved to the right position if their
   entry has been moved (this happens when scrolling on the language selector).
 - It is now synced with the compiz gsetting key used to define which keybinding
   must be used to open the menus (so now, changing that value applies to both
   opening and closing the indicators, not only to the open action).

On the Tests side, I've re-enabled and updated the panel-service unit-test, that now is working again, plus I've added new tests for the Indicator and AppmenuIndicator classes and updated the tests for IndicatorEntry against the new API.
Some more tests are covered on the lp:~3v1n0/unity/indicators-tests dependent branch.

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

202 + // We have to do this because on certain systems X won't have time to
203 + // respond to our request for XUngrabPointer and this will cause the
204 + // menu not to show
205 + auto data = new ShowEntryData();

Can we use a smart pointer for this please? Once you use a smart pointer you won't need this:

279 + delete data;

...and there's a larger design issue around how we create Indicator instances. This code:

671 - Indicator::Ptr indicator(new Indicator(name));
672 + Indicator* indptr;
673 +
674 + if (name == "libappmenu.so")
675 + indptr = new AppmenuIndicator(name);
676 + else
677 + indptr = new Indicator(name);
678 +
679 + Indicator::Ptr indicator(indptr);

Makes me uneasy - especially this bit:

685 +
686 + if (indicator->IsAppmenu())
687 + {
688 + AppmenuIndicator *appmenu = dynamic_cast<AppmenuIndicator*>(indicator.get());
689 +
690 + if (appmenu)
691 + appmenu->on_show_appmenu.connect(sigc::mem_fun(owner_, &Indicators::OnShowAppMenu));
692 + }
693 +

Why are we using a boolean member variable to encode class type? Maybe I'm missing something, but why not just do this:

AppmenuIndicator *appmenu = dynamic_cast<AppmenuIndicator*>(indicator.get());

if (appmenu)
    appmenu->on_show_appmenu.connect(sigc::mem_fun(owner_, &Indicators::OnShowAppMenu));

..or even better, hook up the signal for all indicators, and have child classes that don't need the signal simply not use it.

This is wrong:

818 + return proxy_->id().c_str();

The method returns a std::string, so you don't need the ".c_str" on the end.

These:

1127 +#define COMPIZ_OPTIONS_PATH "/apps/compiz-1/plugins/unityshell/screen0/options"
1128 +#define MENU_TOGGLE_KEYBINDING_PATH COMPIZ_OPTIONS_PATH"/panel_first_menu"

Don't need to be #defines - nor do the three #defines right above them.

In panel-service.c, I'm 99% sure there's a memory leak on line 829, where we do this:

  gchar *entry_id = get_indicator_entry_id_by_entry (entry);
  g_hash_table_insert (self->priv->id2entry_hash, entry_id, entry);

entry_id needs to be freed.

The points above need to be fixed. You should also get someone else to look at this (someone who understands the panel code).

Cheers,

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> 202 + // We have to do this because on certain systems X won't have time
> to
> 203 + // respond to our request for XUngrabPointer and this will cause the
> 204 + // menu not to show
> 205 + auto data = new ShowEntryData();
>
> Can we use a smart pointer for this please? Once you use a smart pointer you
> won't need this:
>
> 279 + delete data;

Mh, I didn't used these, not to change too much the pre-existent code.

> ...and there's a larger design issue around how we create Indicator instances.
> This code:
>
> 671 - Indicator::Ptr indicator(new Indicator(name));
> 672 + Indicator* indptr;
> 673 +
> 674 + if (name == "libappmenu.so")
> 675 + indptr = new AppmenuIndicator(name);
> 676 + else
> 677 + indptr = new Indicator(name);
> 678 +
> 679 + Indicator::Ptr indicator(indptr);
>
> Makes me uneasy - especially this bit:
>
> 685 +
> 686 + if (indicator->IsAppmenu())
> 687 + {
> 688 + AppmenuIndicator *appmenu =
> dynamic_cast<AppmenuIndicator*>(indicator.get());
> 689 +
> 690 + if (appmenu)
> 691 + appmenu->on_show_appmenu.connect(sigc::mem_fun(owner_,
> &Indicators::OnShowAppMenu));
> 692 + }
> 693 +
>
> Why are we using a boolean member variable to encode class type? Maybe I'm
> missing something, but why not just do this:
>
> AppmenuIndicator *appmenu = dynamic_cast<AppmenuIndicator*>(indicator.get());

Using that bool check is faster than doing an unneeded dymamic_cast (actually we could even use just a static_cast there). And currently we only have two kinds of indicators that we must care of, standard indicators and appmenu indicators. Maybe we could use a GetType or something...

> if (appmenu)
> appmenu->on_show_appmenu.connect(sigc::mem_fun(owner_,
> &Indicators::OnShowAppMenu));
>
> ..or even better, hook up the signal for all indicators, and have child
> classes that don't need the signal simply not use it.

Mh, I don't like too much the idea of adding a signal that is not related to all the indicators to the Indicator class. Also because that class will be filled with some other stuff soon, and I don't want to repeat them in the base class...

> This is wrong:
>
> 818 + return proxy_->id().c_str();
>
> The method returns a std::string, so you don't need the ".c_str" on the end.

True. The mistake was already there, but I didn't notice it. Thanks.

> These:
>
> 1127 +#define COMPIZ_OPTIONS_PATH
> "/apps/compiz-1/plugins/unityshell/screen0/options"
> 1128 +#define MENU_TOGGLE_KEYBINDING_PATH
> COMPIZ_OPTIONS_PATH"/panel_first_menu"
>
> Don't need to be #defines - nor do the three #defines right above them.

Mh... In a C scope they don't look so bad... Also I should repeat some strings without them.

> In panel-service.c, I'm 99% sure there's a memory leak on line 829, where we
> do this:
>
> gchar *entry_id = get_indicator_entry_id_by_entry (entry);
> g_hash_table_insert (self->priv->id2entry_hash, entry_id, entry);
>
> entry_id needs to be freed.

Not really: http://developer.gnome.org/glib/2.29/glib-Hash-Tables.html#g-hash-table-insert :)

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> > This is wrong:
> >
> > 818 + return proxy_->id().c_str();
> >
> > The method returns a std::string, so you don't need the ".c_str" on the end.
>
> True. The mistake was already there, but I didn't notice it. Thanks.

Ah, actually I already fixed in another branch... I put the fix here too.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

671 - Indicator::Ptr indicator(new Indicator(name));
672 + Indicator* indptr;
673 +
674 + if (name == "libappmenu.so")
675 + indptr = new AppmenuIndicator(name);
676 + else
677 + indptr = new Indicator(name);
678 +
679 + Indicator::Ptr indicator(indptr);

It's a kind of object factory, for me it's ok.

685 +
686 + if (indicator->IsAppmenu())
687 + {
688 + AppmenuIndicator *appmenu = dynamic_cast<AppmenuIndicator*>(indicator.get());
689 +
690 + if (appmenu)
691 + appmenu->on_show_appmenu.connect(sigc::mem_fun(owner_, &Indicators::OnShowAppMenu));
692 + }
693 +

If you can remove this please do... :) Otherwise it's ok for me.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> 685 +
> 686 + if (indicator->IsAppmenu())
> 687 + {
> 688 + AppmenuIndicator *appmenu =
> dynamic_cast<AppmenuIndicator*>(indicator.get());
> 689 +
> 690 + if (appmenu)
> 691 + appmenu->on_show_appmenu.connect(sigc::mem_fun(owner_,
> &Indicators::OnShowAppMenu));
> 692 + }
> 693 +
>
> If you can remove this please do... :) Otherwise it's ok for me.

Yes, done. It was possible to get that before as well, but I didn't like to connect to the appmenu specific signal before than the others :)

Revision history for this message
Michal Hruby (mhr3) wrote :

183 data->proxy = proxy_;

Makes me sad that it doesn't use the dbus proxy class from unity core.

194 + g_idle_add_full (G_PRIORITY_DEFAULT, (GSourceFunc) send_show_entry, data, NULL);

Moreover this is pretty dangerous, it should at least grab a ref on the proxy. Alternatively such timeouts should be removed in the destructor.

1114 +#include <fcntl.h>

I hope this isn't needed?

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> 183 data->proxy = proxy_;
>
> Makes me sad that it doesn't use the dbus proxy class from unity core.

Yes, you're right.
Unfortunately that code was written before it was available I guess, so I just didn't rewrite the whole thing.
I see if that's quickly feasible ;)

> 194 + g_idle_add_full (G_PRIORITY_DEFAULT, (GSourceFunc) send_show_entry,
> data, NULL);
>
> Moreover this is pretty dangerous, it should at least grab a ref on the proxy.
> Alternatively such timeouts should be removed in the destructor.

Sure, again... I just followed the old school! :)

> 1114 +#include <fcntl.h>
>
> I hope this isn't needed?

Yes, no more needed. /me cleaning it.

Revision history for this message
Michal Hruby (mhr3) wrote :

> DBusIndicators: use glib::Object to handle the dbus proxy, so we have ref-counting for free

So much nicer, thx!

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve
Revision history for this message
Tim Penhey (thumper) wrote :

Gah... I was wanting to work out how to remove the IsAppmenu bit, but since the cure is worse than the symptoms, I'm prepared to accept it.

review: Approve
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity failed due to conflicts:

text conflict in CMakeLists.txt
text conflict in plugins/unityshell/src/PanelIndicatorEntryView.cpp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.