void menu_quit_fn(object o, ButtonPressEventArgs args)
    {
        MainClass.userlogout = true;
        //if (onLogoutWork != null)
        {
            Logger.Log("Running logout tasks first",Helpers.LogLevel.Debug);
            if(MainClass.client.Inventory.Store!=null)
                MainClass.client.Inventory.Store.SaveToDisk(MainClass.client.Settings.ASSET_CACHE_DIR + System.IO.Path.DirectorySeparatorChar + MainClass.client.Inventory.Store.RootFolder.UUID.ToString() + ".osl");
            Logger.Log("Done",Helpers.LogLevel.Debug);
        }

        LogoutDlg ld = new LogoutDlg();
        ld.Modal = false;
        ld.Run();
        //Gtk.Application.Quit();
    }
    void MainWindow_DeleteEvent(object o, DeleteEventArgs args)
    {
        bool hidewindow=MainClass.appsettings.minimise;
        ResponseType result=ResponseType.Close;
        CloseMinimiseDlg cmd=new CloseMinimiseDlg();
        if(!hidewindow)
        {
            result = (ResponseType)cmd.Run();
        }
        else
        {
            bool minimise=MainClass.appsettings.default_minimim;
            if(minimise==true)
                result=ResponseType.Accept;
        }

        if(result==ResponseType.Cancel)
        {
            args.RetVal = true;
            cmd.Destroy();
            return;
        }

        if(result==ResponseType.Close)
        {
             if (oncleanuptime != null)
                oncleanuptime();

            args.RetVal = false;
            cmd.Destroy();

            if(MainClass.client.Network.Connected)
            {
                MainClass.userlogout = true;
                LogoutDlg ld = new LogoutDlg();
                ld.Modal = false;
                ld.Run();
            }

            return;
        }

        if(result==ResponseType.Accept)
        {
            cmd.Destroy();
            args.RetVal = true;
            this.Visible = false;
            return;
        }

        args.RetVal = true;
    }