From 70ebe79a1986c19f45df3bb57d0b6a84474f1697 Mon Sep 17 00:00:00 2001 From: Javier Jardon Date: Tue, 5 Jul 2011 15:49:19 +0100 Subject: Do not create a new GtkMenu instance with every change But remove the children and rebuild the menu again so Its up-to-date --- src/indicator-power.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') 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); -- cgit v1.2.3