After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740574 - [review] dcbw/indicator-cleanups: code consolidation and addition of composite icon support for indicators
[review] dcbw/indicator-cleanups: code consolidation and addition of composit...
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: nm-applet
git master
Other Linux
: Normal normal
: ---
Assigned To: Dan Williams
NetworkManager maintainer(s)
Depends on:
Blocks: nm-review nm-1-2
 
 
Reported: 2014-11-23 14:02 UTC by Pavel Simerda
Modified: 2016-03-18 14:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-use-hash-table-for-icon-caching.patch (20.52 KB, patch)
2014-11-24 23:46 UTC, Pavel Simerda
none Details | Review
0002-return-icon-name-from-get_icon-whenever-possible.patch (31.02 KB, patch)
2014-11-24 23:47 UTC, Pavel Simerda
none Details | Review
0003-indicator-add-support-for-enable-indicator.patch (31.95 KB, patch)
2014-11-24 23:47 UTC, Pavel Simerda
none Details | Review
0004-indicator-add-device-specific-icon-code.patch (15.90 KB, patch)
2014-11-24 23:51 UTC, Pavel Simerda
none Details | Review
0001-use-hash-table-for-icon-caching.patch (20.66 KB, patch)
2014-11-25 20:29 UTC, Pavel Simerda
committed Details | Review
0002-remove-pos-from-applet_menu_item_add_complex_separat.patch (10.32 KB, patch)
2014-11-25 20:29 UTC, Pavel Simerda
committed Details | Review
0003-return-icon-name-from-get_icon-whenever-possible.patch (32.69 KB, patch)
2014-11-25 20:29 UTC, Pavel Simerda
none Details | Review
0004-indicator-add-support-for-enable-indicator.patch (28.55 KB, patch)
2014-11-25 20:30 UTC, Pavel Simerda
none Details | Review
0005-indicator-add-device-specific-icon-code.patch (15.92 KB, patch)
2014-11-25 20:30 UTC, Pavel Simerda
none Details | Review
this is what I changed (1.10 KB, patch)
2014-12-08 23:01 UTC, Pavel Simerda
none Details | Review
0001-return-icon-name-from-get_icon-whenever-possible.patch (32.85 KB, patch)
2014-12-08 23:02 UTC, Pavel Simerda
none Details | Review
0001-return-icon-name-from-get_icon-whenever-possible.patch (33.47 KB, patch)
2014-12-08 23:08 UTC, Pavel Simerda
none Details | Review
0001-fixup-return-icon-name-from-get_icon-whenever-possib.patch (3.02 KB, patch)
2014-12-12 18:26 UTC, Dan Williams
none Details | Review
0001-return-icon-name-from-get_icon-whenever-possible.patch (32.98 KB, patch)
2014-12-16 23:01 UTC, Pavel Simerda
none Details | Review
0002-indicator-add-support-for-enable-indicator.patch (28.37 KB, patch)
2014-12-16 23:24 UTC, Pavel Simerda
none Details | Review
0003-indicator-add-device-specific-icon-code.patch (15.87 KB, patch)
2014-12-16 23:26 UTC, Pavel Simerda
none Details | Review
fixup for attachment 292861 (2.78 KB, patch)
2014-12-17 11:16 UTC, Thomas Haller
none Details | Review
fixup for attachment 292862 (2.90 KB, text/x-c++)
2014-12-17 11:17 UTC, Thomas Haller
  Details
fixup for attachment 292863 (1.22 KB, patch)
2014-12-17 11:17 UTC, Thomas Haller
none Details | Review
fixup for attachment 292862 (1.36 KB, patch)
2014-12-17 11:43 UTC, Thomas Haller
none Details | Review
Screenshot of dcbw/indicator with GNOME Shell appindicator extension (44.33 KB, image/png)
2015-02-17 14:42 UTC, Dan Williams
  Details
screenshot of missing connection connection (14.69 KB, image/png)
2016-03-16 10:05 UTC, Thomas Haller
  Details

Description Pavel Simerda 2014-11-23 14:02:18 UTC
As far as I understand, at least Unity, KDE and Enlightenment are moving away from old Xembed based systray API and the preferred way to support all of those is to use the appindicator API, possibly via libappindicator library.

