diff options
author | Javier Jardon <javier.jardon@codethink.co.uk> | 2011-07-05 15:49:19 +0100 |
---|---|---|
committer | Javier Jardon <javier.jardon@codethink.co.uk> | 2011-07-05 15:49:19 +0100 |
commit | 70ebe79a1986c19f45df3bb57d0b6a84474f1697 (patch) | |
tree | 9a2ced8cf45db917e9840f5f10d561ca469c34b0 /src/indicator-power.c | |
parent | fed51c17453052ed88d43995a1a47d62869aa7de (diff) | |
download | ayatana-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
Diffstat (limited to 'src/indicator-power.c')
-rw-r--r-- | src/indicator-power.c | 7 |
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); |