- modest_shell_add_banner (MODEST_SHELL (shell), MODEST_SHELL_BANNER (self));
- } else if (MODEST_IS_SHELL (toplevel)) {
+
+ toplevels = gtk_window_list_toplevels ();
+ while (toplevels) {
+ if (gtk_window_has_toplevel_focus (GTK_WINDOW (toplevels->data))) {
+ toplevel = toplevels->data;
+ break;
+ }
+ toplevels = g_list_next (toplevels);
+ }
+
+ if (toplevel == NULL)
+ toplevel = shell;
+ }
+
+ if (MODEST_IS_SHELL (toplevel)) {