From ad592c81d71c57726b6d0a172b0bc6e05bbcdd43 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Mon, 28 Oct 2013 14:27:41 +0100 Subject: grid: don't add duplicate entries when the menu tree changes Fix a few bugs in our shell-app-system code that are exposed by this change. --- shell/launcher-grid.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'shell/launcher-grid.c') diff --git a/shell/launcher-grid.c b/shell/launcher-grid.c index 2ba8443..916722d 100644 --- a/shell/launcher-grid.c +++ b/shell/launcher-grid.c @@ -25,6 +25,13 @@ child_activated_cb (GtkWidget *grid, gtk_widget_hide (gtk_widget_get_parent (scrolled_window)); } +static void +destroy_widget (GtkWidget *widget, + gpointer data) +{ + gtk_widget_destroy (widget); +} + static void installed_changed_cb (ShellAppSystem *app_system, GtkWidget *grid) { @@ -32,13 +39,13 @@ installed_changed_cb (ShellAppSystem *app_system, GtkWidget *grid) GHashTableIter iter; gpointer key, value; - /* FIXME: if the tree changes while we're running, we'll readd entries - * that haven't been removed from the tree, so we'll get lots of dups */ + /* Remove all children first */ + gtk_container_foreach (GTK_CONTAINER (grid), destroy_widget, NULL); g_hash_table_iter_init (&iter, entries); while (g_hash_table_iter_next (&iter, &key, &value)) { - GDesktopAppInfo *info = value; + GDesktopAppInfo *info = G_DESKTOP_APP_INFO (value); GtkWidget *app = app_launcher_new_from_desktop_info (info); gtk_container_add (GTK_CONTAINER (grid), app); -- cgit v1.3.1