I was curious how it's possible that we don't support it yet even though Unity is reported not to support the old way any more. I realized Ubuntu is using a patch that won't easily apply to the current master and even when adapted, won't work as expected (i.e. won't build without appindicator support).

I adapted the patch to the current master, fixed a lot of problems and split it into a couple of patches. Will attach them to the bug report.
Comment 1 Pavel Simerda 2014-11-23 20:08:08 UTC
Just found a mailing list discussion on the previous attempt to include this in nm-applet. Pity it was never actually done.

https://mail.gnome.org/archives/networkmanager-list/2011-March/msg00030.html
Comment 2 Pavel Simerda 2014-11-24 23:46:25 UTC
Created attachment 291425 [details] [review]
0001-use-hash-table-for-icon-caching.patch
Comment 3 Pavel Simerda 2014-11-24 23:47:10 UTC
Created attachment 291426 [details] [review]
0002-return-icon-name-from-get_icon-whenever-possible.patch
Comment 4 Pavel Simerda 2014-11-24 23:47:50 UTC
Created attachment 291427 [details] [review]
0003-indicator-add-support-for-enable-indicator.patch
Comment 5 Pavel Simerda 2014-11-24 23:51:40 UTC
Created attachment 291428 [details] [review]
0004-indicator-add-device-specific-icon-code.patch

This is what I have. It's a substantially reworked version of the latest Ubuntu patch (I can't find a link right now).
Comment 6 Pavel Simerda 2014-11-24 23:52:39 UTC
First reviews welcome. This will probably take a bit longer, I expect a lot of issues and improvements.
Comment 8 Pavel Simerda 2014-11-25 11:15:22 UTC
Posponing review. There are two things I want to change. First of all --disable-indicator won't work now, second, there are many things in the indicator patch that could go to the previous patch, actually.
Comment 9 Pavel Simerda 2014-11-25 20:29:00 UTC
Created attachment 291494 [details] [review]
0001-use-hash-table-for-icon-caching.patch
Comment 10 Pavel Simerda 2014-11-25 20:29:34 UTC
Created attachment 291495 [details] [review]
0002-remove-pos-from-applet_menu_item_add_complex_separat.patch
Comment 11 Pavel Simerda 2014-11-25 20:29:51 UTC
Created attachment 291496 [details] [review]
0003-return-icon-name-from-get_icon-whenever-possible.patch
Comment 12 Pavel Simerda 2014-11-25 20:30:12 UTC
Created attachment 291497 [details] [review]
0004-indicator-add-support-for-enable-indicator.patch
Comment 13 Pavel Simerda 2014-11-25 20:30:33 UTC
Created attachment 291498 [details] [review]
0005-indicator-add-device-specific-icon-code.patch
Comment 14 Pavel Simerda 2014-11-25 20:33:01 UTC
(In reply to comment #8)
> First of all --disable-indicator won't work now,

Fixed.

> second, there are many things in the indicator patch that could go to the previous patch, actually.

Reworked.

The resulting patchset still doesn't work great with --enable-indicator but I would still like to get reviewed and merged at least the first three patches and I'll be happy for comments on the last two as well.
Comment 15 Thomas Haller 2014-12-01 15:18:59 UTC
>> use hash table for icon caching

in nma_icon_check_and_load():

-         return applet->fallback_icon;
+         icon = g_object_ref (applet->fallback_icon);
      }

once we fail to load the ion, add the fallback to the hash table.


Minor complaint: nma_icon_check_and_load() should have a name like "applet_icon_*()", and @applet should be the first parameter. So that it has the look of being a method of "NMApplet".

But this is already pre-existing, so feel free not to do that...



>> return icon name from get_icon() whenever possible

bond_get_icon() and related might not set the out-arguments.
Also, they require the out-args to be not NULL, while applet_get_device_icon_for_state() allows for missing arguments.

I think applet_get_device_icon_for_state() should resolve this by ensuring out-args are always set (to NULL) and passing a dummy argument to dclass->get_icon() in case the caller passed NULL.


> indicator: add support for --enable-indicator

+#ifdef ENABLE_INDICATOR
+    if (app_indicator_get_status (applet->app_indicator) == APP_INDICATOR_STATUS_PASSIVE)
+#endif
     if (!gtk_status_icon_is_embedded (applet->status_icon))

this looks wrong. Add Braces and fix indention?
Comment 16 Pavel Simerda 2014-12-02 14:26:21 UTC
(In reply to comment #15)
> >> use hash table for icon caching
> 
> in nma_icon_check_and_load():
> 
> -         return applet->fallback_icon;
> +         icon = g_object_ref (applet->fallback_icon);
>       }
> 
> once we fail to load the ion, add the fallback to the hash table.

As you wish. The original code seemed to retry each time but I agree that it's not useful.

> Minor complaint: nma_icon_check_and_load() should have a name like
> "applet_icon_*()",

I definitely agree, I didn't want to change the name without feedback from the upstream, though. Let's agree on some name. I propose `applet_icon()` or `applet_get_icon()`. The API is there to retrieve an icon by name, the checking, loading and caching are implementation details.

> and @applet should be the first parameter. So that it has
> the look of being a method of "NMApplet".

I'll handle this once we have a final name.

> But this is already pre-existing, so feel free not to do that...

I'll be happy to improve nm-applet as you instruct ;).

> >> return icon name from get_icon() whenever possible
> 
> bond_get_icon() and related might not set the out-arguments.

The purpose is to keep all common code in `applet_get_device_icon_for_state()`. Let's talk about that function instead.

> Also, they require the out-args to be not NULL, while
> applet_get_device_icon_for_state() allows for missing arguments.

I was actually trying to make it effective. We might want to talk on IRC on how exactly this should be improved.

> I think applet_get_device_icon_for_state() should resolve this by ensuring
> out-args are always set (to NULL) and passing a dummy argument to
> dclass->get_icon() in case the caller passed NULL.

Basically yes, let's talk about the details off bugzilla.

> > indicator: add support for --enable-indicator
> 
> +#ifdef ENABLE_INDICATOR
> +    if (app_indicator_get_status (applet->app_indicator) ==
> APP_INDICATOR_STATUS_PASSIVE)
> +#endif
>      if (!gtk_status_icon_is_embedded (applet->status_icon))
> 
> this looks wrong. Add Braces and fix indention?

It's the easiest way to write it. With braces, you will have two ifdefs or you will have to duplicate the second if. Feel free to decide on the preferred way.
Comment 17 Dan Williams 2014-12-05 18:05:51 UTC
I'm happy with "applet_get_icon()".  That can be a follow-up patch though.

I think the original code retried each time to ensure it picked up new icons on theme changes, and to ensure that we didn't get broken icons in the cache forever because something (package manager) was writing new ones to disk when a theme change happened.  Or something like that.  Happy to drop that part now since this seems unlikely.
Comment 18 Dan Williams 2014-12-05 18:06:55 UTC
Also, if you wouldn't mind updating the commit message shortlog with the "applet: " prefix that would be great.
Comment 19 Dan Williams 2014-12-05 18:54:55 UTC
The first two are uncontroversial, I have pushed them:

