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 414032 - Tray icon too complex and broken under KDE
Tray icon too complex and broken under KDE
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: gnome-power-manager
SVN TRUNK
Other Linux
: Normal normal
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2007-03-02 22:20 UTC by Pascal Terjan
Modified: 2007-03-15 21:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoid doing everything twice (1.50 KB, patch)
2007-03-02 22:21 UTC, Pascal Terjan
none Details | Review
Avoid changing visibility to the current one (567 bytes, patch)
2007-03-02 22:22 UTC, Pascal Terjan
none Details | Review
Avoid doing everything twice (1.70 KB, patch)
2007-03-02 22:26 UTC, Pascal Terjan
none Details | Review
Avoid doing everything twice (3rd try) (2.70 KB, patch)
2007-03-03 22:20 UTC, Pascal Terjan
none Details | Review
Code simplification, 4th try (2.70 KB, patch)
2007-03-04 13:46 UTC, Pascal Terjan
none Details | Review

Description Pascal Terjan 2007-03-02 22:20:48 UTC
Mandriva bug http://qa.mandriva.com/show_bug.cgi?id=29059

gnome-power-manager calls gtk_status_icon_set_visible several times after each change, and under kde this make the icon disappear (until another icon is added to the tray). I don't know if the bug is in GtkStatusIcon or KDE tray and will investigate later but anyway the gnome-power-manager code should be simplified.

Currently it is basically :

gpm_tray_icon_set_image_from_stock() {
  if (stock_id != NULL) {
    gtk_status_icon_set_visible (GTK_STATUS_ICON (icon->priv->status_icon), TRUE);
  } else {
    gtk_status_icon_set_visible (GTK_STATUS_ICON (icon->priv->status_icon), FALSE);
  }
}

gpm_tray_icon_show(icon, enabled) {
  gtk_status_icon_set_visible (GTK_STATUS_ICON (icon->priv->status_icon), enabled);
}

gpm_tray_icon_sync(icon) {
  if (stock_id) {
    gpm_tray_icon_set_image_from_stock (icon, stock_id);
    gpm_tray_icon_show (icon, TRUE);
  } else {
    gpm_tray_icon_show (icon, FALSE);
  }
}

I think that testing stock_id both inside and outside gpm_tray_icon_set_image_from_stock is quite useless, so is calling gtk_status_icon_set_visible from inside and from outside.

So, here are 2 patches.
Comment 1 Pascal Terjan 2007-03-02 22:21:25 UTC
Created attachment 83763 [details] [review]
Avoid doing everything twice
Comment 2 Pascal Terjan 2007-03-02 22:22:09 UTC
Created attachment 83764 [details] [review]
Avoid changing visibility to the current one
Comment 3 Pascal Terjan 2007-03-02 22:24:48 UTC
Hmm sorry, I reworked the first patch before sending it and it is now wrong :-)
Comment 4 Pascal Terjan 2007-03-02 22:26:34 UTC
Created attachment 83765 [details] [review]
Avoid doing everything twice
Comment 5 Pascal Terjan 2007-03-03 22:20:53 UTC
Created attachment 83847 [details] [review]
Avoid doing everything twice (3rd try)
Comment 6 Richard Hughes 2007-03-04 12:51:05 UTC
For some reason this breaks changing the "dispay icon when.." policy in gnome-power-preferences.
Comment 7 Pascal Terjan 2007-03-04 13:30:22 UTC
OK, I'll re-read it all :)
Comment 8 Pascal Terjan 2007-03-04 13:42:37 UTC
That's because I had put the gpm_tray_icon_show inside if (strcmp (icon->priv->stock_id, stock_id) != 0), here is a new patch.
Comment 9 Pascal Terjan 2007-03-04 13:46:17 UTC
Created attachment 83885 [details] [review]
Code simplification, 4th try
Comment 10 Richard Hughes 2007-03-15 21:57:48 UTC
2007-03-15  Richard Hughes  <richard@hughsie.com>

	* src/gpm-tray-icon.c: (gpm_tray_icon_show),
	(gpm_tray_icon_set_image_from_stock), (gpm_tray_icon_sync):
	Simplify the icon display code. Fixes g-p-m on the KDE tray.
	Many thank to Pascal Terjan for the patch. Fixes #414032