aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardon <javier.jardon@codethink.co.uk>2011-07-05 15:49:19 +0100
committerJavier Jardon <javier.jardon@codethink.co.uk>2011-07-05 15:49:19 +0100
commit70ebe79a1986c19f45df3bb57d0b6a84474f1697 (patch)
tree9a2ced8cf45db917e9840f5f10d561ca469c34b0
parentfed51c17453052ed88d43995a1a47d62869aa7de (diff)
downloadayatana-indicator-power-70ebe79a1986c19f45df3bb57d0b6a84474f1697.tar.gz
ayatana-indicator-power-70ebe79a1986c19f45df3bb57d0b6a84474f1697.tar.bz2
ayatana-indicator-power-70ebe79a1986c19f45df3bb57d0b6a84474f1697.zip
Do not create a new GtkMenu instance with every change
But remove the children and rebuild the menu again so Its up-to-date
-rw-r--r--src/indicator-power.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/indicator-power.c b/src/indicator-power.c
index 896555b..eb2b605 100644
--- a/src/indicator-power.c
+++ b/src/indicator-power.c
@@ -369,9 +369,14 @@ build_menu (IndicatorPower *self)
IndicatorPowerPrivate *priv = self->priv;
GtkWidget *item;
GtkWidget *image;
+ GList *children;
guint n_devices = 0;
- priv->menu = GTK_MENU (gtk_menu_new ());
+ if (priv->menu == NULL)
+ priv->menu = GTK_MENU (gtk_menu_new ());
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->menu));
+ g_list_foreach (children, (GFunc) gtk_widget_destroy, NULL);
/* devices */
n_devices += menu_add_device (priv->menu, priv->device);