9e037ec34ee6efabbdb7cede0a5b95d995a602bb
applet: use hash table for icon caching

995b6800661948c4f6760641effdee924f40c440
applet: remove pos from applet_menu_item_add_complex_separator_helper()

The third (return icon name from get_icon() whenever possible) can probably be pushed very soon too, after some small fixups for thaller's comments.

I'd take a patch to rename nma_icon_check_and_load() too.
Comment 20 Dan Williams 2014-12-05 18:55:49 UTC
Comment on attachment 291495 [details] [review]
0002-remove-pos-from-applet_menu_item_add_complex_separat.patch

(pushed)
Comment 21 Pavel Simerda 2014-12-08 23:00:02 UTC
I'm sorry for delaying this, I made some heavy modifications and only then I realized that it's too much and was too tired already. So I restarted with just the minimal changes to get the patch in a shape...
Comment 22 Pavel Simerda 2014-12-08 23:01:39 UTC
Created attachment 292336 [details] [review]
this is what I changed
Comment 23 Pavel Simerda 2014-12-08 23:02:32 UTC
Created attachment 292337 [details] [review]
0001-return-icon-name-from-get_icon-whenever-possible.patch

And this is the new patch.
Comment 24 Pavel Simerda 2014-12-08 23:08:59 UTC
Created attachment 292338 [details] [review]
0001-return-icon-name-from-get_icon-whenever-possible.patch

Another improved version. We now rely on nm_icon_check_and_load() always returing a pixbuf or aborting. That's a reasonable requirement as that function already returns a fallback icon where appropriate and it simplifies the code substantially.
Comment 25 Pavel Simerda 2014-12-08 23:11:57 UTC
Also pushed the whole branch to:

https://github.com/pavlix/nm-applet
Comment 26 Dan Williams 2014-12-12 18:25:43 UTC
Review of attachment 292338 [details] [review]:

::: src/applet.c
@@ +2392,3 @@
+		case ICON_LAYER_VPN:
+			tip = g_string_new (applet->tip);
+

This seems a bit fragile, to use applet->tip to build the VPN bits.  Yeah, I know it gets set to the right thing by the first call of this function in applet_update_icon().  But it's depending on a side-effect of a previous call, and I think we can clean that up more.

How about instead move the tip code back to applet_update_icon(), but make it more explicit?  I'll attach a patch to show what I mean; I think it'll be a lot simpler.

@@ +2450,3 @@
+#else
+	gtk_status_icon_set_tooltip (applet->status_icon, applet->tip);
+#endif

The applet requires GTK3+ now, so we can just call tooltip_text()

@@ +2897,2 @@
 out:
+	applet_common_get_device_icon (state, out_pixbuf, out_icon_name, applet);

Shouldn't t here be a return or something in the 'if (dclass)' bits?  If not, then applet_common_get_device_icon() could overwrite the allocated values from the dclass->get_icon() bits.

@@ +3024,3 @@
+	foo_set_icon (applet, ICON_LAYER_VPN, pixbuf, icon_name, vpn_tip);
+	if (icon_name)
+		g_free (icon_name);

See my fixup patch for what I think is a simpler way to handle foo_set_icon() and the tooltips.
Comment 27 Dan Williams 2014-12-12 18:26:41 UTC
Created attachment 292625 [details] [review]
0001-fixup-return-icon-name-from-get_icon-whenever-possib.patch

