GNOME Bugzilla – Bug 414032
Tray icon too complex and broken under KDE
Last modified: 2007-03-15 21:57: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.
Created attachment 83763 [details] [review] Avoid doing everything twice
Created attachment 83764 [details] [review] Avoid changing visibility to the current one
Hmm sorry, I reworked the first patch before sending it and it is now wrong :-)
Created attachment 83765 [details] [review] Avoid doing everything twice
Created attachment 83847 [details] [review] Avoid doing everything twice (3rd try)
For some reason this breaks changing the "dispay icon when.." policy in gnome-power-preferences.
OK, I'll re-read it all :)
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.
Created attachment 83885 [details] [review] Code simplification, 4th try
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