A fixup patch for 0001-return-icon-name-from-get_icon-whenever-possible.patch that simplifies tooltip handling.
Comment 28 Pavel Simerda 2014-12-14 23:36:35 UTC
Are we ready to push if the fixup is applied?
Comment 29 Dan Williams 2014-12-16 17:20:54 UTC
(In reply to comment #28)
> Are we ready to push if the fixup is applied?

The fixup doesn't address this comment:

@@ +2897,2 @@
 out:
+    applet_common_get_device_icon (state, out_pixbuf, out_icon_name, applet);

Shouldn't t here be a return or something in the 'if (dclass)' bits?  If not,
then applet_common_get_device_icon() could overwrite the allocated values from
the dclass->get_icon() bits.

So that piece is still outstanding.  Once that's fixed up I think we can push.  If you can do that today/tomorrow then I think it can go in for 1.0.
Comment 30 Pavel Simerda 2014-12-16 23:01:48 UTC
Created attachment 292861 [details] [review]
0001-return-icon-name-from-get_icon-whenever-possible.patch

fixed and tested version of the first patch
Comment 31 Pavel Simerda 2014-12-16 23:24:31 UTC
Created attachment 292862 [details] [review]
0002-indicator-add-support-for-enable-indicator.patch

No change (apart from rebasing), just fixing the order.
Comment 32 Pavel Simerda 2014-12-16 23:26:33 UTC
Created attachment 292863 [details] [review]
0003-indicator-add-device-specific-icon-code.patch

Removed unintended change for the non-indicator mode.

Basically patches 0002 and 0003 don't affect indicator mode (unless I missed something else). The `applet_schedule_update_menu()` is a noop in non-indicator mode. Other changes are in #ifdef sections.
Comment 33 Thomas Haller 2014-12-17 11:16:42 UTC
Created attachment 292883 [details] [review]
fixup for attachment  292861 [details] [review]
Comment 34 Thomas Haller 2014-12-17 11:17:13 UTC
Created attachment 292884 [details]
fixup for attachment   292862 [details] [review]
Comment 35 Thomas Haller 2014-12-17 11:17:47 UTC
Created attachment 292885 [details] [review]
fixup for attachment  292863 [details] [review]
Comment 36 Thomas Haller 2014-12-17 11:43:44 UTC
Created attachment 292892 [details] [review]
fixup for attachment 292862 [details] [review]
Comment 37 Thomas Haller 2014-12-17 11:47:30 UTC
Attached 4 minor patches with fixups.



setup_widgets():

I pushed a fixup for this (with no functional change). But is it correct, that we execute *both* setup functions and then
  "return success || success_setup_indicator" ?

Maybe better:

+#ifdef ENABLE_INDICATOR
+    if (!setup_indicator_menu (applet))
+         return FALSE;
+#endif
+
+    return success;



I did not carefully review new parts with "#ifdef ENABLE_INDICATOR". I think it's new code, and looks good (certainly good enough for inclusion). If there happen to be issues, let's fix them later.

I cared more about changes to pre-existing code, which gets also fixed in the same patch. Would be nice to have them separate, because they seem to fix preexisting issues that might be worth backporting separately. Anyway, just talking generally. Don't bother now. I'm ok with how it is.



but for:
applet_connection_info_cb():
     menu = GTK_MENU_SHELL (gtk_menu_new ());
+    g_object_ref_sink (menu);
 

now we take an additional ref. Is this correct?



Overall, LGTM!
Comment 38 Pavel Simerda 2014-12-17 13:06:03 UTC
(In reply to comment #37)
> Attached 4 minor patches with fixups.
> 
> 
> 
> setup_widgets():
> 
> I pushed a fixup for this (with no functional change). But is it correct, that
> we execute *both* setup functions and then
>   "return success || success_setup_indicator" ?

It doesn't sound correct, I will look at it.

> I did not carefully review new parts with "#ifdef ENABLE_INDICATOR". I think
> it's new code, and looks good (certainly good enough for inclusion). If there
> happen to be issues, let's fix them later.

+1

> I cared more about changes to pre-existing code, which gets also fixed in the
> same patch. Would be nice to have them separate, because they seem to fix
> preexisting issues that might be worth backporting separately.

I will try to split the patches, accordingly just after lunch.

> but for:
> applet_connection_info_cb():
>      menu = GTK_MENU_SHELL (gtk_menu_new ());
> +    g_object_ref_sink (menu);
> 
> 
> now we take an additional ref. Is this correct?

Probably not. Removed.

Current version available at:

Repository: git@github.com:pavlix/nm-applet.git
Branch: indicator
Comment 39 Pavel Simerda 2014-12-17 16:38:39 UTC
Updated branch, split patches, improved setup_widgets. The appindicator part currently fails, will fixup the respective patch ASAP.
Comment 40 Pavel Simerda 2014-12-17 23:12:18 UTC
Updated branch, now nma_icons_init() is called only for non-indicator mode. Icon and menu is now shown also when built with libappindicator.
Comment 41 Thomas Haller 2015-01-06 15:22:56 UTC
>> trivial: use assert, not g_return_if_fail

usually I prefer g_return_*() over g_assert(). The former *is* effectively an assertion and must be fixed just the same. But it's a bit more forgiving in face of a bug. With this change, nma will dump core, while otherwise it might be able to limp away.

I would drop this patch.

(also, I would not call it "trivial")




I like all the other patches, now it's more easy to see that they add new code and leave existing code untouched.
Comment 42 Pavel Simerda 2015-01-06 15:57:37 UTC
(In reply to comment #41)
> >> trivial: use assert, not g_return_if_fail
> 
> usually I prefer g_return_*() over g_assert()

All of those are about the existence of the main object. It always exists. I wouldn't be afraid of dropping the assertions entirely. Using `g_return_*()` suggests that the caller should check the result for being NULL which means additional code that has no real function.

Feel free to drop the patch or keep it as you wish, though.

> I like all the other patches, now it's more easy to see that they add new code
> and leave existing code untouched.

Thanks! I don't have push access, so please get it pushed.
Comment 43 Pavel Simerda 2015-01-07 22:33:58 UTC
(In reply to comment #38)
> Repository: git@github.com:pavlix/nm-applet.git
> Branch: indicator

Removed the assertion patch.
Comment 44 Pavel Simerda 2015-01-09 18:15:07 UTC
Issues were found with nm-applet initialization, I will give it a bit more love and come back with an updated patchset.
Comment 45 Dan Williams 2015-01-10 01:56:02 UTC
> indicator: add device specific icon code

I'd actually rather just use the same code for indicator & non-indicator cases.  libdbusmenu removes pango markup, so we don't  need to bother stripping that out ourselves.

Second, GtkImageMenuItem is deprecated, so we should be using GtkMenuItem (which is a Bin) and packing an Box + Label + Image into the menu item instead.  However, libdbusmenu upstream doesn't support images like this, but only supports GtkImageMenuItem (which of course is deprecated).  libdbusmenu upstream should be updated to ensure that images can be used in normal GtkMenuItems.

I'm working on some adjustments to the menu itself, but could you provide a picture of what the appindicator version looks like when the icons show up?
Comment 46 Pavel Simerda 2015-01-13 14:25:29 UTC
By the way you can easily test the indicator code by building it with the correct parameters and running it from the source directory. If you don't have a system tray that supports it, you can use stalonetray.

    ./autogen.sh --prefix=/usr --sysconfdir=/etc --enable-indicator
    ./src/nm-applet
Comment 47 Pavel Simerda 2015-01-13 14:31:43 UTC
(In reply to comment #45)
> > indicator: add device specific icon code
> 
> I'd actually rather just use the same code for indicator & non-indicator cases.

Same here.

Just improving the patchset in small steps until it can get accepted and then would continue to improve the code further.

>  libdbusmenu removes pango markup, so we don't  need to bother stripping that
> out ourselves.

Any fixups?

> Second, GtkImageMenuItem is deprecated, so we should be using GtkMenuItem
> (which is a Bin) and packing an Box + Label + Image into the menu item instead.
>  However, libdbusmenu upstream doesn't support images like this, but only
> supports GtkImageMenuItem (which of course is deprecated).  libdbusmenu
> upstream should be updated to ensure that images can be used in normal
> GtkMenuItems.

For now I would live with what is there and just use a couple of ifdefs to keep support for libdbusmenu. I don't see a good reason to delay delivering the feature at least into the tree because of such minor issues.

So what is the plan?
Comment 48 Pavel Simerda 2015-01-15 15:40:20 UTC
(In reply to comment #43)
> (In reply to comment #38)
> > Repository: git@github.com:pavlix/nm-applet.git
> > Branch: indicator

New patchset pushed. Removed almost all warnings.

From my debugging it is clear that the conflicting registration comes from the same nm-applet instance.

How to test:

CFLAGS=-ggdb ./autogen.sh --prefix=/usr --sysconfdir=/etc --disable-migration --enable-indicator
make
./src/nm-applet --no-agent

Note: I'm using --disable-migration and --no-agent to avoid other warnings.

There is still the warning caused by repeated call to app_indicator_set_menu():

(nm-applet:15546): libappindicator-WARNING **: Unable to connect to the Notification Watcher: GDBus.Error:org.kde.StatusNotifierWatcher.Item.AlreadyRegistered

Trace back for the warning:

  • #0 g_logv
    from /usr/lib64/libglib-2.0.so.0
  • #1 g_log
    from /usr/lib64/libglib-2.0.so.0
  • #2 register_service_cb
    at app-indicator.c line 1396
  • #3 g_simple_async_result_complete
    from /usr/lib64/libgio-2.0.so.0
  • #4 ??
    from /usr/lib64/libgio-2.0.so.0
  • #5 g_simple_async_result_complete
    from /usr/lib64/libgio-2.0.so.0
  • #6 ??
    from /usr/lib64/libgio-2.0.so.0
  • #7 g_simple_async_result_complete
    from /usr/lib64/libgio-2.0.so.0
  • #8 ??
    from /usr/lib64/libgio-2.0.so.0
  • #9 g_main_context_dispatch
    from /usr/lib64/libglib-2.0.so.0
  • #10 ??
    from /usr/lib64/libglib-2.0.so.0
  • #11 g_main_loop_run
    from /usr/lib64/libglib-2.0.so.0
  • #12 main
    at main.c line 109

The systray implementation is Enlightenment git master. As I see it, the problem is either that libappindicator registers again when app_indicator_set_menu() gets called the second time, or Enlightenment doesn't handle the update.
Comment 49 Pavel Simerda 2015-02-07 21:41:31 UTC
Pushed an updated version, fixed non-indicator version, removed stuff that cause bug #744150. Will test in indicator mode later.
Comment 50 Pavel Simerda 2015-02-08 14:00:17 UTC
Added further fixes, split out some patches, removed some unrelated changes, changed --enable-indicatir to --with-appindicator (as in build with the libappindicator library). Tested appindicator mode a bit. 

af13a322ab31d575d5ff566ed96b9b9a00d6a130 applet: don't unref menu item widgets
a32f62746ad2ccf0848da50e6f1e2d30fd6702f6 applet: initialize nm-client before the widgets
ac0ac243fe1bdad06225e0f91cf43fd38fb636dd applet: simplify initialization and finalization
d53343d85400716364ffd89e3375e6914f31d8bc applet: return icon name from from applet_update_icon()
6e6c47c38e4711123d1e615e84e2f41535bd2570 applet: prepare for appindicator patch
45aed6b41223554b89963bb16c05bf6edfcffcab applet: add support for --with-appindicator

https://github.com/pavlix/nm-applet/commits/indicator

I'm starting to use the resulting code on a daily basis and it seems to work well. Please review and push to git master.
Comment 51 Pavel Simerda 2015-02-08 14:01:07 UTC
(In reply to comment #50)
> Please review and push to git master.

Except the last EXPERIMENTAL patch of course.
Comment 52 Pavel Simerda 2015-02-08 14:32:36 UTC
Some screenshots (enlightenment + nm-applet):

http://www.enlightenment.org/ss/e-54d7711cf392c9.17663480.jpg
http://www.enlightenment.org/ss/e-54d77194b036b3.97183338.jpg

Note there's still a warning (only for --with-appindicator) but I don't think it's caused by nm-applet.

(nm-applet:16980): libappindicator-WARNING **: Unable to connect to the Notification Watcher: GDBus.Error:org.kde.StatusNotifierWatcher.Item.AlreadyRegistered
Comment 53 Pavel Simerda 2015-02-15 12:30:11 UTC
Bump.
Comment 54 Dan Williams 2015-02-16 21:06:18 UTC
I pushed the first three patches since they are uncontroversial:

applet: don't unref menu item widgets
applet: initialize nm-client before the widgets
applet: simplify initialization and finalization
Comment 55 Pavel Simerda 2015-02-16 22:54:57 UTC
Thanks! Pushed a rebased version version (on github). On IRC we talked about the necessity to pass icon names instead of pixbufs. We also talked about using multiple stock icons for menu items where it makes sense.

We concluded that the resulting code is not perfect and that nm-applet appindicator support needs continued work. We didn't come to a conclusion as whether the continued work will happen after merging the rest of the patches or whether the patches should be modified.

You also pushed fixups to master. I'm still urging to get at least EXPERIMENTAL level of libappindicator support landed to git master ASAP. I promised to continue providing fixup/improvement patches after the appindicator support is in master.

Everyone: Please continue reviewing and testing!
Comment 56 Dan Williams 2015-02-17 05:49:54 UTC
Ok, please look at dcbw/indicator and see if the many modifications to "applet: add support for --with-appindicator" work for you.  In summary, they are:

1) move all indicator-specific stuff out of applet-device-* and into mb-menu-item.c and ap-menu-item.c

2) bring back composited icons in the menu, since dbusmenu and libappindicator supports this (tested in GNOME Shell with the appindicator extension, and yes they work)

3) removal of CFLAGS/LIBADD stuff from the gconf-helpers code, no reason they should be needed there

4) make the VPN submenu items always check-menu-items instead of ImageMenuItems, like the indicator version already does

5) remove some #ifdefs around gtk_widget_show() which shouldn't hurt the non-indicator case

What I wasn't really happy about, and apparently didn't express clearly enough on IRC, was the half-usage of the ap-menu-item.c and mb-menu-item.c stuff.  I wanted them to be used the same way from applet-device-* regardless of whether indicator was enabled or not, so that the menu objects encapsulated the differences of indicator vs. non-indicator, leaving much cleaner code.  The patch is now like net +200 LoC instead of twice that.

What do you think?  Can you test this branch and let me know if it works for you?
Comment 57 Pavel Simerda 2015-02-17 12:14:40 UTC
With dcbw/indicator:

CFLAGS=-ggdb ./autogen.sh --prefix=/usr --sysconfdir=/etc --disable-migration --with-appindicator && make && ./src/nm-applet

https://www.enlightenment.org/ss/e-54e33054e5e694.48406175.jpg
Comment 58 Dan Williams 2015-02-17 14:42:11 UTC
Created attachment 297023 [details]
Screenshot of dcbw/indicator with GNOME Shell appindicator extension
Comment 59 Pavel Simerda 2015-02-17 15:31:21 UTC
> 8beedc3e565b343aeb36aed96741044040011c3d
> applet: simplify mobile broadband menu item finalization

+1 (no real relation to appindicator patchset)

> 0c3600238bb2da31af48d7184df5cf3ddebec2b8
> applet: clean up NMNetworkMenuItem

+1 (no real relation to appindicator patchset)

> 6f75bfefbd6c0605666191d5153b8a83974a3f1c
> applet: remove obsolete support for ModemManager <= 0.7

+1 (no real relation to appindicator patchset)

> 7f45ba6c25a8fe6a94b55b68d6ad20110f288492
> applet: return icon name from from applet_update_icon()

+1 (one of appindicator patches)

> 40f052d38af9e9f3bc42c6cbbb51e9044ab73663
> applet: prepare for appindicator patch

This one really belongs either just before the final patch or squashed into the final patch. I'll keep it separate for now. I also see some bad changes there that haven't been part of the patchset, so I'm afraid you used an older version of the patchset.

> d558ea0c58c1adfd3d11d6c2a5bc960183347b13
> applet: simplify NMNetworkMenuItem initialization

Great job but I moved it before the previous patch.

> bb6e147576ca7679ac82c50fba57f1d44da7d267 applet: add support for --with-appindicator

Good, except that it wasn't meant ot contain changes to the non-appindicator code. I moved those changes into the "prepare" patch and split that one into smaller pieces.

Just pushed a branch:

8beedc3e565b343aeb36aed96741044040011c3d applet: simplify mobile broadband menu item finalization
0c3600238bb2da31af48d7184df5cf3ddebec2b8 applet: clean up NMNetworkMenuItem
6f75bfefbd6c0605666191d5153b8a83974a3f1c applet: remove obsolete support for ModemManager <= 0.7
7f45ba6c25a8fe6a94b55b68d6ad20110f288492 applet: return icon name from from applet_update_icon()
dc3d725b4b6797697757a65c3a1f7123b5a5c736 applet: simplify NMNetworkMenuItem initialization
9a7bd6b2deb8d09c3dfb519e72d3fe468c246a77 applet: clean up menu item label handling
d9f0a1f1c440d32adf4a0637c35462d203dd1513 applet: add applet_schedule_update_menu()
b15b48ff0890f2b51288ad98724e0a8d0ce12bf1 applet: run gtk_widget_show()
bbe45f583f372ed486f2255f559aa81d26bade53 applet: don't call gtk_image_new_from_stock()
37f62b6524a07f091cb68a1189a2922ced3795e9 applet: use GtkCheckMenuItem
e14bada7d5c253993b3de9595e041df122b8249e applet: wait with hash table lookup after assertions
751b6fcc236b7157acf7721cfbe381e952dd142e applet: simplify nma_icons_init()
c5b1eca82c6808afd3a6668ac0b0e9ae4c378c6c applet: prepare for appindicator patch
2bd4e529cd09133914f0af93df67f372a10d9300 applet: add support for --with-appindicator

Most of the patches should be good to go. The final result uses pixbuf but those seem to be not supported by Enlightenment, I'll investigate it a bit more.

(In reply to Pavel Simerda from comment #57)
> With dcbw/indicator:
> 
> CFLAGS=-ggdb ./autogen.sh --prefix=/usr --sysconfdir=/etc
> --disable-migration --with-appindicator && make && ./src/nm-applet
> 
> https://www.enlightenment.org/ss/e-54e33054e5e694.48406175.jpg

This turned out to be the screenshot of pavlix/indicator, not dcbw/indicator with which I have no menu icons at all.
Comment 60 Pavel Simerda 2015-02-17 18:40:07 UTC
Thanks for pushing part of the patches during IRC discussion and for preparing the EXPERIMENTAL patch. The current indicator branch on my github is ready to merge into master except EXPERIMENTAL.
Comment 61 Dan Williams 2015-02-17 20:23:29 UTC
Branch pushed to master with a small fixup to the GtkCheckMenuItem patch that removes an orphaned call to gtk_image_menu_item_set_image().
Comment 62 Dan Williams 2015-02-17 20:37:16 UTC
Also pushed 59678db1c7e0b3afbad15356b6936b614dd61cd2 (applet/indicator: use icon names by default) which defaults to icon names.  Please test and let me know if this all works.
Comment 63 Pavel Simerda 2015-02-18 09:27:56 UTC
The release tracker can be used to find (some of the) features that have been added before that release. Adding back.

Build nm-applet master and started using it from now on. Works great with Enlightenment git master. There is a known regression from non-appindicator mode of not showing the composite pixmaps (nor the respective information) for the status icon and for wifi menu items.

As my work was inspiried by using Enlightenment, the next step would be to contact them about the composite pixbufs. Then we will probably want to make a choice, either automatic or manual, whether to use icon names or pixbufs. One idea is to actually default to pixbufs (as it's fuller in features) and switch to icon names via 'nm-applet --no-pixbufs'.

Anyway, the worst part is behind us, thank you! The danger of having huge incompatible patches in distributions is over.
Comment 65 Thomas Haller 2015-09-03 11:46:25 UTC
I wonder, why is this BZ still open? What is left to do?


(In reply to Pavel Simerda from comment #63)
> Build nm-applet master and started using it from now on. Works great with
> Enlightenment git master. There is a known regression from non-appindicator
> mode of not showing the composite pixmaps (nor the respective information)
> for the status icon and for wifi menu items.

"Non-composite", you mean that for example there is no longer an indication in the icon for encrypted Wi-Fis, right?

Is that unfixable, or just to be done?

> As my work was inspiried by using Enlightenment, the next step would be to
> contact them about the composite pixbufs. Then we will probably want to make
> a choice, either automatic or manual, whether to use icon names or pixbufs.
> One idea is to actually default to pixbufs (as it's fuller in features) and
> switch to icon names via 'nm-applet --no-pixbufs'.



I also noticed, that for me (plasma5), nm-applet no longer reacts on left-mouse click. And on right-mouse-click, the popup menue is a combination of what used to be left+right. Is that also correct? Is it a known issue?
Comment 66 Dan Williams 2015-09-03 16:44:51 UTC
(In reply to Thomas Haller from comment #65)
> I wonder, why is this BZ still open? What is left to do?
> 
> 
> (In reply to Pavel Simerda from comment #63)
> > Build nm-applet master and started using it from now on. Works great with
> > Enlightenment git master. There is a known regression from non-appindicator
> > mode of not showing the composite pixmaps (nor the respective information)
> > for the status icon and for wifi menu items.
> 
> "Non-composite", you mean that for example there is no longer an indication
> in the icon for encrypted Wi-Fis, right?

It's fixable in two ways:

1) we create new icons for every possible permutation of the final icon

2) somebody enhances dbusmenu/appindicator to allow sending the pixmap data instead of just an icon name.  eg, see the code protected by DBUSMENU_PIXMAP_SUPPORT.

> Is that unfixable, or just to be done?
> 
> > As my work was inspiried by using Enlightenment, the next step would be to
> > contact them about the composite pixbufs. Then we will probably want to make
> > a choice, either automatic or manual, whether to use icon names or pixbufs.
> > One idea is to actually default to pixbufs (as it's fuller in features) and
> > switch to icon names via 'nm-applet --no-pixbufs'.
> 
> 
> 
> I also noticed, that for me (plasma5), nm-applet no longer reacts on
> left-mouse click. And on right-mouse-click, the popup menue is a combination
> of what used to be left+right. Is that also correct? Is it a known issue?

I'm not sure about left-click vs. right-click thing, but the "combined menu" thing is definitely intentional because I don't htink dbusmenu/appindicator allows the icon to differentiate left and right click.  You just get the the "show yourself" signal.  So all of our info has to be in one menu.

-----

The last thing that would be great, and hugely clean up the applet implementation would be if dbusmenu/appindictor could handle composed GtkMenuItem objects.  GtkImageMenuItem is deprecated upstream, but we have to use it here because that's the only way that the GTK dbusmenu bindings accept an icon.  If the GTK dbusmenu bindings could be updated to look at the children of the GtkMenuItem for a GtkImage object and a GtkLabel object, it should work for both composed GtkMenuItems and existing GtkImageMenuItems.  Then we could remove a lot of the #ifdef stuff from the applet.
Comment 67 Dan Williams 2016-02-22 21:18:42 UTC
https://code.launchpad.net/~dcbw/libdbusmenu/libdbusmenu/+merge/286843

once that's applied to libdbusmenu we can merge this and depend on an up-to-date libdbusmenu:

dcbw/indicator-cleanups

and the only ENABLE_INDICATOR ifdefs are in applet.c.
Comment 68 Dan Williams 2016-02-22 21:22:55 UTC
The libdbusmenu and dcbw/indicator-cleanups do a few things:

1) dbusmenu can already handle Pango markup, so just remove that ifdef stuff.

2) the dbusmenu changes look for GtkImages in regular GtkMenuItems which means we can use our composited pixmaps (like security lock over wifi strength) in the icon

3) which means we can remove usage of the deprecated GtkImageMenuItem, which we were only keeping around to enable the appindicator stuff
Comment 69 Thomas Haller 2016-02-24 16:25:29 UTC


+    static gboolean icons_shown = FALSE;
 
     g_return_val_if_fail (applet != NULL, NULL);
 
     menu = GTK_MENU_SHELL (gtk_menu_new ());
 
+    if (G_UNLIKELY (icons_shown == FALSE)) {
+         GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (menu));
+
+         /* We always want our icons displayed */
+         if (settings)
+              g_object_set (G_OBJECT (settings), "gtk-menu-images", TRUE, NULL);
+         icons_shown = TRUE;
+    }


this seems very strange. I don't understand, why we set the property of a newly created @menu only once (guarded by a static variable).




The rest lgtm.




If these patches require a very new libdbusmenu, maybe we should hold them back? At least the last one...
Comment 70 Dan Williams 2016-02-27 16:34:39 UTC
(In reply to Thomas Haller from comment #69)
> 
> 
> +    static gboolean icons_shown = FALSE;
>  
>      g_return_val_if_fail (applet != NULL, NULL);
>  
>      menu = GTK_MENU_SHELL (gtk_menu_new ());
>  
> +    if (G_UNLIKELY (icons_shown == FALSE)) {
> +         GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET
> (menu));
> +
> +         /* We always want our icons displayed */
> +         if (settings)
> +              g_object_set (G_OBJECT (settings), "gtk-menu-images", TRUE,
> NULL);
> +         icons_shown = TRUE;
> +    }
> 
> 
> this seems very strange. I don't understand, why we set the property of a
> newly created @menu only once (guarded by a static variable).

GtkSettings are actually a global object for the GdkScreen this widget is displayed on (and in this case, we only care about one screen), so we only need to set the property once.  Hence why it's guarded with a static variable.

We set this property to TRUE because libdbusmenu checks this property to see whether or not to display the icon that we have packed into our GtkMenuItem, like the wifi strength icon or the WWAN signal icon.  If the gtk-menu-images property is not TRUE then our icons don't get displayed.  And now, most desktop environments turn menu icons off by default, so we must manually set it to TRUE.  This is also why I removed the GtkStockIcon stuff from the "Connection Information" and "About..." menu items, because by setting this property to TRUE those icons will be displayed as well.  But since standard menu icons seem to be out-of-favor these days, we don't need them anyway.

> If these patches require a very new libdbusmenu, maybe we should hold them
> back? At least the last one...

Yeah, probably.  My patches/cleanups have been merged to libdbusmenu in Launchpad, but no release yet.  I've pinged the maintainer to see if they'll do one soon.
Comment 71 Dan Williams 2016-02-29 16:50:00 UTC
There is now a new release of libdbusmenu with the required changes: https://launchpad.net/libdbusmenu/16.04/16.04.0
Comment 72 Dan Williams 2016-03-01 17:12:57 UTC
Rebased on master and updated with a pkg-config check for the necessary dbusmenu version.

Please review dcbw/indicator-cleanups
Comment 73 Thomas Haller 2016-03-03 18:07:29 UTC
lgtm.

Maybe merge the first two patches, but wait with the last patch after 1.2? 

Merging it would mean, applet --with-appindicator won't even build on fc23, which seems a bit drastic.
Comment 74 Dan Williams 2016-03-04 16:35:51 UTC
I would say we just merge the whole thing; indicator is new with 1.2 and we might as well just require the dep.  We can certainly update libdbusmenu in Fedora at least, other distros can update if they want the indicator.
Comment 75 Dan Williams 2016-03-15 20:33:21 UTC
Repushed dcbw/indicator-cleanups with patches to allow indicator/status-icon to be built together and switched at runtime with --indicator.  Please review!
Comment 76 Thomas Haller 2016-03-16 09:59:23 UTC
(In reply to Dan Williams from comment #75)
> Repushed dcbw/indicator-cleanups with patches to allow indicator/status-icon
> to be built together and switched at runtime with --indicator.  Please
> review!


>> applet: build (but disable) notifications code for indicator too

+#ifdef ENABLE_INDICATOR
+#define INDICATOR_ENABLED(a) (a->app_indicator != NULL)
+#else
+#define INDICATOR_ENABLED(a) (FALSE)
+#endif

parentheses around "a"?


>> applet: allow indicator and status icon to be built together
>> applet: add --indicator to switch between indicator and status icon at runtime

pushed to commits to fix building --without-appindicator.



Branch LGTM.
Comment 77 Thomas Haller 2016-03-16 10:05:27 UTC
Created attachment 324081 [details]
screenshot of missing connection connection

with-appindicator, the connection name is missing. Also, when I press "Disconnect", there is no way to reconnect, because not connections are shown.
Comment 78 Thomas Haller 2016-03-16 10:11:56 UTC
-    AC_DEFINE([ENABLE_INDICATOR], 1, [Enable using libappindicator])
+    AC_DEFINE([WITH_INDICATOR], 1, [Enable using libappindicator])

I think it should be "WITH_APPINDICATOR"
Comment 79 Dan Williams 2016-03-17 21:30:32 UTC
Squashed and repushed; how about now?
Comment 80 Thomas Haller 2016-03-18 11:56:59 UTC
lgtm
Comment 81 Dan Williams 2016-03-18 14:55:58 UTC
merged to git master